mirror of
https://github.com/postgres/postgres.git
synced 2026-06-10 17:20:31 -04:00
Add missing initialization
The backend running REPACK can check DecodingWorkerShared->initialized
before the worker could have the chance to initialize it, possibly
leading to wrong behavior.
While at it, remove DecodingWorkerShared->worker_dsm_segment, because
that doesn't actually need to be in shared memory; a simple local-memory
global variable is enough.
Oversights in commit 28d534e2ae.
Author: Antonin Houska <ah@cybertec.at>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/18181295-8375-4789-ad32-269d78d6001e@gmail.com
This commit is contained in:
parent
191a037d4f
commit
05c401d578
3 changed files with 6 additions and 3 deletions
|
|
@ -3311,6 +3311,7 @@ start_repack_decoding_worker(Oid relid)
|
|||
BUFFERALIGN(REPACK_ERROR_QUEUE_SIZE);
|
||||
seg = dsm_create(size, 0);
|
||||
shared = (DecodingWorkerShared *) dsm_segment_address(seg);
|
||||
shared->initialized = false;
|
||||
shared->lsn_upto = InvalidXLogRecPtr;
|
||||
shared->done = false;
|
||||
SharedFileSetInit(&shared->sfs, seg);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ static bool am_repack_worker = false;
|
|||
/* The WAL segment being decoded. */
|
||||
static XLogSegNo repack_current_segment = 0;
|
||||
|
||||
/* Our DSM segment, for shutting down */
|
||||
static dsm_segment *worker_dsm_segment = NULL;
|
||||
|
||||
/*
|
||||
* Keep track of the table we're processing, to skip logical decoding of data
|
||||
* from other relations.
|
||||
|
|
@ -78,9 +81,9 @@ RepackWorkerMain(Datum main_arg)
|
|||
ereport(ERROR,
|
||||
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("could not map dynamic shared memory segment"));
|
||||
worker_dsm_segment = seg;
|
||||
|
||||
shared = (DecodingWorkerShared *) dsm_segment_address(seg);
|
||||
shared->dsm_seg = seg;
|
||||
|
||||
/* Arrange to signal the leader if we exit. */
|
||||
before_shmem_exit(RepackWorkerShutdown, PointerGetDatum(shared));
|
||||
|
|
@ -176,7 +179,7 @@ RepackWorkerShutdown(int code, Datum arg)
|
|||
PROCSIG_REPACK_MESSAGE,
|
||||
shared->backend_proc_number);
|
||||
|
||||
dsm_detach(shared->dsm_seg);
|
||||
dsm_detach(worker_dsm_segment);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ typedef struct DecodingWorkerShared
|
|||
PGPROC *backend_proc;
|
||||
pid_t backend_pid;
|
||||
ProcNumber backend_proc_number;
|
||||
dsm_segment *dsm_seg;
|
||||
|
||||
/*
|
||||
* Memory the queue is located in.
|
||||
|
|
|
|||
Loading…
Reference in a new issue