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 1wjppC-000JqC-27 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jul 2026 02:58:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wjppB-005rPj-0p for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jul 2026 02:58:17 +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 1wjppA-005rPa-34 for pgsql-hackers@lists.postgresql.org; Wed, 15 Jul 2026 02:58:16 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wjpp8-00000000JHR-3928 for pgsql-hackers@postgresql.org; Wed, 15 Jul 2026 02:58:16 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-38101f85591so166297a91.1 for ; Tue, 14 Jul 2026 19:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1784084292; x=1784689092; darn=postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :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=wVJsWJbGstukoBZ9DJYFoBv3jApY4rJiH3NgPJVi/tw=; b=DKa9D/XzNM1aTgt7SoGQ3OlxnAL/nda9LQs8JGmlzg5JypQ+jPnuk7VWcvLUujSbQ2 gcTAqkYtM1qHxGeS4FBDgZf2MJWlcnELhLT0EtT+gMnvXBWEUaxioRDf68/mlO5vHsJV 7rxhJCYtG3CA0jrDryJGXN5iKHEqFxyMFBMz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784084292; x=1784689092; h=user-agent:in-reply-to:content-transfer-encoding :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=wVJsWJbGstukoBZ9DJYFoBv3jApY4rJiH3NgPJVi/tw=; b=WmLdDlUiaAqcYLurQ+SwG9SX0dQGL92VLU3wUAf/WkG+vLmBM3X5MAF7jyitumGIJo AHATiK9PMnFeSGsPz9Uy20EtBsbJM1XACeOzqK6JWU1BfaQ/EF3NLOhd+ftl2kHtzEEA OCyUCTduHidwalr+yQXJ73V8oLFgRjAgjznTQ2WIuSK4mjXU5Zt5LmIceFPkOAPKzqr4 R+eJMGDRP7zZi/n+Pbb90kTuZ5v+R2UyQdISzNO3TuTlxIhOrEZS4IcZrhf1PPWSBoiV rCMZsl/gMxhJh0SGcebvDoc08c+ibOUQNNA1Pora0srCrqv3sm7JHoc8PSsHW7ZctOz2 +WTw== X-Forwarded-Encrypted: i=1; AHgh+RqY8V/Y86mjuV7HMni2UNbGfs/oLhTp3eVDPiL+3O8IT3aYWctrL8tohJelNJsy5SLJSy5CfZVYuXbCV6KZ@postgresql.org X-Gm-Message-State: AOJu0YyIHLHr3sx3IqcAJwAF3mzhe55Fi+8kFMM2rpq70Wry3z5KWumL CYJi19cNpw8zWFEcr6Eef/I85aBgji4L8aCtfdktPf6xbyf1cXBrsmwQxuX7zusnFg== X-Gm-Gg: AfdE7cnVcN5d05+YNufUH9cDmF4Bf91bc1RqSD5pbTLBxuMF1MbsT9aSGj/QKmrjWuR Op6ZSiR2z/tKOMhDE9xbqL/j8SZWUzv5GnZNYOCQZ8CwUHZlgbs86izE2vlRtNs+u5a/kVBFOCv yng5/JQk6gh8UwqyrncP19OTsNJ8CXcqXUrqbPhKrIyTJPrzJQK5GPwcfYKW8HrL44WjaivtjUH LaYHiUF4ygxIk1iRImKDFFDRdFysF6YUbkDeJQyaGgOLASCdwf5p82iMht/oTQeQ9Lo7snIltUc YVA/q7ESKN2Qg9Cx9v63r4uQdQc/mXDRzww+Y05unfxGgdsQCOW0Mt0TC/Rg4XB4COW6TNwn+3u SPkunTrFzZjv2i1NxvHHJW7P2kEsyNlhoASAxhVvAaJDEc6qO8k0GwCLRMnnwIagoBc4kMz+NYY Wxb9y1FMwC0LADMkQ1sPYwBX/4qOqj75YNh+uyd5wSQDAm X-Received: by 2002:a17:90b:2fc6:b0:387:d9cc:7dc3 with SMTP id 98e67ed59e1d1-38d16190945mr19630779a91.21.1784084292240; Tue, 14 Jul 2026 19:58:12 -0700 (PDT) Received: from microsoft.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-313b4cbafa1sm84418316eec.6.2026.07.14.19.58.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2026 19:58:11 -0700 (PDT) Date: Tue, 14 Jul 2026 19:58:09 -0700 From: Noah Misch To: Amit Kapila Cc: vignesh21@gmail.com, pgsql-hackers@postgresql.org Subject: Re: sequencesync worker race with REFRESH SEQUENCES Message-ID: <20260715025809.cd.noahmisch@microsoft.com> References: <20260710045217.f0.noahmisch@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.3.0 (2026-01-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 13, 2026 at 03:37:54PM +0530, Amit Kapila wrote: > On Fri, Jul 10, 2026 at 10:22 AM Noah Misch wrote: > > Fable 5 also wrote a lot more that neither it nor I confirmed by test case > > construction. I'm attaching the report; feel free to disregard. Finding-2 > > about default_transaction_read_only=on looks worth fixing if true, > > Agreed on Finding-2 as well. The issue is that the sequencesync > worker sets the value via SetSequence(), which calls > PreventCommandIfReadOnly("setval()") for non-temp sequences, so with > "default_transaction_read_only=on" on the subscriber the worker's > transaction is read-only and sequence sync fails and never reaches > READY. Table apply is unaffected only because > ExecSimpleRelationInsert() bypasses the executor's > ExecCheckXactReadOnly() path which is an undocumented, untested detail > rather than a stated guarantee. > > For a minimal backpatch, we can force the sequencesync worker to run > read-write (e.g. set default_transaction_read_only=off for its session > at startup) so it matches table apply, plus a test that sets the GUC > on the subscriber and verifies sequences reach READY. Separately, it's > worth documenting that logical replication apply is exempt from > default_transaction_read_only — it's a per-transaction default meant > to guard user writes and never makes the node physically read-only — > and making that exemption explicit for all logical replication workers > so tables no longer rely on the bypass. What do you think? I wouldn't document those things. default_transaction_read_only just has the user write "BEGIN READ WRITE" instead of plain "BEGIN". Hence, it's more like an "are you sure?" prompt than a restrictive guard. It's no surprise that logical replication apply achieves the equivalent of BEGIN READ WRITE; I don't see that outcome as an exemption. If easy, I would have the worker do the C equivalent of "BEGIN READ WRITE" instead of actually changing the GUC. That makes it clear exactly which areas are overriding the default. But changing the GUC is fine.