postgresql数据库搜索和处理死锁

news/2024/7/9 22:14:31 标签: postgresql

1、搜索死锁

通过语句SELECT * FROM pg_stat_activity WHERE datname='databasename' and waiting='t';即可搜索出有死锁的进程,其中databasename为database的名称;
出来的结果中datid即为此database的编号,pid即为死锁的进程号,此部分可以在数据库服务器上的进程中可以看到,通过ps -ef|grep postgres即可看到;

2、处理死锁

方法一:SELECT pg_cancel_backend(PID),缺点是这种方式只能kill select查询,对update、delete 及DML不生效;
方法二:SELECT pg_terminate_backend(PID),这种可以kill掉各种操作(select、update、delete、drop等)操作


http://www.niftyadmin.cn/n/1859190.html

相关文章

postgresql备份和还原

1、备份 使用命令pg_dump -h localhost -U user database > C:\name.bak localhost为地址,如果在本机则使用localhost即可;user为数据库所属的账户;database为要备份的库;C:\name.bak为备份路径,如果为当前文件夹,则使用相对…

Spring----AOP

1、事务配置 <tx:advice id"txAdvice" transaction-manager"transactionManager"><tx:attributes><tx:method name"do*" propagation"REQUIRED" /><tx:method name"delete*" propagation"REQUIR…

JsessionId简介与过滤

一、JsessionId jsessionid是标识session的&#xff0c;它保存在cookie中。一般情况下不会出现在url中&#xff0c;服务器会从客户端的cookie中取出来。 但是如果客户端禁用了cookie的话&#xff0c;就要重写url了&#xff0c;显式的将jsessionid重写到Url中&#xff0c;方便服…

python3.6: error while loading shared libraries: libpython3.6m.so.1.0

前两天在一台linux服务器安装python3.6的时候报了如下错误&#xff1a; python3.6: error while loading shared libraries: libpython3.6m.so.1.0:cannot open shared object file: No such file or directory 使用命令ldd /usr/local/Python-3.6/bin/python3检查其动态链接发…

python安装psycopg2报错’Error: pg_config executable not found‘

最近代码需要使用到postgresql&#xff0c;但是在安装psycopg2的时候发现报错了&#xff0c;错误如下&#xff1a; Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting psycopg2Downloading http://mirrors.aliyun.com/pypi/packages/23/7e/93c325482c32…

Java设置session超时时间

一、原因 一般的情况下系统登录后&#xff0c;都会设置一个当前session失效的时间&#xff0c;以确保在用户长时间不与服务器交互的情况下自动退出登录&#xff0c;销毁session。 二、配置 web.xml(以分钟为单位) <sesion-config><session-timeout>120</ses…

shell常用时间戳的获取和转换时间

1、获取当前日期时间 要获取当前日期时间&#xff0c;返回如1970-01-01 00:00:00则使用如下代码&#xff1a; currentTime date "%Y-%m-%d %H:%M:%S"输出2019-04-29 09:49:48 也可以使用简写&#xff1a; currentTime date "%F %T"格式可以根据需要修改…

linux环境下python的virtualenv虚拟环境与使用

一、前言 python的虚拟环境virtualenv是用于创建一个独立的python环境&#xff0c;带独立的库&#xff0c;和其他python环境完全独立互不影响&#xff0c;可以创建多个。需要在机器上先安装好一个python。 二、创建virtualenv虚拟环境 1、安装virtualenv 使用pip安装virtua…