Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
Currently, lock_t is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: {shared,exclusive,gap-read,gap-write}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (acquired by UPDATE, DELETE, or a locking SELECT) prevents any subsequent INSERT to that range.
INSERT will acquire a gap-write or insert-intention lock (LOCK_INSERT_INTENTION). It conflicts with previously granted gap-read locks. Gap-read locks may be granted on the same lock if a gap-write lock has been granted to an active transaction.
An INSERT requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions.
In lock_rec_has_to_wait(), gap-write locks do not conflict with gap-write locks of other transactions, even though lock_mode_compatible() would not hold.
A transaction can wait for at most one record. MDEV-24671 already simplified lock waits by introducing the function lock_wait(). If we pack 2 record heap numbers per byte (4 bits per heap number) in the record lock bitmap, there is no space for a further LOCK_WAIT flag. We might want to create a special type of bitmap for a waiting lock request, to avoid allocating a large bitmap (if the record heap number is 3000, the size of a straightforward bitmap would be 1500 bytes). We might store the attributes of the single-record lock request in the trx_t object. Maybe we could just preallocate a record lock bitmap object in trx_t, to be used for all waiting requests?
Attachments
Issue Links
- blocks
-
MDEV-21452 Use condition variables and normal mutexes instead of InnoDB os_event and mutex
-
- Closed
-
- relates to
-
MDEV-17512 Deadlock after locking all rows in table
-
- Open
-
-
MDEV-20605 Awaken transaction can miss inserted by other transaction records due to wrong persistent cursor restoration
-
- Closed
-
-
MDEV-21974 InnoDB DML under backup locks make buffer pool usage grow permanently
-
- Open
-
-
MDEV-10962 Deadlock with 3 concurrent DELETEs by unique key
-
- Closed
-
-
MDEV-11215 Several locks taken to same record inside a transaction.
-
- Stalled
-
-
MDEV-18706 ER_LOCK_DEADLOCK on concurrent read and insert into already locked gap
-
- In Review
-
-
MDEV-20612 Improve InnoDB lock_sys scalability
-
- Closed
-
-
MDEV-26779 reduce lock_sys.wait_mutex contention by using spinloop construct
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue relates to |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 3 bits per record heap number to represent the 6 combinations of lock modes: {not held,shared,exclusive}×{record,gap}.
(An exclusive gap lock would correspond to {{LOCK_INSERT_INTENTION}}.) A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 3 bits per record heap number to represent the 6 combinations of lock modes: \{not held,shared,exclusive\}×\{record,gap\}.
(An exclusive gap lock would correspond to {{LOCK_INSERT_INTENTION}}.) A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Link | This issue relates to MDEV-11215 [ MDEV-11215 ] |
Link | This issue relates to MDEV-17512 [ MDEV-17512 ] |
NRE Projects | RM_105_CANDIDATE |
Assignee | Marko Mäkelä [ marko ] | Eugene Kosov [ kevg ] |
Link | This issue relates to MDEV-18706 [ MDEV-18706 ] |
Fix Version/s | 10.5 [ 23123 ] |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 3 bits per record heap number to represent the 6 combinations of lock modes: \{not held,shared,exclusive\}×\{record,gap\}.
(An exclusive gap lock would correspond to {{LOCK_INSERT_INTENTION}}.) A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all 9 combinations of record and gap lock modes: {unlocked,shared,exclusive}×{none,gap-read,gap-write}
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all 9 combinations of record and gap lock modes: {unlocked,shared,exclusive}×{none,gap-read,gap-write}
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all 9 combinations of record and gap lock modes: \{unlocked,shared,exclusive\}×\{none,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Link |
This issue relates to |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all 9 combinations of record and gap lock modes: \{unlocked,shared,exclusive\}×\{none,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Link |
This issue relates to |
Link | This issue relates to MDEV-21974 [ MDEV-21974 ] |
Link |
This issue blocks |
Link | This issue relates to MDEV-17512 [ MDEV-17512 ] |
Link |
This issue relates to |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (taken by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any {{INSERT}} to that range. A gap-write lock ({{LOCK_INSERT_INTENTION}}) is mutually exclusive with gap-read locks. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read or gap-write locks may be held on the same gap by different transactions, as long as there are not both gap-read and gap-write locks for the same gap. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (acquired by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any subsequent {{INSERT}} to that range. {{INSERT}} will acquire a gap-write or insert-intention lock ({{LOCK_INSERT_INTENTION}}). It conflicts with *previously granted* gap-read locks. Gap-read locks may be granted on the same lock if a gap-write lock has been granted to an active transaction. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions. Currently, gap-write locks conflict with gap-write locks of other transactions. This may be unnecessary. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (acquired by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any subsequent {{INSERT}} to that range. {{INSERT}} will acquire a gap-write or insert-intention lock ({{LOCK_INSERT_INTENTION}}). It conflicts with *previously granted* gap-read locks. Gap-read locks may be granted on the same lock if a gap-write lock has been granted to an active transaction. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions. Currently, gap-write locks conflict with gap-write locks of other transactions. This may be unnecessary. A transaction can wait for at most one record. It might be simplest to not create a separate bitmap for that, but instead store the attributes of the lock request in the {{trx_t}} object. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (acquired by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any subsequent {{INSERT}} to that range. {{INSERT}} will acquire a gap-write or insert-intention lock ({{LOCK_INSERT_INTENTION}}). It conflicts with *previously granted* gap-read locks. Gap-read locks may be granted on the same lock if a gap-write lock has been granted to an active transaction. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions. In {{lock_rec_has_to_wait()}}, gap-write locks do not conflict with gap-write locks of other transactions, even though {{lock_mode_compatible()}} would not hold. A transaction can wait for at most one record. |
Workflow | MariaDB v3 [ 87694 ] | MariaDB v4 [ 130846 ] |
Assignee | Eugene Kosov [ kevg ] | Vladislav Lesin [ vlad.lesin ] |
Description |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}.
There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap-read lock (acquired by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any subsequent {{INSERT}} to that range. {{INSERT}} will acquire a gap-write or insert-intention lock ({{LOCK_INSERT_INTENTION}}). It conflicts with *previously granted* gap-read locks. Gap-read locks may be granted on the same lock if a gap-write lock has been granted to an active transaction. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions. In {{lock_rec_has_to_wait()}}, gap-write locks do not conflict with gap-write locks of other transactions, even though {{lock_mode_compatible()}} would not hold. A transaction can wait for at most one record. |
Currently, {{lock_t}} is a union of table locks and record lock bitmaps. There can be multiple record lock bitmaps in a transaction. A record lock bitmap is specific to an index leaf page and a locking mode. It could be more efficient to use a single bitmap per page, with 4 bits per record heap number to represent all combinations of record and gap lock modes: \{shared,exclusive,gap-read,gap-write\}. There are two types of gap locks (covering the open range of keys from the preceding record to the anchor record). A gap\-read lock (acquired by {{UPDATE}}, {{DELETE}}, or a locking {{SELECT}}) prevents any subsequent {{INSERT}} to that range. {{INSERT}} will acquire a gap-write or insert-intention lock ({{LOCK_INSERT_INTENTION}}). It conflicts with *previously granted* gap-read locks. Gap-read locks may be granted on the same lock if a gap\-write lock has been granted to an active transaction. An {{INSERT}} requires both a gap-write lock and an exclusive lock on the key that is being inserted. Any amount of gap-read locks may be held on the same gap by different transactions. In {{lock_rec_has_to_wait()}}, gap-write locks do not conflict with gap-write locks of other transactions, even though {{lock_mode_compatible()}} would not hold. A transaction can wait for at most one record. |
Link | This issue relates to MDEV-17512 [ MDEV-17512 ] |