PostgreSQL 19 업그레이드 전 pg_upgrade --check
PostgreSQL 19(2026-11-19)로 올리기 전 pg_upgrade --check 로 막힐 곳을 찾고, 릴리스 노트의 호환성 변경 중 설정·인덱스·이름 문제를 18 서버에서 미리 확인합니다.
PostgreSQL 19 는 2026-11-19 에 나왔고, 18 에서 올리려면 pg_upgrade·덤프 복원·논리 복제 중 하나가 필요합니다. 먼저 pg_upgrade --check 로 막힐 곳을 찾습니다. 정본은 릴리스 노트 「Migration to Version 19」와 pg_upgrade 문서입니다. 출력은 18.7·19.0 빈 클러스터의 것입니다.
[1] 점검에는 19 바이너리가 필요합니다. postgres:19 이미지가 2026-11-20 에 없어(not found), postgres:18 컨테이너에 PGDG apt 의 postgresql-19 를 설치했습니다.
$ dpkg -l 'postgresql-1[89]' | grep '^ii' | awk '{print $2, $3}'postgresql-18 18.7-1.pgdg13+2postgresql-19 19.0-1.pgdg13+1[2] 옛 클러스터는 지금 쓰는 18 데이터 폴더(시험에서는 빈 /tmp/old)이고, 새 클러스터는 19 의 initdb 로 호환되는 옵션을 써서 따로 만듭니다. 첫 줄은 이후 명령의 변수입니다.
$ export O=/usr/lib/postgresql/18/bin N=/usr/lib/postgresql/19/bin$ $O/initdb -D /tmp/old -U postgres$ $N/initdb -D /tmp/new -U postgres[3] 새 판의 pg_upgrade --check 를 돌립니다. 데이터를 바꾸지 않으며 현재 폴더에 쓰기 권한이 필요합니다. --link 등으로 올릴 거라면 점검에도 같은 옵션을 줍니다.
$ $N/pg_upgrade --check -b $O -B $N -d /tmp/old -D /tmp/new | tail -n 3Checking new cluster tablespace directories ok *Clusters are compatible*[4] 막히는 첫째 경우는 btree_gist 의 inet·cidr 인덱스입니다. 노트는 inet·cidr 기본 연산자 클래스가 내장 GiST 로 바뀌어 pg_upgrade 가 이런 인덱스를 막는다고 적습니다. 켜 둔 18 서버에서 찾는 쿼리와 점검 결과입니다.
$ $O/psql -h /tmp -d postgres -Atc "SELECT c.relname, o.opcname FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid JOIN pg_opclass o ON o.oid = ANY (i.indclass::oid[]) WHERE o.opcname IN ('gist_inet_ops', 'gist_cidr_ops')"hosts_addr_gist|gist_inet_ops $ $N/pg_upgrade --check -b $O -B $N -d /tmp/old -D /tmp/new | tail -n 9Checking for uses of gist_inet_ops/gist_cidr_ops fatal…binary-upgraded. Replace them with indexes that use the built-in GiSTinet_ops operator class.A list of indexes with the problem is in the file: /tmp/new/pg_upgrade_output.d/20261119T231633.113/gist_inet_ops.txtFailure, exiting[5] 둘째 막힘은 이름에 줄바꿈·캐리지 리턴이 든 데이터베이스·역할·테이블스페이스입니다(노트는 pg_upgrade 도 막는다고 적음). 줄바꿈이 든 이름의 DB 로 점검하면 「…invalid characters (newline or carriage return)」 와 함께 이름을 바꾸라는 안내가 나옵니다.
[6] 점검이 잡지 않는 설정 변경: 노트는 max_locks_per_transaction 64 → 128, JIT 기본 끔, io_workers 제거를 적습니다. 18 서버($O/psql 로 같은 쿼리)는 io_workers|3, jit|on, max_locks_per_transaction|64 였습니다. 새 클러스터를 띄워 보냅니다(-h /tmp 는 소켓 폴더).
$ $N/pg_ctl -D /tmp/new -o "-c listen_addresses='' -c unix_socket_directories=/tmp" -l /tmp/new.log -w start$ $N/psql -h /tmp -d postgres -Atc "SELECT name, setting FROM pg_settings WHERE name IN ('jit','max_locks_per_transaction','io_workers') ORDER BY 1"jit|offmax_locks_per_transaction|12819 에는 io_workers 가 없습니다. postgresql.conf 에 옛 이름이 남으면 19 가 FATAL: unrecognized configuration parameter "io_workers" 로 시작을 거부합니다. 대체 변수는 io_min_workers·io_max_workers 등 네 개입니다. max_locks_per_transaction 은 같은 수용량에 사실상 두 배가 필요하다고 노트가 적습니다.
[7] 노트의 나머지 호환성 항목 중 해당하는 것을 고릅니다(일부만 추렸습니다).
| 노트의 변경 | 볼 곳 |
|---|---|
MD5 인증 뒤 경고(md5_password_warnings 로 끔) | 아래 쿼리 |
| RADIUS 인증 제거 | pg_hba.conf 의 radius (보는 법) |
standard_conforming_strings 항상 켬 · MULE_INTERNAL 제거 | 끈 채 만든 옛 덤프 · 그 인코딩 DB |
전문 검색·pg_trgm 문자 분류 변경 | 노트 원문: 「it is recommended to reindex all indexes which use full text search and pg_trgm after the upgrade, and to recompute any stored tsvector values」. 대상: libc 가 아닌 로케일 제공자가 LC_CTYPE 과 다르게 동작하는 DB |
MD5 역할은 SELECT rolname FROM pg_authid WHERE rolpassword LIKE 'md5%' 로 찾습니다(슈퍼유저 권한). 인증 오류는 password authentication failed 순서로 봅니다.
[8] 올린 뒤에는 문서대로 통계를 다시 만듭니다(일부만 옮겨집니다). 18.7 보안 업데이트는 별도 글.
$ vacuumdb --all --analyze-in-stages --missing-stats-only$ vacuumdb --all --analyze-only