Update pool.py - #828
Conversation
Use if instead of a try / except loop to avoid circular call
|
I have trouble reproducing the bug. Our setup is quite complex, and I manage to produce the bug, but not every time and not at the same time ... I am trying to corner the bug better, but for now I can't give you a minimal example |
|
further query to the DB fails sql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: sorry, too many clients already |
|
ah, very good. so, if we limit the resources artificially, we should be able to produce a test that presents the same behavior. |
|
Yes, we're not seeing it in the prod postgresql VM, we tracked the Postgresql connections (with : The "too many connections" error ends up killing the irods process though We updated postgresql to 17 without changing the issue |
I suspect killing the db and trying a request from the python client is enough to reproduce the long traceback at the origin of the issue |
oh, yes, that might do it. definitely not something we've tested before. |
|
So, we appear to have fixed the problem with a strict reuse of the session for each 'agent', so: class iRODSAgent:
...
def __enter__(self):
super().__enter__()
self.session = irods_conn(self.conf)
return self
def __exit__(self, exc_type, exc_value, traceback):
self.session.cleanup()
super().__exit__(exc_type, exc_value, traceback)What create zombie session is doing something like: # Within the agent class
def do_smthg(self):
session = iRODSSession(...)
session.do_something()and not # Within the agent class
def do_smthg(self):
self.session.do_something()Fewww ^^' |
|
So I see two things that work?
|
|
@glyg, I have doubts as to whether I'm reproducing the same syndrome here, In my attempts I have duplicated similar errors, through a script such as this one: Presumablly because keeping the Having said all this, I've tried with the code fixes provided in this PR and they don't seem to address the errors I was seeing. The "simple"/efficient way to handle that, for the above script anyway, is to move the creation of I'm not sure if your use-case involves hanging on to references of the old sessions or not. But apparently calling Whatever the case, I cannot seemingly reproduce this issue at all, let alone reliably, so I am not sure where that leaves us with implementing a test method validating the fix. |
|
All of that said, as stated there seems to be no disadvantage to us changing the try/except to if/then in that it would be more future-proof. I cannot see where the current additive risk of a spurious |
|
After some discussion, @d-w-moore and I landed at the following.
@d-w-moore is going to open a new issue which explains why this PR is necessary. As for the issue opened by @glyg, I think that can be addressed by documenting which usage patterns lead to confusing behavior or poor performance. |


Use if instead of a try / except loop to avoid circular call, see #827