public inbox for [email protected]
help / color / mirror / Atom feedFrom: Chao Li <[email protected]>
To: Antonin Houska <[email protected]>
Cc: Postgres hackers <[email protected]>
Subject: Re: repack: fix uninitialized DecodingWorkerShared.initialized
Date: Fri, 17 Apr 2026 11:41:37 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <26785.1776265652@localhost>
References: <[email protected]>
<26785.1776265652@localhost>
> On Apr 15, 2026, at 23:07, Antonin Houska <[email protected]> wrote:
>
> Chao Li <[email protected]> wrote:
>
>> I have not reviewed the repack-related patches before. Recently, I started trying to understand how repack works and trace through the code.
>
> Thanks, I appreciate that!
>
>> While tracing start_repack_decoding_worker(), I noticed something suspicious:
>>
>> ```
>> seg = dsm_create(size, 0);
>> shared = (DecodingWorkerShared *) dsm_segment_address(seg);
>> shared->lsn_upto = InvalidXLogRecPtr;
>> shared->done = false;
>> SharedFileSetInit(&shared->sfs, seg);
>> shared->last_exported = -1;
>> SpinLockInit(&shared->mutex);
>> shared->dbid = MyDatabaseId;
>> ```
>>
>> Here, the code creates a shared-memory segment and lets “shared" point to that memory. It then initializes some fields of “shared". However, later code reads shared->initialized, but this field was not initialized:
>
> The problem was noticed earlier this week and I already posted a fix [1].
>
>> For the fix, since start_repack_decoding_worker() is not on a hot path, I think it is fine to zero the whole shared struct explicitly, and then initialize the non-zero fields afterwards.
>
> Although not strongly, I prefer setting individual fields explicitly.
>
>
> [1] https://www.postgresql.org/message-id/182883.1776073323%40localhost
>
> --
> Antonin Houska
> Web: https://www.cybertec-postgresql.com
I saw 05c401d5786a05ea630e884ffa492aa01683d15b has fixed this issue, so this patch is no longer needed.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
view thread (4+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: repack: fix uninitialized DecodingWorkerShared.initialized
In-Reply-To: <[email protected]>
* 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