agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Antonin Houska <ah@cybertec.at>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Cc: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Cc: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Robert Treat <rob@xzilla.net>
Subject: Re: Adding REPACK [concurrently]
Date: Mon, 13 Apr 2026 11:42:03 +0200
Message-ID: <182883.1776073323@localhost> (raw)
In-Reply-To: <18181295-8375-4789-ad32-269d78d6001e@gmail.com>
References: <202604072027.gazfa2zt2l2j@alvherre.pgsql>
<a38fc771-c860-4605-8c44-d16e8aff2534@gmail.com>
<121156.1775818667@localhost>
<18181295-8375-4789-ad32-269d78d6001e@gmail.com>
Alexander Lakhin <exclusion@gmail.com> wrote:
> I've stumbled upon one more issue with this feature:
> CREATE TABLE t (i int PRIMARY KEY);
> REPACK (CONCURRENTLY) t;
>
> fails for me with sanitizers enabled and
> min_dynamic_shared_memory = '1GB'
> in postgresql.conf as below:
> 2026-04-12 13:23:02.000 UTC [2733633] LOG: statement: REPACK (CONCURRENTLY) t;
> repack.c:3373:15: runtime error: load of value 240, which is not a valid value for type '_Bool'
> #0 0x6441f7eba454 in start_repack_decoding_worker .../src/backend/commands/repack.c:3373
> #1 0x6441f7ebdaad in rebuild_relation .../src/backend/commands/repack.c:1010
> #2 0x6441f7ebe9a2 in cluster_rel .../src/backend/commands/repack.c:656
> #3 0x6441f7ebefea in process_single_relation .../src/backend/commands/repack.c:2359
> #4 0x6441f7ebf870 in ExecRepack .../src/backend/commands/repack.c:296
> #5 0x6441f886f20e in standard_ProcessUtility .../src/backend/tcop/utility.c:867
I could not reproduce the problem, but noticed that the field is not
initialized correctly. Please confirm that 0001 should fix that.
While working on it, I noticed that one field can be removed from
DecodingWorkerShared - 0002 removes that.
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
Attachments:
[text/x-diff] 0001-Add-missing-initialization.patch (884B, ../182883.1776073323@localhost/2-0001-Add-missing-initialization.patch)
download | inline diff:
From c049bbe9b02e4adfbf6ebbea6eaabad900dc67a0 Mon Sep 17 00:00:00 2001
From: Antonin Houska <ah@cybertec.at>
Date: Mon, 13 Apr 2026 11:28:57 +0200
Subject: [PATCH 1/2] Add missing initialization.
Backend can check the variable before the worker could have the chance to
initialize it.
---
src/backend/commands/repack.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 58e3867246f..67364cc60e3 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -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);
--
2.47.3
[text/x-diff] 0002-Remove-dsm_seg-from-DecodingWorkerShared.patch (2.0K, ../182883.1776073323@localhost/3-0002-Remove-dsm_seg-from-DecodingWorkerShared.patch)
download | inline diff:
From 35711000d05bdbc2b1faf0e25938976d2b665555 Mon Sep 17 00:00:00 2001
From: Antonin Houska <ah@cybertec.at>
Date: Mon, 13 Apr 2026 11:36:41 +0200
Subject: [PATCH 2/2] Remove dsm_seg from DecodingWorkerShared.
The value is only needed by te worker, so there is no need to store it in
shared memory.
---
src/backend/commands/repack_worker.c | 5 +++--
src/include/commands/repack_internal.h | 1 -
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c
index 5bd020e0184..a594d6db25f 100644
--- a/src/backend/commands/repack_worker.c
+++ b/src/backend/commands/repack_worker.c
@@ -51,6 +51,7 @@ static XLogSegNo repack_current_segment = 0;
static RelFileLocator repacked_rel_locator = {.relNumber = InvalidOid};
static RelFileLocator repacked_rel_toast_locator = {.relNumber = InvalidOid};
+static dsm_segment *worker_dsm_segment = NULL;
/* REPACK decoding worker entry point */
void
@@ -78,9 +79,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 +177,7 @@ RepackWorkerShutdown(int code, Datum arg)
PROCSIG_REPACK_MESSAGE,
shared->backend_proc_number);
- dsm_detach(shared->dsm_seg);
+ dsm_detach(worker_dsm_segment);
}
bool
diff --git a/src/include/commands/repack_internal.h b/src/include/commands/repack_internal.h
index 3ff64444351..6a85cee8910 100644
--- a/src/include/commands/repack_internal.h
+++ b/src/include/commands/repack_internal.h
@@ -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.
--
2.47.3
view thread (415+ messages) latest in thread
Message-ID: <182883.1776073323@localhost>
Permalink: ../182883.1776073323@localhost/
Also on: postgresql.org/message-id/182883.1776073323@localhost
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: ah@cybertec.at, exclusion@gmail.com, alvherre@alvh.no-ip.org, amit.kapila16@gmail.com, kuroda.hayato@fujitsu.com, srinath2133@gmail.com, mihailnikalayeu@gmail.com, boekewurm+postgres@gmail.com, pgsql-hackers@lists.postgresql.org, rob@xzilla.net
Subject: Re: Adding REPACK [concurrently]
In-Reply-To: <182883.1776073323@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox