@@ -131,7 +131,6 @@ int pm_mmap_mtrlogbuf_init(const size_t size) {
131
131
mmap_mtrlogbuf->size = size;
132
132
mmap_mtrlogbuf->cur_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
133
133
mmap_mtrlogbuf->prev_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
134
- // mmap_mtrlogbuf->mtr_sys_lsn = 0;
135
134
mmap_mtrlogbuf->ckpt_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
136
135
PMEMMMAP_INFO_PRINT (" MTR LOG BUFFER structure initialization finished!\n " );
137
136
return 0 ;
@@ -174,50 +173,57 @@ void pm_mmap_write_logfile_header_ckpt_info(uint64_t offset, uint64_t lsn) {
174
173
// (eager) checkpoint mtr log return ckpt_offset
175
174
void pm_mmap_log_commit (ulint cur_space, ulint cur_page, ulint cur_offset) {
176
175
177
- PMEM_MMAP_MTRLOG_HDR tmp_mmap_hdr;
178
176
size_t offset = mmap_mtrlogbuf->ckpt_offset ;
179
177
bool ckpt_flag = true ;
180
178
181
179
while (true ) {
180
+
182
181
if (offset >= cur_offset) {
183
182
break ;
184
183
}
185
184
186
- memset (&tmp_mmap_hdr, 0 , sizeof (PMEM_MMAP_MTRLOG_HDR));
187
- memcpy (&tmp_mmap_hdr, gb_pm_mmap + offset, PMEM_MMAP_MTRLOG_HDR_SIZE);
188
- ut_ad (tmp_mmap_hdr == NULL );
189
- // fprintf(stderr, "[mtr-commit] offset: %lu len: %lu cur_offset: %lu cur_space: %lu cur_page: %lu\n",
190
- // offset, tmp_mmap_hdr.len, cur_offset, cur_space, cur_page);
185
+ PMEM_MMAP_MTRLOG_HDR *tmp_mmap_hdr = (PMEM_MMAP_MTRLOG_HDR *) malloc (PMEM_MMAP_MTRLOG_HDR_SIZE);
186
+ memset (tmp_mmap_hdr, 0 , sizeof (PMEM_MMAP_MTRLOG_HDR));
187
+ memcpy (tmp_mmap_hdr, gb_pm_mmap + offset, PMEM_MMAP_MTRLOG_HDR_SIZE);
188
+ ut_ad (tmp_mmap_hdr == NULL );
191
189
192
190
// (jhpark): At this point, call checkpoint and then call commit
193
191
// no need to commit
194
- if (tmp_mmap_hdr.len == 0 ) {
192
+ if (tmp_mmap_hdr->len == 0 ) {
193
+ // fprintf(stderr, "[mtr-commit] no need to commit!!! offset: %lu len: %lu cur_offset: %lu cur_space: %lu cur_page: %lu\n",
194
+ // offset, tmp_mmap_hdr->len, cur_offset, cur_space, cur_page);
195
195
break ;
196
- }
197
-
198
- if (tmp_mmap_hdr. need_recv == false ) {
196
+ }
197
+
198
+ if (tmp_mmap_hdr-> need_recv == false ) {
199
199
mmap_mtrlogbuf->ckpt_offset = offset;
200
- offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr. len ;
200
+ offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr-> len ;
201
201
continue ;
202
202
}
203
203
204
- if (cur_space == tmp_mmap_hdr.space &&
205
- cur_page == tmp_mmap_hdr.page_no ) {
204
+ if (cur_space == tmp_mmap_hdr->space &&
205
+ cur_page == tmp_mmap_hdr->page_no ) {
206
+
206
207
// 1. unset recovery flag
207
208
bool val = false ;
208
209
memcpy (gb_pm_mmap + offset, &val, (size_t )offsetof (PMEM_MMAP_MTRLOG_HDR, len));
209
210
// 2. keep ckpt_offset (continuous)
210
- offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr.len ;
211
+ offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr->len ;
212
+
211
213
if (ckpt_flag) {
212
214
mmap_mtrlogbuf->ckpt_offset = offset;
213
215
}
214
- // fprintf(stderr, "[mtr-commit] YES ckpt_offset: %lu space: %lu page_no: %lu\n"
215
- // ,mmap_mtrlogbuf->ckpt_offset,tmp_mmap_hdr. space, tmp_mmap_hdr. page_no);
216
+ // fprintf(stderr, "[mtr-commit] YES ckpt_offset: %lu space: %lu page_no: %lu\n"
217
+ // ,mmap_mtrlogbuf->ckpt_offset,tmp_mmap_hdr-> space, tmp_mmap_hdr-> page_no);
216
218
} else {
217
- // fprintf(stderr, "[mtr-commit] NO space: %lu page_no: %lu\n",tmp_mmap_hdr.space, tmp_mmap_hdr.page_no);
218
- offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr.len ;
219
+ // fprintf(stderr, "[mtr-commit] NO space: %lu page_no: %lu\n"
220
+ // ,tmp_mmap_hdr->space, tmp_mmap_hdr->page_no);
221
+
222
+ offset += PMEM_MMAP_MTRLOG_HDR_SIZE + tmp_mmap_hdr->len ;
219
223
ckpt_flag = false ;
220
224
}
225
+ // free tmp_mmap_hdr
226
+ free (tmp_mmap_hdr);
221
227
}
222
228
}
223
229
@@ -324,7 +330,6 @@ ssize_t pm_mmap_mtrlogbuf_write(
324
330
ulint page_off = mach_read_from_2 (ptr);
325
331
ptr += 2 ;
326
332
ulint state = mach_parse_compressed (&ptr, end_ptr);
327
- // fprintf(stderr, "mtr page_offset: %lu state : %lu\n", page_off, state);
328
333
329
334
// At this point, we can remove mtr log for this undo page
330
335
if (state >= TRX_UNDO_CACHED) {
@@ -336,7 +341,6 @@ ssize_t pm_mmap_mtrlogbuf_write(
336
341
pm_mmap_log_commit (cur_space, cur_page, offset+n);
337
342
}
338
343
} else {
339
-
340
344
// fprintf(stderr, "[mtr-write] not commit cur_space: %lu cur_page: %lu cur_offset: %lu\n"
341
345
// ,cur_space, cur_page, org_offset);
342
346
}
0 commit comments