1

I need to run some code for cleaning up after a database connection is gracefully closed or rudely interrupted/lost. This clean-up cannot be handled within the scope of a transaction inside the connection. So the clean-up (modifying some records, etc.) must be handled on the server-side in PL/pgSQL or Java etc. after the connection is gone. The clean-up is critical, so it must be done reliably every time.

Is there a hook for code to be called on every connection closure/loss in the Postgres server?

1 Answer 1

2

Theoretically you can write C extension and you can register your callback on shared memory cleaning. It is possible only in C extension. It is called every time - at session end - not only when connection is lost.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.