Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9SP2-0001dg-Iu for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jun 2023 15:27:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9SP0-0006HA-OW for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jun 2023 15:27:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9SP0-0006H1-EE for pgsql-hackers@lists.postgresql.org; Wed, 14 Jun 2023 15:27:18 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q9SOw-002M0C-Lc for pgsql-hackers@postgresql.org; Wed, 14 Jun 2023 15:27:17 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9768fd99c0cso165222566b.0 for ; Wed, 14 Jun 2023 08:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1686756432; x=1689348432; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=NvKm+PNgueh/RwPd/YMvw/o50+W36hGFOZYH/LXnPCo=; b=AV2nImCeJJyYiQ0LGuIR4PzKnLHhf2urht0UAxkFr/eGTKRMBk2oUpFY52tX6ruJpf OpvrQC0rentQTNPR3rUX9VJuKNuYG+AuSRCWI9lpreyH7g8ZUgELM9ZGwIcOMBkDSBTU vvgOLNUX2OanbxFwden2luDOuJ908Rju+1Oxda0ZVMTZvA1Ok3aeDW3jfw9xZJHtobyo SJXY7DroVE/7vbAl3CTu6xW/H/5SJPKG7/0L249JIPxmWcvnshBTZ/T02xSD+krQeGCV g5qMiK0LFcn7yf2Vu/z5AF8iFxuk8jNyOOLayWRpO/2YiXN3i0UllPwXciGeA+Ig2Kee xO4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686756432; x=1689348432; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NvKm+PNgueh/RwPd/YMvw/o50+W36hGFOZYH/LXnPCo=; b=bSU5hKzhRmDUihm3EbQySIiwKJLTsZO6LWPubbhKk902JUhv6aTTkWywJ8OAIQKrBB ZpxXWTFkZt0RSi0yFCy8L5RNrFO/NCFGmNxh4kZlz8RgPQ/CxYwroHPD7fVIk0M/t5FS 04uPlHPgInQx+5Ik5LZjQflQo+0EHPZmNT46NBbUQG2Ca6wWzHq2aM/ud+N2hAHeBqr1 7o+C6PQ2ypvogyrH0c4jZmegwGemh39BQXQKSqL3m9kycPqQ+V+/VHU9BKB1HuK6HcJl ygFkm8AoC6uhWBWP0716pJzIHnjOU/lmgsuUOO7XyCrkYw0PGoy6H/3ktYWvfhR0lMZp BP0g== X-Gm-Message-State: AC+VfDxB/OSYyFGUtqTvrx0M5zJ1tAGRYK38Lu+BTqjEuZOpWHUmwOVj dgnppXxCbIKnrYXAO6N+iJpquw== X-Google-Smtp-Source: ACHHUZ6+NJlZbRNEzM17ALC7N3oyLX351CgOYTfnhbnaKA1+em6oioNMYJ1K5ZIylZZUG4DqExuWtg== X-Received: by 2002:a17:906:6a0d:b0:932:f88c:c2ff with SMTP id qw13-20020a1709066a0d00b00932f88cc2ffmr2064628ejc.34.1686756432187; Wed, 14 Jun 2023 08:27:12 -0700 (PDT) Received: from [10.137.0.17] (static-84-42-175-93.bb.vodafone.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id kf10-20020a17090776ca00b00965f6ad266bsm7994224ejc.119.2023.06.14.08.27.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jun 2023 08:27:11 -0700 (PDT) Message-ID: <07301efe-2f6f-145c-dbfd-20991c89f586@enterprisedb.com> Date: Wed, 14 Jun 2023 17:27:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: TRAP: FailedAssertion("prev_first_lsn < cur_txn->first_lsn", File: "reorderbuffer.c", Line: 927, PID: 568639) Content-Language: en-US To: "Zhijie Hou (Fujitsu)" , Amit Kapila Cc: Alexander Lakhin , Masahiko Sawada , pgsql-hackers References: <99b45770-e3d8-4522-ea52-f4509931c65b@enterprisedb.com> <1f860e40-9f95-f0f8-ff4b-4b780f9151ad@gmail.com> <45567656-fb0e-c844-48fb-f4c2a54dc2af@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/14/23 15:39, Zhijie Hou (Fujitsu) wrote: > On Wednesday, June 14, 2023 5:05 PM Tomas Vondra wrote: >> ... >> >> Also, can you try if we still stream the partial transaction with >> create_logical_replication_slot building a full snapshot? > > Yes, It can fix this problem because force create_logical_replication_slot > build a full snapshot can avoid restoring the snapshot. But I am not sure if > this is the best fix for this for the same reason(it's costly) mentioned by > Amit[1]. > Costly compared to the current behavior? Sure, but considering the current behavior is incorrect/broken, that seems rather irrelevant. Incorrect behavior can be infinitely faster. I doubt it's significantly costlier than just setting the "full snapshot" flag when building the initial snapshot - sure, it will take more time than now, but that's kinda the whole point. It seems to me the problem is exactly that it *doesn't* wait long enough. I may be misunderstanding the solution you proposed, but this: One idea to fix the partial change stream problem would be that we record all the running transaction's xid when restoring the snapshot in SnapBuildFindSnapshot(), and in the following decoding, we skip decoding changes for the recorded transaction sounds pretty close to what building a correct snapshot actually does. But maybe I'm wrong - ultimately, the way to compare those approaches seems to be to prototype this proposal, and do some tests. There's also the question of back branches, and it seems way simpler to just flip a flag and disable broken optimization than doing fairly complex stuff to save it. I'd also point out that (a) this only affects the initial snapshot, not every time we start the decoding context, and (b) the slots created from walsender already do that with (unless when copy_data=false). So if needs_full_snapshot=true fixes the issue, I'd just do that as the first step - in master and backpatches. And then if we want to salvage the optimization, we can try fixing it in master. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company