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 1wXfKA-003PEx-0Q for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2026 13:19: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 1wXfK8-00G74j-2r for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jun 2026 13:19: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 1wXfK8-00G74b-1r for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2026 13:19:56 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXfK6-00000002YJk-0mdY for pgsql-hackers@lists.postgresql.org; Thu, 11 Jun 2026 13:19:56 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-397e391cb2aso40850471fa.2 for ; Thu, 11 Jun 2026 06:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781183992; cv=none; d=google.com; s=arc-20240605; b=FYMqan0MfpGqmJnjp/YZ87wWis526wuxMpaP0/xQtHPmR94DgxLgrBV8fiFakdSWvx hjz0QTDeKNMUM8noHJaYU4C6CjCAtB2BwnMoUcJ4dlPVbKRsUILDmdIyyBj/hgO5pBjL YTqze+MQyFUm/T/IFwCdV39DeZqqciY5+ejaunt67GbF5Mp7mYvOZNuFy2k3xVD4dFTE G+dy/qcqkA2WIomQOm/tIcg4wAB30s+FuOtCS8YYsJ0W22Z84VAQQOU+4i+a4f7Jnhtt wMwj4F81c6dwuKje93upms5sTAiRUyztI53kzQ3rgpCWPFmmbPoJDZ++blOsmxEGq1IY 2eNA== 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=ravAvOCZzhsQequdvWLhk53HGYHqJ9VpFN/8TJGKSIo=; fh=v3CjElmREU/bOoZ5CUFpsvtx8HPzxNRMJ9XHitwFcFM=; b=fRKA6bu2iTlafLiGFGvrdEwvTjnasSUjbJWpNqsip5Y1egVY1UoTOUyKDvIExgUU2T c0ueTz+jcDULC7vQfr4vw9R86qeGJlxUpOgb+K6Tdkx8Q2tKnAyqx0CTm10wcvZawSGO W7+GX+o8aVAP+Qmp02hTUvjMbo5Y8OX0m29GWPopDwfpxez4F/VM/ssbtjNxGeeCIe0X KLXof3KkdM1sSTAr/j9d0rp/lGk4ijFBLXxlOokhECMVlaSDA05bUZP5jdnYQlvD/h7+ vtGv+7NBVk3NyuK3GZuWSOTcaNzl8pAvmFcczPpjIjQS8b4cbIyia0W34vQM3BnioYk3 eQyg==; 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=1781183992; x=1781788792; 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=ravAvOCZzhsQequdvWLhk53HGYHqJ9VpFN/8TJGKSIo=; b=T4pdUt4DJznejDOZnYYVtF+20GTMR0Q1Wq/Noc6ToaPTDH9XzkTzY90RU4qd9y4ljw q91FojkxtbKCKMe331chMgrTH6g3DDLqRpfguAZAaweaEbw2hn8+kP9UVwnC/KM6SrA1 EPSjkXf7fL8DOs8KpzwUHiz80CEjFQTVtRJkJ80ID7eJYZIkTNBwn4dJLnq3rJ3jl6FW +qRo9ngaBW1ts39dldjwnpiOgw6extBW1iCwh3UnNladhgzdjzf4gcdGAlgPHys5jUs/ eGE5yS/02u6OkEr7MKaQyEEX7HBZ0bMReoJkpuXKKvRsRvtldDfgOj0CovQwoB9qkMNU iC1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781183992; x=1781788792; 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=ravAvOCZzhsQequdvWLhk53HGYHqJ9VpFN/8TJGKSIo=; b=Df/4udr3HMNHCFXloQtSefsl3zpplAXiUutgwL+eKtr6YRYejcqkjy5AbU87Vs/R5i 81BGc2V7PpSIgy3toQ+AdMhbPUyi5MSVhjSDDjaR6s63IWUdC6WllAYn7cZHMbqzq+xU 4sIxaxH5MCeK47w1X9+W3YjTh+sA662+K1rt2s9xX+Is3KM8RYrN/Qb5bZwQ5G/2Ye6P 27W869+1T5EQ2j3W9P1OGfXUbJ52Gb1mZrHiDrFclUutE2L3lmXffDxONz8rEIiK5v4J Z7dTPfrr/bLEEt8FHIByEpTQv6kQpiXafhvQtBy4eiH5MDSOM7j8qqeS2ns8HOAebfhN Yhww== X-Forwarded-Encrypted: i=1; AFNElJ+l+XueSOFidh0AQsXl7KOLIS5zeC27gkScqxwYRJcZ+qoMyZOBbWAB33CoGPJtB7l3PfgtdirDAD/pyvMg@lists.postgresql.org X-Gm-Message-State: AOJu0YxV4gOX9nO5kca191cXdvfg65y6HWvZNntuWoaCT8psEV1Y2Xpr cadA2GcL/PVHbv69/1xfofe1rn6P01n0XUKiKAQlHlBtYxR9uoj1AhvC54qDLf8j1zZY+rzmobO Xait7lUBVQ8nBjj/rztYdoGiuN1FpD6Q= X-Gm-Gg: Acq92OE4a0/jK6FsuMOu9LPjR2mJdMeI9ZDlqXdMYnQlDT5WcYyrM3YiOt3OPA12wiM 5RHgRzs4ksDraME8n5SXI6iyTw/7jHlKa7STvAyTYAMr4DDwa0wI+w98PjYY89l1Iuxfc7wqQJ7 C7wt+lkMvOTsRjYzlsVDKUqdkAVSwkhk9mRIakoXR0uielaRSGU0eE+RwtvMvjFvowXQeWwmqp6 utva135GtmiAippT992/NtOFsxdhQNVH6V88HaCtjpxRWvvu1EQW16CsUlaSU7M6j/ysjqGKnbb qYsjO5P66bhceYlmdBEL5xTJFxx+7tTz+B3Ox9icTjC1Bkg74X91xE0QQGdlG/v0fMnJFMxMcE1 pQMXwWPE7IsxrPuG5kePM+WignKS5tLk2sQ== X-Received: by 2002:a05:651c:2127:b0:393:fe12:579c with SMTP id 38308e7fff4ca-3991a03e63dmr8210781fa.7.1781183991337; Thu, 11 Jun 2026 06:19:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Thu, 11 Jun 2026 22:19:33 +0900 X-Gm-Features: AVVi8CcYLcKddi_D5MusuGtxXqLtBP9IF8fg9bhv5J000K0zhASaqfuDZt5bIck Message-ID: Subject: Re: Fix race in ReplicationSlotRelease for ephemeral slots To: Amit Kapila Cc: "Zhijie Hou (Fujitsu)" , Xuneng Zhou , 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 Thu, Jun 11, 2026 at 8:18=E2=80=AFPM Amit Kapila wrote: > 1. Stale name read in local_sync_slot_required(): The reused cell > holds a different name. local_sync_slot_required() might return false > (drop needed). But then the in_use && synced spinlock check sees > synced =3D false and skips the actual drop. The wrong decision is > caught. Yes, we could skip the actual drop. But then wouldn't we still emit the log message "dropped replication slot ..." even though no slot was actually dropped? > 2. Wrong database OID read at line 551: The reused cell holds OID_B > from the new slot. We lock OID_B, then at lines 563=E2=80=93565 we see sy= nced > =3D false, skip the drop, and unlock OID_B at line 579. Since no drop > occurred, the cell is still the same non-synced slot, so the lock and > unlock see the same OID_B. Symmetric =E2=80=94 no lock leak. What happens if the slot for OID_B is dropped after we lock OID_B, and then a new slot for OID_C reuses the same array entry? In that case, wouldn't the later unlock read OID_C from local_slot->data.database even though the lock was originally taken on OID_B? Regards, --=20 Fujii Masao