This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new eb0a42c6024 Fix die_commit_pending_replication.sql
eb0a42c6024 is described below
commit eb0a42c6024eaa964010fed912ee8d1e13a375d2
Author: Jinbao Chen <[email protected]>
AuthorDate: Sat Feb 21 15:27:51 2026 +0800
Fix die_commit_pending_replication.sql
---
src/backend/replication/gp_replication.c | 7 ++--
src/backend/replication/syncrep.c | 54 ++++++++++++++++++++++-------
src/backend/utils/misc/guc.c | 23 ------------
src/include/replication/walsender_private.h | 7 ----
4 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/src/backend/replication/gp_replication.c
b/src/backend/replication/gp_replication.c
index 9ae6444ce45..77e9fa6248a 100644
--- a/src/backend/replication/gp_replication.c
+++ b/src/backend/replication/gp_replication.c
@@ -582,7 +582,7 @@ GetMirrorStatus(FtsResponse *response, bool
*ready_for_syncrep)
break;
}
- response->IsSyncRepEnabled = WalSndCtl->sync_standbys_defined;
+ response->IsSyncRepEnabled = WalSndCtl->sync_standbys_status &
SYNC_STANDBY_DEFINED;
LWLockRelease(SyncRepLock);
@@ -598,7 +598,8 @@ GetMirrorStatus(FtsResponse *response, bool
*ready_for_syncrep)
void
SetSyncStandbysDefined(void)
{
- if (!WalSndCtl->sync_standbys_defined)
+ if (((((volatile WalSndCtlData *) WalSndCtl)->sync_standbys_status) &
+ (SYNC_STANDBY_INIT | SYNC_STANDBY_DEFINED)) ==
SYNC_STANDBY_INIT)
{
set_gp_replication_config("synchronous_standby_names", "*");
@@ -611,7 +612,7 @@ SetSyncStandbysDefined(void)
void
UnsetSyncStandbysDefined(void)
{
- if (WalSndCtl->sync_standbys_defined)
+ if (WalSndCtl->sync_standbys_status & SYNC_STANDBY_DEFINED)
{
set_gp_replication_config("synchronous_standby_names", "");
diff --git a/src/backend/replication/syncrep.c
b/src/backend/replication/syncrep.c
index be0e16dcea2..8f705fa6a3a 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -222,7 +222,8 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
* don't touch the queue.
*/
if (!SyncRepRequested() ||
- (!IS_QUERY_DISPATCHER() && !((volatile WalSndCtlData *)
WalSndCtl)->sync_standbys_defined))
+ (!IS_QUERY_DISPATCHER() && ((((volatile WalSndCtlData *)
WalSndCtl)->sync_standbys_status) &
+
(SYNC_STANDBY_INIT | SYNC_STANDBY_DEFINED)) == SYNC_STANDBY_INIT))
return;
/* Cap the level for anything other than commit to remote flush only. */
@@ -335,19 +336,46 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
* (SYNC_STANDBY_INIT is not set), fall back to a check based on the
LSN,
* then do a direct GUC check.
*/
- if (((!IS_QUERY_DISPATCHER()) && !WalSndCtl->sync_standbys_defined) ||
- lsn <= WalSndCtl->lsn[mode])
+ if (!IS_QUERY_DISPATCHER())
{
- elogif(debug_walrepl_syncrep, LOG,
- "syncrep wait -- Not waiting for syncrep
because xlog up to LSN (%X/%X) which is "
- "greater than this backend's commit LSN (%X/%X)
has already "
- "been replicated.",
- (uint32) (WalSndCtl->lsn[mode] >> 32), (uint32)
WalSndCtl->lsn[mode],
- (uint32) (lsn >> 32), (uint32) lsn);
-
-
- LWLockRelease(SyncRepLock);
- return;
+ if (WalSndCtl->sync_standbys_status & SYNC_STANDBY_INIT)
+ {
+ if ((WalSndCtl->sync_standbys_status &
SYNC_STANDBY_DEFINED) == 0 ||
+ lsn <= WalSndCtl->lsn[mode])
+ {
+ LWLockRelease(SyncRepLock);
+ return;
+ }
+ }
+ else if (lsn <= WalSndCtl->lsn[mode])
+ {
+ /*
+ * The LSN is older than what we need to wait for. The
sync standby
+ * data has not been initialized yet, but we are OK to
not wait
+ * because we know that there is no point in doing so
based on the
+ * LSN.
+ */
+ LWLockRelease(SyncRepLock);
+ return;
+ }
+ else if (!SyncStandbysDefined())
+ {
+ /*
+ * If we are here, the sync standby data has not been
initialized yet,
+ * and the LSN is newer than what need to wait for, so
we have fallen
+ * back to the best thing we could do in this case: a
check on
+ * SyncStandbysDefined() to see if the GUC is set or
not.
+ *
+ * When the GUC has a value, we wait until the
checkpointer updates
+ * the status data because we cannot be sure yet if we
should wait or
+ * not. Here, the GUC has *no* value, we are sure that
there is no
+ * point to wait; this matters for example when
initializing a
+ * cluster, where we should never wait, and no sync
standbys is the
+ * default behavior.
+ */
+ LWLockRelease(SyncRepLock);
+ return;
+ }
}
/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 84d4d7210e2..ea90748970f 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -4748,29 +4748,6 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
break;
}
- /*
- * Check permission to run ALTER SYSTEM on the target variable
- */
- if (!superuser())
- {
- if (resetall)
- ereport(ERROR,
-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to perform
ALTER SYSTEM RESET ALL")));
- else
- {
- AclResult aclresult;
-
- aclresult = pg_parameter_aclcheck(name, GetUserId(),
-
ACL_ALTER_SYSTEM);
- if (aclresult != ACLCHECK_OK)
- ereport(ERROR,
-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to
set parameter \"%s\"",
- name)));
- }
- }
-
/*
* Unless it's RESET_ALL, validate the target variable and value
*/
diff --git a/src/include/replication/walsender_private.h
b/src/include/replication/walsender_private.h
index 78140f4f7d0..a6b6493db40 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -138,13 +138,6 @@ typedef struct
*/
XLogRecPtr lsn[NUM_SYNC_REP_WAIT_MODE];
- /*
- * Are any sync standbys defined? Waiting backends can't reload the
- * config file safely, so checkpointer updates this value as needed.
- * Protected by SyncRepLock.
- */
- bool sync_standbys_defined;
-
/*
* Status of data related to the synchronous standbys. Waiting backends
* can't reload the config file safely, so checkpointer updates this
value
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]