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

pqsql/chanserv: Does not survive PostgreSQL server restart #43

Open
pandame opened this issue Feb 14, 2016 · 1 comment
Open

pqsql/chanserv: Does not survive PostgreSQL server restart #43

pandame opened this issue Feb 14, 2016 · 1 comment

Comments

@pandame
Copy link
Contributor

pandame commented Feb 14, 2016

pqsql currently does not survive the PostgreSQL server restarting or going away at all.

If the PostgreSQL server goes away, it will send some input, signaling PQisBusy == false, but we may not even have queryhead != NULL at the time, leading to a crash. To avoid the crash, queryhead == NULL would first need to be checked, then PQresultStatus(PQgetResult(dbconn)) should be verified to be PGRES_FATAL_ERROR, else the connection may continue to function as intended.

The discussion about PostgreSQL bug 5837 has yielded that the API is meant to be used with PQisBusy to immediately go ahead to PQgetResult, which will then inform about the fatal error. PQstatus will still return CONNECTION_OK despite it obviously not being okay.

However, even if that were to be detected correctly, then there is no reasonable recovery plan:

  1. Reconnecting is very risky. Should the connectdb() function hang due to its nature of connecting in a blocking manner, all network I/O will stall, possibly sendq'ing newserv off the network.
  2. At the very least, the chanserv does not survive a reload the pqsql module, it crashes at least somewhere around dbhandler/loadmaillocksdone/csc_dochanstat/chanservstdmessage due to invalid parameters. Due to this, waiting for the PostgreSQL server to be confirmed working and then reloading pqsql manually is no option. More modules may or may not fail in similar ways.

PostgreSQL servers may go away even over local connections when admins enable automatic security updates on Linux distributions and the like, due to it being restarted in the process.

@pandame pandame changed the title v/chanserv pqsql/chanserv: Does not survive PostgreSQL server restart Feb 14, 2016
@retropc
Copy link
Member

retropc commented Mar 7, 2016

it should be able to survive reloading the pqsql module
I don't think the database restarting causing it to crash is much of a problem though

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

No branches or pull requests

2 participants