为什么informix数据库锁表重启后就坏了
我的informix数据库是装载windows下的
因为之前的数据库是用oracle,现在换成informix,老是遇到锁表的问题,有的可以抛出来,然后改改应用就OK了,问题是有些锁表直接就死掉了,怎么也连不上,onmode -z杀不掉session,oninit说实例仍然在运行,onmode -m半天没反应,进去select数据库报no connections are allowed in quiescent mode ,去重启服务失败,然后整个重启就说一些服务启动后又停止了,没什么可做的之类,搞的现在一锁表就要配置一个新的服务,然后再建数据库,搞的我都快疯掉了,网上查了很多,都说重启数据库就OK了,可是根本就重启不了,等半天再启动就不行了,进去什么也没有,有木有牛人能告诉我这个问题到底是怎么回事,该怎样解决,小弟先谢谢各位了。
[最优解释]
应该将锁表的SQL语句合出来看看,看看能否优化
转:
锁表处理步骤:
1、onstat -ks
[其他解释]
1、要找到在执行什么操作时锁表,SQL语句?才能避免;
2、错误日志(系统日志)中有无信息;
3、锁表后强行退出?数据库被破坏?。
[其他解释]
onmode -ky
[其他解释]
grep HDR+X //重查询是那个表被锁
address wtlist owner lklist type tblsnum rowid key#/bsiz
c1809510 0 d656e774 c181cb3c HDR+X 6002e1 2c602 0
需要关注lklist和type项,从上面来看tblsnum为6002e1(6292193十六进制转换成十进制)
的表被锁了。可以重查询是那个表被锁:
dbaccess :select * from systables where partnum='6292193'得到
tabname basetab_mvpn
owner smpmml
partnum 6292193
tabid 12813
rowsize 464
ncols 61
nindexes 1
nrows 2984
created 12/10/2002
version 839843846
tabtype T
locklevel R
npused 746
fextsize 16
nextsize 16
flags 0
2、onstat -u,将owner(address)为d656e774的线程找出来
address flags sessid user tty wait tout locks nreads nwrites
d656e774 Y--P--- 4261 smp20 - d6ad2330 0 180 99620 16
3、onstat -g sql d656e774可以将这个线程执行过的sql语句打印出来。
4、只要用informix用户执行onmode-z sessid干掉线程
onmode-z 4261
重点说明:onstat -g ses sessid找个进程PID来,然后ps -ef
[其他解释]
grep Pid; kill -9 pid
在处理这些问题时还会遇到表被锁是因为该线程还没有执行完毕,此时就不能简单的 onmode -z杀线程
[其他解释]
这个不行,等了半天直接告诉我超时了。
in DBSPACETEMP: 'emvsbspace'
13:25:55 Physical Recovery Started at Page (1:2468).
13:25:55 Physical Recovery Complete: 0 Pages Examined, 0 Pages Restored.
13:25:55 Logical Recovery Started.
13:25:55 10 recovery worker threads will be started.
13:25:56 Logical Recovery has reached the transaction cleanup phase.
13:25:56 Logical Recovery Complete.
0 Committed, 0 Rolled Back, 0 Open, 0 Bad Locks
13:25:57 Onconfig parameter STORAGE_FULL_ALARM modified from 0 to 3.
13:25:57 Dataskip is now OFF for all dbspaces
13:25:57 Init operation complete - Mode Online
13:25:57 Checkpoint Completed: duration was 0 seconds.
13:25:57 Tue Sep 20 - loguniq 4, logpos 0x904018, timestamp: 0x41c3e Interval: 56
13:25:57 Maximum server connections 0
13:25:57 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 2, Llog used 1
13:25:57 On-Line Mode
13:26:00 SCHAPI: Started dbScheduler thread.
13:26:00 Booting Language <spl> from module <>
13:26:00 Loading Module <SPLNULL>
13:26:00 SCHAPI: Started 2 dbWorker threads.
13:31:26 Checkpoint Completed: duration was 0 seconds.
13:31:26 Tue Sep 20 - loguniq 4, logpos 0x910018, timestamp: 0x4264d Interval: 57
13:31:26 Maximum server connections 1
13:31:26 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 14, Llog used 12
13:38:10 Logical Log 4 Complete, timestamp: 0x46fe7.
13:38:21 Checkpoint Completed: duration was 0 seconds.
13:38:21 Tue Sep 20 - loguniq 5, logpos 0x180018, timestamp: 0x4703e Interval: 58
13:38:21 Maximum server connections 2
13:38:21 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 657, Llog used 564
13:38:22 'ca5' - New logging mode: BUFFERED
13:38:22 Checkpoint Completed: duration was 0 seconds.
13:38:22 Tue Sep 20 - loguniq 5, logpos 0x182098, timestamp: 0x47051 Interval: 59
13:38:22 Maximum server connections 2
13:38:22 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 1, Plog used 0, Llog used 3
13:41:39 Checkpoint Completed: duration was 1 seconds.
13:41:39 Tue Sep 20 - loguniq 5, logpos 0x4a3018, timestamp: 0x4e21e Interval: 60
13:41:39 Maximum server connections 3
13:41:39 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 1595, Llog used 801
13:41:40 'ca5' - New logging mode: BUFFERED
13:41:40 Checkpoint Completed: duration was 0 seconds.
13:41:40 Tue Sep 20 - loguniq 5, logpos 0x4a5098, timestamp: 0x4e231 Interval: 61
13:41:40 Maximum server connections 3
13:41:40 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 1, Plog used 0, Llog used 3
13:46:53 Checkpoint Completed: duration was 0 seconds.
13:46:53 Tue Sep 20 - loguniq 5, logpos 0x4a8018, timestamp: 0x4e269 Interval: 62
13:46:53 Maximum server connections 3
13:46:53 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 0, Llog used 3
13:56:53 Checkpoint Completed: duration was 0 seconds.
13:56:53 Tue Sep 20 - loguniq 5, logpos 0x4ac7b4, timestamp: 0x4e41c Interval: 63
13:56:53 Maximum server connections 3
13:56:53 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 8, Llog used 4
这是今天那个库的log文件拷贝的日志,我把原来那个数据库删了,又重建的,然后用备份的数据恢复了。就是那个ca5坏掉了。
3。onstat -u
[其他解释]
转:
1。找到被锁表的partnum:select hex(partnum) from systables where tabname = ”tmp”;
2。onstat -k
[其他解释]
grep owner 找到用户会话session号;
4。onmode -z sesid 杀掉该session;
5。如果第4步失败,则进一步onstat -g ses