Skip to content

Commit 50c9687

Browse files
committed
MDEV-23807 ut_a(n_pending_flushes) failed in fil_node_t::prepare_to_close_or_detach()
Before closing file handles, we really must wait until there are no pending os_file_flush(). This was missed in commit b1ab211 (MDEV-15053) where we changed the following: fil_node_close_to_free(): Wait for n_pending==0. Because we no longer do an extra lookup of the tablespace between fil_io() and the completion of the operation, we must give fil_node_t::complete_io() a chance to decrement the counter.
1 parent 1adb537 commit 50c9687

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,9 @@ fil_try_to_close_file_in_LRU(
561561
continue;
562562
}
563563

564-
if (node->n_pending_flushes > 0) {
565-
564+
if (const auto n = node->n_pending_flushes) {
566565
ib::info() << "Cannot close file " << node->name
567-
<< ", because n_pending_flushes "
568-
<< node->n_pending_flushes;
566+
<< ", because n_pending_flushes " << n;
569567
}
570568

571569
if (node->needs_flush) {
@@ -915,7 +913,7 @@ pfs_os_file_t fil_node_t::close_to_free(bool detach_handle)
915913
fil_system.unflushed_spaces.remove(*space);
916914
}
917915

918-
if (n_pending)
916+
if (n_pending || n_pending_flushes)
919917
{
920918
mutex_exit(&fil_system.mutex);
921919
os_thread_sleep(100);
@@ -939,7 +937,6 @@ pfs_os_file_t fil_node_t::close_to_free(bool detach_handle)
939937
ut_ad(UT_LIST_GET_LEN(fil_system.LRU) > 0);
940938
UT_LIST_REMOVE(fil_system.LRU, this);
941939
}
942-
ut_a(!n_pending_flushes);
943940
ut_a(!being_extended);
944941
if (detach_handle)
945942
{
@@ -982,7 +979,6 @@ std::vector<pfs_os_file_t> fil_system_t::detach(fil_space_t *space,
982979
temp_space= nullptr;
983980

984981
ut_a(space->magic_n == FIL_SPACE_MAGIC_N);
985-
ut_a(space->n_pending_flushes == 0);
986982

987983
for (fil_node_t* node= UT_LIST_GET_FIRST(space->chain); node;
988984
node= UT_LIST_GET_NEXT(chain, node))
@@ -1003,6 +999,7 @@ std::vector<pfs_os_file_t> fil_system_t::detach(fil_space_t *space,
1003999
handles.push_back(handle);
10041000
}
10051001

1002+
ut_ad(space->n_pending_flushes == 0);
10061003
return handles;
10071004
}
10081005

@@ -1612,15 +1609,18 @@ void fil_close_all_files()
16121609
if (!node->is_open()) {
16131610
goto next;
16141611
}
1615-
if (!node->n_pending) {
1612+
if (!node->n_pending
1613+
&& !node->n_pending_flushes) {
16161614
node->close();
16171615
goto next;
16181616
}
16191617
}
16201618

16211619
ib::error() << "File '" << node->name
16221620
<< "' has " << node->n_pending
1623-
<< " operations";
1621+
<< " operations and "
1622+
<< node->n_pending_flushes
1623+
<< " flushes";
16241624
}
16251625

16261626
space = UT_LIST_GET_NEXT(space_list, space);
@@ -1988,17 +1988,18 @@ fil_check_pending_io(
19881988

19891989
*node = UT_LIST_GET_FIRST(space->chain);
19901990

1991-
if (space->n_pending_flushes > 0 || (*node)->n_pending > 0) {
1991+
const auto f = space->n_pending_flushes;
1992+
const auto p = (*node)->n_pending;
19921993

1994+
if (f || p) {
19931995
ut_a(!(*node)->being_extended);
19941996

19951997
/* Give a warning every 10 second, starting after 1 second */
19961998
if ((count % 500) == 50) {
19971999
ib::info() << "Trying to delete"
19982000
" tablespace '" << space->name
1999-
<< "' but there are "
2000-
<< space->n_pending_flushes
2001-
<< " flushes and " << (*node)->n_pending
2001+
<< "' but there are " << f
2002+
<< " flushes and " << p
20022003
<< " pending i/o's on it.";
20032004
}
20042005

0 commit comments

Comments
 (0)