This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new c680b293a72 Wait more time for writer gang
c680b293a72 is described below

commit c680b293a720acc75232f0b364ae71bd4c7001eb
Author: kongfanhsen <[email protected]>
AuthorDate: Mon Sep 29 15:36:56 2025 +0800

    Wait more time for writer gang
    
    The mechanism of fork gang adopts the asynchronous mode,
    Search for writer proc entry and retry only 5 times.
    Waiting for a total of 5 * 2=10 milliseconds,
    the writer process may not have started.
    Add the guc parameter find_writer_proc_retry_time to control
    the number of retries. When the fork gang takes a long time,
    you can increase the parameters.
---
 src/backend/storage/lmgr/lock.c   |  4 +++-
 src/backend/utils/misc/guc.c      | 10 ++++++++++
 src/include/storage/lock.h        |  1 +
 src/include/utils/sync_guc_name.h |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 016ad29072c..cbc873e0b70 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -330,6 +330,8 @@ static LOCALLOCK *StrongLockInProgress;
 LOCALLOCK *awaitedLock;
 ResourceOwner awaitedOwner;
 
+/* find writer proc entry retry time */
+int    find_writer_proc_retry_time = 5;
 
 #ifdef LOCK_DEBUG
 
@@ -938,7 +940,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
                                /* Find the guy who should manage our locks */
                                volatile PGPROC * proc = 
FindProcByGpSessionId(gp_session_id);
                                int count = 0;
-                               while(proc==NULL && count < 5)
+                               while(proc==NULL && count < 
find_writer_proc_retry_time)
                                {
                                        pg_usleep( /* microseconds */ 2000);
                                        count++;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d8cdf027df5..fb09180ebe9 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2652,6 +2652,16 @@ static struct config_int ConfigureNamesInt[] =
                NULL, NULL, NULL
        },
 
+       {
+               {"find_writer_proc_retry_time", PGC_USERSET, DEVELOPER_OPTIONS,
+                       gettext_noop("Sets the retry time of find writer proc 
entry."),
+                       NULL
+               },
+               &find_writer_proc_retry_time,
+               5, 1, 5000,
+               NULL, NULL, NULL
+       },
+
 #ifdef LOCK_DEBUG
        {
                {"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 0c0284c9ed3..2c594cd68d8 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -35,6 +35,7 @@ typedef struct PROC_QUEUE
 
 /* GUC variables */
 extern int     max_locks_per_xact;
+extern int     find_writer_proc_retry_time;
 
 #ifdef LOCK_DEBUG
 extern int     Trace_lock_oidmin;
diff --git a/src/include/utils/sync_guc_name.h 
b/src/include/utils/sync_guc_name.h
index 7a867660754..ca9f7ef45f8 100644
--- a/src/include/utils/sync_guc_name.h
+++ b/src/include/utils/sync_guc_name.h
@@ -199,3 +199,4 @@
                "wal_sender_timeout",
                "work_mem",
                "zero_damaged_pages",
+               "find_writer_proc_retry_time",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to