DBA/Postgresql

wal_log_hint에 대한 테스트

da-dba 2024. 5. 3. 15:09

WAL_LOG_HINT가 설정되지 않았을때의 pg_rewind 테스트

g_rewind를 사용하기 위해서는 Target Database (Failover 되기전의 Master 서버였던 서버, Old Master)에서 wal_log_hint 옵션이 활성화 되어 있어야한다.
만약 rewind시 활성화가 되어 있지 않다면 다음과 같은 에러메세지를 출력한다

postgres@VS1-REPL-TEST-001:~$ /usr/lib/postgresql/12/bin/pg_rewind --source-server='host=10.**.***.** port=5432 user=TEST1 password=! dbname=test' --target-pgdata=/var/lib/postgresql/12/main -P
pg_rewind: connected to server
pg_rewind: fatal: target server needs to use either data checksums or "wal_log_hints = on"

이는 Promote한 Slave Server의 WAL Checkpoint의 시작지점이 Target Server와 일치해야 하나,Target Server에서 Slave가 Promote한 이후 Transaction (WAL)이 쌓인 이력이 있는 경우 발생한다.
wal_log_hint가 활성화 된 경우, 중요하지 않은 Page buffer에 대해서도 WAL Logging을 하며, rewind에 필요한 정보가 담기게 된다.

 

테스트 결과, WAL_LOG_HINT가 활성화 된 이후 Rewinding을 하려는 Old Master에서 WAL 파일을 쌓은 이후에는 rewinding이 정상적으로 동작한다.