187
187
requests on the file */
188
188
ibool stop_new_ops;
189
189
/*!< we set this TRUE when we start
190
deleting a single-table tablespace */
191
ibool is_being_deleted;
192
/*!< this is set to TRUE when we start
193
deleting a single-table tablespace and its
194
file; when this flag is set no further i/o
195
or flush requests can be placed on this space,
196
though there may be such requests still being
197
processed on this space */
190
deleting a single-table tablespace.
191
When this is set following new ops
196
Note that we can still possibly have
197
new write operations because we don't
198
check this flag when doing flush
198
200
ulint purpose;/*!< FIL_TABLESPACE, FIL_LOG, or
200
202
UT_LIST_BASE_NODE_T(fil_node_t) chain;
2305
ut_a(space->stop_new_ops);
2305
2306
ut_a(space->n_pending_ops == 0);
2307
space->is_being_deleted = TRUE;
2309
2308
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
2310
2309
node = UT_LIST_GET_FIRST(space->chain);
2348
2347
rw_lock_x_lock(&space->latch);
2350
2349
#ifndef UNIV_HOTBACKUP
2351
/* Invalidate in the buffer pool all pages belonging to the
2352
tablespace. Since we have set space->is_being_deleted = TRUE, readahead
2353
or ibuf merge can no longer read more pages of this tablespace to the
2354
buffer pool. Thus we can clean the tablespace out of the buffer pool
2355
completely and permanently. The flag is_being_deleted also prevents
2356
fil_flush() from being applied to this tablespace. */
2350
/* IMPORTANT: Because we have set space::stop_new_ops there
2351
can't be any new ibuf merges, reads or flushes. We are here
2352
because node::n_pending was zero above. However, it is still
2353
possible to have pending read and write requests:
2355
A read request can happen because the reader thread has
2356
gone through the ::stop_new_ops check in buf_page_init_for_read()
2357
before the flag was set and has not yet incremented ::n_pending
2358
when we checked it above.
2360
A write request can be issued any time because we don't check
2361
the ::stop_new_ops flag when queueing a block for write.
2363
We deal with pending write requests in the following function
2364
where we'd minimally evict all dirty pages belonging to this
2365
space from the flush_list. Not that if a block is IO-fixed
2366
we'll wait for IO to complete.
2368
To deal with potential read requests by checking the
2369
::stop_new_ops flag in fil_io() */
2358
2370
buf_LRU_flush_or_remove_pages(
2360
2372
? BUF_REMOVE_ALL_NO_WRITE
2365
2377
mutex_enter(&fil_system->mutex);
2379
/* Double check the sanity of pending ops after reacquiring
2380
the fil_system::mutex. */
2381
if (fil_space_get_by_id(id)) {
2382
ut_a(space->n_pending_ops == 0);
2383
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
2384
node = UT_LIST_GET_FIRST(space->chain);
2385
ut_a(node->n_pending == 0);
2367
2388
success = fil_space_free(id, TRUE);
2369
2390
mutex_exit(&fil_system->mutex);
4409
4430
space = fil_space_get_by_id(space_id);
4432
/* If we are deleting a tablespace we don't allow any read
4433
operations on that. However, we do allow write operations. */
4434
if (!space || (type == OS_FILE_READ && space->stop_new_ops)) {
4412
4435
mutex_exit(&fil_system->mutex);
4414
4437
ut_print_timestamp(stderr);
4756
4779
space = UT_LIST_GET_NEXT(unflushed_spaces, space)) {
4758
if (space->purpose == purpose && !space->is_being_deleted) {
4781
if (space->purpose == purpose && !space->stop_new_ops) {
4760
4783
space_ids[n_space_ids++] = space->id;