This has been an issue for a while but has only become a more common issue
for us recently and one we can more easily predict.
We are running pgAgent on windows, and whenever we restart the server, if a
job is in the middle of a run when we restart, it gets stuck in a forever
endless running state.
To fix the issue, we have to go into the pgagent.pga_job table and get rid
of the jobagentid that is in there for the specific job that is stuck.
We are running the pgAgent 3.3.0 that is available via Stack Builder.
Thanks,
Leo