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

Streaming replication : cannot promote to master while master is down #439

Closed
apompee opened this issue Jul 11, 2023 · 2 comments
Closed

Comments

@apompee
Copy link
Contributor

apompee commented Jul 11, 2023

What is the bug or the crash?

The streaming replication works fine and data is correctly replicated. But when trying to promote to master a node if the master is down, the node will loop over an error trying to connect to master.

pg-master:5432 - no response
[Entrypoint]  Waiting for master to ping...

Promoting to master a node would typically happen when the master is down, so it defeats the purpose of this functionnality.

Steps to reproduce the issue

  1. Go to replication_examples/streaming_replication
  2. make up
  3. Check if data is replicated
  4. Stop master and promote to master the node : docker compose down pg-master && PROMOTE_MASTER="True" DESTROY_DATABASE_ON_RESTART="False" docker compose up -d --scale pg-master=0
  5. make node-log

Versions

14-3.2
15-3.3

Additional context

No response

@NyakudyaA
Copy link
Collaborator

Looks like there are a couple of settings that need to be fixed.

  • pg-node needs to be running in order to initiate a promotion.

So rather exec into the container and run

    pg_ctl promote -D ${DATADIR}

Then scale down master and start the pg-node container

Can you confirm if this works and I will do a PR later to auto fix this logic

@apompee
Copy link
Contributor Author

apompee commented Jul 17, 2023

I just did the test. I scaled down the master before promoting the node.
To promote the node, I had to do :

# . env-data.sh 
# su postgres -c "pg_ctl promote -D ${DATADIR}"
waiting for server to promote.... done
server promoted

Then, I could insert into the database without restarting anything :

gis=# INSERT INTO sweets (name ,price) values ('Test', 10);
INSERT 0 1
gis=# select * from sweets; 
 id |    name    | price 
----+------------+-------
  1 | strawberry |  4.50
  2 | Coffee     |  6.20
  3 | lollipop   |  3.80
  4 | Test       |    10

NyakudyaA added a commit that referenced this issue Sep 4, 2023
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