Skip to content

Commit e434f4d

Browse files
committed
resolve allocation issue
1 parent ae3911e commit e434f4d

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

storage/innobase/include/ut0new.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ class ut_allocator {
689689
deallocate_trace(pfx);
690690
#endif /* UNIV_PFS_MEMORY */
691691

692-
fprintf(stderr, "[JONGQ] deallocation free! ptr: %p size: %lu\n",ptr, pfx->m_size);
692+
// fprintf(stderr, "[JONGQ] deallocation free! ptr: %p size: %lu\n",ptr, pfx->m_size);
693693
mmap_buf_sys->cur_offset -= pfx->m_size;
694694
//os_mem_free_large(ptr, pfx->m_size);
695695
}

storage/innobase/pmem/pmem0mmap.cc

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ int pm_mmap_mtrlogbuf_init(const size_t size) {
131131
mmap_mtrlogbuf->size = size;
132132
mmap_mtrlogbuf->cur_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
133133
mmap_mtrlogbuf->prev_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
134-
//mmap_mtrlogbuf->mtr_sys_lsn = 0;
135134
mmap_mtrlogbuf->ckpt_offset = PMEM_MMAP_MTR_FIL_HDR_SIZE;
136135
PMEMMMAP_INFO_PRINT("MTR LOG BUFFER structure initialization finished!\n");
137136
return 0;
@@ -174,50 +173,57 @@ void pm_mmap_write_logfile_header_ckpt_info(uint64_t offset, uint64_t lsn) {
174173
// (eager) checkpoint mtr log return ckpt_offset
175174
void pm_mmap_log_commit(ulint cur_space, ulint cur_page, ulint cur_offset) {
176175

177-
PMEM_MMAP_MTRLOG_HDR tmp_mmap_hdr;
178176
size_t offset = mmap_mtrlogbuf->ckpt_offset;
179177
bool ckpt_flag = true;
180178

181179
while (true) {
180+
182181
if (offset >= cur_offset) {
183182
break;
184183
}
185184

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);
191189

192190
// (jhpark): At this point, call checkpoint and then call commit
193191
// 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);
195195
break;
196-
}
197-
198-
if (tmp_mmap_hdr.need_recv == false) {
196+
}
197+
198+
if(tmp_mmap_hdr->need_recv == false) {
199199
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;
201201
continue;
202202
}
203203

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+
206207
// 1. unset recovery flag
207208
bool val = false;
208209
memcpy(gb_pm_mmap + offset, &val, (size_t)offsetof(PMEM_MMAP_MTRLOG_HDR, len));
209210
// 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+
211213
if (ckpt_flag) {
212214
mmap_mtrlogbuf->ckpt_offset = offset;
213215
}
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);
216218
} 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;
219223
ckpt_flag = false;
220224
}
225+
// free tmp_mmap_hdr
226+
free(tmp_mmap_hdr);
221227
}
222228
}
223229

@@ -324,7 +330,6 @@ ssize_t pm_mmap_mtrlogbuf_write(
324330
ulint page_off = mach_read_from_2(ptr);
325331
ptr += 2;
326332
ulint state = mach_parse_compressed(&ptr, end_ptr);
327-
//fprintf(stderr, "mtr page_offset: %lu state : %lu\n", page_off, state);
328333

329334
// At this point, we can remove mtr log for this undo page
330335
if (state >= TRX_UNDO_CACHED) {
@@ -336,7 +341,6 @@ ssize_t pm_mmap_mtrlogbuf_write(
336341
pm_mmap_log_commit(cur_space, cur_page, offset+n);
337342
}
338343
} else {
339-
340344
//fprintf(stderr, "[mtr-write] not commit cur_space: %lu cur_page: %lu cur_offset: %lu\n"
341345
// ,cur_space, cur_page, org_offset);
342346
}

storage/innobase/srv/srv0start.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,8 +1505,7 @@ innobase_start_or_create_for_mysql(void)
15051505
// for debugging : chagne the mtr log region size
15061506
// original : 1024*1024*1024*8UL (8GB)
15071507
// debugging : 1024*1024*1UL (512MB)
1508-
pm_mmap_mtrlogbuf_init(1024*1024*1UL);
1509-
1508+
pm_mmap_mtrlogbuf_init(1024*1024*1024*1UL);
15101509
// buffer retion initialization (2GB)
15111510
pm_mmap_buf_init(1024*1024*1024*2UL);
15121511

0 commit comments

Comments
 (0)