Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8QHL-0004W2-KZ for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Sep 2019 14:40:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8QHK-0003pu-ID for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Sep 2019 14:40:58 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8QHK-0003pn-9N for pgsql-hackers@lists.postgresql.org; Thu, 12 Sep 2019 14:40:58 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8QHH-000671-FQ for pgsql-hackers@lists.postgresql.org; Thu, 12 Sep 2019 14:40:57 +0000 Received: by mail-qk1-x741.google.com with SMTP id f13so24680554qkm.9 for ; Thu, 12 Sep 2019 07:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ODxaKpS0toWstsOzNcalesLO9RGaeZGjv2Hklgum+vE=; b=QF9ws1gXzS/ZJsDtb6bPSTYBfMsYyWnVahHg1NcYX47kjaHVaXGXOr/w82++cv8SZg Fbnz4gY/fr4qhLXR2YhsdutWE9jTeJg8Vh/a7HEjK1pmxdqKiBELR7qIk0spTwGgKv/3 cB1FOpwnVoHB944+E3zskOqkhHMsZDidNEiB1mwikDilxGkASENKMpmtNGmu58Lt+hI/ EOGZ+CyK5Yz8Mv24iQAnyTIFRpIwc1YlXO8uafTvrsQJapfI22k7O2mjEOQZO2rKaUH+ 6YshjhP7GN6sAuLL0j2D69YnwZOu5C1Takj6xpDcmKvxQoKRj9U8OOmbh76jI7Ld+hal b2ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ODxaKpS0toWstsOzNcalesLO9RGaeZGjv2Hklgum+vE=; b=cagNMJLzX1c0IwRnJ/tY+zBfn+KVtnqUNpK99+bqcxUP563DLCHyxPePTrBYatHZPE pvgjSocwtxC/YJYifMk2LUu2ucPfLSb7pDL1GUKdrRkrI01krCdT/Hm+3WfRw7nfw3aF tMbf+v7GKBveQKmHUO1qiy6pRkhiJvKclRz1ufBphzk4yqluP4WE3JvdnRildV5cu9L8 yHV3Bxqi2B8OjdEalp5ck9GSHK25jgPbxhGcpBrXZPacI/V/Ts3ON4WIH0sRZ3nzORbn zSVmX7giY1s+S1aFxKu9TJyB7/5yNrXkSr1+kAocX/9RvY5VSQVY0SBjXrBtx8J1ScNj WQzg== X-Gm-Message-State: APjAAAX/Fbx6jpcEcQGkKq0R0xKqEMiFtuOAVesekTdlu7FXYIk7ck+9 Wagr5qo3uCwrRCJgcivsPuqfeN0PXXk= X-Google-Smtp-Source: APXvYqx4JKnkHMprkVIM+6rv/bqVnKq8+Y1HuQp2X+1G1uwSwn6oHM4H7b5ezs8I+GdvoaZiT1bZRQ== X-Received: by 2002:a37:274e:: with SMTP id n75mr1709158qkn.134.1568293077685; Thu, 12 Sep 2019 05:57:57 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([179.56.30.174]) by smtp.gmail.com with ESMTPSA id u23sm11672585qkm.49.2019.09.12.05.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2019 05:57:57 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 5246912090A; Thu, 12 Sep 2019 09:57:55 -0300 (-03) Date: Thu, 12 Sep 2019 09:57:55 -0300 From: Alvaro Herrera To: Tomas Vondra Cc: Amit Khandekar , PostgreSQL Hackers Subject: Re: logical decoding : exceeded maxAllocatedDescs for .spill files Message-ID: <20190912125755.GA24047@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190912093055.exeatfemzr3f25yx@development> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Sep-12, Tomas Vondra wrote: > On Wed, Sep 11, 2019 at 09:51:40AM -0300, Alvaro Herrera from 2ndQuadrant wrote: > > On 2019-Sep-11, Amit Khandekar wrote: > > I think doing this all the time would make restore very slow -- there's a > > reason we keep the files open, after all. > > How much slower? It certainly will have a hit, but maybe it's negligible > compared to all the other stuff happening in this code? I dunno -- that's a half-assed guess based on there being many more syscalls, and on the fact that the API is how it is in the first place. (Andres did a lot of perf benchmarking and tweaking back when he was writing this ... I just point out that I have a colleague that had to invent *a lot* of new MemCxt infrastructure in order to make some of Andres' perf optimizations cleaner, just as a semi-related data point. Anyway, I digress.) Anyway, such a fix would pessimize all cases, including every single case that works today (which evidently is almost every single usage of this feature, since we hadn't heard of this problem until yesterday), in order to solve a problem that you can only find in very rare ones. Another point of view is that we should make it work first, then make it fast. But the point remains that it works fine and fast for 99.99% of cases. > > It would be better if we can keep the descriptors open as much as > > possible, and only close them if there's trouble. I was under the > > impression that using OpenTransientFile was already taking care of that, > > but that's evidently not the case. > > I don't see how the current API could do that transparently - it does > track the files, but the user only gets a file descriptor. With just a > file descriptor, how could the code know to do reopen/seek when it's going > just through the regular fopen/fclose? Yeah, I don't know what was in Amit's mind, but it seemed obvious to me that such a fix required changing that API so that a seekpos is kept together with the fd. ReorderBufferRestoreChange is static in reorderbuffer.c so it's not a problem to change its ABI. I agree with trying to get a reorderbuffer-localized back-patchable fix first, then we how to improve from that. > As a sidenote - in the other thread about streaming, one of the patches > does change how we log subxact assignments. In the end, this allows using > just a single file for the top-level transaction, instead of having one > file per subxact. That would also solve this. :-( While I would love to get that patch done and get rid of the issue, it's not a backpatchable fix either. ... however, it does mean we maybe can get away with the reorderbuffer.c-local fix, and then just use your streaming stuff to get rid of the perf problem forever? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services