Bug #99643 | innobase_commit_by_xid/innobase_rollback_by_xid is not thread safe | ||
---|---|---|---|
Submitted: | 20 May 2020 7:24 | Modified: | 26 Jul 12:14 |
Reporter: | zhai weixiang (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 8.0, 5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[20 May 2020 7:24]
zhai weixiang
[20 May 2020 13:37]
MySQL Verification Team
Hi Mr. weixiang, Thank you for your bug report and patch. However, there are some details that are not clear. First of all, there is a check on whether a pointer is NULL or not. Next, why would we need to add begin and end statement in that loop, when we are dealing with those elsewhere ??? Last, but not least, this would remove all benefits for the existing pool, wouldn't it ?????
[21 May 2020 2:44]
zhai weixiang
Hi, TrxInInnoDB trx_in_innodb will implicitly enter innodb while constructing it(same behavior as begin_stmt(trx)), and exit innodb while destructing the object(same as end_stmt(trx)), but hte destructing happens after invoking trx_free_in_background which means: - current thread (thread 1)put back trx_t to pool, and then exit innodb by modifying the trx_t's value (trx_t::in_depth/in_innodb) - meanwhile, the trx_t is already in pool and can be reused by another thread(thread2). So there maybe two thread accessing same trx_t pointer. Let me give you an example: thread1: - invoke trx_free_in_background, now trx_t is in pool, trx_t::in_depth = 1,trx_t::in_innodb++ thread2: get trx_t from pool, and enter innodb: trx_t::in_depth++ (=2) thread1: destructing TrxInInnoDB object: decrease trx_t::in_depth-- (= 1) thread2: exit innodb, decrease trx_t::in_depth-- (=0) thread1: check in_depth = 0, and continue to decrease trx_t::in_innodb (=0) thread2: check in_depth = 0, and continue to decrease trx_t::in_innodb ((unsigned)-1) thread2: enter innodb again, and start waiting (TrxInInnoDB::wait() in include/trx0trx.h) forever...because all flag of trx_t::in_innodb is true
[21 May 2020 12:31]
MySQL Verification Team
Hi Mr. weixiang, Thanks for the feedback. You have convinced me, so I will verify this bug and will let our colleagues analyse it further. I have also concluded that this is 8.0-only bug. Verified as reported.
[26 Sep 2021 13:14]
MySQL Verification Team
Bug #105036 marked as duplicate of this one.
[13 Apr 2023 2:15]
Shaohua Wang
Hi Weixiang, there must be some other bugs here. See the bug: https://bugs.mysql.com/bug.php?id=110652 there are many different values of trx->innodb.
[13 Apr 2023 11:44]
MySQL Verification Team
Thank you, Mr. Wang ......
[22 Sep 2023 11:30]
MySQL Verification Team
Hi, We do not think that this report is the original one for the following bug: https://bugs.mysql.com/bug.php?id=112425
[26 Jul 10:42]
zhai weixiang
This bug is fixed by commit bc9b5f0327fb0104542f9edbeb456e93a5121df5 Can be closed now
[26 Jul 12:14]
MySQL Verification Team
Thank you, very much, Zhai !!!!