Skip to content

Commit c680b29

Browse files
kongfanhsenmy-ship-it
authored andcommitted
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.
1 parent 5ad83d3 commit c680b29

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/backend/storage/lmgr/lock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ static LOCALLOCK *StrongLockInProgress;
330330
LOCALLOCK *awaitedLock;
331331
ResourceOwner awaitedOwner;
332332

333+
/* find writer proc entry retry time */
334+
int find_writer_proc_retry_time = 5;
333335

334336
#ifdef LOCK_DEBUG
335337

@@ -938,7 +940,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
938940
/* Find the guy who should manage our locks */
939941
volatile PGPROC * proc = FindProcByGpSessionId(gp_session_id);
940942
int count = 0;
941-
while(proc==NULL && count < 5)
943+
while(proc==NULL && count < find_writer_proc_retry_time)
942944
{
943945
pg_usleep( /* microseconds */ 2000);
944946
count++;

src/backend/utils/misc/guc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,6 +2652,16 @@ static struct config_int ConfigureNamesInt[] =
26522652
NULL, NULL, NULL
26532653
},
26542654

2655+
{
2656+
{"find_writer_proc_retry_time", PGC_USERSET, DEVELOPER_OPTIONS,
2657+
gettext_noop("Sets the retry time of find writer proc entry."),
2658+
NULL
2659+
},
2660+
&find_writer_proc_retry_time,
2661+
5, 1, 5000,
2662+
NULL, NULL, NULL
2663+
},
2664+
26552665
#ifdef LOCK_DEBUG
26562666
{
26572667
{"trace_lock_oidmin", PGC_SUSET, DEVELOPER_OPTIONS,

src/include/storage/lock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef struct PROC_QUEUE
3535

3636
/* GUC variables */
3737
extern int max_locks_per_xact;
38+
extern int find_writer_proc_retry_time;
3839

3940
#ifdef LOCK_DEBUG
4041
extern int Trace_lock_oidmin;

src/include/utils/sync_guc_name.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,4 @@
199199
"wal_sender_timeout",
200200
"work_mem",
201201
"zero_damaged_pages",
202+
"find_writer_proc_retry_time",

0 commit comments

Comments
 (0)