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 1foUBa-0002YW-Qq for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Aug 2018 13:44:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1foUBY-00008H-PK for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Aug 2018 13:44:04 +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 1foUBY-00008A-IP for pgsql-hackers@lists.postgresql.org; Sat, 11 Aug 2018 13:44:04 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1foUBV-0006Zy-0V for pgsql-hackers@postgresql.org; Sat, 11 Aug 2018 13:44:04 +0000 Received: by mail-wm0-x242.google.com with SMTP id y2-v6so4532063wma.1 for ; Sat, 11 Aug 2018 06:44:00 -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=5fejGSYOqYSHNuGpFg86zmyyUTd5YfDqYd/85y4fsaM=; b=qFqPA2x0O+8aimU7vu02q6SqJgVMl3rdLa8Gf6Cw6e2i6ayR+X7M4lmKBZRrkZZlB5 qPHAA/Is2kGs2YgmbkAuIQtylk2L48b0+8teXYatJJ8YslbwBn1OL/tcmdR3YwC7Y4nT zB1xpS3FlhcWyzXxAbnGRpgeGhE9iRoi16O3cYaShXjlZET37CPRcjbogc83ljPwQPOE FCfWpsYKsO463PQGF1ubNOCGpLtudeXK8sN3htYYSATrZGUKwS/G2EEV2qhHjQ9/NKYz wZx31JVxcGmssatgKMHZIa5xPi68mRC8K6srZ2ZMQqPoGnqYBPgWv7y8fQJpxF07I+hs Kq6g== 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=5fejGSYOqYSHNuGpFg86zmyyUTd5YfDqYd/85y4fsaM=; b=FbGCQiCJcaVcV8tjTLNYvHM4oeFXcPQnDpTj0iKSWjOqCMjhFAJDAkptrKTVINM3Qm Ik2H4GMShXwb2TEBeoojcKR8HCbRnmu7a5e168mnYSFhVDFY78LWkyKfp7Kk7iconzDT xA5i7d/+CHwF3hqczt9eoFmUUH3BbuJPX2f7YRr9YAqpQqY4z7b4uEB2/slDckk6j17C T4UHCVrSjmaGngm7sUEOlBLaaq5LU6W2VdhbTpBpfhhs3dvqiOgWuojnxjtz6JnDE991 UfQChoXB7u5Jq4/1h+xELomXPc6B0gZcKpdgUM5kYGGer4IJndwusyv524zl0/PK4ZUO EqGg== X-Gm-Message-State: AOUpUlFGGXV0Ie2XVqQjJGwwqK1X7tcEqSIKx1weNfjV7wmCE/U+XvER /K1fjTY/JKvFeJZHYPB0Pku1XyjBJWA+fKPAgNxTyz2SZrymCqRR5C6nzYOad8ExrOidSzejTjb 7c/VujblO4USXwRYdyAeD7AaFOJmHxsXrZ1SIi59+KF8TYx7bC83Af4tfi1UrMumgZtXP+eeDtd RR6XbqaH32hng= X-Google-Smtp-Source: AA+uWPyujuAS8qnUsJGc/QbyH6/CjVMBU0sZg0SY+uWjJzFLdcMNW14Vpg6av3Y6e7jOIPVDwursMQ== X-Received: by 2002:a1c:6fdd:: with SMTP id c90-v6mr3838405wmi.16.1533995039761; Sat, 11 Aug 2018 06:43:59 -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 r16-v6sm18879269wru.59.2018.08.11.06.43.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 06:43:58 -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: <79a0c7f4-89fb-cf8d-82eb-5a7ca8e08d56@2ndquadrant.com> Date: Sat, 11 Aug 2018 15:43:55 +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="------------18D063A07D59A581A45628FF" 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. --------------18D063A07D59A581A45628FF 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. > I think the fix can be as simple as attached ... I'm mostly afk for the weekend, so I'll commit & backpatch on Monday or so. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------18D063A07D59A581A45628FF Content-Type: text/x-patch; name="reorderbuffer-close.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="reorderbuffer-close.patch" diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 47e669578f..1a1a0fa469 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -3327,6 +3327,8 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname) new_ent->combocid = ent->combocid; } } + + CloseTransientFile(fd); } --------------18D063A07D59A581A45628FF--