Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDa5z-0038Kb-0Q for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Apr 2026 03:42:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDa5y-007vta-0Z for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Apr 2026 03:42:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDa5x-007vtS-2s for pgsql-hackers@lists.postgresql.org; Fri, 17 Apr 2026 03:42:17 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDa5v-00000001Pek-3Bak for pgsql-hackers@lists.postgresql.org; Fri, 17 Apr 2026 03:42:17 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-35d9923eec5so165463a91.2 for ; Thu, 16 Apr 2026 20:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776397335; x=1777002135; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tVBomZYjHGIxvOaFDv8/jWiUA5pS0KV6huCzTUFSrAs=; b=lCb96XTzqDLarJ26Mo3VrMHyUH6cBfilB/OxFWKFRJwlpLbnafvrlCs+5+qwBfl4Ci Kvj2f+Z17HJGKynq6Nm688eNgOSac7Z+Mc1x+T3FWhPFtoQB1MwVTybf5m4Zz8DY16HB FKvrM/BGC2kFlij9Oo3LrZnk4/iFQeMpE7mO9fx8NDlblt4Eej9IYGVLCEAp/FHIfIjL brB2/wYRfr8okUNHmJDQRjCZJs6u/JzLPWZbxdLKJr3UNHgNr/qY0pSTWq3Zw3WvYxwb qVWzXB5WNOc82XgTNOAYjVUvLRJRLwrvaUL84tQ0NdB01KtAm/RRxPJwoVzGemd+BrA2 /Pmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776397335; x=1777002135; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tVBomZYjHGIxvOaFDv8/jWiUA5pS0KV6huCzTUFSrAs=; b=U8m2+SCbqv/Hry2qR9ACkHeGshgo3Rq3X4bqh9MGFGwfktXn/lIgnNzOkyuN+MaTMI X//zJczdlwFpyLI/XMT8k7DhywnDgX7zYZYTIoh9ey7n7WYe3jUaBuJy6aTr11dI7mNe LbPoHGiERBWlsfjQdmLGtzJtPYyG+0QMHLcHYuk+LkGFf+JGjuvfKGNAnLBtIyrWNFBg k5Wr8WzsmjS5p5lcVdeTm+/UoLsrZza0SNAKyki8Mf+RmcK226f4MhZNhuJhF9tIZjKT KYnNdtLiCXI/Kyym8oU7VBc3RO52j9gwPg31aAZLO3cMb6CyliOwAHgKs4f+pQsbGob9 0VKA== X-Gm-Message-State: AOJu0Yw5Hn05iLJMfqJrIom2LsbRxStDAYvKPXhyBBtBrnv6EYB7QBqD LVi01kxmMrErRenNNhpdrtbS3LYAA2tX2ROMMm0A8kbcJUkJcJp49j5FZ0/tDlKKx3s= X-Gm-Gg: AeBDieuv+l12Dv2Hwh2ZqoFeVtu1dw0ir9ZodAGGSsYsymJGKHuwtdsiELgVVLaYewb HITxJPjMFiSMrck6xc0Vyc30h/i02xBBUJKLM6zoK/GwaM66HYptGjtBQ7Jxr7i4suuJpxWi87p IbTmbgYUAhQQCq2Z9U1Q96qRvHtJjKBhb+cGQG9jcb/4fRzlqy2yBa260hj6Z4vuzIPWwV8uP5L pqO/G8A5/yLP3LmO1og+flk1zS6p6ge3M0gcODuNsetxoQqpqZ2YEAecupxzlnjqXnZ5YX544pg fzZiIxrcv7T7ZTOoSPydBsqfld5Bl9wItmE12eyiIhTcDdZi0y/IT5rLsG7//3zEqzWeO/XnTU9 +RBxrdauKizjlKOGWLMHG7s59ORlXvseE8T5L9elknGKxBXSSmebdc5tBAJZk6QUI8zwmG7OnI3 iW6tuFHQlyq8PInkWM1u/NJJDeoCHvDqTM6okEFK/icH4= X-Received: by 2002:a17:90a:c110:b0:35b:e529:2d60 with SMTP id 98e67ed59e1d1-361403e1021mr1055331a91.8.1776397335036; Thu, 16 Apr 2026 20:42:15 -0700 (PDT) Received: from smtpclient.apple ([103.230.144.55]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3614195a9fbsm426381a91.11.2026.04.16.20.42.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2026 20:42:14 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: repack: fix uninitialized DecodingWorkerShared.initialized From: Chao Li In-Reply-To: <26785.1776265652@localhost> Date: Fri, 17 Apr 2026 11:41:37 +0800 Cc: Postgres hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <9AFE5694-9420-40C3-842C-4A4473E1D02B@gmail.com> <26785.1776265652@localhost> To: Antonin Houska X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 15, 2026, at 23:07, Antonin Houska wrote: >=20 > Chao Li wrote: >=20 >> I have not reviewed the repack-related patches before. Recently, I = started trying to understand how repack works and trace through the = code. >=20 > Thanks, I appreciate that! >=20 >> While tracing start_repack_decoding_worker(), I noticed something = suspicious: >>=20 >> ``` >> seg =3D dsm_create(size, 0); >> shared =3D (DecodingWorkerShared *) dsm_segment_address(seg); >> shared->lsn_upto =3D InvalidXLogRecPtr; >> shared->done =3D false; >> SharedFileSetInit(&shared->sfs, seg); >> shared->last_exported =3D -1; >> SpinLockInit(&shared->mutex); >> shared->dbid =3D MyDatabaseId; >> ``` >>=20 >> Here, the code creates a shared-memory segment and lets =E2=80=9Cshared= " point to that memory. It then initializes some fields of =E2=80=9Cshared= ". However, later code reads shared->initialized, but this field was not = initialized: >=20 > The problem was noticed earlier this week and I already posted a fix = [1]. >=20 >> 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. >=20 > Although not strongly, I prefer setting individual fields explicitly. >=20 >=20 > [1] = https://www.postgresql.org/message-id/182883.1776073323%40localhost >=20 > --=20 > 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/