From d63f54c67d033968127319ec08d35f493684bccd Mon Sep 17 00:00:00 2001 From: Satya Bodapati Date: Mon, 28 Jan 2013 20:13:44 +0530 Subject: [PATCH] Bug#16183892 - INNODB PURGE BUFFERING IS NOT CRASH-SAFE With innodb_change_buffering enabled, Innodb buffers all modifications to secondary index leaf pages when the leaf pages are not in buffer pool. Crash InnoDB while an IBUF_OP_DELETE is being applied. Restart and note that the same record can be applied again which may lead to crash. Mark the change buffer record processed, so that it will not be merged again in case the server crashes between the following mtr_commit() and the subsequent mtr_commit() of deleting the change buffer record. Testcase: No testcase because it is difficult to get the timing right with the two asyncronous task purge and change buffering Approved by Marko. rb#1893 --- storage/innobase/ibuf/ibuf0ibuf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 70af56b99f2..11505121fa2 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2013, 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 as published by the Free Software @@ -4685,6 +4685,16 @@ loop: == page_no); ut_ad(ibuf_rec_get_space(&mtr, rec) == space); + /* Mark the change buffer record processed, + so that it will not be merged again in case + the server crashes between the following + mtr_commit() and the subsequent mtr_commit() + of deleting the change buffer record. */ + + btr_cur_set_deleted_flag_for_ibuf( + btr_pcur_get_rec(&pcur), NULL, + TRUE, &mtr); + btr_pcur_store_position(&pcur, &mtr); ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr);