-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
[bitnami/postgresql-ha] ERROR: cannot execute INSERT in a read-only transaction #23219
Comments
-----------------------------PostgreSQL configuration file-----------------------------listen_addresses = '*' ssl = 'on' wal_level = 'hot_standby' max_wal_size = '400MB' archive_mode = 'on' max_wal_senders = '16' max_replication_slots = '10' primary_conninfo = 'host=postgresql-ha-postgresql-1.postgresql-ha-postgresql-headless.ns1.svc.cluster.local port=5432 user=repmgr logging_collector = 'on' log_directory = '/opt/build/postgresql/logs' log_connections = 'false' client_min_messages = 'error' shared_preload_libraries = 'repmgr, pgaudit, repmgr' include_dir = 'conf.d' pgaudit.log_catalog = 'off' |
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback. |
ping |
Hi @rohitkgupta, I'm sorry for the late response. I may need more information to help you with this issue. Does your issue persist over time when the master/slave switch happens? Or is this issue transient? Please notice that short downtimes may happen when master is switched because in case of failure, the chart behavior would be the following:
If the error |
@migruiz4 |
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback. |
same issue for me with pgpool:4.5.1-debian-12-r0 downgrade to 4.5.0-debian-12-r10 to fix |
Thank you very much for your feedback @BK-STAR77! The container logic has not received any change from 4.5.0 to 4.5.1 that could cause this behavior. Checking pgpool release notes, it appears that it could be related to the change of the default value for failover_on_backend_shutdown. Could you please confirm if setting |
I have same issue here and reverting manually to 4.5.0-debian-12-r10 in deployment is working now... but, this could be very dangerous for production... |
Is it a variable in the values.yaml ? |
I don't see this variable in values.yaml :/ |
We are experiencing very bad failover issues also. We updated to the newer charts from waaaaaay back and the latest charts appear to not failover correctly at all. We are using kubernetes. We deploy then deploy our other pods to connect and all is fine. with a corresponding error in pgpool of the following There have been other errors too that state it is in read-only mode
We have attempted to downgrad the image of pgpool to 4.5.0 while still using the current charts but pgpool will fail to start with the following error.
So currently, it appears the pg 16 chart version 14+ do not properly failover which makes HA useless and dangerous. We were hoping to update since previous issues with pgpool and the chart caused pgpool to restart beacause of liveness probes and those updates to the probe script were added and we hoped all was fixed. There was also a previous issue where the DB would go into split brain pretty often and that was super dangerous because it wouldn't fail and you would have one outdated db and one current and it would read from both... so we had to shut off loadbalancing. Edit:After restarting PGPool they all EVENTUALLY came back up. Will test again to see if it works eventually WITHOUT restart and see if it replicates again. I am also pouring through the other issues to see if any are related. |
@Stevenpc3 Exactly the same thing is happening to me, but as I only started using postgresql-ha about a month ago I thought it was a problem with some bad configuration on my part. But I had this problem for weeks, and only by deleting the extra primary one did it start to work, because it recreated everything, but automatically it doesn't work. In my case I ended up having different random data and I noticed that I had two primary. |
@apoca that issue you are describing is split-brain #20998 more on the internet about it too. The issue I mentioned at the bottom of my comment is more like replication stops working with no errors or issues detected and is super dangerous and makes failover pointless. Both of those above issues are not related to the current issue in this thread though. This thread appears to be an issue with PGPool and/or the bitnami chart configs that use it. |
You can add the flag
|
Is the "postgresql-ha:" name correct? My config file has the name as "postgresql:" - also, the Is it not meant to be:
? |
My apologies, your way is correct for using the chart directly. I am using a wrapper chart. We have a chart that uses this chart as a dependency so we can template a few things. |
Since you talk about this, I have a question here... I have software as a service and I create a schema database and a user/password as well as the necessary permissions in real time... Sometimes I have a problem with Kind because saying that the database does not exist (but it exists) my question is whether this “false” cache solves this type of problem in pgpool? |
We had someone do a bit of testing... We tried to reproduce the steps described in a comment by user "rafariossaa" (#23219 (comment)). Summary:
The longer version: The comment from rafariossaa sets up the database, adds a separate pod to run psql from (which is a good trick), and then runs a command to connect to pgpool and continuously insert into a test table. The watch is inside psql, so there's one db connection that is kept open.
Generally, failing the primary pod here causes the psql connection to break and you can restart the command and things work seem fine. You can change the psql command so that it creates a db connection for each command (here, an insert and a select).
Generally, this reproduces the pgpool issue. Failing the primary pod causes a few failed connections (connection refused while things fail over) and then an error about the read-only transaction ("ERROR: cannot execute INSERT in a read-only transaction"), where pgpool has apparently failed to point to the correct postgres instance. On suggestion, we installed the "vanilla" bitnami charts. In the as-is configuration, this will reproduce the read-only transaction issue. After adding the settings from the Github thread, I've been unable to reproduce the issue so far:
Will do more testing. |
Hi, |
Not sure if after the feedback this issue could be closed. |
We are still experiencing this issue. Disabling the connection cache feels like a bad move, as it pretty much defeats the purpose of using a pooler in the first place |
@gtudan, consider that if you loose the master, you are going to have some connection cut/re-connection. Could you elaborate a bit more in you case or open a new issue ? In that case, feel free to link to this one if consider it. |
@rafariossaa Sure, if the master is gone, the connection cache for that node has to be flushed. In our scenario we observed writes on the slave even when both nodes were up - I assume that happened after a helm upgrade when a failover/failback was not properly performed, but I'm not sure. I totally understand that disabling the connection cache prevents those issues, as the connections are reestablished every time. But I don't quite see why the cache should have to be disabled in normal operations to prevent write operations ending up on the slave. Unfortunately, we had to rollback to the non-ha chart, because we could not figure out this issue, so I'm currently not able to reproduce this. We'll plan to retry in a few weeks, hopefully I'll be able to provide further insights then. |
I don't like the idea of disable the cache either. |
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback. |
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary. |
This config does not working for me. One of 3 Pgpool nodes keeps setting previously replica node as primary node when doing |
Name and Version
bitnami/postgresql-ha 6.5.5
What architecture are you using?
None
What steps will reproduce the bug?
Postgresql replicas=2 and Pgpool replicas=2
ERROR: cannot execute INSERT in a read-only transaction
This error occurs because Pgpool attempts to execute INSERT and UPDATE queries on a PostgreSQL instance that is in a read-only state.
Are you using any custom parameters or values?
What is the expected behavior?
Pgpool should consistently direct queries to the master node and promptly switch to the new master node whenever a change occurs.
What do you see instead?
Pgpool doesn't switch to the master node until we restart pgpool deployment.
The text was updated successfully, but these errors were encountered: