当前位置:网站首页>Who says that PT online schema change does not lock the table, or deadlock

Who says that PT online schema change does not lock the table, or deadlock

2022-07-06 12:11:00 wx5caecf2ed0645


background : Online one 3000W Your table needs to be added , Table has 20G size .

evening 11 Start at pt-online-schema-change Add fields

pt-online-schema-change -h $IP -u $user -p $password -P $PORT --alter="$STATEMENT" --charset=utf8   --no-check-replication-filters --execute D=$DATABASE,t=$TABLE

Into the morning 12 The increase is completed around halfpastten , But a deadlock message was reported .



LATEST DETECTED DEADLOCK

------------------------

180125 0:08:28

*** (1) TRANSACTION:

TRANSACTION C591765D9, ACTIVE 0 sec setting auto-inc lock

mysql tables in use 2, locked 2

LOCK WAIT 4 lock struct(s), heap size 1248, 1 row lock(s), undo log entries 2

MySQL thread id 35165134485, query id 636648490142 10.47.132.26 zhs_writer update

REPLACE INTO `DB`.`_Table_new` (`user_id`, `username`, `password`, `mobile`, `kid`, `maintype`, `subtype`, `user_type`, `enabled`, `device_uuid`, `register_time`, `first_login_time`, `last_login_time`, `sandbox`, `origin`, `is_biz`, `uid`, `is_del`) VALUES (NEW.`user_id`, NEW.`username`, NEW.`password`, NEW.`mobile`, NEW.`kid`, NEW.`maintype`, NEW.`subtype`, NEW.`user_type`, NEW.`enabled`, NEW.`device_uuid`, NEW.`register_time`, NEW.`first_login_time`, NEW.`last_login_time`, NEW.`sandbox`, NEW.`origin`, NEW.`is_biz`, NEW.`uid`, NEW.`is_del`)

*** (1) WAITING FOR THIS LOCK TO BE GRANTED:

TABLE LOCK table `DB`.`_Table_new` trx id C591765D9 lock mode AUTO-INC waiting

*** (2) TRANSACTION:

TRANSACTION C591765D3, ACTIVE 0 sec fetching rows, thread declared inside InnoDB 499

mysql tables in use 2, locked 2

46 lock struct(s), heap size 6960, 2483 row lock(s), undo log entries 2418

MySQL thread id 35165133950, query id 636648489679 10.47.109.162 dba_account Sending data

INSERT LOW_PRIORITY IGNORE INTO `DB`.`_Table_new` (`user_id`, `username`, `password`, `mobile`, `kid`, `maintype`, `subtype`, `user_type`, `enabled`, `device_uuid`, `register_time`, `first_login_time`, `last_login_time`, `sandbox`, `origin`, `is_biz`, `uid`, `is_del`) SELECT `user_id`, `username`, `password`, `mobile`, `kid`, `maintype`, `subtype`, `user_type`, `enabled`, `device_uuid`, `register_time`, `first_login_time`, `last_login_time`, `sandbox`, `origin`, `is_biz`, `uid`, `is_del` FROM `DB`.`Table` FORCE INDEX(`PRIMARY`) WHERE ((`user_id` >= '224531025')) AND ((`user_id` <= '224534530')) LOCK IN SHARE MODE /*pt-online-schema-change 15213 copy nibble*/

*** (2) HOLDS THE LOCK(S):

TABLE LOCK table `DB`.`_Table_new` trx id C591765D3 lock mode AUTO-INC

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 2689 page no 723971 n bits 144 index `PRIMARY` of table `DB`.`Table` trx id C591765D3 lock mode S waiting

Record lock, heap no 47 PHYSICAL RECORD: n_fields 20; compact format; info bits 0

0: len 4; hex 0d621bd6; asc b ;;

1: len 6; hex 000c591765d9; asc Y e ;;

2: len 7; hex 16000f00160bae; asc ;;

3: len 11; hex 3133363530323230393635; asc 13650220965;;

4: len 30; hex 663762363936323535643939653338306338623733623231303336643838; asc f7b696255d99e380c8b73b21036d88; (total 32 bytes);

5: len 11; hex 3133363530323230393635; asc 13650220965;;

6: len 0; hex ; asc ;;

7: len 1; hex 01; asc ;;

8: len 1; hex 80; asc ;;

9: len 1; hex 82; asc ;;

10: len 1; hex 01; asc ;;

11: len 16; hex 32363838313062346264633836303639; asc 268810b4bdc86069;;

12: len 8; hex 800012586de60fae; asc Xm ;;

13: len 8; hex 800012586de62386; asc Xm # ;;

14: len 8; hex 8000125a8d2ea47c; asc Z . |;;

15: len 1; hex 80; asc ;;

16: len 8; hex 77656978696e7971; asc weixinyq;;

17: len 1; hex 80; asc ;;

18: len 8; hex 8000000000000000; asc ;;

19: len 1; hex 80; asc ;;

*** WE ROLL BACK TRANSACTION (1)



When pt Three triggers are created when adding fields     When inserting new table data, you add S lock     When the program needs to update this data, it needs to add a X lock   There's a deadlock

terms of settlement : Reduce the granularity of data from old table to new table ( To be continued )


原网站

版权声明
本文为[wx5caecf2ed0645]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131557025845.html