Hi again,
the script already starts with
"set session transaction isolation level read uncommitted"
as told by River on this list a few months ago. Beside this, the last time it run it did not affect the replication lag. So, I'm not sure that this script caused these problems.
.. and the script pauses, if the replication lag raises above a few seconds, just to make sure it gets not killed again ... During these pauses it sleeps and there are no pending database queries.
How can it affect the replication lag then? Please find out the real source of these problems and do not kill random processes.
-- Aka