database - PostgreSQL 错误:进程仍在等待数据库 0 的关系 2676 上的 AccessShareLock
问题描述
我们无法连接到 PostgreSQL 实例,我们必须重新启动 PostgreSQL 服务才能连接到实例,但几天后我们开始收到同样的错误。
日志显示以下错误
2019-02-18 08:00:03.043 UTC [5053] postgres@utilitydbLOG: process 5053 still waiting for AccessShareLock on relation 2676 of database 0 after 1000.431 ms
2019-02-18 08:04:04.486 UTC [5170] bucardo@bucardoLOG: process 5170 still waiting for AccessShareLock on relation 2676 of database 0 after 1001.006 ms
2019-02-18 08:15:02.802 UTC [5445] postgres@utilitydbLOG: process 5445 still waiting for AccessShareLock on relation 2676 of database 0 after 1000.425 ms
2019-02-18 08:30:02.844 UTC [5846] postgres@utilitydbLOG: process 5846 still waiting for AccessShareLock on relation 2676 of database 0 after 1000.501 ms
2019-02-18 08:33:23.428 UTC [5940] bucardo@bucardoLOG: process 5940 still waiting for AccessShareLock on relation 2676 of database 0 after 1001.265 ms
2019-02-18 08:45:02.869 UTC [6269] postgres@utilitydbLOG: process 6269 still waiting for AccessShareLock on relation 2676 of database 0 after 1000.340 ms
2019-02-18 08:51:08.230 UTC [6478] dbuser@postgresLOG: process 6478 still waiting for AccessShareLock on relation 2676 of database 0 after 1000.438 ms
当我检查服务状态时,它显示以下详细信息
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
postgres: postgres utilitydb [local] startup waiting
我知道我需要检查数据库中的锁,但日志中提供的信息并不那么详细。PostgreSQL 系统表中没有 oid = 0 的数据库。
我该如何调试这个问题?
任何帮助,将不胜感激。
解决方案
有东西ACCESS EXCLUSIVE
锁定了pg_authid_rolname_index
索引。
持有此锁时,没有人可以使用该索引,并且由于这是用户表上的索引(pg_authid
),您需要搜索某个用户名,因此无法成功登录。
您已成为“拒绝服务”攻击的牺牲品。
如果存在持有锁的活动数据库会话,则将其终止。
如果即使重新启动数据库,锁仍然存在,它必须是一个准备好的事务。关闭数据库并清理pg_twophase
数据目录的子目录。
更好地保护您的数据库并更改所有超级用户密码。
推荐阅读
- php - 保留报价账单和运输国家 ELSE 根据 IP 分配位置(地理位置)
- javascript - 无法通过 react ref 获得正确的 clientWidth 或 clientHeight
- .net - 更改接入点时出现本机 WiFi 错误
- python - python requests 'application/x-www-form-urlencoded;charset=utf-8' 没有返回正确的内容
- c - 使用while循环在C中反转字符串
- ruby-on-rails - 无法通过捆绑器 Heroku 安装 gem,设计 4.5.0 不可用
- matlab - MATLAB:网络有共同的价值,如何将它们分组?
- python - 无法从 Django sqlite3 数据库中删除项目,出现错误“外键约束失败”
- amcharts - 日期轴:年份标签被截断到十位
- android - 从 Firebase 存储中检索图像