Skip to content

Commit e3c39c0

Browse files
committed
MDEV-13564 follow-up: Remove dead code
In MariaDB 10.4.0, commit 09af00c removed the crash-upgrade logic for the MariaDB 10.2 innodb_safe_truncate=OFF TRUNCATE TABLE (which was the only option between MariaDB 10.2.2 and 10.2.18), but failed to adjust some comments and code. buf_page_io_complete(): Remove a bogus comment about TRUNCATE. dict_recreate_index_tree(): Unused function; remove. fil_space_t::stop_new_ops: Clarify the comment. fil_space_acquire_low(): Remove a bogus comment about TRUNCATE. fil_check_pending_ops(), fil_check_pending_io(): Adjust a warning message. This code is only invoked as part of DISCARD TABLESPACE or DROP TABLE. DROP TABLE is internally used as part of ALTER TABLE, OPTIMIZE TABLE, or TRUNCATE TABLE. RemoteDatafile::create_link_file(): Clarify a comment. ibuf_delete_for_discarded_space(): Clarify the function comment. dict_table_x_lock_indexes(), dict_table_x_unlock_indexes(): Merge with the only remaining caller, row_quiesce_set_state(). page_create_zip(): Remove a bogus comment about TRUNCATE.
1 parent d3350c1 commit e3c39c0

File tree

13 files changed

+40
-211
lines changed

13 files changed

+40
-211
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6207,8 +6207,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
62076207
recv_recover_page(bpage);
62086208
}
62096209

6210-
/* If space is being truncated then avoid ibuf operation.
6211-
During re-init we have already freed ibuf entries. */
62126210
if (uncompressed
62136211
&& !recv_no_ibuf_operations
62146212
&& (bpage->id.space() == 0

storage/innobase/dict/dict0crea.cc

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -957,87 +957,6 @@ dict_drop_index_tree(
957957
return false;
958958
}
959959

960-
/*******************************************************************//**
961-
Recreate the index tree associated with a row in SYS_INDEXES table.
962-
@return new root page number, or FIL_NULL on failure */
963-
ulint
964-
dict_recreate_index_tree(
965-
/*=====================*/
966-
const dict_table_t*
967-
table, /*!< in/out: the table the index belongs to */
968-
btr_pcur_t* pcur, /*!< in/out: persistent cursor pointing to
969-
record in the clustered index of
970-
SYS_INDEXES table. The cursor may be
971-
repositioned in this call. */
972-
mtr_t* mtr) /*!< in/out: mtr having the latch
973-
on the record page. */
974-
{
975-
ut_ad(mutex_own(&dict_sys.mutex));
976-
ut_a(!dict_table_is_comp(dict_sys.sys_indexes));
977-
ut_ad(!table->space || table->space->id == table->space_id);
978-
979-
ulint len;
980-
const rec_t* rec = btr_pcur_get_rec(pcur);
981-
982-
const byte* ptr = rec_get_nth_field_old(
983-
rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
984-
985-
ut_ad(len == 4);
986-
987-
ut_ad(table->space_id == mach_read_from_4(
988-
rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__SPACE,
989-
&len)));
990-
ut_ad(len == 4);
991-
992-
if (!table->space) {
993-
/* It is a single table tablespae and the .ibd file is
994-
missing: do nothing. */
995-
996-
ib::warn()
997-
<< "Trying to TRUNCATE a missing .ibd file of table "
998-
<< table->name << "!";
999-
1000-
return(FIL_NULL);
1001-
}
1002-
1003-
ptr = rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__TYPE, &len);
1004-
ut_ad(len == 4);
1005-
ulint type = mach_read_from_4(ptr);
1006-
1007-
ptr = rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__ID, &len);
1008-
ut_ad(len == 8);
1009-
index_id_t index_id = mach_read_from_8(ptr);
1010-
1011-
/* We will need to commit the mini-transaction in order to avoid
1012-
deadlocks in the btr_create() call, because otherwise we would
1013-
be freeing and allocating pages in the same mini-transaction. */
1014-
btr_pcur_store_position(pcur, mtr);
1015-
mtr_commit(mtr);
1016-
1017-
mtr_start(mtr);
1018-
mtr->set_named_space(table->space);
1019-
btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, mtr);
1020-
1021-
/* Find the index corresponding to this SYS_INDEXES record. */
1022-
for (dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
1023-
index != NULL;
1024-
index = UT_LIST_GET_NEXT(indexes, index)) {
1025-
if (index->id == index_id) {
1026-
ulint root_page_no = (index->type & DICT_FTS)
1027-
? FIL_NULL
1028-
: btr_create(type, table->space,
1029-
index_id, index, mtr);
1030-
index->page = unsigned(root_page_no);
1031-
return root_page_no;
1032-
}
1033-
}
1034-
1035-
ib::error() << "Failed to create index with index id " << index_id
1036-
<< " of table " << table->name;
1037-
1038-
return(FIL_NULL);
1039-
}
1040-
1041960
/*********************************************************************//**
1042961
Creates a table create graph.
1043962
@return own: table create node */

storage/innobase/fil/fil0fil.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,10 +1873,8 @@ for concurrency control.
18731873
@param[in] id tablespace ID
18741874
@param[in] silent whether to silently ignore missing tablespaces
18751875
@return the tablespace
1876-
@retval NULL if missing or being deleted or truncated */
1877-
UNIV_INTERN
1878-
fil_space_t*
1879-
fil_space_acquire_low(ulint id, bool silent)
1876+
@retval NULL if missing or being deleted */
1877+
fil_space_t* fil_space_acquire_low(ulint id, bool silent)
18801878
{
18811879
fil_space_t* space;
18821880

@@ -2203,9 +2201,7 @@ enum fil_operation_t {
22032201
@param[in] space tablespace
22042202
@param[in] count number of attempts so far
22052203
@return 0 if no operations else count + 1. */
2206-
static
2207-
ulint
2208-
fil_check_pending_ops(const fil_space_t* space, ulint count)
2204+
static ulint fil_check_pending_ops(const fil_space_t* space, ulint count)
22092205
{
22102206
ut_ad(mutex_own(&fil_system.mutex));
22112207

@@ -2216,7 +2212,7 @@ fil_check_pending_ops(const fil_space_t* space, ulint count)
22162212
if (ulint n_pending_ops = space->n_pending_ops) {
22172213

22182214
if (count > 5000) {
2219-
ib::warn() << "Trying to close/delete/truncate"
2215+
ib::warn() << "Trying to delete"
22202216
" tablespace '" << space->name
22212217
<< "' but there are " << n_pending_ops
22222218
<< " pending operations on it.";
@@ -2263,7 +2259,7 @@ fil_check_pending_io(
22632259
ut_a(!(*node)->being_extended);
22642260

22652261
if (count > 1000) {
2266-
ib::warn() << "Trying to delete/close/truncate"
2262+
ib::warn() << "Trying to delete"
22672263
" tablespace '" << space->name
22682264
<< "' but there are "
22692265
<< space->n_pending_flushes

storage/innobase/fsp/fsp0file.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,9 @@ RemoteDatafile::create_link_file(
931931

932932
prev_filepath = read_link_file(link_filepath);
933933
if (prev_filepath) {
934-
/* Truncate will call this with an existing
935-
link file which contains the same filepath. */
934+
/* Truncate (starting with MySQL 5.6, probably no
935+
longer since MariaDB Server 10.2.19) used to call this
936+
with an existing link file which contains the same filepath. */
936937
bool same = !strcmp(prev_filepath, filepath);
937938
ut_free(prev_filepath);
938939
if (same) {

storage/innobase/ibuf/ibuf0ibuf.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,15 +4614,10 @@ ibuf_merge_or_delete_for_page(
46144614
ibuf_add_ops(ibuf->n_discarded_ops, dops);
46154615
}
46164616

4617-
/*********************************************************************//**
4618-
Deletes all entries in the insert buffer for a given space id. This is used
4619-
in DISCARD TABLESPACE, IMPORT TABLESPACE, and 5.7 TRUNCATE TABLE recovery.
4620-
NOTE: this does not update the page free bitmaps in the space. The space will
4621-
become CORRUPT when you call this function! */
4622-
void
4623-
ibuf_delete_for_discarded_space(
4624-
/*============================*/
4625-
ulint space) /*!< in: space id */
4617+
/** Delete all change buffer entries for a tablespace,
4618+
in DISCARD TABLESPACE, IMPORT TABLESPACE, or crash recovery.
4619+
@param[in] space missing or to-be-discarded tablespace */
4620+
void ibuf_delete_for_discarded_space(ulint space)
46264621
{
46274622
mem_heap_t* heap;
46284623
btr_pcur_t pcur;

storage/innobase/include/dict0crea.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,6 @@ dict_create_index_tree(
9696
dict_index_t* index, /*!< in/out: index */
9797
const trx_t* trx); /*!< in: InnoDB transaction handle */
9898

99-
/*******************************************************************//**
100-
Recreate the index tree associated with a row in SYS_INDEXES table.
101-
@return new root page number, or FIL_NULL on failure */
102-
ulint
103-
dict_recreate_index_tree(
104-
/*======================*/
105-
const dict_table_t* table, /*!< in: the table the index
106-
belongs to */
107-
btr_pcur_t* pcur, /*!< in/out: persistent cursor pointing
108-
to record in the clustered index of
109-
SYS_INDEXES table. The cursor may be
110-
repositioned in this call. */
111-
mtr_t* mtr); /*!< in: mtr having the latch
112-
on the record page. The mtr may be
113-
committed and restarted in this call. */
114-
11599
/** Drop the index tree associated with a row in SYS_INDEXES table.
116100
@param[in,out] rec SYS_INDEXES record
117101
@param[in,out] pcur persistent cursor on rec

storage/innobase/include/dict0dict.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -910,24 +910,6 @@ inline ulint dict_table_extent_size(const dict_table_t* table)
910910
return FSP_EXTENT_SIZE;
911911
}
912912

913-
/*********************************************************************//**
914-
Obtain exclusive locks on all index trees of the table. This is to prevent
915-
accessing index trees while InnoDB is updating internal metadata for
916-
operations such as truncate tables. */
917-
UNIV_INLINE
918-
void
919-
dict_table_x_lock_indexes(
920-
/*======================*/
921-
dict_table_t* table) /*!< in: table */
922-
MY_ATTRIBUTE((nonnull));
923-
/*********************************************************************//**
924-
Release the exclusive locks on all index tree. */
925-
UNIV_INLINE
926-
void
927-
dict_table_x_unlock_indexes(
928-
/*========================*/
929-
dict_table_t* table) /*!< in: table */
930-
MY_ATTRIBUTE((nonnull));
931913
/********************************************************************//**
932914
Checks if a column is in the ordering columns of the clustered index of a
933915
table. Column prefixes are treated like whole columns.

storage/innobase/include/dict0dict.ic

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -705,28 +705,6 @@ dict_tf_to_sys_tables_type(
705705
return(type);
706706
}
707707

708-
/*********************************************************************//**
709-
Obtain exclusive locks on all index trees of the table. This is to prevent
710-
accessing index trees while InnoDB is updating internal metadata for
711-
operations such as truncate tables. */
712-
UNIV_INLINE
713-
void
714-
dict_table_x_lock_indexes(
715-
/*======================*/
716-
dict_table_t* table) /*!< in: table */
717-
{
718-
dict_index_t* index;
719-
720-
ut_ad(mutex_own(&dict_sys.mutex));
721-
722-
/* Loop through each index of the table and lock them */
723-
for (index = dict_table_get_first_index(table);
724-
index != NULL;
725-
index = dict_table_get_next_index(index)) {
726-
rw_lock_x_lock(dict_index_get_lock(index));
727-
}
728-
}
729-
730708
/*********************************************************************//**
731709
Returns true if the particular FTS index in the table is still syncing
732710
in the background, false otherwise.
@@ -748,24 +726,6 @@ dict_fts_index_syncing(
748726
}
749727
return(false);
750728
}
751-
/*********************************************************************//**
752-
Release the exclusive locks on all index tree. */
753-
UNIV_INLINE
754-
void
755-
dict_table_x_unlock_indexes(
756-
/*========================*/
757-
dict_table_t* table) /*!< in: table */
758-
{
759-
dict_index_t* index;
760-
761-
ut_ad(mutex_own(&dict_sys.mutex));
762-
763-
for (index = dict_table_get_first_index(table);
764-
index != NULL;
765-
index = dict_table_get_next_index(index)) {
766-
rw_lock_x_unlock(dict_index_get_lock(index));
767-
}
768-
}
769729

770730
/********************************************************************//**
771731
Gets the number of fields in the internal representation of an index,

storage/innobase/include/fil0fil.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,15 @@ struct fil_space_t {
9292
/** Log sequence number of the latest MLOG_INDEX_LOAD record
9393
that was found while parsing the redo log */
9494
lsn_t enable_lsn;
95+
/** set when an .ibd file is about to be deleted,
96+
or an undo tablespace is about to be truncated.
97+
When this is set following new ops are not allowed:
98+
* read IO request
99+
* ibuf merge
100+
* file flush
101+
Note that we can still possibly have new write operations
102+
because we don't check this flag when doing flush batches. */
95103
bool stop_new_ops;
96-
/*!< we set this true when we start
97-
deleting a single-table tablespace.
98-
When this is set following new ops
99-
are not allowed:
100-
* read IO request
101-
* ibuf merge
102-
* file flush
103-
Note that we can still possibly have
104-
new write operations because we don't
105-
check this flag when doing flush
106-
batches. */
107104
/** whether undo tablespace truncation is in progress */
108105
bool is_being_truncated;
109106
#ifdef UNIV_DEBUG
@@ -1112,10 +1109,8 @@ for concurrency control.
11121109
@param[in] id tablespace ID
11131110
@param[in] silent whether to silently ignore missing tablespaces
11141111
@return the tablespace
1115-
@retval NULL if missing or being deleted or truncated */
1116-
UNIV_INTERN
1117-
fil_space_t*
1118-
fil_space_acquire_low(ulint id, bool silent)
1112+
@retval NULL if missing or being deleted */
1113+
fil_space_t* fil_space_acquire_low(ulint id, bool silent)
11191114
MY_ATTRIBUTE((warn_unused_result));
11201115

11211116
/** Acquire a tablespace when it could be dropped concurrently.

storage/innobase/include/ibuf0ibuf.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,11 @@ ibuf_merge_or_delete_for_page(
337337
ulint zip_size,
338338
bool update_ibuf_bitmap);
339339

340-
/*********************************************************************//**
341-
Deletes all entries in the insert buffer for a given space id. This is used
342-
in DISCARD TABLESPACE and IMPORT TABLESPACE.
343-
NOTE: this does not update the page free bitmaps in the space. The space will
344-
become CORRUPT when you call this function! */
345-
void
346-
ibuf_delete_for_discarded_space(
347-
/*============================*/
348-
ulint space); /*!< in: space id */
340+
/** Delete all change buffer entries for a tablespace,
341+
in DISCARD TABLESPACE, IMPORT TABLESPACE, or crash recovery.
342+
@param[in] space missing or to-be-discarded tablespace */
343+
void ibuf_delete_for_discarded_space(ulint space);
344+
349345
/** Contract the change buffer by reading pages to the buffer pool.
350346
@param[in] full If true, do a full contraction based
351347
on PCT_IO(100). If false, the size of contract batch is determined

0 commit comments

Comments
 (0)