記一次update死鎖處理

背景

讓DBA查日志

show engine innodb status
可以看到兩條數(shù)據(jù)

UPDATE  nr_activity_dish SET day_stock='9999', dstock_update_time='20191024' WHERE (activity_id =  '5000000003940695') AND (dish_id =  '1547797854069605')

UPDATE  nr_activity_dish SET day_stock='9999', dstock_update_time='20191024' WHERE (activity_id =  '5000000003940695') AND (dish_id =  '15477812970614023')

雖然acitivity_id和dish_id都是獨(dú)立索引连锯,但是update加鎖時(shí)候只會(huì)使用一個(gè)穷娱,導(dǎo)致多行數(shù)據(jù)被鎖

------------------------
LATEST DETECTED DEADLOCK
------------------------
2019-10-24 01:08:15 7f7f58063700
*** (1) TRANSACTION:
TRANSACTION 2559276227, ACTIVE 0 sec fetching rows
mysql tables in use 3, locked 3
LOCK WAIT 396 lock struct(s), heap size 46632, 4 row lock(s)
MySQL thread id 22749534, OS thread handle 0x7f7f4ea61700, query id 5012948981 10.252.16.9 mai_elemarketing Searching rows for update
/*E:shardkey=shardid&appid=bdwaimai_marketing.elemarketing&shardvalue=11&rid=bdwaimai_wmq.pusher^^6004B4B47E7B4332B85DDBE44BD6E15C|1571850495596&rpcid=1.1.5:E*//*E:group=place_waimai_elemarketing-bdwaimai_marketing_elemarketing_group&sqlId=9000591fb4342a9196717dfad9f4d6c4:E*/UPDATE  nr_activity_dish SET day_stock='9999', dstock_update_time='20191024' WHERE (activity_id =  '5000000003940695') AND (dish_id =  '1547797854069605')
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 31 page no 33335403 n bits 80 index `PRIMARY` of table `place_waimai_elemarketing`.`nr_activity_dish` trx id 2559276227 lock_mode X locks rec but not gap waiting
Record lock, heap no 11 PHYSICAL RECORD: n_fields 23; compact format; info bits 0
 0: len 8; hex 80000000a8f7234b; asc       #K;;
 1: len 6; hex 00009775741a; asc    ut ;;
 2: len 7; hex 38000078352df6; asc 8  x5- ;;
 3: len 8; hex 0011c379381ca157; asc    y8  W;;
 4: len 8; hex 00000000850540fd; asc       @ ;;
 5: len 8; hex 0036fcfd28036d07; asc  6  ( m ;;
 6: len 19; hex e781abe783a7203730672a34e4b8aa2fe7bb84; asc        70g*4   /   ;;
 7: len 4; hex 800001e0; asc     ;;
 8: len 4; hex 800001e0; asc     ;;
 9: len 30; hex 7b2261637469766974795f6964223a223530303030303030303339343036; asc {"activity_id":"50000000039406; (total 908 bytes);
 10: len 4; hex 8000000a; asc     ;;
 11: len 4; hex 0000270f; asc   ' ;;
 12: len 4; hex 0000270f; asc   ' ;;
 13: len 4; hex 8000270f; asc   ' ;;
 14: len 4; hex 8000270f; asc   ' ;;
 15: len 4; hex 8134172f; asc  4 /;;
 16: len 4; hex 80000000; asc     ;;
 17: len 4; hex 80000000; asc     ;;
 18: len 1; hex 01; asc  ;;
 19: len 4; hex 5da5e015; asc ]   ;;
 20: len 4; hex 5daf3711; asc ] 7 ;;
 21: len 8; hex 8000000000000012; asc         ;;
 22: len 6; hex 5daf37110bae; asc ] 7   ;;

