gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

pg_waldump: Added option --last-valid-walname

Open Annu149 opened this issue 1 year ago • 1 comments

Context: As suggested here we need to fetch the last valid wal segment to calculate the remaining bytes of startup recovery. So added option --last-valid-walname to pg_waldump to emit the last valid wal segment for the timeline provided with -t.

New option: --last-valid-walname output last valid wal segment for given timeline

Usage: pg_waldump -p <pg_wal_path> -t <timeline> --last-valid-walname

Example:

pg_waldump -p ./gpAux/gpdemo/datadirs/dbfast3/demoDataDir2/pg_wal/ -t 15 --last-valid-walname 
000000010000000000000003

Testing: Added TAP tests for pg_waldump

Code changes borrowed from: https://www.postgresql.org/message-id/attachment/129055/v5-0001-Introduce-feature-to-start-WAL-receiver-eagerly.patch

Suggested-by : Soumyadeep Chakraborty [email protected]

Here are some reminders before you submit the pull request

  • [ ] Add tests for the change
  • [ ] Document changes
  • [ ] Communicate in the mailing list if needed
  • [ ] Pass make installcheck
  • [ ] Review a PR in return to support the community

Annu149 avatar Apr 10 '24 19:04 Annu149

Responding to offline questions here, so that others can follow along, and we have a record of the decisions taken:

pg_waldump fails if no path is provided with -p or invalid timeline is provided. Should we do the same in case no valid wal file is found for given timeline?

What if no wal segment is found for given timeline? Should we print a message that 'No valid wal file found' with non-zero exit code?

Yes, just call fatal_error for this case, with error message: could not find valid WAL segment for timeline \"%d\". fatal_error implicitly returns exit(EXIT_FAILURE).

Output format? the output looks like below- pg_waldump -p ./gpAux/gpdemo/datadirs/dbfast3/demoDataDir2/pg_wal/ -t 15 --last-valid-wal 3

Have, LastValidWalSegment return XLogSegno, but print the full xlog filename utilizing XLogFilename in the callsite.

flag combinations? Right now the options -p and -t are needed with --last-valid-wal. What should we do if --last-valid-wal used with other options?

Since we just print the name of the log file, we aren't really dumping the contents (unlike the other pg_waldump options), the other flags don't really apply here. We can safely ignore the other flags. We can just add a validation that the timeline id is explicitly specified (and if not just pg_log_error("...") and goto bad_argument;). ~-p need not be specified btw and can be populated from defaults.~ Similarly, we also should enforce that -p was specified.

To make things clearer, --last-valid-wal -> --last-valid-walname

Shorthand for --last-valid-wal -> -w ? Please let me know if any other suggestions

Lets not provide the short option (avoids future conflict with upstream, in case upstream introduces a -w). So, lets just have --last-valid-wal.

soumyadeep2007 avatar Apr 12 '24 00:04 soumyadeep2007