Repository navigation
Make fdbbackup query exit non-zero when it fails - #14125
Merged
saintstack merged 2 commits intoOct 22, 2026
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Every failure path printed a JSON error object and returned normally, so stopAfter() yielded a present Optional and main() kept FDB_EXIT_SUCCESS. Automation checking the exit code read failures as successes. queryBackup now reports its status through the fstatus future, which was already declared and inspected for this but never assigned. An absent value means stopAfter() absorbed a fatal error, so it maps to FDB_EXIT_ERROR. Throwing instead would emit SevError and a stderr line for an ordinary "no restorable files set" answer, breaking stdout as a single parseable document.
saintstack
force-pushed
the
dev/stack/fdbbackup-query-exit-code
branch
from
October 13, 2026 20:38
a6690f8 to
477ff5f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
@saintstack LGTM for the most part. I had two thoughts:
|
…-resolution errors dir_backup_tests now runs `fdbbackup query` against an existing backup (exit 0) and a missing one (non-zero). The success check is skipped for encrypted backups because query cannot be given an encryption key and fails with "Restore error" on the manifest. Move the restore-timestamp resolution inside queryBackup's try so a failure there is reported as a JSON error with FDB_EXIT_ERROR like every other failure, instead of escaping to stopAfter().
Contributor
Author
Good review. Done. Please take another look @akshay-v-kaushik |
Contributor
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos on macOS 14.x
|
Contributor
Author
|
Thanks for the review @akshay-v-kaushik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fdbbackup queryreports failures as a JSON object on stdout and then returns normally.stopAfter()therefore yields a presentOptional, andmain()leaves the exit status atFDB_EXIT_SUCCESS.Every failure path is affected, including "no restorable files set found for specified key ranges" and the catch-all for an arbitrary
Error. Automation that checks the exit code — the normal thing for shell automation to trust — reads those failures as successes.Fix
queryBackupnow returns its own exit status through thefstatusfuture. That future was already declared and already inspected inmain()for exactly this purpose, but nothing had ever assigned it.The six failure paths
co_return FDB_EXIT_ERROR; the success path returnsFDB_EXIT_SUCCESS.The
fstatuscheck is also widened so an absent value maps toFDB_EXIT_ERROR. Absent meansstopAfter()absorbed a fatal error rather than the command choosing a status — reachable here because the restore-timestamp resolution at the top ofqueryBackupsits outside the function'stry.Why not just throw
Throwing from the failure paths would produce the right exit code via the existing
fcheck, butstopAfter()would also raise aSevErrortrace event and printFatal Error: ...to stderr for an ordinary "no restorable files set" answer. That is the wrong severity for a routine negative result, and it breaks the one useful property this subcommand has: stdout is a single parseable JSON document and nothing else.Note that
submitBackupandsubmitDBBackupalready throwactor_cancelledspecifically to reachstopAfter's quiet branch, so the tension withstopAfter's severity is pre-existing.Testing
ninja fdbbackup backup_testsclean.BackupTests: 21/21, exit 0.Failure path, against a container URL that does not resolve:
Previously
exit=0.The success path returning 0 has not been exercised against a real backup container. It is
co_return FDB_EXIT_SUCCESSwithFDB_EXIT_SUCCESS == 0.Caveat
stopAfterleaves its result at the initializedT()forplease_reboot,please_reboot_delete,actor_cancelledandlocal_config_changed. Forintthat is0, so a cancelled query still exits 0 and the new absent-value branch does not cover it. This matches the pre-existing behaviour through thefpath and does not matter for a one-shot CLI, but it means this change should not be described as "any failure now exits non-zero".Compatibility
fdbbackup querypreviously exited 0 on failure and now exits 1. Anything relying on the old behaviour — for example treating a non-zero exit as "the binary itself broke" rather than "the query failed" — will see a change. The JSON on stdout is unchanged in both shape and content.No
fdbbackup queryinvocation exists infdb-kubernetes-tests.