From f56293fd29a738fe42604ef9eca2a183b196daac Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 17 Apr 2021 11:43:05 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fixddl=5Fpbe=E5=86=85=E5=AD=98=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E6=9C=AA=E7=BD=AE=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/heap.cpp | 3 +++ src/common/backend/utils/mmgr/portalmem.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/common/backend/catalog/heap.cpp b/src/common/backend/catalog/heap.cpp index 5abc1440d..c23c22265 100644 --- a/src/common/backend/catalog/heap.cpp +++ b/src/common/backend/catalog/heap.cpp @@ -4060,6 +4060,9 @@ Node* parseParamRef(ParseState* pstate, ParamRef* pref) pfree_ext(val); if (pref->number == params_info->numParams && u_sess->parser_cxt.ddl_pbe_context != NULL) { MemoryContextDelete(u_sess->parser_cxt.ddl_pbe_context); + if (((IS_PGXC_COORDINATOR || IS_PGXC_DATANODE) && IsConnFromCoord())) { + u_sess->parser_cxt.param_info = NULL; + } u_sess->parser_cxt.ddl_pbe_context = NULL; } } else { diff --git a/src/common/backend/utils/mmgr/portalmem.cpp b/src/common/backend/utils/mmgr/portalmem.cpp index 6c87e2023..18c0215b3 100644 --- a/src/common/backend/utils/mmgr/portalmem.cpp +++ b/src/common/backend/utils/mmgr/portalmem.cpp @@ -591,6 +591,11 @@ void PortalDrop(Portal portal, bool isTopCommit) MemoryContextDelete(portal->copyCxt); u_sess->parser_cxt.param_message = NULL; + + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) { + u_sess->parser_cxt.param_info = NULL; + } + /* release portal struct (it's in u_sess->portal_mem_cxt) */ pfree(portal); } From cffbc66df38e500512dae92fdbb9213e0d12a9c6 Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 17 Apr 2021 11:48:56 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96pg=5Frecvlogical=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_basebackup/pg_recvlogical.cpp | 7 +++---- src/bin/pg_basebackup/streamutil.cpp | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/bin/pg_basebackup/pg_recvlogical.cpp b/src/bin/pg_basebackup/pg_recvlogical.cpp index f6e53833b..6718e834e 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.cpp +++ b/src/bin/pg_basebackup/pg_recvlogical.cpp @@ -669,9 +669,9 @@ static int getOptions(const int argc, char* const* argv) break; case 'p': check_env_value_c(optarg); - if (atoi(optarg) <= 0) { + if (checkIsDigit(optarg) == 0) { fprintf(stderr, _("%s: invalid port number \"%s\"\n"), progname, optarg); - return 1; + exit(1); } dbport = pg_strdup(optarg); break; @@ -736,8 +736,7 @@ static int getOptions(const int argc, char* const* argv) fsync_interval = atoi(optarg) * 1000; if (fsync_interval < 0) { - fprintf(stderr, _("%s: invalid fsync interval \"%s\"\n"), progname, optarg); - return -1; + fsync_interval = 0; } break; case 'S': diff --git a/src/bin/pg_basebackup/streamutil.cpp b/src/bin/pg_basebackup/streamutil.cpp index 5a480e498..63e69f03e 100644 --- a/src/bin/pg_basebackup/streamutil.cpp +++ b/src/bin/pg_basebackup/streamutil.cpp @@ -22,6 +22,7 @@ #include "knl/knl_variable.h" #include "utils/timestamp.h" #include "streamutil.h" +#include "libpq/libpq-int.h" #include #include #include @@ -138,6 +139,17 @@ static void CalculateArgCount(int *argcount) return; } +static void CheckConnectionHost(PGconn* tmpconn) +{ + if (tmpconn == NULL || tmpconn->sock < 0) { + fprintf(stderr, "failed to connect %s:%s.\n", + (dbhost == NULL) ? "Unknown" : dbhost, + (dbport == NULL) ? "Unknown" : dbport); + PQfinish(tmpconn); + exit(1); + } +} + /* * Connect to the server. Returns a valid PGconn pointer if connected, * or NULL on non-permanent error. On permanent error, the function will @@ -212,10 +224,7 @@ PGconn* GetConnection(void) * If there is too little memory even to allocate the PGconn object * and PQconnectdbParams returns NULL, we call exit(1) directly. */ - if (tmpconn == NULL) { - fprintf(stderr, _("%s: could not connect to server\n"), progname); - exit(1); - } + CheckConnectionHost(tmpconn); if (PQstatus(tmpconn) == CONNECTION_BAD && PQconnectionNeedsPassword(tmpconn) && dbgetpassword != -1) { dbgetpassword = 1; /* ask for password next time */ From 71ee36edc80243e6e68c5d97ccd54d31f7b01915 Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 17 Apr 2021 11:49:20 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSystemCache=E6=B8=85?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/process/threadpool/knl_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gausskernel/process/threadpool/knl_session.cpp b/src/gausskernel/process/threadpool/knl_session.cpp index 958562eeb..582154027 100644 --- a/src/gausskernel/process/threadpool/knl_session.cpp +++ b/src/gausskernel/process/threadpool/knl_session.cpp @@ -1254,7 +1254,7 @@ static void alloc_context_from_top(knl_session_context* sess, MemoryContext top_ "SessionCacheMemoryContext", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + (1024 * 1024)); /* set max block size to 1MB */ sess->temp_mem_cxt = AllocSetContextCreate(top_mem_cxt, "SessionTempMemoryContext", ALLOCSET_DEFAULT_MINSIZE, From fc2d689d4a0bdee2042ffb8ddedd98b04f0a4a01 Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 17 Apr 2021 11:50:39 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpbe=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E6=9C=BAsmp=E4=BD=BF=E7=94=A8limit=E5=87=BA?= =?UTF-8?q?=E7=8E=B0hang=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/process/tcop/postgres.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gausskernel/process/tcop/postgres.cpp b/src/gausskernel/process/tcop/postgres.cpp index e0854e147..f14106f55 100644 --- a/src/gausskernel/process/tcop/postgres.cpp +++ b/src/gausskernel/process/tcop/postgres.cpp @@ -4849,14 +4849,6 @@ static void exec_execute_message(const char* portal_name, long max_rows) u_sess->xact_cxt.pbe_execute_complete = false; } -#ifndef ENABLE_MULTIPLE_NODES - if (u_sess->xact_cxt.pbe_execute_complete == true) { - /* Set sync point for waiting all stream threads complete. */ - StreamNodeGroup::syncQuit(STREAM_COMPLETE); - UnRegisterStreamSnapshots(); - } -#endif - if (ENABLE_WORKLOAD_CONTROL) { if (g_instance.wlm_cxt->dynamic_workload_inited) { if (t_thrd.wlm_cxt.parctl_state.simple == 0) From 4384f940ec090f69a3e22bb02f646e3f6c2ca4c2 Mon Sep 17 00:00:00 2001 From: wangxin Date: Sat, 17 Apr 2021 11:51:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E8=A7=A3=E7=A0=81=E7=9A=84=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=A7=BD=E6=97=B6=EF=BC=8C=E5=A4=87=E6=9C=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=81=9C=E6=AD=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/replication/slot.cpp | 4 ++-- src/include/replication/slot.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/storage/replication/slot.cpp b/src/gausskernel/storage/replication/slot.cpp index 0fbdfa661..133ff0f4f 100644 --- a/src/gausskernel/storage/replication/slot.cpp +++ b/src/gausskernel/storage/replication/slot.cpp @@ -386,7 +386,7 @@ void ReplicationSlotCreate(const char *name, ReplicationSlotPersistency persiste /* * Find a previously created slot and mark it as used by this backend. */ -void ReplicationSlotAcquire(const char *name, bool isDummyStandby, bool isDrop) +void ReplicationSlotAcquire(const char *name, bool isDummyStandby, bool allowDrop) { ReplicationSlot *slot = NULL; int i; @@ -421,7 +421,7 @@ void ReplicationSlotAcquire(const char *name, bool isDummyStandby, bool isDrop) if (active) { if ((slot->data.database != InvalidOid || isDummyStandby != slot->data.isDummyStandby) #ifndef ENABLE_MULTIPLE_NODES - && !isDrop + && !allowDrop #endif ) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), errmsg("replication slot \"%s\" is already active", name))); diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h index 567daae27..07f2cf3e8 100644 --- a/src/include/replication/slot.h +++ b/src/include/replication/slot.h @@ -207,7 +207,7 @@ extern void ReplicationSlotCreate(const char* name, ReplicationSlotPersistency p Oid databaseId, XLogRecPtr restart_lsn, char* extra_content = NULL, bool encrypted = false); extern void ReplicationSlotPersist(void); extern void ReplicationSlotDrop(const char* name, bool for_backup = false); -extern void ReplicationSlotAcquire(const char* name, bool isDummyStandby, bool isDrop = false); +extern void ReplicationSlotAcquire(const char* name, bool isDummyStandby, bool allowDrop = false); extern bool IsReplicationSlotActive(const char *name); bool ReplicationSlotFind(const char* name); extern void ReplicationSlotRelease(void);