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 1riZp4-000OMI-UR for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2024 12:59:39 +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 1riZp3-00CeoL-EZ for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2024 12:59:37 +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 1riZp3-00CeoD-6A for pgsql-bugs@lists.postgresql.org; Fri, 08 Mar 2024 12:59:37 +0000 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1riZp1-003RHW-13 for pgsql-bugs@lists.postgresql.org; Fri, 08 Mar 2024 12:59:37 +0000 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6e5027608a9so931474a34.1 for ; Fri, 08 Mar 2024 04:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709902773; x=1710507573; 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=PonJLfxf0hGbRSd/D3LS/yU7b0vIVswk2wtD+vXlma4=; b=elC+JCM9XARWcArP08j+YcteMk2MNc7ygIL4nqDxCDe/JjLfyxjq1we7Vi1BKTzsf8 7r9KmQBtB8NmCzpLPmoJeueofTwUMcpPLvjfCFFHIJJimDX+z3xVt6LpTCwLdlFy/W84 XhG4nFvLqqWuESRW7d0ejihk2Tx33objTf/+KWrngVeToR8L1yQA4SCHXpgI1EPrPnon xVsiYQkJQKjkDJItrtPOsekfj+STdGXrAZlJd6YnTp7KSz/gpZTFWPjHNvRpvBgH8ytM FR+bfovdMlhE6wan3+cChmz+C+UetYtB7vDdpzEDODRVGQh2XJe1L4aIZTEqdBCsxNc9 NOPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709902773; x=1710507573; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PonJLfxf0hGbRSd/D3LS/yU7b0vIVswk2wtD+vXlma4=; b=tALSeAIop4Cp21lQU5BOY8UILkxJHgnMQBH1FZplNpVY7/49odrZ9TNhu1OVX9f3rF b1LFNcfL2md3vUxrZznR+8te7FKGLg2laG3V+bp++DYSIZfGcdDNSf7Nw0YJTL+WZd0E MoDiKvYgU/3u8nLD6fMEQEL3j08k49uyNFLaGeUkkqtk6QfQ0xcEEbfP3+9q+bNvcrqg 2rZDiXP4g4+mrSQErzS2nDyqOqOJxfhI/Ly0Qger5lY9sz1BNVs0Sb3eC+4XeKUkoKyV B7pN+pHM/o4VIfT/g6kbhc3Uo9gdvAXrQGSGXjI2TE7tFLANbnvinZL+vGxqsesx3bWw jU4A== X-Forwarded-Encrypted: i=1; AJvYcCWM2FfkMJjYjeiqX7YYpgJiJtb5ykfSiZMhtmYEdMlERtyd8xgRuSWSxQ4YMQeoIBGZV+PpM+QYEW9T8tnebUERcRT+cWzuH85YWaLVz/Iz X-Gm-Message-State: AOJu0YxvnTaY4DmvYB1bBvtNR+U4R7oq24kDeiYFYxtxWDN48VWO+LOS 5SUWQEhsK6+L0SR3CnMVOdVcRcDSI+evOvgiOmUxzNf1hbaD2Oo0+mnXFQdJ/t1JSRl7HI9G/DL YCKN3QEXobt+s87FGiefDPoU/QWI= X-Google-Smtp-Source: AGHT+IFeihzUXas04ocide7LmU87vH5UJcM23DMCIJ+sXYpYqxmuiJyWuyquSA4i5Re4Frk+Ii04lAN9K6j/j+oNPjI= X-Received: by 2002:a05:6870:2156:b0:221:96fd:1465 with SMTP id g22-20020a056870215600b0022196fd1465mr1620125oae.42.1709902772901; Fri, 08 Mar 2024 04:59:32 -0800 (PST) MIME-Version: 1.0 References: <18369-ad61699bf91c5bc0@postgresql.org> <6d0e80d6.c1fc.18deeb8120a.Coremail.ocean_li_996@163.com> <45809022.60b5.18e11d304cf.Coremail.ocean_li_996@163.com> In-Reply-To: <45809022.60b5.18e11d304cf.Coremail.ocean_li_996@163.com> From: Amit Kapila Date: Fri, 8 Mar 2024 18:29:21 +0530 Message-ID: Subject: Re: RE: Re:BUG #18369: logical decoding core on AssertTXNLsnOrder() To: ocean_li_996 Cc: "Hayato Kuroda (Fujitsu)" , Alexander Lakhin , "pgsql-bugs@lists.postgresql.org" , feichanghong@qq.com 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 Wed, Mar 6, 2024 at 9:04=E2=80=AFAM ocean_li_996 = wrote: > > Thanks for your attention. > > At 2024-03-05 17:24:05, "Hayato Kuroda (Fujitsu)" wrote: > > >Dear Haiyang Li, > > > >... > >## Found issue > > > >### Empty transaction is decoded on PG14 and PG15 > > > >However, there is a room for generating ReorderBufferTxn for empty trans= actions, > >which was introduced by 6b77048e5. Conditions are: > > > >1. There are sub transactions which modify only temp tables, and > >2. the top transaction modifies the catalog. > > > >The call-stack toward the generation is below. > > > >``` > >ReorderBufferTXNByXid(create =3D true, create_as_top =3D true) > >ReorderBufferXidSetCatalogChanges() // for sub transactions > >SnapBuildXidSetCatalogChanges() // for top transaction > >DecodeCommit() // for top transacti= on > >``` > > > >The path has been introduced by 6b77048e5. > >Previously, calling ReorderBufferXidSetCatalogChanges() for sub transact= ions > >would be skipped, if they do not have catalog changes or they have not d= ecoded yet. > >However, the commit ensures sub transactions must be marked as containin= g > >catalog changes, and this also enforces to decode transactions even if i= t is > >empty. > > > >### Assertion failure > > > >The empty transactions would be created as top transactions. At that tim= e, > >AssertTXNLsnOrder() is called so that we ensured that first_lsn of top-t= ransactions > >must be strictly higher than previous. But they can be the same if there= are more > >than two empty transactions. It led an assertion failure. > > > Your analysis is correct for me. Actually, I mentioned in [1] that I can= reproduce this issue before 6b77048e5. > After some attempts and analysis, I also believe that the issue will only= occur after 6b77048e5. > > > ... > > > >## Possible solutions > > > >I think there are several solutions. > >Note that I assumed here that fixes for all the versions should be almos= t the same. > > > >* Ease the condition in AssertTXNLsnOrder(). If the decoded transaction = is empty, > > it can be allowed that the first_lsn is same as previous one. > > PSA file to see my consideration. > LGFM. For my observation, the most case failed on AsserTXNOrder is check= ing empty > decoded transaction. Maybe we should pay more attention to review Reorder= BufferTXNIsEmpty. > > >* Generate a ReorderBufferTXN as sub transaction when we are in this pat= h. > > The approach has already been shared by you. However, note that this n= eeds to > > extend the ReorderBufferXidSetCatalogChanges function, and breaks ABI > > compatibility [1]. > Yes, It breaks ABI compatibility. > One possibility is introducing ReorderBufferXidSetCatalogChangesEx, a new API with a bool parameter. I don't know if this is a good idea but I prefer not to tinker with asserts as proposed by Kuroda-San in another approach. --=20 With Regards, Amit Kapila.