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.98.2) (envelope-from ) id 1x9G8H-00000001r6l-0ieM for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 06:07:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x9G8G-00000003Gw7-1KBH for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 06:07:04 +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.98.2) (envelope-from ) id 1x9G8F-00000003Gvy-3afH for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2026 06:07:04 +0000 Received: from mail-wr2-x0f.google.com ([2a00:1450:4864:30::f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x9G8D-00000000nkB-2CQa for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2026 06:07:03 +0000 Received: by mail-wr2-x0f.google.com with SMTP id ffacd0b85a97d-4885d4825adso357454f8f.0 for ; Tue, 22 Sep 2026 23:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790143621; x=1790748421; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EW84mEO0C6uOoDSB5sTXOy49GAxZ90SdC2bmhmlpjtw=; b=hMfpKrBNYP8jtGR2TYF15qZ1r5/W//5tcmS3PfDJosfn7kUzngRe7UHlEFaA0k4hdm 4uHxecSPnDrRqxJGw46ebyB2fGCRZ07Sg0okzZZz0ZUUhxpqFYOVV1r1qKEHOJgYWegJ 3QDkBu1niqdP+gh+gQVYh9GeUNAw9aDWzzgF6RrcPUvlgKFz+pwU6XJ8mvbn1KJgeNUZ KqSNRBgSPczmJFy91iU+WQFhOxC1oYENliv+Y2tA/C4VBCBbZR9oxl0OAnUhWqCHAXy1 FyB0CqDyxYwqFgfCpQQMlcZX+rlkTQz4n3Vl7Cnp5UX6I+aDakpKzKySfxV8GO9Q6XS1 2KoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790143621; x=1790748421; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EW84mEO0C6uOoDSB5sTXOy49GAxZ90SdC2bmhmlpjtw=; b=uQM4oOcXrO+bxWJgvOo8iSYDvTH2nJD0TPQDEieoTCFzZTHdwda9mQOYjJGQcOtMZP wUW1YBTWOS4hTIEfXRGtg7t9cWDWA3Yn2d3Pn1Q9w0VRFIAWFfKnLuf5NDHbm7wqjjZc 8U7UVwYEdmO5YqPDv8n8zsNFIbHwOPTPN4g+MGr48lL4OroimAhWJvTTAgK3/Pb/30e5 +06dOz6xYw7kV2I/zr8rDtr7hApS1NFwYndI3QPsZxr+HQP7ovcLV7tz5ahSqp55QSCg bg5pmYduMEJFbPCeRBB8N6zLeiMjOpXMqHUBgsEbXLMa1BO+9vPDiafCl/GOHLcwhknM YJGg== X-Forwarded-Encrypted: i=1; AKwUvBwBEr+2ZxsPcJSGmBM3qqQdP7DsMqufFIIDim3Yri+bwsrHYar7xzNX4zBqqU9WaWEjSKFcDe8RnbEScHkh@lists.postgresql.org X-Gm-Message-State: AFuF++mpdueoTF3aceMIx4BVbVxh1CcuBqSOTmKn6fWhn0jpwGCz8P9d cIfo8HotnwfMYEowwep+ctQu2J9lG2YNcTE326VGfXMy27YDeWV/pUNw X-Gm-Gg: AYBFou3UjP1OqzL0JVH4waiTMlw0kiuFZmQH2wJwDhQ+/fGfwa8RavwQKhMISLHyLkX BOTDsgnXYlbxYeoO19pP/ZbLB/Wi0idlxXJMb+NMd9aC3D1cnuHG+Cn+qvp/12yl78HK3A9XA3v euNGJDfoKcnIbvHp3QcjLsrm/zqEtfFoYHEJ2xNStigUmuvld4iP1MHmN7ed+sNmcRW3Sc9PRqN 3AVw8h0dYkp2NolqHt7KFyYoFvBAlAtBJsyiBA7YBBhrCvoiwoejmWKV5IRnWjQwjMQLQTXMrZ4 YeLWp1cL3EQuuZgm5dLMYmNlkOcLU09c4QR3DH1MZw7Dtfi4YeWMbyJXD0GT33v2fgtBE7QMwS9 MOYWa+Ag/JbdjkLGcd66ChkbKos0kXbGINjf61BC+h5zH8vyeF0hl7MHMtyOqbsqRKjbteyRP84 xlnO36k8+b50TYqqlobVFXEDJl04lavDEvLLgAcKRBxN37eOvCKljkTxF+j0WYEBHJdOl8se6zL 23bEraaxlBJvPlP9cppwvMdcnywBa4zuRAJ9V/+c5hdqfOozTVLv4ufcZw= X-Received: by 2002:a05:6000:400f:b0:487:958:795a with SMTP id ffacd0b85a97d-488670838demr2433233f8f.25.1790143620537; Tue, 22 Sep 2026 23:07:00 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-488688893a0sm4385117f8f.32.2026.09.22.23.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 23:07:00 -0700 (PDT) Date: Wed, 23 Sep 2026 06:06:58 +0000 From: Bertrand Drouvot To: shveta malik Cc: JoongHyuk Shin , Amit Kapila , Rui Zhao , pgsql-hackers@lists.postgresql.org Subject: Re: Persist slot invalidations before publishing them Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Sep 22, 2026 at 03:46:55PM +0530, shveta malik wrote: > I had a look at 002 to review slotsync path, Thanks for looking at it! > + /* > + * A failed invalidation can still hold the slot's I/O lock. Release it > + * before slot cleanup acquires ReplicationSlotAllocationLock, which > + * checkpoints hold while acquiring slot I/O locks. > + */ > + LWLockReleaseAll(); > + > > Could it be problematic to call LWLockReleaseAll() inside a localized > error cleanup callback (PG_ENSURE_ERROR_CLEANUP) rather than waiting > for AbortTransaction or proc_exit? Since the goal is just to avoid > deadlock with the Checkpointer, shouldn't we explicitly release that > one specific lock? > if (MyReplicationSlot != NULL && > LWLockHeldByMe(&MyReplicationSlot->io_in_progress_lock)) > { > LWLockRelease(&MyReplicationSlot->io_in_progress_lock); > } > > I don't have an exact scenario to worry about, but it seems like > overkill. Thoughts? Yeah, it's probably better to be specific here. One concern with the proposed check is that all existing uses of LWLockHeldByMe() appear to be for assertions or debugging (as documented on top of LWLockHeldByMe()). Also, releasing an LWLock after ERROR requires restoring the interrupt holdoff expected by LWLockRelease(). Another possibility would be to make ReplicationSlotPersistInvalidation() always leave the caller acquired I/O lock held. Slotsync could then release that specific lock in a PG_CATCH() block, something like: " PG_CATCH(); { HOLD_INTERRUPTS(); LWLockRelease(&slot->io_in_progress_lock); PG_RE_THROW(); } PG_END_TRY(); LWLockRelease(&slot->io_in_progress_lock); " This would avoid both LWLockReleaseAll() and using LWLockHeldByMe() for normal control flow. Does that sound preferable? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com