Re: refactoring basebackup.c
Sumanta Mukherjee <sumanta.mukherjee@enterprisedb.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Document BaseBackupSync and BaseBackupWrite wait events.
- 749320cdc3fd 15.3 landed
- 4b1ad19a4e22 16.0 landed
-
Support long distance matching for zstd compression
- 2820adf7755d 16.0 landed
-
Fix possible NULL-pointer-deference in backup_compression.c.
- 8e053dc6dfbe 15.0 landed
-
Allow parallel zstd compression when taking a base backup.
- 51c0d186d99a 15.0 landed
-
Make PostgreSQL::Test::Cluster::run_log() return a useful value.
- ad4f2c47de44 15.0 landed
-
Fix a few goofs in new backup compression code.
- 61762426e6ed 15.0 landed
-
Replace BASE_BACKUP COMPRESSION_LEVEL option with COMPRESSION_DETAIL.
- ffd53659c46a 15.0 landed
-
Add 'basebackup_to_shell' contrib module.
- c6306db24bd9 15.0 landed
-
Allow extensions to add new backup targets.
- e4ba69f3f4a1 15.0 landed
-
Change HAVE_LIBLZ4 and HAVE_LIBZSTD tests to USE_LZ4 and USE_ZSTD.
- 75eae090876f 15.0 landed
-
pg_basebackup: Clean up some bogus file extension tests.
- d6f1cdeb9a9e 15.0 landed
-
pg_basebackup: Avoid unclean failure with server-compression and -D -.
- b2de45f9200d 15.0 landed
-
Fix LZ4 tests for remaining buffer space.
- 1d4be6be65ab 15.0 landed
-
Add support for zstd base backup compression.
- 7cf085f077df 15.0 landed
-
pg_basebackup: Allow client-side LZ4 (de)compression.
- 751b8d23b788 15.0 landed
-
Add suport for server-side LZ4 base backup compression.
- dab298471ff2 15.0 landed
-
Add min() and max() aggregates for xid8.
- 400fc6b6487d 15.0 cited
-
Remove superfluous variable.
- 82331ed4dd60 15.0 landed
-
pg_basebackup: Cleaner handling when compression is multiply specified.
- 51891d5a9560 15.0 landed
-
Allow server-side compression to be used with -Fp.
- d45099425eb1 15.0 landed
-
pg_basebackup: Fix a couple of recently-introduced bugs.
- dabf63bc9a5b 15.0 landed
-
Tidy up a few cosmetic issues related to pg_basebackup.
- e1f860f13459 15.0 landed
-
Server-side gzip compression.
- 0ad8032910d5 15.0 landed
-
Unbreak pg_basebackup/t/010_pg_basebackup.pl on msys
- 4f0bcc735038 15.0 cited
-
Suppress variable-set-but-not-used warning from clang 13.
- dc43fc9b3aa3 15.0 cited
-
Extend the options of pg_basebackup to control compression
- 5c649fe15336 15.0 cited
-
Support base backup targets.
- 3500ccc39b0d 15.0 landed
-
Modify pg_basebackup to use a new COPY subprotocol for base backups.
- cc333f32336f 15.0 landed
-
Document that tar archives are now properly terminated.
- 81fca310b38e 15.0 landed
-
Fix thinko in bbsink_throttle_manifest_contents.
- 1b098da20093 15.0 landed
-
Have the server properly terminate tar archives.
- 5a1007a5088c 15.0 landed
-
Minimal fix for unterminated tar archive problem.
- 57b5a9646d97 15.0 landed
-
Introduce 'bbstreamer' abstraction to modularize pg_basebackup.
- 23a1c6578c87 15.0 landed
-
Introduce 'bbsink' abstraction to modularize base backup code.
- bef47ff85df1 15.0 landed
-
Refactor basebackup.c's _tarWriteDir() function.
- 967a17fe2fa7 15.0 landed
-
Flexible options for CREATE_REPLICATION_SLOT.
- 0266e98c6b86 15.0 landed
-
Flexible options for BASE_BACKUP.
- 0ba281cb4bf9 15.0 landed
Hi Robert, Please see my comments inline below. On Tue, May 12, 2020 at 12:33 AM Robert Haas <robertmhaas@gmail.com> wrote: > Yeah, that needs to be tested. Right now the chunk size is 32kB but it > might be a good idea to go larger. Another thing is that right now the > chunk size is tied to the protocol message size, and I'm not sure > whether the size that's optimal for disk reads is also optimal for > protocol messages. One needs a balance between the number of packets to be sent across the network and so if the size of reading from the disk and the network packet size could be unified then it might provide a better optimization. > > I don't think it's a particularly bad thing that we include a small > amount of progress for sending an empty file, a directory, or a > symlink. That could make the results more meaningful if you have a > database with lots of empty relations in it. However, I agree that the > effect of compression shouldn't be included. To get there, I think we > need to redesign the wire protocol. Right now, the server has no way > of letting the client know how many uncompressed bytes it's sent, and > the client has no way of figuring it out without uncompressing, which > seems like something we want to avoid. > > I agree here too, except that if we have too many tar files one might cringe but sending the xtra amt from these tar files looks okay to me. > There are some other problems with the current wire protocol, too: > > 1. The syntax for the BASE_BACKUP command is large and unwieldy. We > really ought to adopt an extensible options syntax, like COPY, VACUUM, > EXPLAIN, etc. do, rather than using a zillion ad-hoc bolt-ons, each > with bespoke lexer and parser support. > > 2. The client is sent a list of tablespaces and is supposed to use > that to expect an equal number of archives, computing the name for > each one on the client side from the tablespace info. However, I think > we should be able to support modes like "put all the tablespaces in a > single archive" or "send a separate archive for every 256GB" or "ship > it all to the cloud and don't send me any archives". To get there, I > think we should have the server send the archive name to the clients, > and the client should just keep receiving the next archive until it's > told that there are no more. Then if there's one archive or ten > archives or no archives, the client doesn't have to care. It just > receives what the server sends until it hears that there are no more. > It also doesn't know how the server is naming the archives; the server > can, for example, adjust the archive names based on which compression > format is being chosen, without knowledge of the server's naming > conventions needing to exist on the client side. > > One thing to remember here could be that an optimization would need to be made between the number of options we provide and people coming back and saying which combinations do not work For example, if a user script has "put all the tablespaces in a single archive" and later on somebody makes some script changes to break it down at "256 GB" and there is a conflict then which one takes precedence needs to be chosen. When the number of options like this become very large this could lead to some complications. > I think we should keep support for the current BASE_BACKUP command but > either add a new variant using an extensible options, or else invent a > whole new command with a different name (BACKUP, SEND_BACKUP, > whatever) that takes extensible options. This command should send back > all the archives and the backup manifest using a single COPY stream > rather than multiple COPY streams. Within the COPY stream, we'll > invent a sub-protocol, e.g. based on the first letter of the message, > e.g.: > > t = Tablespace boundary. No further message payload. Indicates, for > progress reporting purposes, that we are advancing to the next > tablespace. > f = Filename. The remainder of the message payload is the name of the > next file that will be transferred. > d = Data. The next four bytes contain the number of uncompressed bytes > covered by this message, for progress reporting purposes. The rest of > the message is payload, possibly compressed. Could be empty, if the > data is being shipped elsewhere, and these messages are only being > sent to update the client's notion of progress. > Here I support this. > I thought about that a bit, too. There might be some way to unify that > by having some common context object that's defined by basebackup.c > and all archivers get it, so that they have some commonly-desired > details without needing bespoke code, but I'm not sure at this point > whether that will actually produce a nicer result. Even if we don't > have it initially, it seems like it wouldn't be very hard to add it > later, so I'm not too stressed about it. > --Sumanta Mukherjee EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company > > >