synchronous_standby_names
| 버전 | 기본값 | context | 타입 |
|---|---|---|---|
| 14 | the setting of cluster_name if set | sighup | string |
| 15 | the setting of cluster_name if set | sighup | string |
| 16 | the setting of cluster_name if set | sighup | string |
| 17 | the setting of cluster_name if set | sighup | string |
| 18 | the setting of cluster_name if set | sighup | string |
| 19 | the setting of cluster_name if set | sighup | string |
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_commit을 local이나 off로 두어 대기를 건너뛸 수 있다.
출처: PostgreSQL 18 문서