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 1wZkOP-001FwD-2s for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2026 07:08: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 1wZkOO-004rWd-25 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jun 2026 07:08:56 +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 1wZkOO-004rWV-16 for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2026 07:08:56 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZkOM-00000000s1a-1e8O for pgsql-hackers@lists.postgresql.org; Wed, 17 Jun 2026 07:08:56 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-beeba001887so701354666b.3 for ; Wed, 17 Jun 2026 00:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781680133; cv=none; d=google.com; s=arc-20240605; b=PZrEVBpcPRu0Ho/3l8nu1r/hX0UIad4dMgVkgvyk8/HkEKQPk+gSx7eM/xr0LXArBF OS4Lj7cnTSCBX9DD8TcsV5f9H96tj0X9S/TSqeerP8n6X8XZQ3vVOwrd8F8jUQrrDBB4 +0AVhUgz2yil2TLg+1Fv78aFCSz6/T6n3D7nYePNM4n0wyj+p+G4N88I6a44xz3EnWPw U7Who4i09dAFbKq8ItugF73dub7WgW545KJxbat8IdwsyVAWRs946DmydHF4SOGypEDu wGJ8eoLmQYpN1rIkfPiqLKIyV76nUXGP71H4UUfe6FHL+Vo5ypwB678MGY52BhOSSPAq A0DQ== 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=bDcu+WEEH0sNxmEwEtpChZaukColC6Jx2OfjO0uqFW0=; fh=kyMk1ZCNA1jam9s4I596iYOH+ZAjiKsmg6UgMPBVw6w=; b=bqr28xyt63iPYxSy+hc/WLG5wy/+BoYkqz8VUNvpBI+/GFFW1m87IBQF0EWsHrAMzS A5/uStfnjGJQWYLQt74jcZ3zA5Fm6YSFZDOM47W4+3iIQSIRKXLRziCkJ+gAO+tk+5wi 38fO0NkQZKyQGeuyxIHz/ywRNFXEBUDCgJFMScOBj+CGJBMkQEZFAfCALeYpeySt80/R Tm/0pVOOvlTJ9YWKBu3pHJzP4XIJaU+Z99OxCdUqigOJTaNb80Dnwm6GxOUoPj4ESdJx OoI7hEuy6dyHFrzhzIve68Aw19WOFKjS3/NYPIDpoUU1FBS4aaBJQtOO90Sjtwb/T9Mc YwtQ==; 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=1781680133; x=1782284933; 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=bDcu+WEEH0sNxmEwEtpChZaukColC6Jx2OfjO0uqFW0=; b=W0RPSJUTnpdtNJBqcLeMyw62PSXhCc2N3QMQJaWFVL6fEaHgEDYZUp9zOa0CKX7oVc 0pnTNBskx1E4mBt5MF3O2S9K2EyFj9grEKGugU1u4VuCpKhRVb+vehzmJ6Pg882Qvoif fSD8lIAce2mX8VyUHzIvP39SQFKDGnEf9HW0oIVWjxJUhyXC6on+qg+SeSLZ2AEYycRT bceISQUs2zuZ11noOHaJB4k1NF9K8TiEexo8Mz2A6IYLVuViOTyal46m36doNRO9z2m8 OF9PNnjYqFeIJ5lMDJunTA/VJ7byATsdCsTINRVJCU4wYTT9M5J7b6+IE7iLbwkQOtlC v93A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781680133; x=1782284933; 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=bDcu+WEEH0sNxmEwEtpChZaukColC6Jx2OfjO0uqFW0=; b=MTZSkcq87rlLlAMPn7N8HMYUSDbb0fx1oD/m6ww8LS8bLkf+cbI0VrPruv3xICcVnp Sfn09nM9A72IWCid7L+yu4XhExjphNAU1biEy2//UfhSlgM/+9SjUpTuHUrK9hOPW6sX xpIPX6IAhorznUbmmC9zhGxxWuaA/HtU09O7+TQK5x28PxWKrj/tdyOQMSFsngHOQuUn GsjSHQSt0fQa/dAm0UHv4OxFfxFpaMf3O36D/MXXx15ovvyXnxXDhpmnac6nKCYzo/lx LLPSxW1SRjvfz/pRdWgNW/x5D8wvU1wSIeQgbGACfWVxn8dSBZllM+JPnNR8pqM9jM3x 8WTw== X-Forwarded-Encrypted: i=1; AFNElJ+tROGszqJd3tEiGl0mbuYCaYiGo484d4pBFx3hp02jbM2O/udM/bPRVHDyggzjiUrXLXVQnMPmjiI5I13C@lists.postgresql.org X-Gm-Message-State: AOJu0Yx+wLRk1FUM++lAF2bf0bnidH/7JQLlI2DNQKCLVmXRREkwphRq /vB0j7EQX/3jsk2mukukhBra4nGZrvj7/hqJ1AJoF6bO8wpFQAcTAiFcEXiVuDocyIWXKfWg2R7 5uZPfWexTyj01cgnhJMk0L6U/3SgCJZI= X-Gm-Gg: Acq92OE2dVqq83ZHK4kHEmSXlf9/+rkToF/+AQ0EWITHg8zZ2IqvJN/lhG5odlqs4AB vumXzx0QYv7gh166UDPB+5JLU+fF+VyX7A3nbXnMF1Rw98kwctLsz5k9n0xiWmVe5qbNmmbgn0o 19r+L1VfUashr7a5oQaLHeWRVFvcGNvOZnHZCQaA59y/RW7yNptfN5NjeG5m6vreHP1BQQWF476 m8x79G4W1AH7UOhRC5lW7Y4oaFT0AuwPac4Zn3LD8rNbW1s+gHF50+IJComNPVcbwChorllgZ6s 1WmdWgjrKSrxv4wAb6MhljOb2yxydbRh/r4ix5Ov+qz9B6/9s/vv8Zok3sO0dbYazlOGinICM9c oTFD8AWNRQr8wdj+AtUOGODQrwrJMwQ24wuEtzA== X-Received: by 2002:a17:907:3e21:b0:c05:7426:40cb with SMTP id a640c23a62f3a-c05a1e4af00mr161448266b.1.1781680133032; Wed, 17 Jun 2026 00:08:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Xuneng Zhou Date: Wed, 17 Jun 2026 15:08:40 +0800 X-Gm-Features: AVVi8Ce5D84ydm958csXyGTgCHi8iYP7kqIKUEG1FM4nnpOSzYWl2uzlzWb45zI Message-ID: Subject: Re: Fix race in ReplicationSlotRelease for ephemeral slots To: "Zhijie Hou (Fujitsu)" Cc: Amit Kapila , 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 6:32=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Tuesday, June 16, 2026 5:36 PM Amit Kapila w= rote: > > > > On Tue, Jun 16, 2026 at 2:24=E2=80=AFPM Zhijie Hou (Fujitsu) > > wrote: > > > > > > > > > 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 point, and we can also skip initializing slot_name. > > > (Please refer to the attached patch for suggested changes) > > > This seems ok to me. The only risk is that people who don't know the assumption might think this getter is unsafe. > > + 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 immedia= tely > > after dropping the slot under synced slot check? > > I think we can do that. +1. Placing the log message within the lock window looks OK to me since the cost is small. > I'm attaching the new patches for all supported > branches, incorporating both my and Amit's comments. I hope this helps mo= ve the > fix forward. > > I also confirmed that the fix works on all supported branches. Thanks for your preparation for patches and confirmation of them! --=20 Regards, Xuneng Zhou HighGo Software Co., Ltd.