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 1wZTBD-00144W-1W for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 12:46:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZTBC-00HT97-0l for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 12:46:10 +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 1wZTBB-00HT8z-34 for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 12:46:09 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZTBA-00000000dti-2ZiL for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 12:46:09 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-48662d16d08so1754956b6e.2 for ; Tue, 16 Jun 2026 05:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781613967; cv=none; d=google.com; s=arc-20240605; b=e9HAAm8p4Er0Y4D17O5OxzSWESdpOsDIVXgQ1N4M5xPhsXzXn2+xA1bRR7za+qFcmA ZSY/1aCkpf4hlY+mYw9eAU0nKwxUP5YG+Xi2R2IGKJYBW3DI6UK9wggNrz/noEHI2e6V bnPs8Uwcj5J0xGdoRQ2+4bAuUam4N7hLOy1p4SZ/sIcptMhnHdVdZGAc/i4rHHsoFHOt PskJZpxpuJXQIvv7h+cDnX3muZChTPpvRYSwxbxfAr+is9sw5Wpos3ASuu6W4Vw1PBjj H+DIULkn2ZoXAXwhCSdxu5w94AfOn9Hp2BYDkK54/sXZLOztl+4ndoSxB2DNlWu/W/Y9 WGSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pPrWm/PdReGLpAPECu8m1u5D3Sj8B2lXI3J/oV+51/w=; fh=m0Ugs9N9m7EdmWh8up4DYp67eBCQlINcf7mXVD2sPV4=; b=IyOvTugwksHC134y47M+iSIRI7MtnBV/hJI5OofTUtclTtwGeItMlJCPHaIhXz0uju pXTdpBHf45cBMjxUdpnWCPVBscr+XgWYoSSQxE50LIXiBQe2pU9cTl2/7a/DflduDJ/v 2e8LMrkv41oDHcJZtqP6QObWaxuAIdmpYvCPQUsienZrv3HMlf0U4l45bOvQ6O5Ej17g H/G2KEtOVHi12IzeAaKHTCCw4L44aAzG3rDJa/ctEGlXE4MIUlwcqIfxRAnmgv5BXaNB 5QHOHK5kJHVdbwiVUgWdITGaXQvkWG3uQSbSycHAWFkYZTdM4GYulqZaqvRnC1ZP5Xs8 1fBg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781613967; x=1782218767; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pPrWm/PdReGLpAPECu8m1u5D3Sj8B2lXI3J/oV+51/w=; b=XQcZmL/jjHibcWfKASmWH1ADm/ysWJKXGJqFeY6IKDJHxJmFcP6DuX8MDEm8qfbZGT EBTb985/KMvB27XjsiaECdqXCzoY/Vs5ABKLUOv6UByHGgm0X5DzSG4L/UFbrXuYBlMq 7FnivtYh5yg6TbbZc0jPG22KmRki85yD/ODq3//tzHpDJ18zIJPYQC47fCjrrNcTnH0c mAoIWT23bQYYI7R11F+z/b1XA5hFm5Jto5zfTB9k8BH6uuCKbJjc2DsJbbSz9UDRpriU L/l+9483lISlhn1ewufcBDz82AFcUTqDPYZyrkpZ4PC53hzPK0RunkX60ucvavP7eKVD Wcnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781613967; x=1782218767; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pPrWm/PdReGLpAPECu8m1u5D3Sj8B2lXI3J/oV+51/w=; b=Qind0BEAt3zmgCl1qz+yN+DuKOzINLhTXOvDspPjNgOSUmIHKJXStZvOG3Z5sQ17r1 7Lfgzwz/z/wxiXNLws8/OfE4WZGIqRNcXlTXcag+ZyHCp5BSkfw/ckf0IrPUa0jrjpjc CvnbLqXh7n+ALmBXY4Avy2U9paxwvZA03Hhns1m6DB5hM0PeCCUbbw+TRL11MOgz1gwn S/U07lYUKfg52YFWySEg0BldFxUp/5QKCNSUmgyZLJkoogZ9PaggrW/ekkCgG41Khqg5 jw9uKVedYWlrWS8IdFPlEY2niVig9Yy0CbTlOgcIIQ2SMWLkV35W9j9bDddmAyEJC3gN 2C6w== X-Forwarded-Encrypted: i=1; AFNElJ9ZEp99tOzoNJzlV/HkOoOmhxDjINxwWRnfsmQmaJ02YYd7h2tL0HlvIcY2odejlYcQNyLLUeqJbCwLTd1d@lists.postgresql.org X-Gm-Message-State: AOJu0Yyq3wlFx9skE6uYo1b46TuVX9BgZjsEmW+iiuX5NLyJ3wZjCK0O eqF+jVbG3re09wBnh9Tkwyd/PVL5FdRBlbkMh6U9hXvngkFxx6xoPVP7lPPwnxrtDvmVZGT1A7c iqvlfeyL7saP+II+P3Aqgs8JZNeAjrEg= X-Gm-Gg: Acq92OHV+cJwRQ4VJcKpLMr05hjZUpuC1XXT04nCyO4+8dWfi5J9lLlD2PrbdJb9Ldn ++47BKDv+4T76tRpgNhBqzi8JkSMZhoe5Tr07YZEVcrLiOYt9W11DUKFbqrv4UeaY1gCUm6Zegv 9OgtTJBz9LtyBc7/17lRpbyBVv0yFV6BcCER+yO4x49ryP/8nW7mxcJWMUShezo6jnxhKuouQWp CwL5So5W/GE6C7/O3OkuTjRE3yhtWHCmF5KYy4lyByujK2dKFejOBr5YekfzUNPnpkJbOWlXHER a28Ar4Tluj3M5guRQJ08fbe5JQCyp/fWfnmR1UkbCSY+KEVGjo/wW9HNFvnHJtf68G8lpUbWf1U UTPMwNGx9hneG8SOGucrexTWpkM1BHPWcKw== X-Received: by 2002:a05:6808:16ac:b0:486:4892:d55b with SMTP id 5614622812f47-48741a14cfdmr10731659b6e.19.1781613967518; Tue, 16 Jun 2026 05:46:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Tue, 16 Jun 2026 21:45:55 +0900 X-Gm-Features: AVVi8CditwzQOXjC1EewP1ToAyozLktLZBjpcdvQuDygew0aCJvToA4UVyK7Qgk Message-ID: Subject: Re: Fix race in ReplicationSlotRelease for ephemeral slots To: Amit Kapila Cc: Xuneng Zhou , "Zhijie Hou (Fujitsu)" , Srinath Reddy Sadipiralla , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 12, 2026 at 7:54=E2=80=AFPM Amit Kapila wrote: > I feel even if there is an argument to do such a refactoring, it can > be done separately. We can push forward with 0001 and then do more > discussion for 0002, if required. I can take care of 0001 unless > Fujii-San wishes to take care of it? Yeah, please feel free to work on 0001. Regarding 0002, since the race is very rare and non-fatal, I'm okay with accepting the risk rather than adding more refactoring just to avoid it. I'm a bit tempted to add a source comment explaining the risk and why we accept it, though, so other developers can understand the tradeoff. For example: diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c index 05637344363..ca49f20e7d9 100644 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@ -560,6 +560,12 @@ drop_local_obsolete_slots(List *remote_slot_list) * the same shared memory as that of 'local_slot'. Thus check if * local_slot is still the synced one before performing the actual * drop. + * + * Because local_slot still points to a reusable slot-array entry, + * fields such as name or database OID could already be stale here. + * That could cause an incorrect cleanup decision for this cycle or + * briefly lock an unrelated database. We accept that risk because + * this race is rare and non-fatal. */ SpinLockAcquire(&local_slot->mutex); synced_slot =3D local_slot->in_use && local_slot->data.synced; Regards, --=20 Fujii Masao