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.94.2) (envelope-from ) id 1sMQo7-002JGp-0i for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Jun 2024 11:27:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sMQo5-003k6B-AL for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Jun 2024 11:27:21 +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.94.2) (envelope-from ) id 1sMQo4-003k63-Vu for pgsql-hackers@lists.postgresql.org; Wed, 26 Jun 2024 11:27:21 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sMQo1-003dnR-SM for pgsql-hackers@lists.postgresql.org; Wed, 26 Jun 2024 11:27:20 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-364ff42999eso5204406f8f.3 for ; Wed, 26 Jun 2024 04:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1719401236; x=1720006036; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bg6MCsFkXgyL4xih2aTK3KH7HpSSHLYs/0948IDhnAU=; b=HdiFGmcxlTUPiI0Nk/sSQ5nH4pNFkAsG6+VMmnfmoUvXCzXj6ponbkwpuGxhQuiN5s CgXaLAQs56i4cmRpeMDLI/qkA/j6QRpwZXz+dnwfqUzD0zu4uNM+l+JZAEpezH8Dc2j5 bGXWQGEEVOmQW1+xSVCRKVeJT46gv4vMVBbwCKWjUCEbKy3k9Nno/eT6Vp3b8usu6v6U Xjj+Ml8pX66oVQFCCNxAZf99Ft1QTcJYQ2MZHljRXiq1AXLxWRBLDKbpQPhnNB8kmeMo u1z05vA0iaMFCkCtPepBVvLg9L0JpQspIJUfuHTU0T/TeMiNeqteke35lcmaIITakdBv 5kBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719401236; x=1720006036; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bg6MCsFkXgyL4xih2aTK3KH7HpSSHLYs/0948IDhnAU=; b=lTscufflrknI3bNiUcQGVB5TDzf4u15KzWdVPdDIFoQsQ29S45Q/KeQTJ6tRmdogIR eFyH2Z0fz+KapNeaBF12x8LlwioJX8XH7rv2NC5DYj63xooJQU3fBHjXAztZ1ix4myfG dcqHF46UGgLY37DQ4fmU2B2SsX+FhiKrPl8noNsg3syAsI55qAOpy/ccgieeQpvsSqA7 hSRCANxS1t99IXJuA91t6ZSLniZeM8u32lnhtazd638+0E1g+AlLP/hl58IK1VTkIOby 98rPBnpgfAQXWLFfmntt/rg6SQHETet/aoRJoSAoXkRhHI/Mr9cgx1PnCV5dzE1+Lcn/ Gafg== X-Forwarded-Encrypted: i=1; AJvYcCXQa+7DbXdkhDz9kUQZPVlGNeUz1VUqQawg3mA49bay3Q2KD8YvR6TyCclstLH5pEb6PCTEl4NZH/eiY8YQN+Dz1GZViMI7EE8O4hCmnn5xoeVU X-Gm-Message-State: AOJu0YzTQA7DFCL1zUUHR/0ymQN1dG+QlIy4/V+KqqZpOYRPcENooRbS 3IXZ8rYniliDnHOGWB5tv5cGDZkMcOxK1uXSo9Dv9AuZ2u0wZSeehCivnZtp7W2cEw+2yTtB1LV Szg== X-Google-Smtp-Source: AGHT+IE0Jd9zRJ9IFg+rqf2/2/33h10cRE9mjjvvba4iNykin/W9B1EOyPd2IjSVLmoDJrme23CE4w== X-Received: by 2002:a05:6000:182:b0:366:ddb6:a067 with SMTP id ffacd0b85a97d-366e94a21bbmr7718571f8f.20.1719401236125; Wed, 26 Jun 2024 04:27:16 -0700 (PDT) Received: from [10.137.0.18] (10.218.164.109.static.wline.lns.sme.cust.swisscom.ch. [109.164.218.10]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366383f667dsm15340489f8f.16.2024.06.26.04.27.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jun 2024 04:27:15 -0700 (PDT) Message-ID: Date: Wed, 26 Jun 2024 13:27:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: long-standing data loss bug in initial sync of logical replication To: Amit Kapila Cc: Andres Freund , PostgreSQL Hackers References: <20231118015443.sfxfbr4eqolxbmjc@awork3.anarazel.de> <20231118025445.crhaeeuvoe2g5dv6@awork3.anarazel.de> <49958b83-009a-9360-2969-ea42cd15fff7@enterprisedb.com> <20231118181257.qtebsnkrzj3icg36@awork3.anarazel.de> <3c5ad91c-330a-0c5a-974a-da3801ffc18b@enterprisedb.com> <20231118210519.yborkczu2aln6zdd@awork3.anarazel.de> <5cc4bbc8-b2ad-3e6e-9878-cef8ddde8ffe@enterprisedb.com> <20231119021830.d6t6aaxtrkpn743y@awork3.anarazel.de> <571f7387-edfa-4733-a335-ccce7ce01574@enterprisedb.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/25/24 07:04, Amit Kapila wrote: > On Mon, Jun 24, 2024 at 8:06 PM Tomas Vondra > wrote: >> >> On 6/24/24 12:54, Amit Kapila wrote: >>> ... >>>> >>>>>> I'm not sure there are any cases where using SRE instead of AE would cause >>>>>> problems for logical decoding, but it seems very hard to prove. I'd be very >>>>>> surprised if just using SRE would not lead to corrupted cache contents in some >>>>>> situations. The cases where a lower lock level is ok are ones where we just >>>>>> don't care that the cache is coherent in that moment. >>>> >>>>> Are you saying it might break cases that are not corrupted now? How >>>>> could obtaining a stronger lock have such effect? >>>> >>>> No, I mean that I don't know if using SRE instead of AE would have negative >>>> consequences for logical decoding. I.e. whether, from a logical decoding POV, >>>> it'd suffice to increase the lock level to just SRE instead of AE. >>>> >>>> Since I don't see how it'd be correct otherwise, it's kind of a moot question. >>>> >>> >>> We lost track of this thread and the bug is still open. IIUC, the >>> conclusion is to use SRE in OpenTableList() to fix the reported issue. >>> Andres, Tomas, please let me know if my understanding is wrong, >>> otherwise, let's proceed and fix this issue. >>> >> >> It's in the commitfest [https://commitfest.postgresql.org/48/4766/] so I >> don't think we 'lost track' of it, but it's true we haven't done much >> progress recently. >> > > Okay, thanks for pointing to the CF entry. Would you like to take care > of this? Are you seeing anything more than the simple fix to use SRE > in OpenTableList()? > I did not find a simpler fix than adding the SRE, and I think pretty much any other fix is guaranteed to be more complex. I don't remember all the details without relearning all the details, but IIRC the main challenge for me was to convince myself it's a sufficient and reliable fix (and not working simply by chance). I won't have time to look into this anytime soon, so feel free to take care of this and push the fix. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company