Skip to content

Commit

Permalink
Bug #30770380 INNODB: IBUF CURSOR RESTORATION FAILS!
Browse files Browse the repository at this point in the history
Problem:
The server terminates abnormally when it fails to restore cursor
over insert buffer (Ibuf) index while deleting a insert buffer
record.

Analysis:
when background io thread read an secondary index page form disk to
the buffer pool, we merge Ibuf entries into that index page and
remove those Ibuf entries.
If at the same time, truncate operation is being executed,
truncate remove all ibuf entries for the tablespace.
If both io thread and truncate thread delete ibuf entries for
same page and if delete an entry requires node merge (pessimistic
delete) then first we mark that entry as delete-marked so other
thread will not apply it on index page and later we restore the
cursor on that record and do a pessimistic delete.
In this situation, if io thread removes Ibuf entry then truncate
thread will not be able to restore the cursor on ibuf entry.
Or if truncate thread removes Ibuf entry then io thread will not be
able to restore the cursor on Ibuf entry.

Fix:
Added a check If Ibuf cursor restoration fails when truncate operation
is being executed for that tablespace then we assume that other
thread must have removed that ibuf entry therefore do not delete
ibuf entry.

RB: 24334
Reviewed by : Annamalai Gurusami <[email protected]>
  • Loading branch information
sachinagarwal1111 committed May 11, 2020
1 parent f5acdcd commit 5a0b4ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions storage/innobase/ibuf/ibuf0ibuf.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1997, 2020, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
Expand Down Expand Up @@ -4258,10 +4258,11 @@ ibuf_restore_pos(
return(TRUE);
}

if (fil_space_get_flags(space) == ULINT_UNDEFINED) {
/* The tablespace has been dropped. It is possible
that another thread has deleted the insert buffer
entry. Do not complain. */
if (fil_space_get_flags(space) == ULINT_UNDEFINED ||
fil_space_is_being_truncated(space)) {
/* The tablespace has been dropped. Or the tablespace is being
truncated. It is possible that another thread has deleted
the insert buffer entry. Do not complain. */
ibuf_btr_pcur_commit_specify_mtr(pcur, mtr);
} else {
ib::error() << "ibuf cursor restoration fails!."
Expand Down

0 comments on commit 5a0b4ba

Please sign in to comment.