Returns error code 74 on WAL fetch when WAL file does not exist #1195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Database name
Postgres
Pull request description
Describe what this PR fix
When running wal-g in restore_command, postgres has 3 ways to handle a exit code:
0: No problem, next WAL file...
1 - 125: End of timeline? Ok, lets stop recovery and go online
It would be great if wal-g would be able to distinguish between these cases with a proper exit code too.
Mostly it is so, but config errors, tcp errors, dns errors, etc have the same error code as 'archive does not exist (both 1).
This small change will allow wal-g to return exit code 74 when the wal file does not exist.
Please provide steps to reproduce (if it's a bug)
wal-g wal-fetch 000000010000000300000099 /tmp/000000010000000300000099
. It is 1.WALG_S3_PREFIX=123 wal-g wal-fetch 000000010000000300000099 /tmp/000000010000000300000099
. It is also 1. We should distinguish, but this not different to Postgres either...wal-g wal-fetch 00000001000000030000009A /tmp/00000001000000030000009A
and print the exit code. It is also 1, but should be distinguishablePlease see #1126 for more info.
Even with this fix, we still need Postgres to act differently too.
We have requested a change but it is not considered by the PG community yet.
For now we could make this work with a bash script: