PostgreSQL参数—deadlock_timeout
PostgreSQL参数—deadlock_timeout
参数说明
postgres=# show deadlock_timeout;
deadlock_timeout
------------------
1s
(1 row)
postgres=# \x
Expanded display is on.
postgres=# select * from pg_settings where name = 'recovery_target_timeline';
-[ RECORD 1 ]---+----------------------------------------
name | recovery_target_timeline
setting | latest
unit |
category | Write-Ahead Log / Recovery Target
short_desc | Specifies the timeline to recover into.
extra_desc |
context | postmaster
vartype | string
source | default
min_val |
max_val |
enumvals |
boot_val | latest
reset_val | latest
sourcefile |
sourceline |
pending_restart | f
postgres=#
复制
参数变更
此参数只能在服务器启动时应用,因此任何更改都需要重新启动服务器。这些设置的值通常存储在postgresql.conf
文件中,或在启动服务器时通过命令行传递。
postgres=# show deadlock_timeout;
deadlock_timeout
------------------
1s
(1 row)
postgres=# alter system set deadlock_timeout=2;
ALTER SYSTEM
postgres=# show deadlock_timeout;
deadlock_timeout
------------------
1s
(1 row)
postgres=# exit
[postgres@lyp ~]$ pg_ctl restart
waiting for server to shut down....... done
server stopped
waiting for server to start....2022-02-25 23:26:32.660 CST [9286] LOG: redirecting log output to logging collector process
2022-02-25 23:26:32.660 CST [9286] HINT: Future log output will appear in directory "log".
done
server started
[postgres@lyp ~]$ psql
psql (14.1)
Type "help" for help.
postgres=# show deadlock_timeout;
deadlock_timeout
------------------
2ms
(1 row)
postgres=#
复制
参数含义
deadlock_timeout
(integer
)
这是在检查是否存在死锁条件之前等待锁的时间。死锁检查相对昂贵,因此服务器不会在每次等待锁时都运行它。我们乐观地假设死锁在生产应用程序中并不常见,只需在锁上等待一段时间,然后再检查死锁。增加此值可减少不必要的死锁检查所浪费的时间,但会减慢真正死锁错误的报告速度。如果指定此值没有单位,则以毫秒为单位。默认值为一秒 (1s
),这可能是在实践中想要的最小值。在负载很重的服务器上,您可能需要提升它。理想情况下,该设置应该超过您的典型事务时间,以提高在服务员决定检查死锁之前释放锁的几率。只有超级用户可以更改此设置。
当log_lock_waits被设置时,这个参数还可以决定发出关于锁等待的日志之前等待的时间量。如果你想分析锁延迟,你可以设置一个比正常的deadlock_timeout
小的值。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
👍
2年前

评论
有用
2年前

评论
您好,您的文章已入选合格奖,10墨值奖励已经到账请查收!
❤️我们还会实时派发您的流量收益。
3年前

评论
相关阅读
外国CTO也感兴趣的开源数据库项目——openHalo
小满未满、
1808次阅读
2025-04-21 16:58:09
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
381次阅读
2025-04-15 14:48:05
转发有奖 | PostgreSQL 16 PGCM高级认证课程直播班招生中!
墨天轮小教习
193次阅读
2025-04-14 15:58:34
中国PostgreSQL培训认证体系新增PGAI应用工程师方向
开源软件联盟PostgreSQL分会
186次阅读
2025-05-06 10:21:13
华象新闻 | PostgreSQL 18 Beta 1、17.5、16.9、15.13、14.18、13.21 发布
严少安
157次阅读
2025-05-09 11:34:10
PG生态赢得资本市场青睐:Databricks收购Neon,Supabase融资两亿美元,微软财报点名PG
老冯云数
148次阅读
2025-05-07 10:06:22
SQL 优化之 OR 子句改写
xiongcc
142次阅读
2025-04-21 00:08:06
告别老旧mysql_fdw,升级正当时
NickYoung
126次阅读
2025-04-29 11:15:18
PostgreSQL中文社区亮相于第八届数字中国峰会
PostgreSQL中文社区
110次阅读
2025-05-07 10:06:20
PostgreSQL的dblink扩展模块使用方法
szrsu
107次阅读
2025-04-24 17:39:30