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 1iBS4B-0007J7-NU for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2019 23:11:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iBS49-0007WC-K1 for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2019 23:11:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iBS49-0007Vv-81 for pgsql-hackers@lists.postgresql.org; Fri, 20 Sep 2019 23:11:53 +0000 Received: from mail.thelabyrinth.net ([45.56.70.56]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iBS45-0007W9-Vq for pgsql-hackers@postgresql.org; Fri, 20 Sep 2019 23:11:52 +0000 Received: from Davids-iMac.local (c-73-39-102-148.hsd1.va.comcast.net [73.39.102.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dsteele) by mail.thelabyrinth.net (Postfix) with ESMTPSA id 7873754683; Fri, 20 Sep 2019 23:11:48 +0000 (UTC) Subject: Re: backup manifests To: Robert Haas Cc: "pgsql-hackers@postgresql.org" References: <4b6244ea-4094-9055-080b-7afb274bf270@pgmasters.net> <146910fc-3df7-eeb4-ac5b-2f57a01f646f@pgmasters.net> From: David Steele Openpgp: preference=signencrypt Autocrypt: addr=david@pgmasters.net; prefer-encrypt=mutual; keydata= mQINBFSheh0BEADGNb3c1kOaX5OGUDhqHTwJ3JW7XAllfWLdknpRg+/fihgLPPRnQHZhjq28 nmMLqM+C8TjezT2BgVACeu8qqASn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ws4yU4tTTUNqFRRAArysPyXEhNNbLncfR5lPGPfZORPqLmIdkNMcDAwmzvC80 g1WH46wPzIcUUTc7DnP0pZNWGmI2NAnAW/c4Ii3aiXQXZDNVRfdZKL5rEY6dtgxdHl4hc6KN KH17wsX4T3dglMqP7VikYT23sNQJVE1oIGjfVR1sOe+DleI5Awa50DgGyLZS9vLfZz/9F28J 2YM1DExVPxbj75bwfOl65hh8B5BCqqrYp5n/JqV2x5+OSPgCHmd7rJtTbTl89MVKc0uR79ZZ hxUBU6m5v2UGHakSlgdbh+qmr6rdFkqRxRFhdepD7u9qvPKHdVIPp23dqkx9r7gIe+RjfkT6 aq12wQhqgGYaae5bqlg0ls1CpfZxsxJmwmO/DJ2W1hdrPhs/7ml9rv552FBQuQ7i9rddeSju lkFsXVWOsbLf45pKAWTwqZihb3nSIoBv53EH0V+1SPzDbgQk2CaQ+DR6k7eujgsI/srPpMtl ehqEQ7kzaKFACBgXBOxkheDR/kJzVJxx0a1rIFnvJGL/h5lgo8onxP5scCpotNx/bJjLkBVk XQvKDUIu9YPy0yENT58C91WWX/Nac3B5W5ZkmWHh6Lh+5eOiRSLV9MDau6ziULNNpuIA90iY 1onr0xRNO2DMyn0NzZzL+Y59WlMyATUcQdTgtmlmTcaxWeRiBRlUBLvHvgHLV94= Message-ID: Date: Fri, 20 Sep 2019 19:11:47 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/20/19 2:55 PM, Robert Haas wrote: > On Fri, Sep 20, 2019 at 11:09 AM David Steele wrote: >> >> It sucks to make that a prereq for this project but the longer we kick >> that can down the road... > > There are no doubt many patches that would benefit from having more > backend infrastructure exposed in frontend contexts, and I think we're > slowly moving in that direction, but I generally do not believe in > burdening feature patches with major infrastructure improvements. The hardest part about technical debt is knowing when to incur it. It is never a cut-and-dried choice. >> This talk was good fun. The largest number of tables we've seen is a >> few hundred thousand, but that still adds up to more than a million >> files to backup. > > A quick survey of some of my colleagues turned up a few examples of > people with 2-4 million files to backup, so similar kind of ballpark. > Probably not big enough for the manifest to hit the 1GB mark, but > getting close. I have so many doubts about clusters with this many tables, but we do support it, so... >>> I hear you saying that this is going to end up being just as complex >>> in the end, but I don't think I believe it. It sounds to me like the >>> difference between spending a couple of hours figuring this out and >>> spending a couple of months trying to figure it out and maybe not >>> actually getting anywhere. >> >> Maybe the initial implementation will be easier but I am confident we'll >> pay for it down the road. Also, don't we want users to be able to read >> this file? Do we really want them to need to cook up a custom parser in >> Perl, Go, Python, etc.? > > Well, I haven't heard anybody complain that they can't read a > backup_label file because it's too hard to cook up a parser. And I > think the reason is pretty clear: such files are not hard to parse. > Similarly for a pg_hba.conf file. This case is a little more > complicated than those, but AFAICS, not enormously so. Actually, it > seems like a combination of those two cases: it has some fixed > metadata fields that can be represented with one line per field, like > a backup_label, and then a bunch of entries for files that are > somewhat like entries in a pg_hba.conf file, in that they can be > represented by a line per record with a certain number of fields on > each line. Yeah, they are not hard to parse, but *everyone* has to cook up code for it. A bit of a bummer, that. > I attach here a couple of patches. The first one does some > refactoring of relevant code in pg_basebackup, and the second one adds > checksum manifests using a format that I pulled out of my ear. It > probably needs some adjustment but I don't think it's crazy. Each > file gets a line that looks like this: > > File $FILENAME $FILESIZE $FILEMTIME $FILECHECKSUM We also include page checksum validation failures in the file record. Not critical for the first pass, perhaps, but something to keep in mind. > Right now, the file checksums are computed using SHA-256 but it could > be changed to anything else for which we've got code. On my system, > shasum -a256 $FILE produces the same answer that shows up here. At > the bottom of the manifest there's a checksum of the manifest itself, > which looks like this: > > Manifest-Checksum > 385fe156a8c6306db40937d59f46027cc079350ecf5221027d71367675c5f781 > > That's a SHA-256 checksum of the file contents excluding the final > line. It can be verified by feeding all the file contents except the > last line to shasum -a256. I can't help but observe that if the file > were defined to be a JSONB blob, it's not very clear how you would > include a checksum of the blob contents in the blob itself, but with a > format based on a bunch of lines of data, it's super-easy to generate > and super-easy to write tools that verify it. You can do this in JSON pretty easily by handling the terminating brace/bracket: { *, "checksum": } But of course a linefeed-delimited file is even easier. > This is just a prototype so I haven't written a verification tool, and > there's a bunch of testing and documentation and so forth that would > need to be done aside from whatever we've got to hammer out in terms > of design issues and file formats. But I think it's cool, and perhaps > some discussion of how it could be evolved will get us closer to a > resolution everybody can at least live with. I had a quick look and it seems pretty reasonable. I'll need to generate a manifest to see if I can spot any obvious gotchas. -- -David david@pgmasters.net