Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1foFRq-0007cZ-S4 for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Aug 2018 21:59:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1foFRp-0005vO-5q for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Aug 2018 21:59:53 +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.89) (envelope-from ) id 1foFRo-0005ut-RQ for pgsql-hackers@lists.postgresql.org; Fri, 10 Aug 2018 21:59:53 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1foFRl-0003MW-CT for pgsql-hackers@postgresql.org; Fri, 10 Aug 2018 21:59:51 +0000 Received: by mail-wr1-x442.google.com with SMTP id r16-v6so9430010wrt.11 for ; Fri, 10 Aug 2018 14:59:49 -0700 (PDT) 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; bh=T9oKugBBUJes2QzwcoDwJp+AQb9XTGoBhU5MFx3CjnU=; b=mDPXbyh/J+VUOMcoAYMrig7GlH+QzxcXAjaBS2t7rI/iA1hgMoJy4SfgD6Sfii08sd 68MioTUfRpzwA8Q6M2c7AEgv3vFaSEOnb043myveRjb3LR3/uW4TK/PZYyG1jdKNA+kF BjL9+ABbrW6I6jR6FKvAzEND1kS7BHduSRdd+2CYMwQPDdvW6JaxIgIayRWSuQJ7pQZZ WFV4k7H/a5+EquO7oj2JBdczHssVOFE2tlYZE3FHGAIJ62Utz8SLLz3etQherFGzFbIp jn/xkA2lLUVfZOemTwMobmWHbFs2yb/GbvH63VoxtiXYSDiqZjlinrkCttYLs1n8DnFA /N7Q== 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; bh=T9oKugBBUJes2QzwcoDwJp+AQb9XTGoBhU5MFx3CjnU=; b=PdYT2vtccoB+se+kn2fRH7yKOBubhrZ1D8JT+oqtiUyV8RbpcYkfJgNLllCmbaOXaI LRb4cYwjySh6lPoRW/hFgqnR3WUmshywHfH0AuX7GPhZlbXh3pTY1yWG2IepKSiOwJdw wGjiKhvRPCXQhjG0JLmUzvCAhkVV0qzu2E7EEKqqXN8CsnxrpsQ1h1Oe0Lcq/n1SdVEt Ks6kstojomNP5tH3rfUX1rc0PHelGz2aodK9R3mEkMH6zcMQiNxd1pTD5Ete1dINKG/i fmvuQbw9i0gw7P3TusprroDspJXnmDtdQ5gmoHaveVcXDnY8Y5b9Ji6qdwiyqW1TGYVJ e3ng== X-Gm-Message-State: AOUpUlH/ReLe6s7IN7b/lMrcIYmJi6RiqOmucT5Wt8Ic8OM7xjq3MAX2 gnVhUnU8AbwoJQfGZUWAHsbmKILRMlK3ufc99BtJ0ZWPix4N7DY+i097LwYYetvVMdZdZ8A+uwf XqYWxSlSIBMTwwBTORA18e0Oe7lgcJ13JIHMduXAIwFiU3ztZkj5ggMq32QPH6dykCkxKsO8v02 m2dhkDdn7AZlI= X-Google-Smtp-Source: AA+uWPxNRBzQtOkQtsIpGmFdRjs5XR/NVmepTI0nOAyDD1bn6mdNQIwnqv5PhrjKRgbBJwH/Dk4EyA== X-Received: by 2002:adf:e14a:: with SMTP id f10-v6mr5051018wri.42.1533938387348; Fri, 10 Aug 2018 14:59:47 -0700 (PDT) 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 139-v6sm5261046wmp.4.2018.08.10.14.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 14:59:46 -0700 (PDT) Subject: Re: logical decoding / rewrite map vs. maxAllocatedDescs To: Andres Freund Cc: Alvaro Herrera , PostgreSQL-development References: <20180809174746.aa6rbpsu4zjipzif@alvherre.pgsql> <20180810211340.nlgyfa7jlmkjcs5m@alap3.anarazel.de> From: Tomas Vondra Message-ID: <470adb65-5101-4659-d213-41bde1eef8f2@2ndquadrant.com> Date: Fri, 10 Aug 2018 23:59:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180810211340.nlgyfa7jlmkjcs5m@alap3.anarazel.de> Content-Type: multipart/mixed; boundary="------------F2DB936F310C963357B84CC7" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F2DB936F310C963357B84CC7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 08/10/2018 11:13 PM, Andres Freund wrote: > On 2018-08-10 22:57:57 +0200, Tomas Vondra wrote: >> >> >> On 08/09/2018 07:47 PM, Alvaro Herrera wrote: >>> On 2018-Aug-09, Tomas Vondra wrote: >>> >>>> I suppose there are reasons why it's done this way, and admittedly the test >>>> that happens to trigger this is a bit extreme (essentially running pgbench >>>> concurrently with 'vacuum full pg_class' in a loop). I'm not sure it's >>>> extreme enough to deem it not an issue, because people using many temporary >>>> tables often deal with bloat by doing frequent vacuum full on catalogs. >>> >>> Actually, it seems to me that ApplyLogicalMappingFile is just leaking >>> the file descriptor for no good reason. There's a different >>> OpenTransientFile call in ReorderBufferRestoreChanges that is not >>> intended to be closed immediately, but the other one seems a plain bug, >>> easy enough to fix. >>> >> >> Indeed. Adding a CloseTransientFile to ApplyLogicalMappingFile solves >> the issue with hitting maxAllocatedDecs. Barring objections I'll commit >> this shortly. > > Yea, that's clearly a bug. I've not seen a patch, so I can't quite > formally sign off, but it seems fairly obvious. > > >> But while running the tests on this machine, I repeatedly got pgbench >> failures like this: >> >> client 2 aborted in command 0 of script 0; ERROR: could not read block >> 3 in file "base/16384/24573": read only 0 of 8192 bytes >> >> That kinda reminds me the issues we're observing on some buildfarm >> machines, I wonder if it's the same thing. > > Oooh, that's interesting! What's the precise recipe that gets you there? > I don't have an exact reproducer - it's kinda rare and unpredictable, and I'm not sure how much it depends on the environment etc. But I'm doing this: 1) one cluster with publication (wal_level=logical) 2) one cluster with subscription to (1) 3) simple table, replicated from (1) to (2) -- publisher create table t (a serial primary key, b int, c int); create publication p for table t; -- subscriber create table t (a serial primary key, b int, c int); create subscription s CONNECTION '...' publication p; 4) pgbench inserting rows into the replicated table pgbench -n -c 4 -T 300 -p 5433 -f insert.sql test 5) pgbench doing vacuum full on pg_class pgbench -n -f vacuum.sql -T 300 -p 5433 test And once in a while I see failures like this: client 0 aborted in command 0 of script 0; ERROR: could not read block 3 in file "base/16384/86242": read only 0 of 8192 bytes client 3 aborted in command 0 of script 0; ERROR: could not read block 3 in file "base/16384/86242": read only 0 of 8192 bytes client 2 aborted in command 0 of script 0; ERROR: could not read block 3 in file "base/16384/86242": read only 0 of 8192 bytes or this: client 2 aborted in command 0 of script 0; ERROR: could not read block 3 in file "base/16384/89369": read only 0 of 8192 bytes client 1 aborted in command 0 of script 0; ERROR: could not read block 3 in file "base/16384/89369": read only 0 of 8192 bytes I suspect there's some other ingredient, e.g. some manipulation with the subscription. Or maybe it's not needed at all and I'm just imagining things. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------F2DB936F310C963357B84CC7 Content-Type: application/sql; name="vacuum.sql" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="vacuum.sql" dmFjdXVtIGZ1bGwgcGdfY2xhc3MK --------------F2DB936F310C963357B84CC7 Content-Type: application/sql; name="insert.sql" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="insert.sql" aW5zZXJ0IGludG8gdCAoYixjKSB2YWx1ZXMgKDEsMSk7Cg== --------------F2DB936F310C963357B84CC7--