Commit de5ab15
MDEV-37977 InnoDB deadlock report incorrectly reports rolled back transaction number
The "WE ROLL BACK TRANSACTION (N)" message in the deadlock report
referred to the wrong transaction number. The victim selection loop
and the display loop in `Deadlock::report()` traversed the cycle in
the same order (`cycle->wait_trx, ..., cycle`) but used misaligned
position numbering:
- **Victim selection** initialized `victim = cycle` at position 1
*before* the loop, then started iterating from `cycle->wait_trx`
at position 2.
- **Display loop** started from `cycle->wait_trx` at label `(1)`,
with `cycle` displayed last at label `(N)`.
This caused `victim_pos` to be off by one relative to the displayed
transaction labels.
Fix: restructure the victim selection loop to start with `l=0` and
`victim=nullptr`, letting the loop handle all transactions uniformly.
The first iteration unconditionally picks `cycle->wait_trx` as the
initial victim at position 1, matching the display loop. The
`thd_deadlock_victim_preference()` call is guarded with a
`victim != nullptr` check to skip it on the first iteration (where
no prior victim exists to compare against).1 parent a40bf40 commit de5ab15
3 files changed
Lines changed: 116 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7014 | 7014 | | |
7015 | 7015 | | |
7016 | 7016 | | |
7017 | | - | |
| 7017 | + | |
7018 | 7018 | | |
7019 | 7019 | | |
7020 | 7020 | | |
7021 | 7021 | | |
7022 | 7022 | | |
7023 | 7023 | | |
7024 | 7024 | | |
7025 | | - | |
7026 | | - | |
7027 | | - | |
| 7025 | + | |
| 7026 | + | |
| 7027 | + | |
| 7028 | + | |
| 7029 | + | |
| 7030 | + | |
7028 | 7031 | | |
7029 | 7032 | | |
7030 | 7033 | | |
7031 | 7034 | | |
7032 | 7035 | | |
7033 | 7036 | | |
7034 | | - | |
7035 | | - | |
7036 | | - | |
7037 | | - | |
7038 | | - | |
7039 | | - | |
7040 | | - | |
| 7037 | + | |
| 7038 | + | |
| 7039 | + | |
| 7040 | + | |
| 7041 | + | |
| 7042 | + | |
| 7043 | + | |
| 7044 | + | |
| 7045 | + | |
| 7046 | + | |
| 7047 | + | |
| 7048 | + | |
7041 | 7049 | | |
7042 | 7050 | | |
7043 | 7051 | | |
| |||
7051 | 7059 | | |
7052 | 7060 | | |
7053 | 7061 | | |
7054 | | - | |
| 7062 | + | |
| 7063 | + | |
7055 | 7064 | | |
7056 | 7065 | | |
7057 | 7066 | | |
| |||
0 commit comments