#####模拟TT锁
1、创建测试表
Command> create table timesten.XIAOXU_04 as select * from TIMESTEN.XIAOXU_01;
47901 rows inserted.
2 设置不自动提交
Command> autocommit 0;
3 查询更新前记录
Command> select count(*) from timesten.XIAOXU_04;
< 47901 >
1 row found.
4 进行删除操作
Command> delete timesten.XIAOXU_04;
47901 rows deleted.
5 打开另一个窗口
5.1 查询表中数据
Command> select count(*) from timesten.XIAOXU_04;
< 47901 >
1 row found.
5.2 进行删除操作
Command> delete timesten.XIAOXU_04;
6003: Lock request denied because of time-out
Details: Tran 8.8 (pid 3078) wants W lock on table TIMESTEN.XIAOXU_04. But tran 1.9 (pid 2797) has it in W (request was W). Holder SQL (delete timesten.XIAOXU_04)
The command failed. ------此处报错,提示有w锁存在。
5.3 查看事物状态
Command> call ttlogholds;
< 11, 6719736, Replication , ORATTS1:TTSTD >
< 11, 30457856, Long-Running Transaction , 1.9 >
< 11, 38057984, Checkpoint , ttprim.ds1 >
< 11, 38062080, Checkpoint , ttprim.ds0 >
4 rows found.
---出现了长事物,根据事物ID进行分析。
5.4 查看长事物对应的锁信息
[timesten@orattm1 ~]$ ttxactadmin -xact 1.9 ttprim
2015-11-11 11:49:08.306
/u01/product/timesten/ttprim
TimesTen Release 11.2.1.9.12
Outstanding locks for transaction 1.9
PID Context TransStatus Loghold Last ID Resource ResourceID Mode SqlCmdID Name
Program File Name: ttIsqlCmd
2797 0xdf7b640 Active 11.30458104 87036:24511 Database 0x01312d0001312d00 IX 0
Table 718128 W 216481680 TIMESTEN.XIAOXU_04
5.6 根据sqlcmdid查询操作sql
Command>vertical 1;
Command> call ttsqlcmdcacheinfo(216481680);
SQLCMDID: 216481680
PRIVATE_COMMAND_CONNECTION_ID: 2048
EXECUTIONS: 3
PREPARES: 3
REPREPARES: 0
FREEABLE: 1
SIZE: 1592
OWNER: TIMESTEN
QUERYTEXT: delete timesten.XIAOXU_04 -------对应的操作SQL。
5.6 对回滚进行事物
$ttxactadmin -xactIdRollback 1.9 ttprim
######至此问题解决##########