Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c13b68

Browse files
author
Amit Kapila
committed
Reset the logical worker type while cleaning up other worker info.
Commit2a8b40e introduces the worker type field for logical replicationworkers, but forgot to reset the type when the worker exits. This can leadto recognizing a stopped worker as a valid logical replication worker.Fix it by resetting the worker type and additionally adding the safeguardto not use LogicalRepWorker until ->in_use is verified.Reported-by: Thomas Munro based on cfbot reports.Author: Hou Zhijie, Alvaro HerreraReviewed-by: Amit KapilaDiscussion:http://postgr.es/m/CA+hUKGK2RQh4LifVgBmkHsCYChP-65UwGXOmnCzYVa5aAt4GWg@mail.gmail.com
1 parent252dcb3 commit9c13b68

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

‎src/backend/replication/logical/launcher.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ logicalrep_worker_cleanup(LogicalRepWorker *worker)
793793
{
794794
Assert(LWLockHeldByMeInMode(LogicalRepWorkerLock,LW_EXCLUSIVE));
795795

796+
worker->type=WORKERTYPE_UNKNOWN;
796797
worker->in_use= false;
797798
worker->proc=NULL;
798799
worker->dbid=InvalidOid;
@@ -862,7 +863,7 @@ logicalrep_sync_worker_count(Oid subid)
862863
{
863864
LogicalRepWorker*w=&LogicalRepCtx->workers[i];
864865

865-
if (w->subid==subid&&isTablesyncWorker(w))
866+
if (isTablesyncWorker(w)&&w->subid==subid)
866867
res++;
867868
}
868869

@@ -889,7 +890,7 @@ logicalrep_pa_worker_count(Oid subid)
889890
{
890891
LogicalRepWorker*w=&LogicalRepCtx->workers[i];
891892

892-
if (w->subid==subid&&isParallelApplyWorker(w))
893+
if (isParallelApplyWorker(w)&&w->subid==subid)
893894
res++;
894895
}
895896

‎src/include/replication/worker_internal.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,10 @@ extern void pa_decr_and_wait_stream_block(void);
327327
externvoidpa_xact_finish(ParallelApplyWorkerInfo*winfo,
328328
XLogRecPtrremote_lsn);
329329

330-
#defineisParallelApplyWorker(worker) ((worker)->type == WORKERTYPE_PARALLEL_APPLY)
331-
#defineisTablesyncWorker(worker) ((worker)->type == WORKERTYPE_TABLESYNC)
330+
#defineisParallelApplyWorker(worker) ((worker)->in_use && \
331+
(worker)->type == WORKERTYPE_PARALLEL_APPLY)
332+
#defineisTablesyncWorker(worker) ((worker)->in_use && \
333+
(worker)->type == WORKERTYPE_TABLESYNC)
332334

333335
staticinlinebool
334336
am_tablesync_worker(void)
@@ -339,12 +341,14 @@ am_tablesync_worker(void)
339341
staticinlinebool
340342
am_leader_apply_worker(void)
341343
{
344+
Assert(MyLogicalRepWorker->in_use);
342345
return (MyLogicalRepWorker->type==WORKERTYPE_APPLY);
343346
}
344347

345348
staticinlinebool
346349
am_parallel_apply_worker(void)
347350
{
351+
Assert(MyLogicalRepWorker->in_use);
348352
returnisParallelApplyWorker(MyLogicalRepWorker);
349353
}
350354

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp