Skip to content

Commit

Permalink
Bug #19140907 DUPLICATES IN UNIQUE SECONDARY INDEX BECAUSE OF FIX OF …
Browse files Browse the repository at this point in the history
…BUG#68021

Problem:

When a unique secondary index is scanned for duplicate checking, gap locks
were not taken if the transaction had isolation level <= READ COMMITTED. 
This change was done while fixing Bug #16133801 UNEXPLAINABLE INNODB UNIQUE
INDEX LOCKS ON DELETE + INSERT WITH SAME VALUES (rb#2035). Because of this
the duplicate check logic failed, and resulted in duplicate values in unique
secondary index.

Solution:

When a unique secondary index is scanned for duplicate checking, gap locks
must be taken irrespective of the transaction isolation level.  This is
achieved by reverting rb#2035.

rb#5910 approved by Jimmy
  • Loading branch information
gurusami committed Jul 3, 2014
1 parent cf50d1e commit 76e690f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions storage/innobase/row/row0ins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ row_ins_scan_sec_index_for_duplicate(
do {
const rec_t* rec = btr_pcur_get_rec(&pcur);
const buf_block_t* block = btr_pcur_get_block(&pcur);
ulint lock_type;
const ulint lock_type = LOCK_ORDINARY;

if (page_rec_is_infimum(rec)) {

Expand All @@ -1712,16 +1712,6 @@ row_ins_scan_sec_index_for_duplicate(
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);

/* If the transaction isolation level is no stronger than
READ COMMITTED, then avoid gap locks. */
if (!page_rec_is_supremum(rec)
&& thr_get_trx(thr)->isolation_level
<= TRX_ISO_READ_COMMITTED) {
lock_type = LOCK_REC_NOT_GAP;
} else {
lock_type = LOCK_ORDINARY;
}

if (allow_duplicates) {

/* If the SQL-query will update or replace
Expand Down

0 comments on commit 76e690f

Please sign in to comment.