*** (2) TRANSACTION:
TRANSACTION 2559276230, ACTIVE 0 sec fetching rows
mysql tables in use 3, locked 3
396 lock struct(s), heap size 46632, 3 row lock(s)
MySQL thread id 22749588, OS thread handle 0x7f7f58063700, query id 5012948983 10.252.64.4 mai_elemarketing Searching rows for update
/*E:shardkey=shardid&appid=bdwaimai_marketing.elemarketing&shardvalue=11&rid=bdwaimai_wmq.pusher^^01FC6E0EFC4C4168BCEAD2F136D68D15|1571850495598&rpcid=1.1.5:E*//*E:group=place_waimai_elemarketing-bdwaimai_marketing_elemarketing_group&sqlId=9000591fb4342a9196717dfad9f4d6c4:E*/UPDATE  nr_activity_dish SET day_stock='9999', dstock_update_time='20191024' WHERE (activity_id =  '5000000003940695') AND (dish_id =  '15477812970614023')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 31 page no 33335403 n bits 80 index `PRIMARY` of table `place_waimai_elemarketing`.`nr_activity_dish` trx id 2559276230 lock_mode X locks rec but not gap
Record lock, heap no 11 PHYSICAL RECORD: n_fields 23; compact format; info bits 0
 0: len 8; hex 80000000a8f7234b; asc       #K;;
 1: len 6; hex 00009775741a; asc    ut ;;
 2: len 7; hex 38000078352df6; asc 8  x5- ;;
 3: len 8; hex 0011c379381ca157; asc    y8  W;;
 4: len 8; hex 00000000850540fd; asc       @ ;;
 5: len 8; hex 0036fcfd28036d07; asc  6  ( m ;;
 6: len 19; hex e781abe783a7203730672a34e4b8aa2fe7bb84; asc        70g*4   /   ;;
 7: len 4; hex 800001e0; asc     ;;
 8: len 4; hex 800001e0; asc     ;;
 9: len 30; hex 7b2261637469766974795f6964223a223530303030303030303339343036; asc {"activity_id":"50000000039406; (total 908 bytes);
 10: len 4; hex 8000000a; asc     ;;
 11: len 4; hex 0000270f; asc   ' ;;
 12: len 4; hex 0000270f; asc   ' ;;
 13: len 4; hex 8000270f; asc   ' ;;
 14: len 4; hex 8000270f; asc   ' ;;
 15: len 4; hex 8134172f; asc  4 /;;
 16: len 4; hex 80000000; asc     ;;
 17: len 4; hex 80000000; asc     ;;
 18: len 1; hex 01; asc  ;;
 19: len 4; hex 5da5e015; asc ]   ;;
 20: len 4; hex 5daf3711; asc ] 7 ;;
 21: len 8; hex 8000000000000012; asc         ;;
 22: len 6; hex 5daf37110bae; asc ] 7   ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 31 page no 35689285 n bits 824 index `idx_aid` of table `place_waimai_elemarketing`.`nr_activity_dish` trx id 2559276230 lock_mode X locks rec but not gap waiting
Record lock, heap no 63 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 8; hex 0011c379381ca157; asc    y8  W;;
 1: len 8; hex 80000000a8f7234b; asc       #K;;

*** WE ROLL BACK TRANSACTION (2)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市蟆淀,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖秽之,帶你破解...
    沈念sama閱讀 206,311評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件孤紧,死亡現(xiàn)場離奇詭異豺裆,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)号显,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,339評論 2 382
  • 文/潘曉璐 我一進(jìn)店門臭猜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人押蚤,你說我怎么就攤上這事蔑歌。” “怎么了揽碘?”我有些...
    開封第一講書人閱讀 152,671評論 0 342
  • 文/不壞的土叔 我叫張陵次屠,是天一觀的道長园匹。 經(jīng)常有香客問我,道長劫灶,這世上最難降的妖魔是什么裸违? 我笑而不...
    開封第一講書人閱讀 55,252評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮本昏,結(jié)果婚禮上供汛,老公的妹妹穿的比我還像新娘。我一直安慰自己涌穆,他們只是感情好怔昨,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,253評論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著宿稀,像睡著了一般朱监。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上原叮,一...
    開封第一講書人閱讀 49,031評論 1 285
  • 那天赫编,我揣著相機(jī)與錄音,去河邊找鬼奋隶。 笑死擂送,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的唯欣。 我是一名探鬼主播嘹吨,決...
    沈念sama閱讀 38,340評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼境氢!你這毒婦竟也來了蟀拷?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,973評論 0 259
  • 序言:老撾萬榮一對情侶失蹤萍聊,失蹤者是張志新(化名)和其女友劉穎问芬,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體寿桨,經(jīng)...
    沈念sama閱讀 43,466評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡此衅,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,937評論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了亭螟。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片挡鞍。...
    茶點(diǎn)故事閱讀 38,039評論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖预烙,靈堂內(nèi)的尸體忽然破棺而出墨微,到底是詐尸還是另有隱情,我是刑警寧澤扁掸,帶...
    沈念sama閱讀 33,701評論 4 323
  • 正文 年R本政府宣布翘县,位于F島的核電站衰琐,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏炼蹦。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,254評論 3 307
  • 文/蒙蒙 一狸剃、第九天 我趴在偏房一處隱蔽的房頂上張望掐隐。 院中可真熱鬧,春花似錦钞馁、人聲如沸虑省。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,259評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽探颈。三九已至,卻和暖如春训措,著一層夾襖步出監(jiān)牢的瞬間伪节,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,485評論 1 262
  • 我被黑心中介騙來泰國打工绩鸣, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留怀大,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,497評論 2 354
  • 正文 我出身青樓呀闻,卻偏偏與公主長得像化借,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子捡多,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,786評論 2 345