Closed antarcticrainforest closed 1 year ago
@jdelic ready for review, thanks.
I have seen that some PR's were merged. I've updated this code accordingly.
@antarcticrainforest
Thank you! Yes, I did some maintenance work on the project to get it to a place where it can be updated :). I'll look into this next. From what I faintly remember, I avoided calling is_usable
because if it raises an exception it might recurse into ensure_connection_with_retries
or something like that...
I'll probably try this patch in production on my end and see what happens.
and indeed the tests fail...
I can't look into that right now, but perhaps later this week.
(if you have time to look into it, that would also be appreciated ;) )
I did have a quick look into what's going on but didn't find an obvious solution. If I have time today, I'll keep digging.
This adds an additional check if the database connection is still usable.
Background
Our django application successfully opens a db connection and does some calculations. These calculations might take a long time. In some cases more time than the
wait_time
of the db server (which is 8 hours by default). In such cases the db server cuts a valid connection. I've noticed that this case is not covered by the patch, so I added an additional check to see if the database connection is still usable. If it isn't a new connection will be established.Here is a minimal example demonstrating the problem after the database servers
wait_timeout
variable has been set to 5 seconds:without proposed change I observe the following behaviour:
with the change we get the expected behaviour:
I couldn't get the unittest working, could someone give me instructions on how to run those tests. Maybe we could also add instructions on running tests to the readme.