Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSuMq-0007ll-JP for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Dec 2017 00:42:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSuMp-0003Ah-LU for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Dec 2017 00:42:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eSuMp-0003AX-73 for pgsql-hackers@lists.postgresql.org; Sun, 24 Dec 2017 00:42:15 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eSuMh-0005vU-Pr for pgsql-hackers@postgresql.org; Sun, 24 Dec 2017 00:42:13 +0000 Received: by mail-wm0-x22a.google.com with SMTP id g75so27786995wme.0 for ; Sat, 23 Dec 2017 16:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=l0INlAqWE3Ps/OBv2tGY4ENvB4lb9bKemK98T0aMZX8=; b=i/IxqArzPGjTwcFjokTq8TmE319YmekV2s7nmv3KWdpygMNiO/P1Yg+5MfCiVs7XjW xyJhmvVn/2YnAarX/UuzYETYRBv0EZ7jHyXGijjixzTSY6/F8iaIY9SOHE6wneXhFxRf /qWLTre/2BuilYKUW5yBJAPP/alpKzuWbvVcuYdx0vXx+zy27o10usKrxU+xNVtZ6Wuj A3y/Vvqcl9BznzQiajuZKNURhZmpHzWvy8WqNQtxFUSzHWYHZ+S9mhyiPwqOoKDeoX0G ckUd3lIbS5GaYMOkEr03sVorWyMXMj4IZcfy/3D/DPT8T9fF7f2ei8rKMPYoWnYxnIr3 xXuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=l0INlAqWE3Ps/OBv2tGY4ENvB4lb9bKemK98T0aMZX8=; b=O4DwB01+zhwkJLsiD6dfxtucGk4v96+uCjcfh3WVJ02lEbeGzrKh81K5b6sYV7o0Xf z5fAtacuYUIYZUStAHeI9VwHWz4EbRihguMdX1YNP/p7Hbrf01Q31hoM4j2ntwtLDJa1 OoahNURsFDhQ8FLWuYJ/f7Z/BDsoN8O0S90AhUXBPCF3J4f4oLg9QgeMkg6+xtZX4wHv PVsNbAQv0meHZV53PcfUfBSlvvfXybXto5EnXRhbsFnLPve76/7Y277TzJHha8VyGeQJ d1D41kpoy/Zmvk+oECbq2geoV3CZCY/M87X+NYDDlcOTMVTUD6+E8SFWUQSj3e0qzPjg Yvfg== X-Gm-Message-State: AKGB3mJTZad7PpsObkOFBW5yEdu0lB6EMrc9N837Ad7cYsuC/q4VfVJ+ yUUvOK/y7ai6oDYPCIS2ZiC0iBD47T+vNzjcmMZhhwou5UKcvERmDmOK4H1LkV5udjMZ+AOdwU6 Iv1jm5X+bpHEzatCcxqswZfVoClckbPOY3yXemQbE1is/ZCfOrknhLDinFGKphUSN7E+zAhb0kv FiHUcz96TB X-Google-Smtp-Source: ACJfBovw3GXVxjB+p+4BVt/15ZuQEV3mpqU+eFeiAegqjyOkHy1ufWqAn6WceULo024hU1bYCqQCKw== X-Received: by 10.28.65.65 with SMTP id o62mr16828768wma.112.1514076124518; Sat, 23 Dec 2017 16:42:04 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id i17sm11396993wrf.71.2017.12.23.16.42.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Dec 2017 16:42:02 -0800 (PST) Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions To: Erik Rijkers Cc: PostgreSQL Hackers References: <688b0b7f-2f6c-d827-c27b-216a8e3ea700@2ndquadrant.com> <1cc7daa2-027e-d490-2396-96e16d328c45@2ndquadrant.com> From: Tomas Vondra Message-ID: Date: Sun, 24 Dec 2017 01:42:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/23/2017 11:23 PM, Erik Rijkers wrote: > On 2017-12-23 21:06, Tomas Vondra wrote: >> On 12/23/2017 03:03 PM, Erikjan Rijkers wrote: >>> On 2017-12-23 05:57, Tomas Vondra wrote: >>>> Hi all, >>>> >>>> Attached is a patch series that implements two features to the logical >>>> replication - ability to define a memory limit for the reorderbuffer >>>> (responsible for building the decoded transactions), and ability to >>>> stream large in-progress transactions (exceeding the memory limit). >>>> >>> >>> logical replication of 2 instances is OK but 3 and up fail with: >>> >>> TRAP: FailedAssertion("!(last_lsn < change->lsn)", File: >>> "reorderbuffer.c", Line: 1773) >>> >>> I can cobble up a script but I hope you have enough from the assertion >>> to see what's going wrong... >> >> The assertion says that the iterator produces changes in order that does >> not correlate with LSN. But I have a hard time understanding how that >> could happen, particularly because according to the line number this >> happens in ReorderBufferCommit(), i.e. the current (non-streaming) case. >> >> So instructions to reproduce the issue would be very helpful. > > Using: > > 0001-Introduce-logical_work_mem-to-limit-ReorderBuffer-v2.patch > 0002-Issue-XLOG_XACT_ASSIGNMENT-with-wal_level-logical-v2.patch > 0003-Issue-individual-invalidations-with-wal_level-log-v2.patch > 0004-Extend-the-output-plugin-API-with-stream-methods-v2.patch > 0005-Implement-streaming-mode-in-ReorderBuffer-v2.patch > 0006-Add-support-for-streaming-to-built-in-replication-v2.patch > > As you expected the problem is the same with these new patches. > > I have now tested more, and seen that it not always fails.  I guess that > it here fails 3 times out of 4.  But the laptop I'm using at the moment > is old and slow -- it may well be a factor as we've seen before [1]. > > Attached is the bash that I put together.  I tested with > NUM_INSTANCES=2, which yields success, and NUM_INSTANCES=3, which fails > often.  This same program run with HEAD never seems to fail (I tried a > few dozen times). > Thanks. Unfortunately I still can't reproduce the issue. I even tried running it in valgrind, to see if there are some memory access issues (which should also slow it down significantly). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services