N
N
noute2020-07-15 16:20:17
PostgreSQL
noute, 2020-07-15 16:20:17

Postgresql replication is broken I know why I don't know how to fix standby?

Good afternoon.
I have configured cascading replication from one master, there is a slave, which in turn, after synchronization, replicates to the last slave.
OC - ​​Ubuntu 18
DBMS - PostgreSQL 10
https://postgrespro.ru/docs/postgrespro/10/warm-standby

The problem is that on the slaves I have an error "

error requested wal segment has already been removed".

Do I understand correctly that this error says that If the base with which WAL is configured to receive has already deleted the segment, then replication will just arise with an error that there is no such segment anymore. If there is nowhere to restore it, then you need to copy the replica again. The easiest way is through pg_basebackup.
https://ru.stackoverflow.com/questions/972585/post...

In this regard, there are questions:

1. Can I do it somehow to a friend?
For example:
Stop the slave, copy the pg_wal folder with files from the master and start it ? Will the slave become the master after that?
I just don’t understand what will need to be done on the slave so that it catches up with the master. In other words, how to restore step by step.

2. Could this error have occurred because of what I'm doing on the master pg_basebackup -D /my_dir. Which, in turn, locks the database and replication cannot go through. More precisely, it passes but with an error.
Then how to do pg_basebackup correctly so that the replica does not break?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-07-15
@melkij

copy the pg_wal folder with files from the master

If the required segment was on the primary, it would have been given to the replica a long time ago at the walreceiver's request. So it's not there.
If you still have all the necessary wal on one of the replicas - yes, you can put them in pg_wal. The base wal will see them in its usual source polling cycle. Or switch primary_conninfo to this replica, it will take it by itself.
Which in turn locks the base

basebackup does not block the base. This is generally a very simple and stupid thing in its essence.
In order for the replica to catch up with the primary in the absence of the necessary WALs, you need knowledge of the PGDATA internals. Which you do not have, which is obvious from the question "Will the slave become the master after this?". Therefore, the only simple and reliable way is to make pg_basebackup again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question