Hi,
Update: I added another test to the attached test-only patch. This new
test uses pg_terminate_backend to trigger reconnection.
Assuming the tests are fully correct (your input appreciated on this) we
can use them to validate the solution.
Kind regards,
Mircea Cadariu