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 1foEU5-0004TZ-0x for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Aug 2018 20:58:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1foEU2-00016W-Nr for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Aug 2018 20:58:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1foEU2-00016P-Gk for pgsql-hackers@lists.postgresql.org; Fri, 10 Aug 2018 20:58:06 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1foETy-00010H-RP for pgsql-hackers@postgresql.org; Fri, 10 Aug 2018 20:58:05 +0000 Received: by mail-wr1-x441.google.com with SMTP id h14-v6so9340724wrw.13 for ; Fri, 10 Aug 2018 13:58:02 -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:content-transfer-encoding; bh=utXHh1C9IP0UgJQ8iRLgcQM7TL68De95s6gP9SEdo50=; b=EB0CqGh114uxdvok/jIWH9uNTcadeOjcjbR4V+22/6xRopAQg1K1ohg2PV0d4Nl/BL +Rv1960qJXu6m0R2rYWqeJVHdntL7zNXCvh1oEeGD6NzpSezouF6BNuBW89H8uuqKbjr 0Pz0t/QAa7n70vDttNSGKjI7ec1e9hoMdl5Z1f+4xswvIaPCrhIFKhpyRDKx2AoI1Y/z 7P4R/f9IBAsSkKPQvvt21KLkyrmgtKySHt11cwtManXpYphvAzBoqBgeSm0SHYFueRcs GoCVDkqB4Vyg1HOA3ujXUeKdeumlLDpkwIQaj8zRymLb/qYJgPAzOiqFaFlq2TaGzv4X reXg== 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=utXHh1C9IP0UgJQ8iRLgcQM7TL68De95s6gP9SEdo50=; b=X8XvDXNsywbJ9zM2aJrbYJgIFuHnWmyfycAEmaIYwbe5QDyD2gSSUFCZNKJFtSMHSG 5bU2ZxA5ZvyiOMSy1ORn35tBt6xLcfXZPIE9spMtJU1fUjkGsNlAGF398BPthLf3ujkB gdzsd8qr6BeOjt1fMgzOEq9lcbllKw5A7v/0+LNwR/RUjrRu9uFGxUWwGkQGKWXilPXa Scp9SAUXD5T/dlDYn7LF6ygOhrAsu8In2YZPlBXh5RqTMN2d35FXLRfi1Lx0xbTwt1BS kaOY2JkCk6Y0t3ZAzvbti0/pz7QBkn9kdVXQXEq+/WofRVMYF0gu8e5/QiHHKOt9fxxD C4JQ== X-Gm-Message-State: AOUpUlEVbvbjnAh7e40r21yc3fVYoa/0Nz/mUrvbEDgrF6g1CUHH5Hlh XN2o/siSa/tM1y5YVYZFwjtNjRVpCaIu/x9l0zxzAauqB20LgVBo+RX/xaAZBksK5uNATJI6oYT RIRUgyjxQDpqwVOb0i6Ec1H2OYxkZ0NkzcGQ7LoblZuOb7NWtb6CvmkVzFocNLukmxHcXgVY7kc eMaegA1oJkx0E= X-Google-Smtp-Source: AA+uWPygzw9Kq7NY8fh7DjaLuV5Myhpz6UhP3NiSB4iwCMRLj7uJ37e6rQewZTzB6NsfLC1unDVqyA== X-Received: by 2002:a5d:4785:: with SMTP id w5-v6mr4895659wrq.188.1533934681169; Fri, 10 Aug 2018 13:58:01 -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 188-v6sm4361809wmr.16.2018.08.10.13.57.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 13:57:59 -0700 (PDT) Subject: Re: logical decoding / rewrite map vs. maxAllocatedDescs To: Alvaro Herrera Cc: PostgreSQL-development References: <20180809174746.aa6rbpsu4zjipzif@alvherre.pgsql> From: Tomas Vondra Message-ID: Date: Fri, 10 Aug 2018 22:57:57 +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: <20180809174746.aa6rbpsu4zjipzif@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. >> But wait, there's more - what happens after hitting the limit? We restart >> the decoding process, and end up getting this: >> >> ERROR: 53000: exceeded maxAllocatedDescs (492) while trying to open >> file "pg_logical/mappings/map-4000-4eb-1_60DE1E08-5376b5-537c6b" >> LOCATION: OpenTransientFile, fd.c:2161 >> LOG: 00000: starting logical decoding for slot "s" >> DETAIL: streaming transactions committing after 1/6097DD48, reading >> WAL from 1/60275848 >> LOCATION: CreateDecodingContext, logical.c:414 >> LOG: 00000: logical decoding found consistent point at 1/60275848 >> DETAIL: Logical decoding will begin using saved snapshot. >> LOCATION: SnapBuildRestore, snapbuild.c:1872 >> ERROR: XX000: subtransaction logged without previous top-level txn >> record > > Hmm, I wonder if we introduced some bug in f49a80c481f7. > Not sure. I've tried reproducing it both on b767b3f2e5b7 (that's f49... in REL_10_STABLE branch) and 09879f7536350 (that's the commit immediately before it), and I can't reproduce it for some reason. I'll try on Monday on the same laptop I used before (it's in the office, so I can't try now). 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. I suppose relfilenode 24573 is pg_class, which is the only table I'm running vacuum full on here. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services