Skip to content
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

stats: reconnect to postgres in case of error #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@ghost ghost commented Dec 4, 2018

reconnects if no cursor can be fetched
still leads to one 500 connection interestingly, but the next will
succeed

reconnects if no cursor can be fetched
still leads to one 500 connection interestingly, but the next will
succeed
@bernhardreiter
Copy link
Member

Hi @wagner-certat, thanks for the pull request!

This seems to be an attempt to solve #12 .
After a brief look I'm unsure about the side effects to robustness,
what if there already is something, re-doing setup may change the behaviour then.
Do you have a situation where it is not possible to get a cursor?
(Which is different from the case outlined in #12).
I'm trying to understand how this could happen in production.

@ghost
Copy link
Author

ghost commented Mar 18, 2019

Hi,

We did have this problem and if I remember correctly, it was after a restart of the posgresql server.
If the connection gets lost, the next command to the database (getting the/a cursor) server will not succeed. Without re-initializing the connection, you'd need to restart the web-/uwsgi-server in this case.

@bernhardreiter
Copy link
Member

Okay, a database restart is the only known observed situation so far. A nice improvement would be to switch the code forwards using a connection pool. For this pull request to be merged as a simpler improvement, I'd like to understand the side effects of the second setup() better.

ghost pushed a commit to certat/intelmq-fody-backend that referenced this pull request Oct 22, 2019
QUERY_EVENT_SUBQUERY_INITIAL is the default dict
QUERY_EVENT_SUBQUERY is the actually used one

This is necessary to allow multiple setup() calls and not let the
QUERY_EVENT_SUBQUERY dictionary grow with removed configuration entries.
See Intevation#18
@ghost
Copy link
Author

ghost commented Oct 22, 2019

Okay, a database restart is the only known observed situation so far.

But can happen and the application should still be usable after such an event.

For this pull request to be merged as a simpler improvement, I'd like to understand the side effects of the second setup() better.

QUERY_EVENT_SUBQUERY is not reset and entries removed from the configuration will stay there. I can imagine, that's acceptable but otherwise 6669211 provides an untested fix (can test it of course if you think the commit is required)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant