Skip to content

Commit f7b2d3f

Browse files
committed
finished recovery implementation
1 parent 9c4dd1b commit f7b2d3f

File tree

13 files changed

+881
-317
lines changed

13 files changed

+881
-317
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,13 +5141,17 @@ buf_page_init_for_read(
51415141
} else {
51425142
ut_ad(mode == BUF_READ_ANY_PAGE);
51435143
}
5144-
51455144
if (page_size.is_compressed() && !unzip && !recv_recovery_is_on()) {
51465145
block = NULL;
51475146
} else {
5147+
//tdnguyen test
5148+
//printf ("\n[begin buf_LRU_get_free_block");
5149+
51485150
block = buf_LRU_get_free_block(buf_pool);
5151+
//printf (" end buf_LRU_get_free_block]");
51495152
ut_ad(block);
51505153
ut_ad(buf_pool_from_block(block) == buf_pool);
5154+
51515155
}
51525156

51535157
buf_pool_mutex_enter(buf_pool);
@@ -5169,7 +5173,6 @@ buf_page_init_for_read(
51695173
bpage = NULL;
51705174
goto func_exit;
51715175
}
5172-
51735176
if (block) {
51745177
bpage = &block->page;
51755178

storage/innobase/buf/buf0flu.cc

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,47 +1087,27 @@ buf_flush_write_block_low(
10871087
break;
10881088
}
10891089
#if defined(UNIV_PMEMOBJ_BUF)
1090-
// We capture the write from buffer pool flush
1091-
// EXCEPT: space 0
1092-
//if (bpage->id.page_no() != 0) {
1093-
//if(0) {
1094-
1090+
1091+
//printf("\n [begin pm_buf_write space %zu page %zu==>", bpage->id.space(),bpage->id.page_no());
1092+
// if (!fsp_is_system_temporary(bpage->id.space())){
10951093
#if defined (UNIV_PMEMOBJ_BUF_V2)
1096-
int ret = pm_buf_write_no_free_pool(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
1094+
int ret = pm_buf_write_no_free_pool(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
10971095
#elif defined (UNIV_PMEMOBJ_BUF_FLUSHER)
1098-
int ret = pm_buf_write_with_flusher(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
1096+
int ret = pm_buf_write_with_flusher(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
10991097
#elif defined (UNIV_PMEMOBJ_BUF_APPEND)
1100-
int ret = pm_buf_write_with_flusher_append(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
1098+
int ret = pm_buf_write_with_flusher_append(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
11011099
#else
1102-
int ret = pm_buf_write(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
1100+
int ret = pm_buf_write(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
11031101
#endif
1104-
assert(ret == PMEM_SUCCESS);
1105-
//we remove this page from LRU
1106-
//assert(buf_page_io_complete(bpage, true));
1107-
assert(buf_page_io_complete(bpage,sync));
1108-
goto skip_write_and_fsync;
1109-
1110-
//if (gb_pmw->pbuf->is_async_only) {
1111-
// if(!sync) {
1112-
// int ret = pm_buf_write(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, false);
1113-
// assert(ret == PMEM_SUCCESS);
1114-
// //After memcpy, We need this call to sync the buffer pool variables
1115-
// assert(buf_page_io_complete(bpage));
1116-
// //goto skip_write;
1117-
// goto skip_write_and_fsync;
1118-
// }
1119-
//}
1120-
//else {
1121-
// //capture both sync and async write from buffer pool
1122-
// int ret = pm_buf_write(gb_pmw->pop, gb_pmw->pbuf, bpage->id, bpage->size, frame, sync);
1123-
// assert(ret == PMEM_SUCCESS);
1124-
// //After memcpy, We need this call to sync the buffer pool variables
1125-
// if (!sync)
1126-
// assert(buf_page_io_complete(bpage));
1127-
// //goto skip_write;
1128-
// goto skip_write_and_fsync;
1129-
//}
1102+
//printf("END pm_buf_write space %zu page %zu]\n", bpage->id.space(),bpage->id.page_no());
1103+
//printf(" END pm_buf_write]");
1104+
assert(ret == PMEM_SUCCESS);
1105+
//we remove this page from LRU
1106+
//assert(buf_page_io_complete(bpage, true));
1107+
assert(buf_page_io_complete(bpage,sync));
1108+
goto skip_write_and_fsync;
11301109
// }
1110+
//skip_pm_write:
11311111
#endif /*UNIV_PMEMOBJ_BUF*/
11321112
/* Disable use of double-write buffer for temporary tablespace.
11331113
Given the nature and load of temporary tablespace doublewrite buffer
@@ -1258,6 +1238,8 @@ buf_flush_page(
12581238
&& is_uncompressed
12591239
&& !rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE)) {
12601240

1241+
//tdnguyen test
1242+
//printf("\n [begin handle buf_dblwr ==> ");
12611243
if (!fsp_is_system_temporary(bpage->id.space())) {
12621244
/* avoiding deadlock possibility involves
12631245
doublewrite buffer, should flush it, because
@@ -1268,6 +1250,8 @@ buf_flush_page(
12681250
}
12691251

12701252
rw_lock_sx_lock_gen(rw_lock, BUF_IO_WRITE);
1253+
1254+
//printf("end handle buf_dblwr] ");
12711255
}
12721256

12731257
/* If there is an observer that want to know if the asynchronous
@@ -1287,8 +1271,11 @@ buf_flush_page(
12871271
point, it is safe to access bpage, because it is io_fixed and
12881272
oldest_modification != 0. Thus, it cannot be relocated in the
12891273
buffer pool or removed from flush_list or LRU_list. */
1290-
1274+
1275+
//tdnguyen test
1276+
//printf("\n [begin buf_flush_write_block_low ==> ");
12911277
buf_flush_write_block_low(bpage, flush_type, sync);
1278+
//printf(" END buf_flush_write_block_low ] ");
12921279
}
12931280

12941281
return(flush);
@@ -2273,10 +2260,13 @@ buf_flush_single_page_from_LRU(
22732260
22742261
Note: There is no guarantee that this page has actually
22752262
been freed, only that it has been flushed to disk */
2276-
2263+
2264+
//tdnguyen test
2265+
//printf("\n [begin buf_flush_page ==>");
22772266
freed = buf_flush_page(
22782267
buf_pool, bpage, BUF_FLUSH_SINGLE_PAGE, true);
22792268

2269+
//printf("END buf_flush_page ");
22802270
if (freed) {
22812271
break;
22822272
}
@@ -4076,8 +4066,9 @@ DECLARE_THREAD(pm_flusher_worker)(
40764066
//worker thread wait until there is is_requested signal
40774067
retry:
40784068
os_event_wait(flusher->is_req_not_empty);
4079-
4080-
//printf("wakeup worker...\n");
4069+
#if defined(UNIV_PMEMOBJ_BUF_RECOVERY_DEBUG)
4070+
printf("wakeup worker...\n");
4071+
#endif
40814072
//looking for a full list in wait-list and flush it
40824073
mutex_enter(&flusher->mutex);
40834074
if (flusher->n_requested > 0) {
@@ -4087,6 +4078,9 @@ DECLARE_THREAD(pm_flusher_worker)(
40874078
if (plist)
40884079
{
40894080
//***this call aio_batch ***
4081+
#if defined(UNIV_PMEMOBJ_BUF_RECOVERY_DEBUG)
4082+
printf("in flusher thread, pointer id=%zu, list_id =%zu\n", i, plist->list_id);
4083+
#endif
40904084
pm_buf_flush_list(gb_pmw->pop, gb_pmw->pbuf, plist);
40914085
flusher->n_requested--;
40924086
os_event_set(flusher->is_req_full);
@@ -4159,6 +4153,7 @@ pm_handle_finished_block_with_flusher(
41594153
pflush_list->n_aio_pending--;
41604154

41614155
if (pflush_list->n_aio_pending + pflush_list->n_sio_pending == 0) {
4156+
//printf("\n [begin finish AIO list %zu\n", pflush_list->list_id);
41624157
//Now all pages in this list are persistent in disk
41634158
//(0) flush spaces
41644159
pm_buf_flush_spaces_in_list(pop, buf, pflush_list);
@@ -4214,7 +4209,8 @@ pm_handle_finished_block_with_flusher(
42144209
pfree_pool->cur_lists++;
42154210
//wakeup who is waitting for free_pool available
42164211
os_event_set(buf->free_pool_event);
4217-
4212+
4213+
//printf("end finish AIO List %zu]", pflush_list->list_id);
42184214
pmemobj_rwlock_unlock(pop, &pfree_pool->lock);
42194215
}
42204216
//the list has some unfinished aio
@@ -4269,12 +4265,14 @@ DECLARE_THREAD(pm_buf_flush_list_cleaner_coordinator)(
42694265
if (srv_shutdown_state != SRV_SHUTDOWN_NONE) {
42704266
break;
42714267
}
4272-
printf("cur free list = %zu\n", D_RW(gb_pmw->pbuf->free_pool)->cur_lists);
4268+
printf("cur free list = %zu, cur spec_list = %zu\n",
4269+
D_RW(gb_pmw->pbuf->free_pool)->cur_lists,
4270+
D_RW(gb_pmw->pbuf->spec_list)->cur_pages);
42734271

42744272
#if defined(UNIV_PMEMOBJ_BUF_FLUSHER)
4275-
mutex_enter(&flusher->mutex);
4276-
printf(" n_requested/size %zu/%zu \n", flusher->n_requested, flusher->size);
4277-
mutex_exit(&flusher->mutex);
4273+
//mutex_enter(&flusher->mutex);
4274+
//printf(" n_requested/size %zu/%zu \n", flusher->n_requested, flusher->size);
4275+
//mutex_exit(&flusher->mutex);
42784276
#endif
42794277
} //end while thread
42804278

storage/innobase/buf/buf0lru.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,12 @@ buf_LRU_get_free_block(
13491349
If we are doing for the first time we'll scan only
13501350
tail of the LRU list otherwise we scan the whole LRU
13511351
list. */
1352+
1353+
//tdnguyen test
1354+
//printf("\n [start buf_LRU_scan ==> ");
13521355
freed = buf_LRU_scan_and_free_block(
13531356
buf_pool, n_iterations > 0);
1357+
//printf("END buf_LRU_scan with freed is %d] ", freed);
13541358

13551359
if (!freed && n_iterations == 0) {
13561360
/* Tell other threads that there is no point
@@ -1419,11 +1423,14 @@ buf_LRU_get_free_block(
14191423
removing the block from page_hash and LRU_list is fairly
14201424
involved (particularly in case of compressed pages). We
14211425
can do that in a separate patch sometime in future. */
1422-
1426+
1427+
//tdnguyen test
1428+
//printf ("\n [start buf_flush_single_page ==>");
14231429
if (!buf_flush_single_page_from_LRU(buf_pool)) {
14241430
MONITOR_INC(MONITOR_LRU_SINGLE_FLUSH_FAILURE_COUNT);
14251431
++flush_failures;
14261432
}
1433+
//printf ("END buf_flush_single_page ]");
14271434

14281435
srv_stats.buf_pool_wait_free.add(n_iterations, 1);
14291436

storage/innobase/buf/buf0rea.cc

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ buf_read_page_low(
152152
or is being dropped; if we succeed in initing the page in the buffer
153153
pool for read, then DISCARD cannot proceed until the read has
154154
completed */
155+
156+
//tdnguyen test
157+
//printf("\n[ start buf_page_init_for_read");
155158
bpage = buf_page_init_for_read(err, mode, page_id, page_size, unzip);
159+
//printf(" end buf_page_init_for_read]");
156160

157161
if (bpage == NULL) {
158162

@@ -167,7 +171,6 @@ buf_read_page_low(
167171
sync ? "sync" : "async"));
168172

169173
ut_ad(buf_page_in_file(bpage));
170-
171174
if (sync) {
172175
thd_wait_begin(NULL, THD_WAIT_DISKIO);
173176
}
@@ -194,31 +197,39 @@ buf_read_page_low(
194197
}
195198
);
196199
#if defined (UNIV_PMEMOBJ_BUF)
197-
//size_t read_bytes= pm_buf_read(gb_pmw->pop, gb_pmw->pbuf, page_id, page_size, (byte*)dst, sync);
200+
//printf ("\n[start our func ");
201+
//printf("pm_buf_read space %zu page %zu start...", page_id.space(), page_id.page_no());
198202
#if defined (UNIV_PMEMOBJ_BUF_APPEND)
199203
const PMEM_BUF_BLOCK* pblock= pm_buf_read_lasted(gb_pmw->pop, gb_pmw->pbuf, page_id, page_size, (byte*)dst, sync);
200204
#else
201205
const PMEM_BUF_BLOCK* pblock= pm_buf_read(gb_pmw->pop, gb_pmw->pbuf, page_id, page_size, (byte*)dst, sync);
202206
#endif
207+
//printf("end pm_buf_read_space, pblock is NULL %d\n ", (pblock==NULL));
203208
//if (read_bytes > 0) {
204209
if (pblock) {
210+
bool compl_ok;
205211
if (sync) {
206212
thd_wait_end(NULL);
207213
/* The i/o is already completed when we arrive from
208214
fil_read */
209-
if (!buf_page_io_complete(bpage)) {
210-
ib::error() <<
215+
//printf("start buf_page_io_complete sync=true ...");
216+
compl_ok = buf_page_io_complete(bpage);
217+
//printf("end buf_page_io_complete \n", sync);
218+
}
219+
else {
220+
//printf("start buf_page_io_complete sync=FALSE ...");
221+
compl_ok = buf_page_io_complete(bpage);
222+
//printf("end buf_page_io_complete \n", sync);
223+
}
224+
if (!compl_ok) {
225+
ib::error() <<
211226
"!!! PMEM_BUF ERROR buf_page_io_complete pblock->id=" << pblock->id
212227
<< ", pmemaddr=" << pblock->pmemaddr
213228
<< ", block_state= " << pblock->state
214229
<< ", bpage->id= " << bpage->id
215230
<< ", page_id= " << page_id;
216-
assert(0);
217-
return(0);
218-
}
219-
}
220-
else {
221-
assert(buf_page_io_complete(bpage)) ;
231+
assert(0);
232+
return(0);
222233
}
223234
}
224235
else {
@@ -265,6 +276,7 @@ buf_read_page_low(
265276

266277
#if defined (UNIV_PMEMOBJ_BUF)
267278
} //end else
279+
//printf("end our func ]\n");
268280
#endif
269281
return(1);
270282
}
@@ -947,11 +959,14 @@ buf_read_recv_pages(
947959
BUF_READ_ANY_PAGE,
948960
cur_page_id, page_size, true);
949961
} else {
962+
//tdnguyen test
963+
//printf("\n[ call buf_read_page_low start cur_page_id = %zu ...", cur_page_id.page_no());
950964
buf_read_page_low(
951965
&err, false,
952966
IORequest::DO_NOT_WAKE,
953967
BUF_READ_ANY_PAGE,
954968
cur_page_id, page_size, true);
969+
//printf("buf_read_page_low ended ]\n");
955970
}
956971
}
957972

0 commit comments

Comments
 (0)