You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
https://perconadev.atlassian.net/browse/PXB-3747
Follow-up to the two commits on this branch that introduced per-datasink
metrics reporting and uncompressed-backup-size tracking. Will be squashed
before merge.
Problem:
--------------
Review raised five issues on the initial split:
1. fs_support_punch_hole was left uninitialized for every non-local
datasink. ds_local_init() probes the filesystem and sets it, but
every other init() allocated ds_ctxt_t with my_malloc() without
MY_ZEROFILL, so the field held whichever bytes my_malloc returned.
ds_create() previously masked this by unconditionally clobbering
the field to false after init, which also discarded the local
datasink's probe result (the regression we already fixed).
That left xbstream - which natively encodes sparse chunks in its
wire format and therefore does support punch-hole - advertising
whatever garbage happened to be there.
2. local_close() writes one trailing zero byte to stamp out the
final page of a sparse file, but it did not add that byte to
ds_local_ctxt_t::bytes_written. Backups with sparse files
therefore under-reported backup_size by 1 byte per sparse file.
3. backup_copy.cc had a "Finsh" typo and an awkwardly reflowed doc
comment above report_backup_size().
4. test/inc/common.sh::sum_file_bytes() ran find without a -d guard,
so callers probing a directory that might not exist got a stray
"No such file or directory" on stderr.
Fix/Implementation:
-------------------
1. Framework-field initialization:
- ds_ctxt_t::pipe_ctxt gets an in-class default of nullptr (matches
the existing fs_support_punch_hole = false default), so every
new ds_ctxt_t site starts with a sane pipe_ctxt.
- The sinks that allocate ds_ctxt_t via my_malloc (local, stdout,
xbstream, buffer, tmpfile) now pass MY_FAE | MY_ZEROFILL, so
those framework fields start at zero/false too.
- xbstream_init() then sets fs_support_punch_hole = true because
the xbstream wire format carries sparse chunks natively and can
faithfully round-trip holes regardless of the extraction
filesystem.
- ds_create()'s normalization block is replaced with a short
comment explaining the new contract: every init() is responsible
for advertising its own capabilities; the framework no longer
overrides them.
2. local_close() adds 1 to ds_local_ctxt_t::bytes_written right
after the successful 1-byte trailing write, so backup_size stays
authoritative for sparse files under --target-dir.
3. "Finsh" -> "Finish"; the report_backup_size() doc comment is
reflowed so the closing parenthesis lands on the same line as
the example it belongs to.
4. sum_file_bytes() early-returns 0 when its argument is not a
directory, eliminating the stray find(1) error and matching the
"0 if the directory is empty or does not exist" contract in the
helper's own comment.
Test:
-----
- bld/ (Debug) rebuild clean.
- t/backup_size_basic.sh: passed.
- t/backup_size_compress.sh: passed.
0 commit comments