Details
Description
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds lock on the record. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code:
dberr_t
|
lock_rec_insert_check_and_lock(...)
|
{
|
...
|
const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; |
|
if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, |
g.cell(), id,
|
heap_no, trx))
|
{
|
trx->mutex_lock();
|
err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame,
|
heap_no, index, thr, nullptr);
|
trx->mutex_unlock();
|
}
|
...
|
}
|
Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction.
The test is attached: ii-conflicts-waiting.test
Attachments
Issue Links
- blocks
-
MDEV-10962 Deadlock with 3 concurrent DELETEs by unique key
-
- Closed
-
- causes
-
MDEV-27992 DELETE fails to delete record after blocking is released
-
- Closed
-
- relates to
-
MDEV-20605 Awaken transaction can miss inserted by other transaction records due to wrong persistent cursor restoration
-
- Closed
-
-
MDEV-24738 Improve the InnoDB deadlock checker
-
- Closed
-
-
MDEV-27550 The test galera.MW-328D no longer reproduces a deadlock
-
- Closed
-
-
MDEV-27922 INSERT fails to return an error after transaction abort
-
- Closed
-
-
MDEV-34877 Port "Bug #11745929 Change lock priority so that the transaction holding S-lock gets X-lock first" fix from MySQL to MariaDB
-
- Closed
-
-
SAMU-292 Loading...
- mentioned in
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
-
Page Loading...
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue relates to |
Description |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
The test is attached: [^ii-conflicts-waiting.test] |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
Description |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t⏎ lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
Description |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t⏎ lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
Summary | insert-intetion lock conflicts with waiting ORDINARY lock | insert-intention lock conflicts with waiting ORDINARY lock |
Description |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds stronger lock, then the second transaction. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds lock on the record. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
Affects Version/s | 10.2 [ 14601 ] | |
Affects Version/s | 10.3 [ 22126 ] | |
Affects Version/s | 10.4 [ 22408 ] | |
Affects Version/s | 10.5 [ 23123 ] |
Description |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds lock on the record. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. I have not yet checked versions less then 10.6. The test is attached: [^ii-conflicts-waiting.test] |
We have two transactions and one record. The first transaction holds ORDINARY S-lock on the record, the second transaction created waiting ORDINARY X-lock and waits for the first transaction. Then the first transaction requests insert-intention lock on the record. And this lock conflicts with the waiting ORDINARY X-lock of the second transaction. What causes deadlock. Why it should conflict? The first transaction already holds lock on the record. And the second's transaction lock contains "waiting" flag.
Let's take a look 10.6 code: {code:java} dberr_t lock_rec_insert_check_and_lock(...) { ... const unsigned type_mode= LOCK_X | LOCK_GAP | LOCK_INSERT_INTENTION; if (lock_t *c_lock= lock_rec_other_has_conflicting(type_mode, g.cell(), id, heap_no, trx)) { trx->mutex_lock(); err= lock_rec_enqueue_waiting(c_lock, type_mode, id, block->frame, heap_no, index, thr, nullptr); trx->mutex_unlock(); } ... } {code} Neither lock_rec_insert_check_and_lock() nor lock_rec_other_has_conflicting() doesn't check conflicting lock is in waiting state and it already waits for the requesting insert-intention lock transaction. The test is attached: [^ii-conflicts-waiting.test] |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | 10.6 [ 24028 ] | |
Fix Version/s | 10.7 [ 24805 ] | |
Fix Version/s | 10.8 [ 26121 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Workflow | MariaDB v3 [ 127341 ] | MariaDB v4 [ 144616 ] |
Comment | [ A comment with security level 'Developers' was removed. ] |
Link |
This issue blocks |
Status | In Progress [ 3 ] | In Testing [ 10301 ] |
Assignee | Vladislav Lesin [ vlad.lesin ] | Matthias Leich [ mleich ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Assignee | Matthias Leich [ mleich ] | Vladislav Lesin [ vlad.lesin ] |
Link |
This issue relates to |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | In Testing [ 10301 ] |
Assignee | Vladislav Lesin [ vlad.lesin ] | Matthias Leich [ mleich ] |
Assignee | Matthias Leich [ mleich ] | Vladislav Lesin [ vlad.lesin ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Assignee | Vladislav Lesin [ vlad.lesin ] | Marko Mäkelä [ marko ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Marko Mäkelä [ marko ] | Vladislav Lesin [ vlad.lesin ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Link | This issue causes TODO-3312 [ TODO-3312 ] |
Fix Version/s | 10.5.14 [ 26809 ] | |
Fix Version/s | 10.6.6 [ 26811 ] | |
Fix Version/s | 10.7.2 [ 26813 ] | |
Fix Version/s | 10.8.1 [ 26815 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Fix Version/s | 10.5 [ 23123 ] | |
Fix Version/s | 10.6 [ 24028 ] | |
Fix Version/s | 10.7 [ 24805 ] | |
Fix Version/s | 10.8 [ 26121 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link |
This issue relates to |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33104 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33105 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33109 ] |
Link | This issue blocks MENT-1414 [ MENT-1414 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33119 ] |
Fix Version/s | 10.3.35 [ 27512 ] | |
Fix Version/s | 10.4.25 [ 27510 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33211 ] |
Link |
This issue relates to |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33105 ] |
Link |
This issue relates to |
Link |
This issue causes |
Link |
This issue relates to |
Link | This issue is duplicated by MENT-1435 [ MENT-1435 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33262 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33271 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33303 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33262 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33649 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33651 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33656 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33701 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33725 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33651 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33829 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34271 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34411 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34452 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34454 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34479 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34482 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34486 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34505 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34516 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34530 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34540 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34607 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34613 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34624 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34643 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34658 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34678 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34696 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34716 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34812 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34828 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34846 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34916 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34932 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34948 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 34482 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33649 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 33701 ] |
Zendesk Related Tickets | 202352 201658 136328 | |
Zendesk active tickets | 201658 |
Resolution | Fixed [ 1 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Link |
This issue relates to |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Fix Version/s | 10.5.16 [ 27508 ] | |
Fix Version/s | 10.6.8 [ 27506 ] | |
Fix Version/s | 10.7.4 [ 27504 ] | |
Fix Version/s | 10.8.3 [ 27502 ] |
Remote Link | This issue links to "SAMU-292 (Jira)" [ 37454 ] |