InnoDB - zaseklá transakce

InnoDB - zaseklá transakce
« kdy: 19. 06. 2020, 13:06:16 »
Pred testem jsem si potreboval smazat obsah vsech tabulek. Protoze jsem si potreboval usnadnit cestu, pouzil jsem
Kód: [Vybrat]
SET FOREIGN_KEY_CHECKS = 1Nasledne smazal obsah vsech tabulek pomoci truncate a nasledne vratil
Kód: [Vybrat]
SET FOREIGN_KEY_CHECKS = 0Tim ovsem doslo k narustu casu potrebneho k cteni dat z databaze.

Podle innodb status je zde uvazla transakce, ktere se nedokazu zbavit (restart jsem nezkousel, chtel bych vedet jak se toho zbavit). Pri mazani jsem ani transakci nepoustel a nic/nikdo jiny s databazi nepracuje.
MySQL thread id 2242 na serveru neexistuje ani v process listu.

I kdyz foreign key v dobe mazani bylo vypnuto v logu je hlaska:
Kód: [Vybrat]
DELETE FROM `dbTest1`.`object` WHERE `id`='18756'
Foreign key constraint fails for table `dbTest1`.`object_price`:
,
  CONSTRAINT `FK_object_price_2` FOREIGN KEY (`object_id`) REFERENCES `object` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
Trying to delete in parent table, in index PRIMARY tuple:

Aktualne je tabulka `dbTest1`.`object_price uplne prazdna (pozadovany stav).

Poradil by nekdo jak se te transakce zbavit a jak vubec mohla vzniknout/uvaznout?



Kód: [Vybrat]
| InnoDB |      |
=====================================
2020-06-19 12:38:17 0x7f1801aea700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 16 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 956 srv_active, 0 srv_shutdown, 932255 srv_idle
srv_master_thread log flush and writes: 933176
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 3625
OS WAIT ARRAY INFO: signal count 3058
RW-shared spins 0, rounds 6620, OS waits 3208
RW-excl spins 0, rounds 7781, OS waits 156
RW-sx spins 50, rounds 919, OS waits 16
Spin rounds per wait: 6620.00 RW-shared, 7781.00 RW-excl, 18.38 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-06-12 11:53:31 0x7f181df3d700 Transaction:
TRANSACTION 3467341, ACTIVE 0 sec updating or deleting
mysql tables in use 3, locked 3
4 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1
MySQL thread id 2242, OS thread handle 139741558462208, query id 94860 localhost ::1 root Updating
DELETE FROM `dbTest1`.`object` WHERE `id`='18756'
Foreign key constraint fails for table `dbTest1`.`object_price`:
,
  CONSTRAINT `FK_object_price_2` FOREIGN KEY (`object_id`) REFERENCES `object` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
Trying to delete in parent table, in index PRIMARY tuple:
DATA TUPLE: 31 fields;
 0: len 4; hex 00004944; asc   ID;;
 1: len 6; hex 00000034e84d; asc    4 M;;
 2: len 7; hex 240000047701ca; asc $   w  ;;
 3: len 4; hex 00000039; asc    9;;
 4: len 2; hex 000a; asc   ;;
 5: len 3; hex 65616e; asc ean;;
 6: len 3; hex 65616e; asc ean;;
 7: len 3; hex 65616e; asc ean;;
 8: len 1; hex 01; asc  ;;
 9: len 1; hex 00; asc  ;;
 10: len 1; hex 10; asc  ;;
 11: len 1; hex 01; asc  ;;
 12: len 2; hex 0000; asc   ;;
 13: len 2; hex 0000; asc   ;;
 14: len 1; hex 80; asc  ;;
 15: len 1; hex 00; asc  ;;
 16: len 8; hex 0000000000000000; asc         ;;
 17: len 8; hex 0000000000000000; asc         ;;
 18: SQL NULL;
 19: len 8; hex 0000000000000000; asc         ;;
 20: len 4; hex cdcccc3d; asc    =;;
 21: len 5; hex 99a698bb63; asc     c;;
 22: len 1; hex 80; asc  ;;
 23: len 5; hex 99a698bb63; asc     c;;
 24: len 4; hex 0000001d; asc     ;;
 25: SQL NULL;
 26: SQL NULL;
 27: len 3; hex 8fcccc; asc    ;;
 28: len 4; hex 00000000; asc     ;;
 29: len 4; hex 00000000; asc     ;;
 30: len 1; hex 81; asc  ;;

But in child table `dbTest1`.`object_price`, in index object_price_object_id, there is a record:
PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 00004944; asc   ID;;
 1: len 4; hex 00009287; asc     ;;

------------
TRANSACTIONS
------------
Trx id counter 3473414
Purge done for trx's n:o < 3473414 undo n:o < 0 state: running
History list length 38
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421216436007576, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421216436020344, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421216436011832, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421216436003320, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421216435999064, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421216435994808, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
3365 OS file reads, 71179 OS file writes, 19622 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 6 merges
merged operations:
 insert 8, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 2 buffer(s)
Hash table size 34679, node heap has 2 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 2 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 1354295221
Log flushed up to   1354295221
Pages flushed up to 1354295221
Last checkpoint at  1354295212
0 pending log flushes, 0 pending chkp writes
7900 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 167772160
Dictionary memory allocated 219104
Buffer pool size   8015
Free buffers       1024
Database pages     6980
Old database pages 2556
Modified db pages  0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 196, not young 628
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3280, created 4247, written 60471
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 6980, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=23787, Main thread ID=139740734998272, state: sleeping
Number of rows inserted 44793, updated 767803, deleted 5653, read 101238297
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
« Poslední změna: 19. 06. 2020, 13:44:56 od Petr Krčmář »


Re:InnoDB - zaseklá transakce
« Odpověď #1 kdy: 19. 06. 2020, 20:24:31 »
Dle popisu je integritu nejdříve zapnul, poté vypnul.