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 1pEbbx-0005zn-5u for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Jan 2023 19:45:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pEbbu-0005u1-R4 for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Jan 2023 19:45:38 +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 1pEbbu-0005tr-Ej for pgsql-hackers@lists.postgresql.org; Sun, 08 Jan 2023 19:45:38 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pEbbm-0000Py-0y for pgsql-hackers@lists.postgresql.org; Sun, 08 Jan 2023 19:45:36 +0000 Received: by mail-io1-xd32.google.com with SMTP id q190so3551959iod.10 for ; Sun, 08 Jan 2023 11:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=yHhzAeevMo5xX9DbE4aJ1JU6yh51fR/Lai/nE6Sibc8=; b=ocmgCtL0qL/WUP7JxEvwfTiuTa54Og2ApAQgpkWULLmRFqIFd+KDOI02N8VfXm1FfJ 1GlVo5Y4pLDVknDi443g/zq5k3ekz52vozrE9L/v6GCbdWmFCU6aThOiZhM1UNkvjtsB e+f14u4kgAkmfVC959KA1w6a0BbfP98/HPrlLSc3cS5oMvn5SghC+Rn8fpeH5Vlhp8s2 q+IrJDhhpd+pAiR9UMeCaw/dhEviaIdRetCI4L6ManKjOE0kSQkDofAdEVdxFkSulLBn rMvwp1oPJ1/z7yx+eFShHyOYvTHZPeDYBwugqaFUHD/NhDiB2NfLfWLrTYIg92eZkxQf ChNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHhzAeevMo5xX9DbE4aJ1JU6yh51fR/Lai/nE6Sibc8=; b=cWvpBmK4HgxGKPmQp4vUWAL4537BesT7h1qcb8UCLeMuZr5pCXR5g0glkr7KHjpiTc zGb/AASoGr/Xw/+wkd273T5fP67njrVxLJ3LefhgoSkbZmu8coJJm4YmuaCY0E1d03uF mNePpTO+roEO3+VL5Ycpyc20Ya3ryl3JnDvtcwFqAoiQ3aELfoZEhCof2En6OA9J2eV9 aVLY4qxjzT8wyzUKpE9kjcDoV3YZ62wQpNfH9Kbg363puTIE5hBOPSqPxVOEa44mXbdy 0TXgYnnFFZYVI6ftUKoRrVawoDpVH7z1Y3b1Y1sJWLaCkV2ULJaV18wTGG/77FDLO4wb 7dRA== X-Gm-Message-State: AFqh2krwOAPsQksAz/je/ui0KLR0/Db3N+KVe5Kv0ywq9ErESrY9wyea WA8bKcATvMuXIEtTQxP1gNvhJQ== X-Google-Smtp-Source: AMrXdXtkQOyCR/8n/FsJ4PxqtS6b2UrbR52WRIXoSiXH7yFoPpF7/xDaz6lW3VxW7NfPFiFh6gXWAg== X-Received: by 2002:a05:6602:2bfa:b0:6e3:8ba8:dd1f with SMTP id d26-20020a0566022bfa00b006e38ba8dd1fmr43153148ioy.15.1673207127272; Sun, 08 Jan 2023 11:45:27 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id c8-20020a6bfd08000000b006bbfb3856d6sm2499181ioi.5.2023.01.08.11.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 11:45:26 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5266D800C2F; Sun, 8 Jan 2023 13:45:25 -0600 (CST) Date: Sun, 8 Jan 2023 13:45:25 -0600 From: Justin Pryzby To: gkokolatos@pm.me Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org, Rachel Heaton Subject: Re: Add LZ4 compression in pg_dump Message-ID: <20230108194524.GA27637@telsasoft.com> References: <4wfmZ9BuGbkM6JXggut4g_gPl1hLbVeUwPEQh5nGgzlKCgnbtRaw7-nPcyPelGdG8ttH9A7vgyX_Z2fwZxuqHt1xENg9mqDfP_94qoZ5WxQ=@pm.me> <20221217232615.GS1153@telsasoft.com> <20221219172706.GA1153@telsasoft.com> <20221220152610.GG1153@telsasoft.com> <20221222170859.GO1153@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221222170859.GO1153@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Dec 22, 2022 at 11:08:59AM -0600, Justin Pryzby wrote: > There's a couple of lz4 bits which shouldn't be present in 002: file > extension and comments. There were "LZ4" comments and file extension stuff in the preparatory commit. But now it seems like you *removed* them in the LZ4 commit (where it actually belongs) rather than *moving* it from the prior/parent commit *to* the lz4 commit. I recommend to run something like "git diff @{1}" whenever doing this kind of patch surgery. + if (AH->compression_spec.algorithm != PG_COMPRESSION_NONE && + AH->compression_spec.algorithm == PG_COMPRESSION_GZIP && This looks wrong/redundant. The gzip part should be removed, right ? Maybe other places that check if (compression==PG_COMPRESSION_GZIP) should maybe change to say compression!=NONE? _PrepParallelRestore() references ".gz", so I think it needs to be retrofitted to handle .lz4. Ideally, that's built into a struct or list of file extensions to try. Maybe compression.h should have a function to return the file extension of a given algorithm. I'm planning to send a patch for zstd, and hoping its changes will be minimized by these preparatory commits. + errno = errno ? : ENOSPC; "?:" is a GNU extension (not the ternary operator, but the ternary operator with only 2 args). It's not in use anywhere else in postgres. You could instead write it with 3 "errno"s or as "if (errno==0): errno=ENOSPC" You wrote "eol_flag == false" and "eol_flag == 0" and true. But it's cleaner to test it as a boolean: if (eol_flag) / if (!eol_flag). Both LZ4File_init() and its callers check "inited". Better to do it in one place than 3. It's a static function, so I think there's no performance concern. Gzip_close() still has a useless save_errno (or rebase issue?). I think it's confusing to have two functions, one named InitCompressLZ4() and InitCompressorLZ4(). pg_compress_specification is being passed by value, but I think it should be passed as a pointer, as is done everywhere else. pg_compress_algorithm is being writen directly into the pg_dump header. Currently, I think that's not an externally-visible value (it could be renumbered, theoretically even in a minor release). Maybe there should be a "private" enum for encoding the pg_dump header, similar to WAL_COMPRESSION_LZ4 vs BKPIMAGE_COMPRESS_LZ4 ? Or else a comment there should warn that the values are encoded in pg_dump, and must never be changed. + Verify that data files where compressed typo: s/where/were/ Also: s/occurance/occurrence/ s/begining/beginning/ s/Verfiy/Verify/ s/nessary/necessary/ BTW I noticed that cfdopen() was accidentally committed to compress_io.h in master without being defined anywhere. -- Justin