lightdb数据库超时相关控制参数
在业务开发中,通常因为代码不规范、中间件缺陷、DBA误提交批量SQL等原因,会导致服务端连接一直存在、但是实际上并未在执行的情况,从而导致数据库连接泄露。为了防止这种异常情况积压,lightdb中包含了多个参数用于控制超时相关的行为:
- lock_timeout:控制多久拿不到锁就自动超时并回滚事务
- idle_in_transaction_session_timeout:设置会话在进入事务块(显示BEGIN)后,一直未退出、也未在执行SQL后多久自动结束会话
- statement_timeout:设置语句执行最长多久,超过之后就自动超时
- idle_session_timeout:设置会话在没有进入事务块(显示BEGIN),也没有执行SQL后多久没活动自动超时
lightdb@oradb=# set idle_session_timeout to 3; SET lightdb@oradb=# lightdb@oradb=# lightdb@oradb=# lightdb@oradb=# commit; FATAL: terminating connection due to idle-session timeout server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded.
lightdb@oradb=# show %idle%; name | setting | description -------------------------------------+---------+-------------------------------------------------------------------------------- idle_in_transaction_session_timeout | 0 | Sets the maximum allowed idle time between queries, when in a transaction. idle_session_timeout | 0 | Sets the maximum allowed idle time between queries, when not in a transaction. tcp_keepalives_idle | 300 | Time between issuing TCP keepalives. (3 rows) lightdb@oradb=# set idle_in_transaction_session_timeout to 3; SET lightdb@oradb=# begin; BEGIN lightdb@oradb=*# select 1; FATAL: terminating connection due to idle-in-transaction timeout server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Succeeded.
lightdb@oradb=# set statement_timeout = 10000; SET lightdb@oradb=# select pg_sleep(10) from pg_class ; ERROR: canceling statement due to statement timeout
详细可见https://www.light-pg.com/docs/lightdb/current/runtime-config-client.html。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2022-05-16 PostgreSQL 14.3、13.7、12.11、11.16 和 10.21 发布
2016-05-16 原百万访问量博客http://blog.chinaunix.net/uid/20656672.html不再维护(10年前数百篇oracle/teradata性能优化、故障处理案例)
2016-05-16 p7-p8面试经验总结--拿到offer