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 1o8iWz-0000za-00 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Jul 2022 13:23:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o8iWx-0003Ik-Tm for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Jul 2022 13:23:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8iWx-0003Ia-GY for pgsql-hackers@lists.postgresql.org; Tue, 05 Jul 2022 13:23:55 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o8iWu-0006gL-Iu for pgsql-hackers@lists.postgresql.org; Tue, 05 Jul 2022 13:23:54 +0000 Received: by mail-ej1-x633.google.com with SMTP id h23so21563137ejj.12 for ; Tue, 05 Jul 2022 06:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:comments:mime-version :content-id:content-transfer-encoding:date:message-id; bh=UBRvWlp9bioPtVFAHPSI8fDIQFoELL9oMveW2rnD5kU=; b=Be4pT6HSdQFr0HxfvD8rQOZZN/z7PoKsGC25CU1I2SmRAAlkYQqY4QifFIZbW1ErtO Ih+RoCn18mfEoprqJQAVPpKxZq5mFMVm6mxcZs59oK7LSVjPrX2tvJq3lD78qTXrUEBx raa09N0G+SzvHzDeA5VMvqXHn6sfD1kpeUJ8gyhKLzJybWuo+CgA6u5MKaj80/UPsq0n /xmK1yjfW//V/uFh/qWku+O1670/LCrSulHBYjy7qf3NssL73YSH5S/YhzPRlVwawU9O c8ObMSeMVKUXhMD+BwmtQFaU6HiXM4bWc4TXNQ0UG8sWTTMD3FE8R6oyMjUmEoJJui4k qWZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :comments:mime-version:content-id:content-transfer-encoding:date :message-id; bh=UBRvWlp9bioPtVFAHPSI8fDIQFoELL9oMveW2rnD5kU=; b=k4pAVb01UAmFv+m2Qaa2InXcnkjxptxu9DSG1xh/7iGgnWyLYWXoiY1bL18NKXeoj0 rzM1OcWYu7oUaX7DEZ3CrIYI5IQunJE49rm15Iy/xxv0JQnitnTm3uW9e/Fv14JqVx7+ d7s3V/uuDrjDy/1JwU/64In4yFIzg7TvQ+0BxCDTZfVj+uikjaQ7g+vWWTzx199uFnHH NVwsluVEh+7L7JJzCpZd9Z9qslAy62N2Q9ilbs8G8pPBLtBIF1dN6ymZLn+oFDPJosTB 9XobwE5HPxhsQqlyXC8dD0CbYoSHUBpfdxu+9f10djbpGztWAYX5IixwV9LGiIP6x2LS Gw3A== X-Gm-Message-State: AJIora+XdxPvw5+bIafi/OZYh33lQW/ADYOrT3QKfVPJ2ZdhkW+33wdt xmxXQqXoPgux2xADb6pbFHwyng== X-Google-Smtp-Source: AGRyM1v0fTFHvjmOclFGrYl1ieMS8+IcLyZFpcDDU9F3PW/2862kFUDHEeXvZ5/HL1DSgkInglvibQ== X-Received: by 2002:a17:906:478e:b0:722:f84d:159f with SMTP id cw14-20020a170906478e00b00722f84d159fmr34194293ejc.182.1657027430846; Tue, 05 Jul 2022 06:23:50 -0700 (PDT) Received: from antos.home (90-183-80-67.rcq.o2.cz. [90.183.80.67]) by smtp.gmail.com with ESMTPSA id d11-20020a1709064c4b00b0070cac22060esm15699279ejw.95.2022.07.05.06.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 06:23:50 -0700 (PDT) From: Antonin Houska To: Peter Eisentraut cc: pgsql-hackers@lists.postgresql.org, Robert Haas , Stephen Frost Subject: Re: Temporary file access API In-reply-to: <46aa800a-dad7-5080-ee9f-371cc2797b36@enterprisedb.com> References: <4987.1644323098@antos> <20220301143431.GT10577@tamriel.snowman.net> <27013.1646738099@antos> <3146.1649408068@antos> <2132.1649664364@antos> <3690.1649755839@antos> <24759.1650466826@antos> <60402.1656952546@antos.home> <46aa800a-dad7-5080-ee9f-371cc2797b36@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Mon, 04 Jul 2022 20:37:30 +0200." X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 27.2.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <85650.1657027465.1@antos.home> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 Jul 2022 15:24:25 +0200 Message-ID: <85651.1657027465@antos.home> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut wrote: > On 04.07.22 18:35, Antonin Houska wrote: > >> Attached is a new version of the patch, to evaluate what the API use = in the > >> backend could look like. I haven't touched places where the file is a= ccessed > >> in a non-trivial way, e.g. lseek() / fseek() or pg_pwrite() / pg_prea= d() is > >> called. > > Rebased patch set is attached here, which applies to the current maste= r. > > (A few more opportunities for the new API implemented here.) > = > I don't understand what this patch set is supposed to do. AFAICT, the t= hread > originally forked off from a TDE discussion and, considering the thread > subject, was possibly once an attempt to refactor temporary file access = to > make integrating encryption easier? The discussion then talked about th= ings > like saving on system calls and excising all OS-level file access API us= e, > which I found confusing, and the thread then just became a general TDE-r= elated > mini-discussion. Yes, it's an attempt to make the encryption less invasive, but there are a= few other objectives, at least: 1) to make the read / write operations "less low-level" (there are common things like error handling which are often ju= st copy & pasted from other places), 2) to have buffered I/O with configurabl= e buffer size (the current patch version still has fixed buffer size though) It's true that the discussion ends up to be encryption-specific, however t= he scope of the patch is broader. The first meassage of the thread references= a related discussion https://www.postgresql.org/message-id/CA+TgmoYGjN_f=3DFCErX49bzjhNG+GoctY+= a+XhNRWCVvDY8U74w@mail.gmail.com which is more important for this patch than the suggestions about encrypti= on. > The patches at hand extend some internal file access APIs and then sprin= kle > them around various places in the backend code, but there is no explanat= ion > why or how this is better. I don't see any real structural savings one m= ight > expect from a refactoring patch. No information has been presented how = this > might help encryption. At this stage I expected feedback from the developers who have already contributed to the discussion, because I'm not sure myself if this version fits their ideas - that's why I didn't elaborate the documentation yet. I'= ll try to summarize my understanding in the next version, but I'd appreciate = if I got some feedback for the current version first. > I also suspect that changing around the use of various file access APIs = needs > to be carefully evaluated in each individual case. Various code has sub= tle > expectations about atomic write behavior, syncing, flushing, error recov= ery, > etc. I don't know if this has been considered here. I considered that, but could have messed up at some places. Right now I'm aware of one problem: pgstat.c does not expect the file access API to rais= e ERROR - this needs to be fixed. -- = Antonin Houska Web: https://www.cybertec-postgresql.com