@@ -152,6 +152,31 @@ static void tc_remove_table(TABLE *table)
152
152
}
153
153
154
154
155
+ static void tc_remove_all_unused_tables (TDC_element *element,
156
+ TABLE_list *purge_tables,
157
+ bool mark_flushed)
158
+ {
159
+ TABLE *table;
160
+
161
+ element->wait_for_mdl_deadlock_detector ();
162
+ /*
163
+ Mark share flushed in order to ensure that it gets
164
+ automatically deleted once it is no longer referenced.
165
+
166
+ Note that code in TABLE_SHARE::wait_for_old_version() assumes that
167
+ marking share flushed is followed by purge of unused table
168
+ shares.
169
+ */
170
+ if (mark_flushed)
171
+ element->flushed = true ;
172
+ while ((table= element->free_tables .pop_front ()))
173
+ {
174
+ tc_remove_table (table);
175
+ purge_tables->push_front (table);
176
+ }
177
+ }
178
+
179
+
155
180
/* *
156
181
Free all unused TABLE objects.
157
182
@@ -176,17 +201,8 @@ struct tc_purge_arg
176
201
177
202
static my_bool tc_purge_callback (TDC_element *element, tc_purge_arg *arg)
178
203
{
179
- TABLE *table;
180
-
181
204
mysql_mutex_lock (&element->LOCK_table_share );
182
- element->wait_for_mdl_deadlock_detector ();
183
- if (arg->mark_flushed )
184
- element->flushed = true ;
185
- while ((table= element->free_tables .pop_front ()))
186
- {
187
- tc_remove_table (table);
188
- arg->purge_tables .push_front (table);
189
- }
205
+ tc_remove_all_unused_tables (element, &arg->purge_tables , arg->mark_flushed );
190
206
mysql_mutex_unlock (&element->LOCK_table_share );
191
207
return FALSE ;
192
208
}
@@ -880,23 +896,9 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
880
896
881
897
element->ref_count ++;
882
898
883
- element->wait_for_mdl_deadlock_detector ();
884
- /*
885
- Mark share flushed in order to ensure that it gets
886
- automatically deleted once it is no longer referenced.
899
+ tc_remove_all_unused_tables (element, &purge_tables,
900
+ remove_type != TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE);
887
901
888
- Note that code in TABLE_SHARE::wait_for_old_version() assumes that
889
- marking share flushed is followed by purge of unused table
890
- shares.
891
- */
892
- if (remove_type != TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE)
893
- element->flushed = true ;
894
-
895
- while ((table= element->free_tables .pop_front ()))
896
- {
897
- tc_remove_table (table);
898
- purge_tables.push_front (table);
899
- }
900
902
if (kill_delayed_threads)
901
903
kill_delayed_threads_for_table (element);
902
904
0 commit comments