From e8606ec86d4b108971060898effcf1a8ac3cc8f5 Mon Sep 17 00:00:00 2001 From: PengJiong Date: Thu, 17 Sep 2020 16:01:51 +0800 Subject: [PATCH 1/2] Fix complie warning. --- src/include/knl/knl_session.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/knl/knl_session.h b/src/include/knl/knl_session.h index 1e5e1ae45..64bf7528d 100644 --- a/src/include/knl/knl_session.h +++ b/src/include/knl/knl_session.h @@ -45,7 +45,6 @@ #include #include "c.h" -#include "access/heapam.h" #include "datatype/timestamp.h" #include "gs_thread.h" #include "knl/knl_guc.h" @@ -60,7 +59,6 @@ #include "storage/backendid.h" #include "storage/s_lock.h" #include "storage/shmem.h" -#include "storage/predicate.h" #include "postmaster/bgworker.h" #include "storage/dsm.h" #include "utils/palloc.h" @@ -2042,6 +2040,8 @@ typedef struct knl_u_ext_fdw_context { } knl_u_ext_fdw_context; /* Info need to pass from leader to worker */ +struct ParallelHeapScanDescData; +typedef uint64 XLogRecPtr; typedef struct ParallelInfoContext { Oid database_id; Oid authenticated_user_id; @@ -2060,7 +2060,7 @@ typedef struct ParallelInfoContext { char *param_space; Size param_len; int pscan_num; - ParallelHeapScanDesc *pscan; + ParallelHeapScanDescData **pscan; int usedComboCids; int sizeComboCids; HTAB *comboHash; From 79c7dca111e07143bdcc3cb2aeccaef73ead02c1 Mon Sep 17 00:00:00 2001 From: PengJiong Date: Thu, 17 Sep 2020 17:23:35 +0800 Subject: [PATCH 2/2] Fix shm_mq memcpy bug. --- .../process/postmaster/bgworker.cpp | 2 +- src/gausskernel/storage/ipc/shm_mq.cpp | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/gausskernel/process/postmaster/bgworker.cpp b/src/gausskernel/process/postmaster/bgworker.cpp index 898268537..93e20897a 100644 --- a/src/gausskernel/process/postmaster/bgworker.cpp +++ b/src/gausskernel/process/postmaster/bgworker.cpp @@ -1065,7 +1065,7 @@ BgwHandleStatus GetBackgroundWorkerPid(const BackgroundWorkerHandle *handle, Thr /* All done. */ LWLockRelease(BackgroundWorkerLock); - ereport(LOG, + ereport(DEBUG1, (errmsg("GetBackgroundWorkerPid slot: %d, pid: %lu", handle->slot, pid))); if (pid == 0) { diff --git a/src/gausskernel/storage/ipc/shm_mq.cpp b/src/gausskernel/storage/ipc/shm_mq.cpp index 9daa949d5..6ab4e5f55 100644 --- a/src/gausskernel/storage/ipc/shm_mq.cpp +++ b/src/gausskernel/storage/ipc/shm_mq.cpp @@ -670,22 +670,25 @@ shm_mq_result shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bo /* Copy as much as we can. */ Assert(mqh->mqh_partial_bytes + rb <= nbytes); - errno_t rc = memcpy_s(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rb, rawdata, rb); - securec_check(rc, "\0", "\0"); - mqh->mqh_partial_bytes += rb; + if (rb != 0) { + errno_t rc = memcpy_s(&mqh->mqh_buffer[mqh->mqh_partial_bytes], rb, rawdata, rb); + securec_check(rc, "\0", "\0"); + mqh->mqh_partial_bytes += rb; - /* - * Update count of bytes that can be consumed, accounting for - * alignment padding. Note that this will never actually insert any - * padding except at the end of a message, because the buffer size is - * a multiple of MAXIMUM_ALIGNOF, and each read and write is as well. - */ - Assert(mqh->mqh_partial_bytes == nbytes || rb == MAXALIGN(rb)); - mqh->mqh_consume_pending += MAXALIGN(rb); + /* + * Update count of bytes that can be consumed, accounting for + * alignment padding. Note that this will never actually insert any + * padding except at the end of a message, because the buffer size is + * a multiple of MAXIMUM_ALIGNOF, and each read and write is as well. + */ + Assert(mqh->mqh_partial_bytes == nbytes || rb == MAXALIGN(rb)); + mqh->mqh_consume_pending += MAXALIGN(rb); + } /* If we got all the data, exit the loop. */ - if (mqh->mqh_partial_bytes >= nbytes) + if (mqh->mqh_partial_bytes >= nbytes) { break; + } /* Wait for some more data. */ still_needed = nbytes - mqh->mqh_partial_bytes;