Skip to content

Commit cb01a0f

Browse files
committed
(1) fix NULL trx when mtr::commit, (2) dynamic size for pref array of pe in TT
1 parent 49924d3 commit cb01a0f

File tree

11 files changed

+272
-98
lines changed

11 files changed

+272
-98
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5847,11 +5847,11 @@ fil_io(
58475847
#else /* UNIV_HOTBACKUP */
58485848
/* Queue the aio request */
58495849
//tdnguyen test
5850-
if (page_id.space() == 0){
5851-
if (page_id.page_no() == 6){
5852-
pm_ppl_test_write_rseg(req_type, page_id, (byte*) buf, page_size.physical());
5853-
}
5854-
}
5850+
//if (page_id.space() == 0){
5851+
// if (page_id.page_no() == 6){
5852+
// pm_ppl_test_write_rseg(req_type, page_id, (byte*) buf, page_size.physical());
5853+
// }
5854+
//}
58555855
//end tdnguyen test
58565856
err = os_aio(
58575857
req_type,
@@ -5970,7 +5970,9 @@ pm_ppl_test_write_rseg(
59705970
}
59715971
//Now follow the logic in trx_undo_mem_create_at_db_start() to get other info
59725972
page_header = undo_page + TRX_UNDO_PAGE_HDR;
5973-
type = mtr_read_ulint(page_header + TRX_UNDO_PAGE_TYPE, MLOG_2BYTES, &mtr);
5973+
5974+
//type = mtr_read_ulint(page_header + TRX_UNDO_PAGE_TYPE, MLOG_2BYTES, &mtr);
5975+
type = mach_read_ulint(page_header + TRX_UNDO_PAGE_TYPE, MLOG_2BYTES);
59745976

59755977
seg_header = undo_page + TRX_UNDO_SEG_HDR;
59765978

storage/innobase/fsp/fsp0fsp.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Created 11/29/1995 Heikki Tuuri
5353

5454
#include <my_aes.h>
5555

56+
#if defined (UNIV_PMEMOBJ_PART_PL)
57+
#include "trx0trx.h" //for trx_t
58+
#endif
59+
5660
/** Returns an extent to the free list of a space.
5761
@param[in] page_id page id in the extent
5862
@param[in] page_size page size
@@ -1677,6 +1681,15 @@ fsp_fill_free_list(
16771681
mtr_start(&ibuf_mtr);
16781682
ibuf_mtr.set_named_space(space);
16791683

1684+
#if defined (UNIV_PMEMOBJ_PART_PL)
1685+
//type 59 MLOG_INIT_FILE_PAGE2
1686+
trx_t* trx = mtr->pmemlog_get_parent_trx();
1687+
if (trx != NULL){
1688+
ibuf_mtr.pmemlog_set_parent_trx(trx);
1689+
ibuf_mtr.pmemlog_set_trx_id(trx->id);
1690+
}
1691+
#endif
1692+
16801693
/* Avoid logging while truncate table
16811694
fix-up is active. */
16821695
if (space->purpose == FIL_TYPE_TEMPORARY

storage/innobase/include/my_pmemobj.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,6 @@ struct __pmem_tx_log_block {
424424

425425
};
426426

427-
// Dirty Page Entry Ref in the log block
428-
struct __pmem_page_ref {
429-
uint64_t key; //fold of page_id_t.fold() in InnoDB
430-
int64_t idx; // index of the entry in DPT
431-
uint64_t pageLSN; //latest LSN on this page caused by the host transction, this value used in reclaiming logs
432-
};
433427

434428
//Dirty Page Table Entry
435429
struct __pmem_dpt_entry {
@@ -487,14 +481,14 @@ struct __pmem_page_part_log {
487481
// Transaction Table
488482
TOID(PMEM_TT) tt; // transaction table
489483

490-
491484
bool is_new;
492485
/*log area as hash table*/
493486
uint64_t n_buckets; //# of buckets
494487
TOID_ARRAY(TOID(PMEM_PAGE_LOG_HASHED_LINE)) buckets;
495488

496489
uint64_t n_blocks_per_bucket; //# load_factor, of log block per bucket
497490

491+
498492
/*
499493
* DRAM objects, alloc every time the server start
500494
* */
@@ -683,6 +677,13 @@ pm_log_redoer_close(PMEM_LOG_REDOER* redoer);
683677

684678
/*Transaction Table Entry*/
685679

680+
// Dirty Page Entry Ref in the log block
681+
struct __pmem_page_ref {
682+
uint64_t key; //fold of page_id_t.fold() in InnoDB
683+
int64_t idx; // index of the entry in DPT
684+
uint64_t pageLSN; //latest LSN on this page caused by the host transction, this value used in reclaiming logs
685+
};
686+
686687
struct __pmem_tt_entry {
687688
PMEMrwlock lock;
688689
uint64_t eid; //block id
@@ -692,6 +693,7 @@ struct __pmem_tt_entry {
692693
/*dirty page array consists of (key, bid) pair of dirty pages caused by this transaction*/
693694
TOID_ARRAY(TOID(PMEM_PAGE_REF)) dp_arr;
694695
uint64_t n_dp_entries;
696+
uint64_t max_dp_entries; //this value may differ to n_pref_per_entry in PMEM_TT due to the realloc mechanism
695697
};
696698

697699
struct __pmem_tt_hashed_line {
@@ -704,9 +706,11 @@ struct __pmem_tt_hashed_line {
704706
};
705707

706708
struct __pmem_tt {
709+
TOID_ARRAY(TOID(PMEM_TT_HASHED_LINE)) buckets;
707710
uint64_t n_buckets;
711+
708712
uint64_t n_entries_per_bucket;
709-
TOID_ARRAY(TOID(PMEM_TT_HASHED_LINE)) buckets;
713+
uint64_t n_pref_per_entry;
710714
};
711715

712716
struct __pmem_log_group {
@@ -1210,7 +1214,17 @@ __update_page_log_block_on_commit(
12101214
PMEM_PAGE_REF* pref,
12111215
int64_t eid);
12121216
void
1213-
__reset_TT_entry(PMEM_TT_ENTRY* pe);
1217+
__reset_TT_entry(
1218+
PMEMobjpool* pop,
1219+
PMEM_PAGE_PART_LOG* ppl,
1220+
PMEM_TT_ENTRY* pe);
1221+
void
1222+
__realloc_TT_entry(
1223+
PMEMobjpool* pop,
1224+
PMEM_PAGE_PART_LOG* ppl,
1225+
PMEM_TT_ENTRY* pe,
1226+
uint64_t new_size);
1227+
12141228
void
12151229
__reset_page_log_block(PMEM_PAGE_LOG_BLOCK* plog_block);
12161230

storage/innobase/include/row0purge.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ struct purge_node_t{
115115
clustered index record */
116116
ibool done; /* Debug flag */
117117
trx_id_t trx_id; /*!< trx id for this purging record */
118+
#if defined (UNIV_PMEMOBJ_PART_PL)
119+
trx_t* trx; /*pointer to transaction*/
120+
#endif
118121

119122
#ifdef UNIV_DEBUG
120123
/***********************************************************//**

storage/innobase/mtr/mtr0mtr.cc

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,7 @@ struct ReleaseBlocks {
348348
void add_dirty_page_to_flush_list(mtr_memo_slot_t* slot) const
349349
{
350350
ut_ad(m_end_lsn > 0);
351-
#if defined (UNIV_PMEMOBJ_PL)
352-
ut_ad(m_start_lsn >= 0);
353-
#else //original
354351
ut_ad(m_start_lsn > 0);
355-
#endif
356352

357353
buf_block_t* block;
358354

@@ -599,6 +595,7 @@ mtr_t::start(bool sync, bool read_only)
599595
m_impl.m_flush_observer = NULL;
600596
#if defined (UNIV_PMEMOBJ_PL)
601597
m_impl.m_parent_trx = NULL;
598+
m_impl.m_trx_id = 0;
602599
m_impl.key_arr = (uint64_t*) calloc(512, sizeof(uint64_t));
603600
m_impl.LSN_arr = (uint64_t*) calloc(512, sizeof(uint64_t));
604601
m_impl.space_arr = (uint64_t*) calloc(512, sizeof(uint64_t));
@@ -1054,6 +1051,8 @@ mtr_t::Command::execute()
10541051

10551052
trx_t* trx;
10561053

1054+
const mtr_buf_t::block_t* front = m_impl->m_log.front();
1055+
byte* start_log_ptr = (byte*) front->begin();
10571056

10581057
len = m_impl->m_log.size();
10591058
n_recs = m_impl->m_n_log_recs;
@@ -1067,37 +1066,24 @@ mtr_t::Command::execute()
10671066
}
10681067

10691068
//tdnguyen test
1069+
mlog_id_t type;
1070+
byte* ptr;
1071+
ptr = start_log_ptr;
1072+
type = (mlog_id_t)((ulint)*ptr & ~MLOG_SINGLE_REC_FLAG);
10701073

10711074
if (trx == NULL){
10721075
if (len > 0){
1073-
ulint i;
1074-
mlog_id_t type;
1075-
ulint space;
1076-
ulint page_no;
1077-
ulint rec_size;
1078-
byte* ptr;
1079-
const mtr_buf_t::block_t* front = m_impl->m_log.front();
1080-
byte* start_log_ptr = (byte*) front->begin();
1081-
ptr = start_log_ptr;
1082-
type = (mlog_id_t)((ulint)*ptr & ~MLOG_SINGLE_REC_FLAG);
1083-
printf("mtr::exec trx is NULL while len > 0 n_recs %zu type %zu \n", n_recs, type);
1084-
1085-
//for (i = 0; i < n_recs; i++){
1086-
// if (i == n_recs - 1){
1087-
// rec_size = len - m_impl->size_arr[i];
1088-
// }
1089-
// else{
1090-
// rec_size = m_impl->size_arr[i+1] - m_impl->size_arr[i];
1091-
// }
1092-
1093-
// //mlog_parse_initial_log_record(ptr, ptr + rec_size, &type, &space, &page_no);
1094-
// printf("mtr::exec trx is NULL while len > 0 n_recs %zu rec %zu type %zu space %zu page %zu \n", n_recs, i, type, space, page_no);
1076+
//check what we miss from capture log
1077+
if (type > 8){
1078+
printf("mtr::exec trx is NULL while len > 0 n_recs %zu type %zu \n", n_recs, type);
1079+
}
1080+
}
1081+
}
1082+
else{
1083+
//test trx_id == 0
1084+
if (trx->id == 0 && len > 0){
1085+
printf("mtr::exec trx->id is ZERO while trx_id is %zu len > 0 n_recs %zu type %zu \n", m_impl->m_trx_id, n_recs, type);
10951086

1096-
// //if (n_recs > 1){
1097-
// // printf("==> TEST in mtr::execute() multi-rec rec %zu type %zu space %zu page %zu trx_id %zu\n", i, type, space, page_no, trx->id);
1098-
// //}
1099-
// ptr += rec_size;
1100-
//}
11011087
}
11021088
}
11031089
//end tdnguyen test
@@ -1186,8 +1172,8 @@ mtr_t::Command::execute()
11861172
if (len > 0){
11871173
if (trx != NULL){
11881174
// PART_PL WRITE LOG
1189-
const mtr_buf_t::block_t* front = m_impl->m_log.front();
1190-
byte* start_log_ptr = (byte*) front->begin();
1175+
//const mtr_buf_t::block_t* front = m_impl->m_log.front();
1176+
//byte* start_log_ptr = (byte*) front->begin();
11911177
////tdnguyen test
11921178
//ulint i;
11931179
//mlog_id_t type;
@@ -1207,6 +1193,8 @@ mtr_t::Command::execute()
12071193
// ptr += rec_size;
12081194
//}
12091195
////end tdnguyen test
1196+
1197+
//fix node->trx->id == 0 even though node->trx_id != 0 in row_purge()
12101198
trx->pm_log_block_id = pm_ppl_write(
12111199
gb_pmw->pop,
12121200
gb_pmw->ppl,

0 commit comments

Comments
 (0)