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 1wfZo4-005WS7-0u for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 09:03:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfZo3-006Pf7-0F for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 09:03:31 +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 1wfZo2-006Pey-2Q for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2026 09:03:30 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfZo0-00000001RJP-0CYn for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2026 09:03:30 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-493b27c7451so13919085e9.0 for ; Fri, 03 Jul 2026 02:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783069406; x=1783674206; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=88hXd9t1yy1nm1+DXNKfXzkgQIMOFX+YjyFgA140A/k=; b=UKVDzUTt5rBML70uVRgF/kgJeayIj4HfiCWe/ggYwlnXULHzNi/UOtOnrjfRP160+4 EL+FC0MfByS1CEPappNZ7aD4Z3f4gaI8MAZGB2JqF5ylPDH/caBZAIo8hod2ky+8EFL4 DTjDtYvglas7jhXH2mZvcNe1JOkLNuLAouQX/zvsFI+bZceT47BJEeopSz5JSwMGjSTO YmLcYX5vG1bqRNXiAJDd4QjhLoRrN8BPIS2Kzs0d5wDYJut7YCTZNwFQ1VLn5q7VCAQs TuJTFYfDAGDvoi8hzWBo0LLvsbp99HXKiEyrI0ARVFzOTvu4Wqp+/d13vs0MkK9/W2cb uxKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783069407; x=1783674207; h=in-reply-to:content-disposition: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; bh=88hXd9t1yy1nm1+DXNKfXzkgQIMOFX+YjyFgA140A/k=; b=hLLK1c5KKru4MMtWoXcBllIa4PPv3zR0AI7AUZcK+Je9JT2UcvDX49eEc4Cti6GtxO zrhl+bsWiD4bhzckCpqcgfB8TXw4ArEMaurtLE2zEI1ekK5B7us+Yi8OAWGrCP3Rk5LU uYtVDxH/gCvyc4VSuU+J5cJ+D2MlggKOdVYTA5dD1Fe5QGlv8GoCmHGSCTQFWx/75v18 gI5EmdgyHfBeQ2WYDWmImhxo87au0MGNj0ic5HT/5EyyAC2C/TCKD5DjwtlcqqKQgxfm K7rAR/8pKDdP6FKOuYqJSk/0ZOKbdIbhMxADA90bKOx5fyn8cJtrLhygOQTrY/h4mVyM 7h4w== X-Forwarded-Encrypted: i=1; AFNElJ/MoGTfTxcLSw2weW8dlIU4rn+J0chKg03dPdbxp95vDULbXX/kyfLX+R/9S4E6RNkjeD+N6fwRuV8Dy9Gt@lists.postgresql.org X-Gm-Message-State: AOJu0YxmUCh+xf85m9HSvnG0xFgyYD/w1e2XnMudZyNM+q/JYmqmFecc cju3aX/5uJ643F6es/vA3ype2GX5NHgC2XW8yzyZFCgchgwqwAfEmeur X-Gm-Gg: AfdE7cnkFQCBFO/NapJ6ieB11rZjZhTv7It12ar7iI5mw6GuI7YAZYZs788SenJUYMP m18EMR/Afn1cR56I657uQrlTPK83Td6GyxhWhqy+4Hp83kKD8PCDk40LEZhRFBxK3FLKhm4UDqn qQFFVyO79W+A8iHlZWvbbSvxQawK8Mk/eyDqf0kXXmYL1Xd65P+g5ckctmVw4qkNdExwAuSUwwm srTs/a5IwsF1ENP4F3fvka7R36+02e58OFL1W4q1lRSo2jZkImYZcbYWf6ux/1nvA7/ZQzRAE7C 4h5q1SIQXK3RB+aNwz2dgMvuwESvgssTzaRDC4le6noI7uh4t94Ys8Wwej6/43QfMvsdZ27iblk ewU/4BO50qWBupZb/LRzlWSBqeL0lanGICsOGRBuhfMaHsAjt60apM+XCB8YkXgHJvcfljze+5/ 8fE7MO6zNrzu5uq5p9ZV3D7yG2nP4TMjDtHu1PdCH4LyTJoE2xb7H2K+X0VSb4bgz0K2zW3gqv X-Received: by 2002:a05:600c:3e19:b0:493:c566:7bd6 with SMTP id 5b1f17b1804b1-493c9b6cdbdmr41781025e9.18.1783069406192; Fri, 03 Jul 2026 02:03:26 -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-477dd94c8ccsm17218917f8f.21.2026.07.03.02.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 02:03:25 -0700 (PDT) Date: Fri, 3 Jul 2026 09:03:24 +0000 From: Bertrand Drouvot To: "Zhijie Hou (Fujitsu)" Cc: Dilip Kumar , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@lists.postgresql.org" Subject: Re: Re-read subscription state after lock in AlterSubscription 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 Fri, Jul 03, 2026 at 08:08:13AM +0000, Zhijie Hou (Fujitsu) wrote: > On Friday, July 3, 2026 1:53 PM Bertrand Drouvot wrote: > > > > That said, what about also fixing DropSubscription() like in the 0002 attached? > > (that would also produce those elog() messages in case of concurrent DROP or > > ALTER). > > For the patch, I'm not sure if we must repeat the checks twice. Thanks for looking at it! > Could we > simply move the original checks to after we take the lock? At least, the > GetSubscription() call and the password check can be moved there and old codes > can be deleted. I'm not sure which checks you refer to. The ones that are keep before the lock acquisition are because we don't want to lock an object we don't have privileges on (see remark 3 in [1]). > BTW, this may not be strictly related, but I think it's not safe to do the > ownership check before locking the subscription as well. If the subscription is > concurrently dropped, a "tuple concurrently updated" error can still occur. That's right, I explained why in remark number 2 in [1]: " the ownership check is intentionally not re-done after the lock because AlterSubscriptionOwner() does not take AccessExclusiveLock on the subscription object: it only takes RowExclusiveLock on the pg_subscription catalog table. This means ownership can change regardless of our lock, making a re-check after lock acquisition pointless. The existing "tuple concurrently updated" error from CatalogTupleUpdate() already provides a protection if ownership changes concurrently. " Does that make sense? [1]: https://postgr.es/m/akZUpiDa1UfmzYxL%40bdtpg Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com