Fix memset_s failed when shared_buffer size execced 409GB.
This commit is contained in:
@ -27,6 +27,23 @@
|
|||||||
|
|
||||||
const int PAGE_QUEUE_SLOT_MULTI_NBUFFERS = 5;
|
const int PAGE_QUEUE_SLOT_MULTI_NBUFFERS = 5;
|
||||||
|
|
||||||
|
static inline void MemsetLongBuffer(char *buffer, Size len)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
while (len > 0) {
|
||||||
|
if (len < SECUREC_MEM_MAX_LEN) {
|
||||||
|
rc = memset_s(buffer, len, 0, len);
|
||||||
|
securec_check(rc, "", "");
|
||||||
|
len = 0;
|
||||||
|
} else {
|
||||||
|
rc = memset_s(buffer, SECUREC_MEM_MAX_LEN, 0, SECUREC_MEM_MAX_LEN);
|
||||||
|
securec_check(rc, "", "");
|
||||||
|
len -= SECUREC_MEM_MAX_LEN;
|
||||||
|
buffer += SECUREC_MEM_MAX_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data Structures:
|
* Data Structures:
|
||||||
* buffers live in a freelist and a lookup data structure.
|
* buffers live in a freelist and a lookup data structure.
|
||||||
@ -95,7 +112,6 @@ void InitBufferPool(void)
|
|||||||
"Checkpoint BufferIds", g_instance.attr.attr_storage.NBuffers * sizeof(CkptSortItem), &found_buf_ckpt);
|
"Checkpoint BufferIds", g_instance.attr.attr_storage.NBuffers * sizeof(CkptSortItem), &found_buf_ckpt);
|
||||||
|
|
||||||
if (g_instance.attr.attr_storage.enableIncrementalCheckpoint && g_instance.ckpt_cxt_ctl->dirty_page_queue == NULL) {
|
if (g_instance.attr.attr_storage.enableIncrementalCheckpoint && g_instance.ckpt_cxt_ctl->dirty_page_queue == NULL) {
|
||||||
errno_t rc;
|
|
||||||
g_instance.ckpt_cxt_ctl->dirty_page_queue_size =
|
g_instance.ckpt_cxt_ctl->dirty_page_queue_size =
|
||||||
g_instance.attr.attr_storage.NBuffers * PAGE_QUEUE_SLOT_MULTI_NBUFFERS;
|
g_instance.attr.attr_storage.NBuffers * PAGE_QUEUE_SLOT_MULTI_NBUFFERS;
|
||||||
MemoryContext oldcontext = MemoryContextSwitchTo(g_instance.increCheckPoint_context);
|
MemoryContext oldcontext = MemoryContextSwitchTo(g_instance.increCheckPoint_context);
|
||||||
@ -106,9 +122,7 @@ void InitBufferPool(void)
|
|||||||
ereport(ERROR, (errmodule(MOD_INCRE_CKPT), errmsg("Memory allocation failed.\n")));
|
ereport(ERROR, (errmodule(MOD_INCRE_CKPT), errmsg("Memory allocation failed.\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = memset_s(g_instance.ckpt_cxt_ctl->dirty_page_queue, queue_mem_size, 0, queue_mem_size);
|
MemsetLongBuffer((char*)g_instance.ckpt_cxt_ctl->dirty_page_queue, queue_mem_size);
|
||||||
securec_check(rc, "", "");
|
|
||||||
|
|
||||||
(void)MemoryContextSwitchTo(oldcontext);
|
(void)MemoryContextSwitchTo(oldcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user