Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jM55V-0001CN-02 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 07:25:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jM55T-0006ah-27 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 07:25:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jM55S-0006aT-NQ for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 07:25:26 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jM55O-0006M5-QU for pgsql-hackers@postgresql.org; Wed, 08 Apr 2020 07:25:25 +0000 Received: by mail-wr1-x42a.google.com with SMTP id c15so6525017wro.11 for ; Wed, 08 Apr 2020 00:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=from:to:subject:in-reply-to:references:comments:mime-version :content-id:content-transfer-encoding:date:message-id; bh=XR0Hdk1p/VWq+qd5oN67nANJ6DlPeGL/fP6NLMflIdc=; b=mcYCn6uHjsBl2MmSkyqNnAd9k2sgBw8MGWWzOCX7eJcNCPOQQsviaaeDhZe5g2ZxiK uukDscXI8P5iKRSqax8xtRY7pljMP6IiwcIVr0m/rlqdFkLTKTdrjejrc4QvQljlDTmE hM+ADlkxQo3N+M/s5ZWo8Rlwc1BE7N2WUbXppl2C+WWSdJ9mhD5du/eEC7Zm3DQmEWPS 6ky4MZEGq4loK207ie/aCoC6f79eBEGkcI/o/1g5FAEpu0FEMfd19zkTYZXERA4PeaMB vSyvZau/me7DbO2uGlvtmEDcbCM+hpNz8GRZoVKeuFy1S4RSvui36SKXVDMjb1OykqxH PwrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:comments :mime-version:content-id:content-transfer-encoding:date:message-id; bh=XR0Hdk1p/VWq+qd5oN67nANJ6DlPeGL/fP6NLMflIdc=; b=YAupEMCZ/X0E12v5TS1roJIHTuBLnR27hYsuUbGytd5Kc/xURTMEzHFyRkJan8d1ro trHnO8DFUeRPXrYSq0l9bddXQRNNZawx21dPc7u5HGaTb/L1AZ/CuJaI3Fu7imOdNOcO g2344646WC+qVVSLEb97JXQ/IaoR7svBv7d3nPTYRnknJq9nxLm379F0eYf2y/W7phNi rvNMrlFP7qhIWObcCpkEUQJ7KaRp/wbBETH3jngrWBTMlXznxWII3qaajNDH8AIAQgql DJtMWATEY+1XoLTX5DdSSm49UldarieM7ackAsj0XUHzgcfICdP4T/97XYXtibvPGwJK g9RQ== X-Gm-Message-State: AGi0Pubit9AcZvEmQT09pn9LQbPG8N2u6Np+UtOfhp1t1VvZpG7gccz2 1SMapHkzeVAX9TbQ79ws6FnNlw== X-Google-Smtp-Source: APiQypI3/Ht+gRlYakLzrj8KZ22CO9BlCQqJgoMy4UReLFe5mW0FzT7AFr2pjce5Nsw/e6mL7LKPrg== X-Received: by 2002:adf:cd0b:: with SMTP id w11mr6654681wrm.161.1586330721393; Wed, 08 Apr 2020 00:25:21 -0700 (PDT) Received: from antos ([77.87.240.5]) by smtp.gmail.com with ESMTPSA id p5sm36491659wrg.49.2020.04.08.00.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 00:25:20 -0700 (PDT) From: Antonin Houska To: Andres Freund , Michael Paquier , pgsql-hackers@postgresql.org, Alvaro Herrera Subject: Re: 2pc leaks fds In-reply-to: <26247.1586157152@antos> References: <20200406025651.fpzdb5yyb7qyhqko@alap3.anarazel.de> <20200406052648.GB2066@paquier.xyz> <20200406054449.ssmrzj4fav3ewvaq@alap3.anarazel.de> <26247.1586157152@antos> Comments: In-reply-to Antonin Houska message dated "Mon, 06 Apr 2020 09:12:32 +0200." X-Mailer: MH-E 8.6+git; nmh 1.7; GNU Emacs 26.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <70057.1586330797.1@antos> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Apr 2020 09:26:37 +0200 Message-ID: <70058.1586330797@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Antonin Houska wrote: > Andres Freund wrote: > > But I'm not sure it's quite the right idea. I'm not sure I fully > > understand the design of 0dc8ead46, but it looks to me like it's > > intended to allow users of the interface to have different ways of > > opening files. If we just close() the fd that'd be a bit more limited. > = > It should have allowed users to have different ways to *locate the segme= nt* > file. The WALSegmentOpen callback could actually return file path instea= d of > the file descriptor and let WALRead() perform the opening/closing, but t= hen > the WALRead function would need to be aware whether it is executing in b= ackend > or in frontend (so it can use the correct function to open/close the fil= e). Well, #ifdef FRONTEND can be used to distinguish the caller of WALRead(). However now that I tried to adjust the API, I see that pg_waldump.c:WALDumpOpenSegment uses specific logic to open the file. So i= f the callback only returned the file name, there would be no suitable place= for the things that WALDumpOpenSegment does. -- = Antonin Houska Web: https://www.cybertec-postgresql.com