postgresql 中的几个 timeout参数 用法情况

这篇文章主要介绍了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会禁用超时机制。这个参数只能在postgresql.conf文件中或在服务器命令行上设置。默认值是 60 秒。
 
wal_sender_timeout中断那些停止活动超过指定毫秒数的复制连接。这对发送服务器检测一个后备机崩溃或网络中断有用。设置为0将禁用该超时机制。这个参数只能在postgresql.conf文件中或在服务器命令行上设置。默认值是 60 秒。
 
补充:Postgresql数据库修改deadlock_timeout参数
 
某产品线提出要将Postgresql测试库中 deadlock_timeout 参数 修改为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/
 
1500 1891 1 0 2018 ? 01:01:47 /opt/app/PostgresPlus/9.2AS/bin/edb-postgres -D /DATA/data_utl
 
(3)切换到 enterprisedb 用户,并登陆数据库
 
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)查看该参数
 
 
1pending_restart —boolean— true if the value has been changed in the configuration file but needs a restart; or false otherwise.
 
即该参数为实时生效型参数
【声明】:芜湖站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

相关文章