From 6d4c121d98d9d221a2eb22436de8613287c38ac4 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 4 Jun 2020 14:37:36 +0530 Subject: MDEV-515 innodb bulk insert - Introduced assign_stat_n_rows() in dict_table_t. It calculates the number of rows in the table and assign stat_n_rows during ha_innobase::open() - Introduced empty_table() in dict_table_t. Basically it empties all the indexes associated with table (not covered the fts index). This is undo operation of bulk operation. - Introduced new variable bulk_trx_id in dict_table_t. It stores the transaction id of bulk insert. Basically it is protected by exclusive lock of the table. - If table is empty then INSERT, INSERT..SELECT does take exclusive lock on the table. - Introduced new undo log record "TRX_UNDO_UNEMPTY". It should be first undo log during bulk operation. While rollback, if innodb encounters the undo record then it should empty the table. Limitations: =========== - InnoDB should write the undo log for consecutive insert during bulk operation - Parallel read should give empty table depends on bulk_trx_id. - Fix all test case failure in innodb suite - FTS index should be handled while rollback of bulk operation --- storage/innobase/row/row0uins.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'storage/innobase/row/row0uins.cc') diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 63edbd9b86d..6329825defd 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -382,6 +382,7 @@ static bool row_undo_ins_parse_undo_rec(undo_node_t* node, bool dict_locked) ut_ad("wrong undo record type" == 0); goto close_table; case TRX_UNDO_INSERT_METADATA: + case TRX_UNDO_UNEMPTY: case TRX_UNDO_INSERT_REC: break; case TRX_UNDO_RENAME_TABLE: @@ -425,8 +426,12 @@ close_table: node->heap); } else { node->ref = &trx_undo_metadata; + if (node->rec_type == TRX_UNDO_UNEMPTY) { + return true; + } } + if (!row_undo_search_clust_to_pcur(node)) { /* An error probably occurred during an insert into the clustered index, @@ -588,6 +593,11 @@ row_undo_ins( log_free_check(); ut_ad(!node->table->is_temporary()); err = row_undo_ins_remove_clust_rec(node); + break; + case TRX_UNDO_UNEMPTY: + node->table->empty_table(); + err = DB_SUCCESS; + break; } dict_table_close(node->table, dict_locked, FALSE); -- cgit v1.2.1