본문으로 건너뛰기
synchronous_standby_names

synchronous_standby_names

버전기본값context타입
14the setting of cluster_name if setsighupstring
15the setting of cluster_name if setsighupstring
16the setting of cluster_name if setsighupstring
17the setting of cluster_name if setsighupstring
18the setting of cluster_name if setsighupstring
19the setting of cluster_name if setsighupstring

synchronous replication을 지원할 standby 서버 목록을 지정한다. 여기 지정된 standby가 데이터 수신을 확인해야 commit을 기다리는 트랜잭션이 진행된다. 비워 두면(기본값) synchronous replication이 비활성화되어 commit이 replication을 기다리지 않는다. postgresql.conf나 서버 커맨드라인에서만 설정할 수 있으며, primary에 설정하는 파라미터다.

여기서 말하는 standby의 이름은 standby 접속 정보의 application_name이다. physical standby라면 primary_conninfo에 설정하며, 기본값은 cluster_name이 설정돼 있으면 그 값, 아니면 walreceiver다. logical replication은 subscription의 접속 정보에 설정하고 기본값은 subscription 이름이다. 실제 synchronous standby로 동작하는 것은 이 목록에 이름이 있으면서 현재 접속해 실시간으로 streaming 중인(pg_stat_replication의 state가 streaming) standby다.

목록은 다음 세 가지 문법 중 하나로 쓴다.

[FIRST] num_sync ( standby_name [, ...] )
ANY num_sync ( standby_name [, ...] )
standby_name [, ...]

FIRST num_sync는 priority 기반 방식이다. 목록 앞쪽 이름일수록 우선순위가 높고, 우선순위 상위 num_sync개의 standby에 WAL이 전달돼야 commit이 진행된다. 현재 synchronous standby가 끊기면 다음 우선순위의 standby가 즉시 그 자리를 대신한다. ANY num_sync는 quorum 기반 방식으로, 나열한 standby 중 어느 것이든 num_sync개가 응답하면 commit이 진행된다. 키워드 없이 이름만 나열하는 세 번째 문법은 FIRST 1과 같은 의미다. 특수 항목 *는 모든 standby 이름과 매칭된다.

synchronous replication이 켜져 있어도 개별 트랜잭션은 synchronous_commitlocal이나 off로 두어 대기를 건너뛸 수 있다.

운영 노트: standby가 하나뿐인 구성에서 이 파라미터를 설정하면 그 standby 장애 시 모든 commit이 멈춘다. 몇 대의 standby 중 몇 대의 응답을 기다릴지(FIRST/ANY와 num_sync)를 가용성과 데이터 보호 요구에 맞춰 설계하고, num_sync가 실제 standby 수를 넘지 않는지 반드시 확인해야 한다.

출처: PostgreSQL 18 문서