Postgres 오류를 스택 트레이스로 분석하기: backtrace_functions 활용
작성자: Phil Eaton작성일: 2025년 7월 31일 Postgres가 크래시(crash)하면 gdb를 사용해 스택 트레이스를 확인할 수 있습니다.그렇다면 Postgres가 크래시하지 않는 일반적인 오류는 어떻게 디버깅할 수 있을까요? 1. Postgres 17 소스 코드 빌드 먼저 Postgres 17 소스를 가져와 디버그 심볼을 포함해 빌드해 보겠습니다. $ git clone https://github.com/postgres/postgres$ cd postgres$ git checkout REL_17_STABLE$ ./configure –enable-debug –without-icu \ –prefix=$(pwd)/build \ –libdir=$(pwd)/build/lib$ make -j16 && make install 2. 데이터베이스 생성 및 시작 $ ./build/bin/initdb testdb$ ./build/bin/pg_ctl -D $(pwd)/testdb -l logfile start 3. psql로 접속 $ ./build/bin/psql postgrespsql (17.5)Type “help” for help.postgres=# 4. 간단한 오류 발생시키기 존재하지 않는 테이블을 조회해 오류를 발생시킵니다. postgres=# SELECT * FROM nothere;ERROR: relation “nothere” does not existLINE 1: SELECT * FROM nothere; […]