-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[-] reset session before returning connection to the pool #589
[-] reset session before returning connection to the pool #589
Conversation
e91bfee
to
255daad
Compare
Thanks for your help. That's indeed might be a problem. I would rather start with not so strict reset statements. IMO temp objects, GUC and advisory locks are top priority. |
Well, I originaly wanted to resolve set role in autonomous tasks and only after realized you are working on that (among other things). Regarding priority, temp & cursors share introduce similar issues when leaked. And leaked listens can cause a lot of major issues when pg_notify is used in triggers. Postgres notification queue is fixed size and once filled all those triggers with pg_notify start throwing errors. |
Indeed, you're right about custom LISTENs... Let me think about it a little :) |
On second thought, maybe we should consider a different approach. |
Well, we have clients with a lot of jobs, so opening/closing connection will really hurt :( |
Separate connection pool for executors? In that case we can safely use |
I believe there is a simpler way. Your first approach sounds good, just need to test that and we're fine. :) Will take a look later |
And that leads towards dynamic pooling for remote connections. If there are benefits for pooling local chains there is benefit for pooling remote connections as well. |
👍 |
Might help for a lot of remote tasks, yes. I wonder how many people prefer to use remote chains instead of having a standalone pg_timetable instance for each target database |
5db2c69
to
32f11d2
Compare
Pull Request Test Coverage Report for Build 5519859534
💛 - Coveralls |
Thanks a lot for your help! |
Tasks can leave objects behind after they finish executing.
Most commonly, session scope temporary tables and advisory locks.
Those objects persist after the connection is returned to the pool and can cause issues when the connection is reused.
Simple example:
Start pg_timetable with
--cron-workers=1
and create a jobSELECT timetable.add_job('tester', '* * * * *', 'create temporary table x();');
First job run will succeed and all other runs during that connections lifetime will fail with:
ERROR: relation "x" already exists (SQLSTATE 42P07)
.This change also enables using
set role
in autonomous tasks as the role is reset when connection is returned to the pool.