diff --recursive -u 55bzrorig/storage/innobase/buf/buf0rea.c 55bzr/storage/innobase/buf/buf0rea.c --- 55bzrorig/storage/innobase/buf/buf0rea.c 2012-08-23 16:17:38.073827000 -0700 +++ 55bzr/storage/innobase/buf/buf0rea.c 2012-09-05 18:50:29.167999779 -0700 @@ -752,6 +752,9 @@ goto tablespace_deleted; } +if (space_ids[i] > 0 && space_ids[i] < 100) +fprintf(stderr, "ibuf_merge_pages for %lu\n", space_ids[i]); + buf_read_page_low(&err, sync && (i + 1 == n_stored), BUF_READ_ANY_PAGE, space_ids[i], zip_size, TRUE, space_versions[i], Only in 55bzr/storage/innobase: CMakeFiles Only in 55bzr/storage/innobase: cmake_install.cmake diff --recursive -u 55bzrorig/storage/innobase/fil/fil0fil.c 55bzr/storage/innobase/fil/fil0fil.c --- 55bzrorig/storage/innobase/fil/fil0fil.c 2012-08-23 16:17:38.073827000 -0700 +++ 55bzr/storage/innobase/fil/fil0fil.c 2012-09-05 20:59:35.076000002 -0700 @@ -163,6 +163,9 @@ ulint magic_n;/*!< FIL_NODE_MAGIC_N */ }; +volatile ulint dropper_id; +volatile int dropper_can_run=0; + /** Value of fil_node_struct::magic_n */ #define FIL_NODE_MAGIC_N 89389 @@ -2255,7 +2258,7 @@ count = 0; - goto try_again; + goto try_again_pre; } else { if (count > 5000) { ut_print_timestamp(stderr); @@ -2283,6 +2286,25 @@ mutex_exit(&fil_system->mutex); count = 0; +try_again_pre: + +if (id > 0 && id < 100) { + int x; + + dropper_can_run=1; + dropper_id = id; + + fprintf(stderr, "dropper starts wait, id %lu, dropper_id %lu\n", id, dropper_id); + + for (x=0; x < 20; ++x) { + if (dropper_can_run == 2) { + break; + } + os_thread_sleep(500000); + } + fprintf(stderr, "dropper done with x=%d, goal state 2 and state %d\n", x, dropper_can_run); +} + try_again: mutex_enter(&fil_system->mutex); @@ -2335,6 +2357,7 @@ mutex_exit(&fil_system->mutex); + /* Important: We rely on the data dictionary mutex to ensure that a race is not possible here. It should serialize the tablespace drop/free. We acquire an X latch only to avoid a race condition @@ -2345,6 +2368,8 @@ There our main motivation is to reduce the contention on the dictionary mutex. */ +if (id > 0 && id < 100) +fprintf(stderr, "dropper lock space->latch\n"); rw_lock_x_lock(&space->latch); #ifndef UNIV_HOTBACKUP @@ -2355,6 +2380,8 @@ completely and permanently. The flag is_being_deleted also prevents fil_flush() from being applied to this tablespace. */ +if (id > 0 && id < 100) +fprintf(stderr, "dropper flush_or_remove\n"); buf_LRU_flush_or_remove_pages( id, evict_all ? BUF_REMOVE_ALL_NO_WRITE @@ -2362,10 +2389,33 @@ #endif /* printf("Deleting tablespace %s id %lu\n", space->name, id); */ + +if (id > 0 && id < 100) +fprintf(stderr, "dropper wait on mutex before free\n"); + +if (id > 0 && id < 100) { + int x; + + dropper_can_run=3; + dropper_id = id; + + fprintf(stderr, "dropper starts second wait, id %lu, dropper_id %lu\n", id, dropper_id); + + for (x=0; x < 20; ++x) { + if (dropper_can_run == 4) { + break; + } + os_thread_sleep(500000); + } + fprintf(stderr, "dropper done with x=%d, goal state 4 and state %d\n", x, dropper_can_run); +} mutex_enter(&fil_system->mutex); success = fil_space_free(id, TRUE); +if (id > 0 && id < 100) +fprintf(stderr, "dropper called fil_space_free\n"); + mutex_exit(&fil_system->mutex); if (success) { @@ -2378,6 +2428,9 @@ rw_lock_x_unlock(&space->latch); } +dropper_id=0; +dropper_can_run=0; + if (success) { #ifndef UNIV_HOTBACKUP /* Write a log record about the deletion of the .ibd @@ -4243,6 +4296,8 @@ } node->n_pending++; + if (space->id > 0 && space->id == dropper_id) + fprintf(stderr, "inc space %lu n_pending %lu\n", space->id, node->n_pending); } /********************************************************************//** @@ -4264,6 +4319,8 @@ ut_a(node->n_pending > 0); + if (node->space->id > 0 && node->space->id == dropper_id) + fprintf(stderr, "dec space %lu n_pending %lu\n", node->space->id, node->n_pending); node->n_pending--; if (type == OS_FILE_WRITE) { @@ -4420,6 +4477,7 @@ (ulong) type, (ulong) space_id, (ulong) block_offset, (ulong) len); + fprintf(stderr, "...deleted %lu\n", space_id); return(DB_TABLESPACE_DELETED); } @@ -4452,6 +4510,24 @@ } } +{ + if (space->id == dropper_id && dropper_can_run == 1 && type == OS_FILE_READ) { + fprintf(stderr, "reader found state 1 for %lu\n", space->id); + dropper_can_run = 2; + + fprintf(stderr, "reader waiting for state 2\n"); + while (dropper_can_run == 2) { + mutex_exit(&fil_system->mutex); + os_thread_yield(); + mutex_enter(&fil_system->mutex); + } + fprintf(stderr, "reader saw state 2\n"); + + } else if (space->id > 0 && space->id < 100) { + /* fprintf(stderr, "reader for id %lu with dropper_id %lu\n", space->id, d_id); */ + } +} + /* Open file if closed */ fil_node_prepare_for_io(node, fil_system, space); @@ -4470,6 +4546,19 @@ /* Now we have made the changes in the data structures of fil_system */ mutex_exit(&fil_system->mutex); +{ + if (space->id == dropper_id && dropper_can_run == 3 && type == OS_FILE_READ) { + fprintf(stderr, "reader found state 3 for %lu\n", space->id); + dropper_can_run = 4; + + os_thread_sleep(5000000); + fprintf(stderr, "reader done sleeping after state 4\n"); + + } else if (space->id > 0 && space->id < 100) { + /* fprintf(stderr, "reader for id %lu with dropper_id %lu\n", space->id, d_id); */ + } +} + /* Calculate the low 32 bits and the high 32 bits of the file offset */ if (!zip_size) { Only in 55bzr/storage/innobase/fil: .fil0fil.c.swp diff --recursive -u 55bzrorig/storage/innobase/ibuf/ibuf0ibuf.c 55bzr/storage/innobase/ibuf/ibuf0ibuf.c --- 55bzrorig/storage/innobase/ibuf/ibuf0ibuf.c 2012-03-23 08:29:42.000000000 -0700 +++ 55bzr/storage/innobase/ibuf/ibuf0ibuf.c 2012-09-05 20:27:37.800000221 -0700 @@ -2708,6 +2708,8 @@ return(ibuf_contract_ext(&n_pages, sync)); } +extern volatile int dropper_can_run; + /*********************************************************************//** Contracts insert buffer trees by reading pages to the buffer pool. @return a lower limit for the combined size in bytes of entries which @@ -2729,6 +2731,11 @@ ulint n_bytes; ulint n_pag2; + while (!dropper_can_run) { + fprintf(stderr, "Merge blocked\n"); + return 0; + } + while (sum_pages < n_pages) { n_bytes = ibuf_contract_ext(&n_pag2, sync); @@ -2739,6 +2746,7 @@ sum_bytes += n_bytes; sum_pages += n_pag2; } + fprintf(stderr, "Merged %lu pages\n", n_pag2); return(sum_bytes); } @@ -3650,6 +3658,7 @@ #ifdef UNIV_IBUF_DEBUG ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED); #endif + if (n_stored > 2) n_stored = 2; buf_read_ibuf_merge_pages(FALSE, space_ids, space_versions, page_nos, n_stored); } Only in 55bzr/storage/innobase: libinnobase.a Only in 55bzr/storage/innobase: Makefile diff --recursive -u 55bzrorig/storage/innobase/srv/srv0srv.c 55bzr/storage/innobase/srv/srv0srv.c --- 55bzrorig/storage/innobase/srv/srv0srv.c 2012-03-23 08:29:42.000000000 -0700 +++ 55bzr/storage/innobase/srv/srv0srv.c 2012-09-05 15:51:16.727999689 -0700 @@ -2802,9 +2802,12 @@ /* Get sleep interval in micro seconds. We use ut_min() to avoid long sleep in case of wrap around. */ +#ifdef ndef os_thread_sleep(ut_min(1000000, (next_itr_time - cur_time) * 1000)); +#endif + os_thread_sleep(10000); srv_main_sleeps++; }