Skip to content
Permalink
Browse files
MDEV-29570 InnoDB fails to clean bulk buffer when server does rollbac…
…k operation

- During bulk insert, server detects the error and does rollback
operation. At that time, InnoDB fails to clean up the bulk insert
buffer

trx_t::rollback_finish(): Removed the clean up of modified tables
from transaction

trx_t::commit_cleanup(): Free the bulk buffer for bulk insert operation

trx_t::commit(): Check whether modified table wasn't dropped only
for non-dictionary transaction
  • Loading branch information
Thirunarayanan committed Sep 28, 2022
1 parent 7c7ac6d commit 7d4b2b9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
@@ -304,3 +304,13 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2);
ALTER TABLE t1 REBUILD PARTITION p0;
DROP TABLE t1;
#
# MDEV-29570 InnoDB fails to clean bulk buffer when server
# does rollback operation
#
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB
PARTITION BY RANGE (pk) (
PARTITION pn VALUES LESS THAN (20));
INSERT INTO t1 VALUES (1),(21);
ERROR HY000: Table has no partition for value 21
DROP TABLE t1;
@@ -315,3 +315,15 @@ INSERT INTO t1 VALUES (1),(2);
ALTER TABLE t1 REBUILD PARTITION p0;
# Cleanup
DROP TABLE t1;

--echo #
--echo # MDEV-29570 InnoDB fails to clean bulk buffer when server
--echo # does rollback operation
--echo #
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB
PARTITION BY RANGE (pk) (
PARTITION pn VALUES LESS THAN (20));
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
INSERT INTO t1 VALUES (1),(21);
# Cleanup
DROP TABLE t1;
@@ -433,6 +433,8 @@ class trx_mod_table_time_t

/** Buffer to store insert opertion */
row_merge_bulk_t *bulk_store= nullptr;

friend struct trx_t;
public:
/** Constructor
@param rows number of modified rows so far */
@@ -517,11 +519,9 @@ class trx_mod_table_time_t
}

/** @return whether the buffer storage exist */
bool bulk_buffer_exist()
bool bulk_buffer_exist() const
{
if (is_bulk_insert() && bulk_store)
return true;
return false;
return bulk_store && is_bulk_insert();
}
};

@@ -59,7 +59,6 @@ const trx_t* trx_roll_crash_recv_trx;
@retval false if the rollback was aborted by shutdown */
inline bool trx_t::rollback_finish()
{
mod_tables.clear();
apply_online_log= false;
if (UNIV_LIKELY(error_state == DB_SUCCESS))
{
@@ -1388,6 +1388,10 @@ void trx_t::commit_cleanup()
ut_ad(!dict_operation);
ut_ad(!was_dict_operation);

if (is_bulk_insert())
for (auto &t : mod_tables)
delete t.second.bulk_store;

mutex.wr_lock();
state= TRX_STATE_NOT_STARTED;
mod_tables.clear();
@@ -1479,8 +1483,11 @@ void trx_t::commit()
ut_d(was_dict_operation= dict_operation);
dict_operation= false;
commit_persist();
#ifdef UNIV_DEBUG
if (!was_dict_operation)
for (const auto &p : mod_tables) ut_ad(!p.second.is_dropped());
#endif /* UNIV_DEBUG */
ut_d(was_dict_operation= false);
ut_d(for (const auto &p : mod_tables) ut_ad(!p.second.is_dropped()));
commit_cleanup();
}

0 comments on commit 7d4b2b9

Please sign in to comment.