postgresql 의 timeout 매개 변수 사용법 설명

오늘 postgresql 의 timeout 인 자 를 정리 하 였 습 니 다.

select version();
                         version                         
---------------------------------------------------------------------------------------------------------
 PostgreSQL 10.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit
(1 row)
select *
from pg_settings ps
where 1=1
and ps.name like '%timeout%'
;
        name         | setting | unit |              category              |                    short_desc                     |       extra_desc       | context | vartype | source | min_val | max_val  | enumvals | boot_val | reset_val | sourcefile | sourceline | pending_restart 
-------------------------------------+---------+------+--------------------------------------------------------------+-------------------------------------------------------------------------------------------+-------------------------------------+-----------+---------+---------+---------+------------+----------+----------+-----------+------------+------------+-----------------
 archive_timeout           | 0    | s  | Write-Ahead Log / Archiving                 | Forces a switch to the next WAL file if a new file has not been started within N seconds. |                   | sighup  | integer | default | 0    | 1073741823 |     | 0    | 0     |      |      | f
 authentication_timeout       | 60   | s  | Connections and Authentication / Security and Authentication | Sets the maximum allowed time to complete client authentication.             |                   | sighup  | integer | default | 1    | 600    |     | 60    | 60    |      |      | f
 checkpoint_timeout         | 300   | s  | Write-Ahead Log / Checkpoints                | Sets the maximum time between automatic WAL checkpoints.                 |                   | sighup  | integer | default | 30   | 86400   |     | 300   | 300    |      |      | f
 deadlock_timeout          | 1000  | ms  | Lock Management                       | Sets the time to wait on a lock before checking for deadlock.               |                   | superuser | integer | default | 1    | 2147483647 |     | 1000   | 1000   |      |      | f 
 idle_in_transaction_session_timeout | 0    | ms  | Client Connection Defaults / Statement Behavior       | Sets the maximum allowed duration of any idling transaction.               | A value of 0 turns off the timeout. | user   | integer | default | 0    | 2147483647 |     | 0    | 0     |      |      | f
 lock_timeout            | 0    | ms  | Client Connection Defaults / Statement Behavior       | Sets the maximum allowed duration of any wait for a lock.                 | A value of 0 turns off the timeout. | user   | integer | default | 0    | 2147483647 |     | 0    | 0     |      |      | f
 statement_timeout          | 0    | ms  | Client Connection Defaults / Statement Behavior       | Sets the maximum allowed duration of any statement.                    | A value of 0 turns off the timeout. | user   | integer | default | 0    | 2147483647 |     | 0    | 0     |      |      | f
 wal_receiver_timeout        | 60000  | ms  | Replication / Standby Servers                | Sets the maximum wait time to receive data from the primary.               |                   | sighup  | integer | default | 0    | 2147483647 |     | 60000  | 60000   |      |      | f
 wal_sender_timeout         | 60000  | ms  | Replication / Sending Servers                | Sets the maximum time to wait for WAL replication.                    |                   | sighup  | integer | default | 0    | 2147483647 |     | 60000  | 60000   |      |      | f
(9 rows)
다음은 이 몇 개의 매개 변 수 를 간단하게 소개 합 니 다.archive_timeout서버 가 주기 적 으로 새로운 WAL 세그먼트 파일 로 전환 하 는 것 을 제어 합 니 다.쉽게 말 하면 정시 압축 파일 입 니 다.authentication_timeout서버 인증 을 완료 한 지 가장 오래 되 며,이 시간 내 에 인증 이 완료 되 지 않 으 면 서버 는 연결 을 닫 습 니 다.checkpoint_timeout자동 WAL 검사 점 사이 의 가장 긴 시간 동안 이 매개 변 수 를 늘 리 면 데이터베이스 가 붕 괴 된 후 회복 하 는 시간 이 길 어 집 니 다.deadlock_timeout자물쇠 검 사 를 하기 전에 한 자물쇠 에서 기다 리 는 총 시간idle_in_transaction_session_timeout여가 시간 초과.이 매개 변수 가 지정 한 시간(밀리초 단위)을 초과 하여 사 무 를 여 는 세 션 을 종료 합 니 다.이 세 션 이 가지 고 있 는 모든 잠 금 이 풀 리 고 있 는 연결 슬롯 을 다시 사용 할 수 있 으 며,이 트 랜 잭 션 에 보 이 는 원본 만 정리 할 수 있 습 니 다.lock_timeout잠 금 대기 시간 초과.문 구 는 표,색인,줄 또는 다른 데이터베이스 대상 의 자 물 쇠 를 가 져 오 려 고 할 때 지정 한 밀리초 가 넘 으 면 이 문 구 는 중 단 됩 니 다.postgresql.conf 에 설정 하 는 것 을 추천 하지 않 습 니 다.statement_timeout제어 문 구 는 실행 시간 이 길 고 단 위 는 ms 입 니 다.설정 값 을 초과 하면 이 문 구 는 중 지 됩 니 다.
postgresql.conf 에 설정 하 는 것 을 추천 하지 않 습 니 다.굳이 설정 하려 면 큰 값 을 설정 해 야 합 니 다.wal_receiver_timeout지정 한 밀리초 이상 의 비활성 상태 에 있 는 복사 링크 를 중단 합 니 다.이것 은 수신 중인 예비 서버 에서 메 인 서버 가 붕괴 되 거나 네트워크 가 끊 어 지 는 것 을 감지 하 는 데 유용 합 니 다.0 으로 설정 하면 시간 초과 메커니즘 을 사용 하지 않 습 니 다.이 매개 변 수 는 post gresql.conf 파일 이나 서버 명령 줄 에 만 설정 할 수 있 습 니 다.기본 값 은 60 초 입 니 다.wal_sender_timeout지정 한 밀리초 이상 의 복사 연결 을 중단 합 니 다.이것 은 송신 서버 에서 예비 기기 가 붕괴 되 거나 네트워크 가 중단 되 는 것 을 감지 하 는 데 유용 하 다.0 으로 설정 하면 이 시간 초과 메커니즘 을 사용 하지 않 습 니 다.이 매개 변 수 는 post gresql.conf 파일 이나 서버 명령 줄 에 만 설정 할 수 있 습 니 다.기본 값 은 60 초 입 니 다.
추가:Postgresql 데이터베이스 수정 deadlocktimeout 매개 변수
모 제품 라인 에서 Postgresql 테스트 라 이브 러 리 의 deadlocktimeout 매개 변 수 는 1s 로 변경 되 었 습 니 다.
이 라 이브 러 리 는 평소에 자신의 손 에서 유지 하지 않 기 때문에 실제 작업 절 차 는 다음 과 같다.
(1)데이터베이스 설치 소속 사용자 확인
어떤 계 정 이 있 는 지 확인 해 보 세 요.postgresql 에서 사용 할 수 있 습 니 다.

bash-4.1$ cd /home
bash-4.1$ ls
aquota.user enterprisedb lost+found prouser puppet
(2)데이터베이스 설치 경 로 를 확인한다.
bash-4.1$ps-ef|grep post 서비스 프로 세 스 를 보고 설치 디 렉 터 리/opt/app/PostgresPlus/9.2as/를 찾 습 니 다.

500 1891 1 0 2018 ? 01:01:47 /opt/app/PostgresPlus/9.2AS/bin/edb-postgres -D /DATA/data_utl
(3)enerprisedb 사용자 로 전환 하고 데이터 베 이 스 를 로그 인 합 니 다.

bash-4.1$ su - enterprisedb
bash-4.1$ psql -U enterprisedb
psql (9.2.14.31)
Type “help” for help.
현재 이 매개 변수 설정 3s 보기

edb=# show deadlock_timeout;
deadlock_timeout

3s
(1 row)
(4)이 인자 보기

pending_restart ―boolean― true if the value has been changed in the configuration file but needs a restart; or false otherwise.
즉,이 매개 변 수 는 실시 간 발효 형 매개 변수 이다.
(5)사용 시도

test=# alter system set deadlock_timeout=‘1s';
오 류 는 다음 과 같다.

ERROR: syntax error at or near “system”
LINE 1: alter system set deadlock_timeout=‘1s';
설명 조회:
alter system 명령 은 9.4 이후 버 전의 버 전에 만 유효 합 니 다.
(6)실행 시도

set deadlock_timeout=‘1s'
edb=# show deadlock_timeout;
1s 로 표시
그러나 나머지 사용자 로그 인 경로 에서 이 매개 변 수 는 여전히 3s 인 것 을 발견 했다.
-이 방법 은 session 단계 로 설정 되 어 있 으 며,Oacle 과 유사 한 alter session set
(7)pg 프로필 수정 시도,진입/DATA/datautl 경로 수정

bash-4.1$ pwd
/DATA/data_utl
bash-4.1$ ls
base pgbin pg_ident.conf pg_notify pg_stat_tmp pg_twophase postgresql.conf postmaster.opts
dbms_pipe pg_clog pg_log pg_serial pg_subtrans PG_VERSION postgresql.conf.20191119 postmaster.pid
global pg_hba.conf pg_multixact pg_snapshots pg_tblspc pg_xlog postgresql.conf.bak utlp.sql
vi postgresql.conf
그 중 deadlocktimeout 설정 이 1s 로 변경 되 었 습 니 다.
(8)데이터베이스 다시 불 러 오기

bash-4.1$ ./pg_ctl reload
server signaled
(9)이 인자 가 적 용 된 것 을 확인 합 니 다.

edb=# show deadlock_timeout;
deadlock_timeout
1s
(1 row)
탈퇴

edb=# \q
9 단계 도 데이터 베 이 스 를 다시 시작 하면 유효 합 니 다.
정지 명령:

./pg_ctl stop -m fast
시작 명령:

./pg_ctl -D /DATA/data_utl start
이상 은 개인 적 인 경험 이 므 로 여러분 에 게 참고 가 되 기 를 바 랍 니 다.여러분 들 도 저 희 를 많이 응원 해 주시 기 바 랍 니 다.만약 잘못 이 있 거나 완전히 고려 하지 않 은 부분 이 있다 면 아낌없이 가르침 을 주시 기 바 랍 니 다.

좋은 웹페이지 즐겨찾기