我的MySQL版本是 服务器版本:5.1.51-ndb-7.1.9a-cluster-com-log MySQL Cluster Server(商业)
我有一个更新查询,导致'超过锁定等待超时;尝试重启事务'。 表create语句是:
CREATE TABLE `NGMP_OLTP`.`MT_Routing_Info` (
`Message_Id` varchar(70) CHARACTER SET latin1 NOT NULL,
`Route_Id` int(10) DEFAULT NULL,
`Spf_Short_Code` varchar(32) CHARACTER SET latin1 DEFAULT NULL,
`Network_Search_Option` smallint(5) DEFAULT NULL,
`Priority` int(10) DEFAULT NULL,
`Charge_Code` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
`Barred` varchar(1) CHARACTER SET latin1 DEFAULT NULL,
`Dynamic_Spoofing` varchar(1) CHARACTER SET latin1 DEFAULT NULL,
`AV_Required` varchar(1) CHARACTER SET latin1 DEFAULT NULL,
`AV_Status` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
`Price_Point` int(10) DEFAULT NULL,
`NW_Connector_Id` int(10) DEFAULT NULL,
`Sent_Time` datetime DEFAULT NULL,
`Operator_Id` int(10) DEFAULT NULL,
`Short_Code` varchar(15) CHARACTER SET utf8 DEFAULT NULL,
`Service_Id` int(10) DEFAULT NULL,
`SMPP_BIND_ID` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`Frgtotal` int(11) DEFAULT '0',
PRIMARY KEY (`Message_Id`),
KEY `IX_MT_Routing_Info` (`Message_Id`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;
正在进行更新的存储过程是:
DELIMITER $$
DROP PROCEDURE IF EXISTS `NGMP_OLTP`.`usp_UpdateMTRouting_Info` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_UpdateMTRouting_Info`(
msgid varchar(50),
senttime varchar(30),
routeid varchar(32),
operid varchar(32),
scode nvarchar(15),
spfsc varchar(32),
nwopt varchar(16),
prty varchar(32),
ccode varchar(64),
barred varchar(1),
dynspf varchar(1),
svcid varchar(32),
prpt varchar(32),
avreqd varchar(1),
avstat varchar(20),
nwconid varchar(32),
tsstr varchar(2000),
isfinalstr varchar(200),
idstr varchar(200) ,
bindid varchar(100)
)
BEGIN
if routeid = '' then set routeid = null; end if;
if operid = '' then set operid = null; end if;
if nwopt = '' then set nwopt = null; end if;
if prty = '' then set prty = null; end if;
if svcid = '' then set svcid = null; end if;
if prpt = '' then set prpt = null; end if;
if nwconid = '' then set nwconid = null; end if;
if bindid = '' then set bindid = null; end if;
UPDATE MT_Routing_Info SET
Route_Id = routeid,
Spf_Short_Code = spfsc,
Network_Search_Option = nwopt,
Priority = prty,
Charge_Code = ccode,
Barred = barred,
Dynamic_Spoofing = dynspf,
AV_Required = avreqd,
AV_Status = avstat,
Price_Point = prpt,
NW_Connector_Id = nwconid,
Sent_Time=senttime,
Operator_Id = operid,
Short_Code = scode,
Service_Id = svcid,
SMPP_BIND_ID=bindid
WHERE Message_Id = msgid;
Call usp_SaveMsgProcStatus (msgid, tsstr, ',', isfinalstr, ',', idstr, ',');
END $$
DELIMITER ;
在MT_Routing_Info表中,我有一个Message_Id列的索引。 show engine ndb status
Type Name Status
ndbcluster connection cluster_node_id=5, connected_host=10.5.20.46,
connected_port=1186, number_of_data_nodes=2, number_of_ready_data_nodes=2, connect_count=0
ndbcluster NdbTransaction created=2, free=2, sizeof=224
ndbcluster NdbOperation created=4, free=4, sizeof=756
ndbcluster NdbIndexScanOperation created=0, free=0, sizeof=888
ndbcluster NdbIndexOperation created=0, free=0, sizeof=760
ndbcluster NdbRecAttr created=0, free=0, sizeof=64
ndbcluster NdbApiSignal created=16, free=16, sizeof=136
ndbcluster NdbLabel created=0, free=0, sizeof=196
ndbcluster NdbBranch created=0, free=0, sizeof=24
ndbcluster NdbSubroutine created=0, free=0, sizeof=68
ndbcluster NdbCall created=0, free=0, sizeof=16
ndbcluster NdbBlob created=0, free=0, sizeof=344
ndbcluster NdbReceiver created=0, free=0, sizeof=92
ndbcluster NdbLockHandle created=0, free=0, sizeof=32
ndbcluster binlog latest_epoch=1412576088948745, latest_trans_epoch=1412541729210383, latest_received_binlog_epoch=0, latest_handled_binlog_epoch=0, latest_applied_binlog_epoch=0
我也尝试过增加超时值: TransactionDeadlockDetectionTimeout = 10000 HeartbeatIntervalDbDb = 3000 HeartbeatIntervalDbApi = 3000 在最好的情况下,我可以删除索引。 当错误开始发生时,表MT_Routing_Info有695563行。 我怎么能摆脱这个?