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 1wZQD8-0011h1-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 09:35:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZQD7-00GV5I-0j for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 09:35:57 +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 1wZQD6-00GV5A-2u for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 09:35:56 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZQD4-00000000hlm-42k4 for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 09:35:56 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-84231305a80so2528368b3a.0 for ; Tue, 16 Jun 2026 02:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781602552; cv=none; d=google.com; s=arc-20240605; b=BzlGBSy8Ea8R+7CyXQ6RtnpymyrjNp6GKWwZVg0Fh1n9Q4RQ70PSWJDMOuXE/vHkKZ BMivPyEvuDhr+A3eTYBvsHncmtFjvGy7d/rzx90Gspre6iJpA8LU6O2hUKlahAb1IWRf rxBFTlrsVuvF4w2tXSTSzC1Wz7lkO8iB9NI64lPWuS78FLN32mAdN0S3T2T8AzBCqHFt fRdIfUqlCw3bT0r4UjZm3ip5S2iwD4qIo5WN2AbWg5d+w02L0W4h7npL1+GvXpH+Rd+4 vNilzOwLBfLUtYJhnvU0zTmO41kpwzZd5MLNSsxNpmahjyJvrLvXn4E7V9MEfL0mvdR5 jhAQ== 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=tqtaqqH9x6M9dG+WKii7nMkDsleQmRk1j3IVkXVgwOM=; fh=947/PMOHgDhesxGlUOrHUQDVdHog4UI5AIzh2cdeNkg=; b=S1AeTQJpcnkJCHbN6xv11PMnS/28xpDgHtGtsm2ZQS7wqKphQ+vru8pRT9WYzm7FMo wF1QDs4fdIkiFjBqS4/Uar/UTIqgmjzLAIW64UOe6+O8NRqqPlKtLL3CkeBNDi8jKBkn nfv9BpG9Rv5IlpbUBh50ZTQGVlwmP87WvcXlC1Eo9cmx/we9XEgVN28RBbI+UuEuDceh 2M2J3XJPp0f6+/LAgG4DIFfFnJ1UdEYG3F4+0eKKv5hjA92IwGRrOjP2dzLl1+nPAMQe qJeH1+nBUaJTzPbcYUQ1CGCNamZq5+mzCRfUJwuQFVm9M9gcbB/K+HdOp2OmLRAHL3E1 c4XA==; 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=1781602552; x=1782207352; 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=tqtaqqH9x6M9dG+WKii7nMkDsleQmRk1j3IVkXVgwOM=; b=kD1f42cwV1gkZj4FbWaAFicafKzol7MqIbZLjOGibfmLDInJUQs3vRNl69PbccwcDG R98yp2og/hm6ezFnrf14sqIWHhzASFUhKd76/J3ZOB/E1K3lEnfHenGIuDmKYPWSf4e5 TV1WC20ytyHCWAbRooRSLDjzUTrj/NGwdHHEncYX6Iyu06RpLpIphDo2gLLPJXz3r/9r qPvFXhkKqlEIpsFd44qx323+0Tc/xIVD5hAsR+2Ki9ul+c512mZaj6cHvQkdGjSMnmJs d1lnOKvGJOJxN76J19ARKgwcgJWVycPdM5vj/kf+7iWw/kCpQBsHLMZrnUKA7RRd/hkb C0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781602552; x=1782207352; 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=tqtaqqH9x6M9dG+WKii7nMkDsleQmRk1j3IVkXVgwOM=; b=NUX7SSdnTsE3WJ5/2yuGKNgaOK6k3p12fC9+pCx+2Va9sra4Myn6z7bnnKM3sx770w pLXwpuCoEI2kWCaE+U2Z6YlQ45XyHhsP3tQ2EUmYhiarbuCd1x1Twy0NCBj3yfQUzO+t 8a1W7SkcqBEuqZARqdZD5tSrEKRBGhQIZmWFQMpUX7+X5UvcfZ9aCsPqYzQ0FOASljLE fuxsYU5oivZ3mXd83d1yEFz11fo/rEh++R3/VeXbgXPWKVx/e7KQIdX2Ng6SN9pK9GVG XmKOxIGaR0QkbsFU/5VvXSxfHv9jkyaNsxFF41jGAMIQmXIj7glWaal1xNcUwkVHqu1V WQHQ== X-Forwarded-Encrypted: i=1; AFNElJ9YF2Pl8Ku3g+3/0/2Hphzm0OxBQuOjU8hLhrzcxdlcGh20SsWMVRCgspIrl1GdrrYRa6Xttk9hnExBuyfB@lists.postgresql.org X-Gm-Message-State: AOJu0YyPjOHkSB4VeN0Lsms5d8vsRdliyDnwnQGGLL5P2niQbmbcxZyJ +0jQLwDZtiMqcfvu3SAMoarls4EUyYMV5PbrBGm3DvNK5GebYdJ696ILO4ODacAHmJUDakDHvfH 6kE2BRaW97DMkq9e5Nzmgulpp7S3CaCA= X-Gm-Gg: Acq92OElkexxkBCyAJ88UHHvl8YjG0ypm3MEEnrcZhhOoE5RDSBDC5C9Ray4FPYLbhZ dqHxTJ8CrNUOsR+lgpZ4FxdHXDMq4ZDltS/QHvzop3tt6Wq8YzEVidLgnhs7KDiduJjQUI/Z5tv zDD2DIPqxxhmQID16xtZ2/+P/y9AgAcNYGloePFM+k4tVHX+36mdnZCXMfxBFhnB5ZiBHrAZBWD fAnAY0mbdBnnRPsJEwCjN52OxBVKif7kIIpX2493eRRPpKDgQxiNtP3ZxPrN6b2ZB0i+QqXiJyC f7g9nkcU8E8nktjTnhAXMO6CucitX+FgZNayCCnSKaoXPpLilO0uWf9H3Itmyj5f+QHr4Zh9A+X 961l/RgK3yIu/Zsklh6Q87nLxAz6G7uRMnDu/ieSN X-Received: by 2002:a05:6a00:1395:b0:842:57e8:1bdb with SMTP id d2e1a72fcca58-844e1999937mr16134764b3a.20.1781602551873; Tue, 16 Jun 2026 02:35:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 16 Jun 2026 15:05:39 +0530 X-Gm-Features: AVVi8Cdl-iab_GZozj13QizsbC-qZ12W5Y9e68KuxrXwMg0RKYoJ9g4rgK-aOYU Message-ID: Subject: Re: Fix race in ReplicationSlotRelease for ephemeral slots To: "Zhijie Hou (Fujitsu)" Cc: Xuneng Zhou , Fujii Masao , 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 Tue, Jun 16, 2026 at 2:24=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Tuesday, June 16, 2026 1:30 PM Xuneng Zhou wrot= e: > > On Fri, Jun 12, 2026 at 6:54=E2=80=AFPM Amit Kapila > > wrote: > > > > > > On Fri, Jun 12, 2026 at 8:22=E2=80=AFAM Xuneng Zhou > > wrote: > > > > > > > > On Thu, Jun 11, 2026 at 9:19=E2=80=AFPM Fujii Masao > > > > In an off-list chat with Zhijie, we kinda thought that holding the > > > > lock of a wrong db for a brief time doesn't seem to harm a lot. The > > > > concurrent dropping-db operation leads to this issue seems rare in > > > > practice. He stated that the deletion of the slot seems unavoidable > > > > because we have to acquire the database lock after releasing the > > > > replication slot lock to avoid the deadlock with the startup/drop d= b > > > > operation. Therefore, he prefered keeping the design simple and > > > > avoiding the fatal issue over doing a broader refactoring work. > > > > > > > > > > +1. I also think this change is not worth it. > > > > I am also OK with the scope of change made by patch 1. > > I have one minor comment for the 0001 patch. > > + NameData slot_name =3D {0}; > ... > SpinLockAcquire(&local_slot->mutex); > synced_slot =3D local_slot->in_use && local_slot-= >data.synced; > + if (synced_slot) > + slot_name =3D local_slot->data.name; > SpinLockRelease(&local_slot->mutex); > > We can defer assigning slot_name until after we pass the existing (synced= _slot) > check. Since it's a synced slot, no other process can change it at that p= oint, > and we can also skip initializing slot_name. (Please refer to the > attached patch for suggested changes) > + if (dropped) + ereport(LOG, + errmsg("dropped replication slot \"%s\" of database with OID %u", + NameStr(slot_name), + slot_database)); Can we avoid the if (dropped) check by placing this LOG message immediately after dropping the slot under synced slot check? --=20 With Regards, Amit Kapila.