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 1fnpDX-0006Pj-AN for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 17:59:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fnpDV-0004zc-3O for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 17:59:21 +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 1fnpDI-0003vZ-Kd for pgsql-hackers@lists.postgresql.org; Thu, 09 Aug 2018 17:59:08 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fnpDE-0007pN-F4 for pgsql-hackers@postgresql.org; Thu, 09 Aug 2018 17:59:06 +0000 Received: by mail-wm0-x243.google.com with SMTP id q8-v6so1156784wmq.4 for ; Thu, 09 Aug 2018 10:59:04 -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=NOBYWupyJFSaiU9h3RtkX06isYWeso3dbi+a+SMicLM=; b=z0E6kVYpxBuYV3V/pCEeLu68Inq05WDo+w+zazxUtLBZoRnIZTlYgftRQqaFt0GagL x82EjoWPA8Kemea+rmaA2C5TAHo1CjW1D4H789zmnzDLwOALu0tQx2+OjVL40XndCzRl sRmNjs9dNVNMFcOyC2A7paWk+nRjxP8fWImPHWN1YvDOsuZXtCbVgrN+x+FeFZR9DMf+ neoRcaxbTtZz7tPh9dTx1sQjWZDAAwum+y9BZRjKxTLHyzHKY+H0sPTde4ndPmd6Bi+3 8SZ8JL3OT71rxYlTb3dSh+pYrLfuQxDyoK0dMMp7CA6qIDxe3Zlkrx6IHF+jCythVpW/ L+mA== 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=NOBYWupyJFSaiU9h3RtkX06isYWeso3dbi+a+SMicLM=; b=MmN8NQyrnOxIa3R4rLZI0oiQWt7FHKiiWSpom4oPddtwlycNwU2J5H8/QAVQ4fwBX+ yEV44Zk2tWuzDJWrKqoatyaTjs5l9rA3oQhAwrFV2gBRIys9dUa1O7EBCxB5zoPxehYX UCiuwqp2/nSA0vJ7HeKeloHIhZ+9NTD6QnhEXH/ZEgXadsCwIEwihDw++zA/b9aCu0aN UbXfxHnYD+xKE5zZprFYf8K5HOlNwt3rvCe5yocDV6IaUqCbzlP3YqAoHsvln+Zx1PiD E+W71hffwKx+JSr1mxTclBqpzBuUp9WxZL2zWlE3/B/PCyq0gjkQEaZueV0HgRLemDaN EtPg== X-Gm-Message-State: AOUpUlHkKIibAHc9TKTCrPch+KJEaTr2KR9xzKq5WplI+RbU2dUe8DK0 7KaP9FrqgoNBh1fH6AemZcFYB/rY8WzJTrvMYwxxOrVQKzV5irVzc62/J2/xfmmhhtugQqbK4DA dCLPOLghdtsrghLkI5mvBePA+Tqg2EWGbf/Xh4bgSH1lAx1Y8K3rLAf2NTpKxsY7ODDZYLZyuPs xKCR1nzNUpICc= X-Google-Smtp-Source: AA+uWPycyNURHH7hPKB2dQmsNSd3sXRPFSy1LACmt+hXD+KVEKJup0qPAakntZuT8ozuFSmLl456sA== X-Received: by 2002:a1c:838a:: with SMTP id f132-v6mr2305601wmd.127.1533837541400; Thu, 09 Aug 2018 10:59:01 -0700 (PDT) Received: from [10.137.2.21] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id i205-v6sm10225523wmf.30.2018.08.09.10.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 10:59:00 -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: <2eeb2d11-70be-edbe-198a-a73a30d58664@2ndquadrant.com> Date: Thu, 9 Aug 2018 19:58: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; format=flowed 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. > >> 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. > That's possible. I'm running on f85537a88d, i.e. with f49a80c481f7. >> I'd say this implies the "can't open file" is handled in a way that corrupts >> the mapping files, making it impossible to restart the decoding. AFAICS the >> only option at this point is to drop the subscription and start over. > > Wow, that seems pretty serious. Clearly that's a different bug that > must be fixed. > Yep. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services