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 1wD1qU-002XE2-2p for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 15:08:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wD1qU-000F0I-0R for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 15:08:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wD1q4-000BE6-29 for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 15:07:36 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wD1q2-00000001Esu-1cTJ for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 15:07:36 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-488a4bc360bso38567255e9.0 for ; Wed, 15 Apr 2026 08:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1776265653; x=1776870453; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SIWlnqdvU1E7ZngA3iu4QWfg7oe+1+m1XSXHlgH/QD0=; b=OR7lWIo+mst0SqRhXc7bZSR4W38KxEuhp+4YzDusOWjS024ZynU2ZLZJ1dLzkp9E9d xjAqNhxDzZKU+FAk4AifCP8FbV/IY3YuiVXgSVz8bMA6GQW8viTxlON0JCiJVwlq0n7T oe+NeQUrvECC0lQidb45rLzb3kPcQFjBbv9xHgrK81v62CoxKZDVhcFEvp639VjKio0e 8WNQrtmgU+Ay/FpgUhcINQCVre8W4QktX7908Ppiq4rzofAEG3RFfE4TwcSyeEwY1IuJ Y8AAOhVNSj4FUtClwYeCMvGF0gbkLUQdvNScAKv6l/ZfXHM6ZrCM2EhFUyMyHrhEnGRc 2xWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776265653; x=1776870453; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SIWlnqdvU1E7ZngA3iu4QWfg7oe+1+m1XSXHlgH/QD0=; b=NSzHQpbdhpFL2JfZZ3vO8Aq39UT4b02nUYRjWOf7xWBvSuVpzv0r3OTH8iKosg4Zqr aSu3GxIICQaq9Wgq/u9pQkebV2JidISGqDnLg0Ct9N+lRRtdmpOqiAZYxHO5iJaOUmUr r78CcDJbUhBvQ5Sepz/LsBJ1tCB0Lf+0WlzPx8zZUuJWqD6qiyyvJUMwp4+V/2ceZigS XjTBPBo+9Wcd0x0LFinYF8GKayD0qzAO4PNsqV0e2Bw4Mj/tkq2UCPgBkdAZZouJYFpL Q2spTu3yRhHFjYAzQmQF523uVvWNfKDYy9tmCm6FFLMDHeXb949aV+PUF/vhP5IC4HB9 7rBg== X-Gm-Message-State: AOJu0YynJ4L9lazMTkXVEwqNL6b/zOa6nHCj99XXTKelwN/t6IJY8wIh TLp8Rhd+HDaYqkccaJ8VG6nG8kN8HzdVYC7kcP/6CZEzFStSoirQDcqNnq5IEV2saGI= X-Gm-Gg: AeBDiesqR28uVsckiOL5xQadcxXmlhuTg6jpQBjRj6x/PPDHAJ/rWDpE/mhOU4fntjs MEr/oMFYTNi0FsZTW8UGj3CMinaq8s4nDVMVIVXocNjWUbA0ImF7Zyd6CIVTO0jk5WYe8yV5Y8b G4lya9XzAW3ar7D6PwSEoZuV1Ezl6grzlsZrRLVzB+kkHckO+2bvUvMU9Nu0ptXIqjlWeaZ1UIB USg6xomVzb0VsTxzuymHk26ansVJtQpN23zDH+qhLQ3k1z60NUyKfdv/fLHMV3Qraq+w7XIf3OM PU2q1zAkrv19VJaeqBBIRlSqBms2LVR8jbD+hwctEDQzNCUCImbcrrVAk0AP7J2thxeYc1hyAj8 Hkt/bn3D1PoZMiN3HNacTOMFhdOgX+jtyZzcF/bycHjBKr7Ns7hrWGJrAvQOfvLPY+OZr8O+R+7 ZcI/HsDB0r48htVjhpuoAyZiJ6A1kFsOfhIu7B X-Received: by 2002:a05:600c:474c:b0:487:219e:42d with SMTP id 5b1f17b1804b1-488d67e72b7mr282398925e9.11.1776265653138; Wed, 15 Apr 2026 08:07:33 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43ead3d5f06sm6136158f8f.17.2026.04.15.08.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 08:07:32 -0700 (PDT) From: Antonin Houska To: Chao Li cc: Postgres hackers Subject: Re: repack: fix uninitialized DecodingWorkerShared.initialized In-reply-to: <9AFE5694-9420-40C3-842C-4A4473E1D02B@gmail.com> References: <9AFE5694-9420-40C3-842C-4A4473E1D02B@gmail.com> Comments: In-reply-to Chao Li message dated "Wed, 15 Apr 2026 18:22:44 +0800." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 15 Apr 2026 17:07:32 +0200 Message-ID: <26785.1776265652@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Chao Li wrote: > I have not reviewed the repack-related patches before. Recently, I starte= d trying to understand how repack works and trace through the code. Thanks, I appreciate that! > While tracing start_repack_decoding_worker(), I noticed something suspici= ous: >=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 initi= alized: 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 init= ialize the non-zero fields afterwards. Although not strongly, I prefer setting individual fields explicitly. [1] https://www.postgresql.org/message-id/182883.1776073323%40localhost --=20 Antonin Houska Web: https://www.cybertec-postgresql.com