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

Failed to create a backend connection #48

Open
helirrodriguez opened this issue Apr 18, 2024 · 21 comments
Open

Failed to create a backend connection #48

helirrodriguez opened this issue Apr 18, 2024 · 21 comments
Assignees

Comments

@helirrodriguez
Copy link

The scenario is the following: The primary server (backend 0) goes down and the standby (backend 1) server is promoted to primary. Postgres works perfectly, reads, writes and works as an isolated primary on another ip and server different from where pgpool resides.
Pgpool would have to redirect connections from the IP and server where it resides to the IP where the Postgre server resides automatically.
When pgpool starts, it detects backend 0 as up and backend 1 as down, when it is the opposite.
psql -h rocky-cluster-ha-1 -p 9999 -U repuser -d testdb
psql: error: connection to server at "rocky-cluster-ha-1" (10.86.14.212), port 9999 failed: FATAL: failed to create a backend connection
DETAIL: executing failover on backend
Finally it is not able to connect to the primary server that is installed on another IP, rocky-cluster-ha-2, and that was previously the standby server. I don't know if it is a validation problem between pgpool and postgre, connection, etc., but I have not been able to make it work with any configuration.

@pengbo0328 pengbo0328 self-assigned this Apr 19, 2024
@pengbo0328
Copy link
Collaborator

@helirrodriguez Was Pgpool-II able to connect to the two PostgreSQL servers before failover?

The scenario is the following: The primary server (backend 0) goes down and the standby (backend 1) server is promoted to primary.

Was the failover performed by pgpool?
Pgpool-II saves the backend status in pgpool_status file. If pgpool detects backend failure, pgpool will update the status file.
When pgpool starts, pgpool will retrieve the backend status from pgpool_status file.
If failover is performed manually or by other HA tool, pgpool may not be able to properly manage the backend status.

There are two ways to reset the status managed by pgpool:

If the above settings does not work properly, please share the configuration file and pgpool logs.

@helirrodriguez
Copy link
Author

helirrodriguez commented Apr 24, 2024 via email

@pengbo0328
Copy link
Collaborator

pengbo0328 commented Apr 30, 2024

@helirrodriguez

There must be an order in the maneuvers between Postgresql and Pgpool?

To do maintenance of primary, if you turn off primary, pgpool will automatically promote standby to primary.
Alternatively, if you don't mind stopping the service, stop pgpool first, and then stop postgresql.
After maintenance, start PostgreSQL first, and then start pgpool.

That is to say the secondary postgres server is stuck in read-only mode.

I think failover didn't performed because the configuration was incorrect.

You can find the settings of failover in the following configuration example:
https://www.pgpool.net/docs/latest/en/html/example-cluster.html

@helirrodriguez
Copy link
Author

helirrodriguez commented Apr 30, 2024 via email

@pengbo0328
Copy link
Collaborator

@helirrodriguez It seems you have resolved this issue.
May I close this issue?

@helirrodriguez
Copy link
Author

helirrodriguez commented May 1, 2024 via email

@pengbo0328
Copy link
Collaborator

But please, if you are so kind, can you tell me the order of maneuvers
between postgresql and pgpool.

Sorry!
If you mean start and stop order,
start order is:
start PostgreSQL first and then start Pgpool-II.

Stop order is:
stop Pgpool-II first and then stop PostgreSQL.

Below is the doc:
https://www.pgpool.net/docs/latest/en/html/install-rpm.html#START-RPM

After this, to start Pgpool-II, run the following command or restart the whole system. Please note that PostgreSQL servers must have been started before this.

To stop Pgpool-II, do this once. Please note that Pgpool-II must be stopped before stopping PostgreSQL.

@helirrodriguez
Copy link
Author

helirrodriguez commented May 4, 2024 via email

@pengbo0328
Copy link
Collaborator

@helirrodriguez If you installed pgpool by compiling the source code, you should follow the following doc to install pgpool recovery.
https://www.pgpool.net/docs/latest/en/html/install-pgpool-recovery.html

Note that pgpool recovery extension needs to be installed on the PostgreSQL servers. If Pgpool-II and PostgreSQL are installed on separate servers, it is not required to install it on the servers where Pgpool-II are running.

@helirrodriguez
Copy link
Author

helirrodriguez commented May 15, 2024 via email

@pengbo0328
Copy link
Collaborator

Hello dear Bo Peng, I am doing tests analyzing what happens when I turn off
the standby server. Pgpool closes all connections and cannot create the
backend connection. There is a way for the connection to continue only with
the primary one.

@helirrodriguez If standby goes down, the existing connection failed.
However, the subsequent connections will be sent to primary.

Do you mean the subsequent connections can't be sent to primary?

You can find the settings of failover in the following configuration example:
https://www.pgpool.net/docs/latest/en/html/example-cluster.html

@helirrodriguez
Copy link
Author

helirrodriguez commented May 16, 2024 via email

@pengbo0328
Copy link
Collaborator

@helirrodriguez I think it is a configuration problem.
Could you share your pgpool.log which contains the logs when you killed the standby process and your pgpool.conf?

@pengbo0328
Copy link
Collaborator

@helirrodriguez I am not able to see the images that you uploaded?
Could you upload them to this issue again?

@helirrodriguez
Copy link
Author

helirrodriguez commented May 21, 2024 via email

@helirrodriguez
Copy link
Author

helirrodriguez commented May 23, 2024 via email

@pengbo0328
Copy link
Collaborator

Sorry. Still couldn't see your images.
Could you upload the images to this thread?
And could you share your pgpool.log which contains the logs when you killed the standby process and your pgpool.conf?

@helirrodriguez
Copy link
Author

helirrodriguez commented May 27, 2024 via email

@helirrodriguez
Copy link
Author

helirrodriguez commented May 27, 2024 via email

@pengbo0328
Copy link
Collaborator

@helirrodriguez Sorry! Still I couldn't see your images and logs.
Did you send to my email?

Hello dear Bo Peng, I am doing tests analyzing what happens when I turn off
the standby server. Pgpool closes all connections and cannot create the
backend connection. There is a way for the connection to continue only with
the primary one. This form of behavior is more dangerous than if the
primary falls, because although the primary is still alive we cannot
provide service.

Let me answer your question.

If standby goes down, the existing connection will be disconnected.
It is the feature of pgpool. However, the subsequent connections will be sent to primary.
If you want to avoid this issue, you need to add retry in your application.

@helirrodriguez
Copy link
Author

helirrodriguez commented May 30, 2024 via email

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

No branches or pull requests

2 participants