Re: refactoring basebackup.c
Jeevan Ladhe <jeevan.ladhe@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
Attachments
- fix_gzip_cleanup_callback_core.patch (application/octet-stream) patch
Thanks, Robert for the patches.
I tried to take a backup using gzip compression and got a core.
$ pg_basebackup -t server:/tmp/data_gzip -Xnone --server-compression=gzip
NOTICE: WAL archiving is not enabled; you must ensure that all required
WAL segments are copied through other means to complete the backup
pg_basebackup: error: could not read COPY data: server closed the
connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The backtrace:
gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000558264bfc40a in bbsink_cleanup (sink=0x55826684b5f8) at
../../../src/include/replication/basebackup_sink.h:268
#2 0x0000558264bfc838 in bbsink_forward_cleanup (sink=0x55826684b710) at
basebackup_sink.c:124
#3 0x0000558264bf4cab in bbsink_cleanup (sink=0x55826684b710) at
../../../src/include/replication/basebackup_sink.h:268
#4 0x0000558264bf7738 in SendBaseBackup (cmd=0x55826683bd10) at
basebackup.c:1020
#5 0x0000558264c10915 in exec_replication_command (
cmd_string=0x5582667bc580 "BASE_BACKUP ( LABEL 'pg_basebackup base
backup', PROGRESS, MANIFEST 'yes', TABLESPACE_MAP, TARGET 'server',
TARGET_DETAIL '/tmp/data_g
zip', COMPRESSION 'gzip')") at walsender.c:1731
#6 0x0000558264c8a69b in PostgresMain (dbname=0x5582667e84d8 "",
username=0x5582667e84b8 "hadoop") at postgres.c:4493
#7 0x0000558264bb10a6 in BackendRun (port=0x5582667de160) at
postmaster.c:4560
#8 0x0000558264bb098b in BackendStartup (port=0x5582667de160) at
postmaster.c:4288
#9 0x0000558264bacb55 in ServerLoop () at postmaster.c:1801
#10 0x0000558264bac2ee in PostmasterMain (argc=3, argv=0x5582667b68c0) at
postmaster.c:1473
#11 0x0000558264aa0950 in main (argc=3, argv=0x5582667b68c0) at main.c:198
bbsink_gzip_ops have the cleanup() callback set to NULL, and when the
bbsink_cleanup() callback is triggered, it tries to invoke a function that
is NULL. I think either bbsink_gzip_ops should set the cleanup callback
to bbsink_forward_cleanup or we should be calling the cleanup() callback
from PG_CATCH instead of PG_FINALLY()? But in the latter case, even if
we call from PG_CATCH, it will have a similar problem for gzip and other
sinks which may not need a custom cleanup() callback in case there is any
error before the backup could finish up normally.
I have attached a patch to fix this.
Thoughts?
Regards,
Jeevan Ladhe
On Tue, Oct 26, 2021 at 1:45 AM Robert Haas <robertmhaas@gmail.com> wrote:
> On Fri, Oct 15, 2021 at 8:05 AM Robert Haas <robertmhaas@gmail.com> wrote:
> > > You mean the way gzip allows us to use our own alloc and free functions
> > > by means of providing the function pointers for them. Unfortunately,
> > > no, LZ4 does not have that kind of provision. Maybe that makes a
> > > good proposal for LZ4 library ;-).
> > > I cannot think of another solution to it right away.
> >
> > OK. Will give it some thought.
>
> Here's a new patch set. I've tried adding a "cleanup" callback to the
> bbsink method and ensuring that it gets called even in case of an
> error. The code for that is untested since I have no use for it with
> the existing basebackup sink types, so let me know how it goes when
> you try to use it for LZ4.
>
> I've also added documentation for the new pg_basebackup options in
> this version, and I fixed up a couple of these patches to be
> pgindent-clean when they previously were not.
>
> --
> Robert Haas
> EDB: http://www.enterprisedb.com
>