Repository navigation
Recover encrypted backup containers after key-read retries are exhausted - #14668
tclinkenbeard-oai wants to merge 2 commits into
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.
tclinkenbeard-oai
left a comment
There was a problem hiding this comment.
Generated by Codex.
What problem is this PR trying to solve? (ELI10)
Imagine the disk holding a backup’s encryption key stops responding. The backup agent tries several times, then remembers the failure. Even after the disk recovers, reopening that backup gives the agent the same container and the same error. The next write fails without reading the key again. Container reuse, previous key lookup
How does this PR solve the problem? (ELI10 and review walkthrough)
The next write tries the key file again. If the disk is back, the write can proceed. If the disk is still down, the agent can report the problem while it tries again.
- The container saves the filename alongside its first key read. A later lookup starts a new read only after
io_errororio_timeout. Concurrent callers share that read, and the first successfully loaded key stays with the container. Initialization, key selection, disk errors - An encrypted file waits for both the underlying file and the selected key. The callback holds the same key it waited for and passes it to the file wrapper. Encrypted file creation
- The agent waits for the initial key result. During a later read, it reports the previous disk error as
success: false. Once that read succeeds, the next status update reports success. Status lookup, agent call site, reported result
What is it trying to do?
Let a long-lived backup agent resume encrypted reads and writes after a temporary disk failure, without restarting the agent or changing keys mid-backup.
Is it correct?
Yes. The container owns the replacement read, so completing a status query early leaves that read available to file operations. The first load can still outlast a status transaction, but subsequent transactions can publish the failure immediately while the retry runs. This also covers keys belonging to finished backups. Status transaction
Are there bugs?
I found no correctness bugs. A short key file produces invalid_encryption_key_file, which stays cached. A disk failure keeps the container in encrypted mode, so opening an encrypted payload still requires a usable key. Key validation, encryption mode and retry guard
Are there omissions?
The regression starts with a cached timeout and checks immediate status, shared key identity, recovery, and propagation of an invalid-key error. It exercises the container boundary directly. I reviewed the published diff without running builds or tests during this review. Public CI was in progress at review time. Regression, checks for the reviewed commit
Are there better ways of doing things?
Keeping the retry in the container gives local and blob-store files the same behavior. The separate status lookup also keeps the agent’s transaction logic simple.
Should this CL be LGTMd?
Yes, LGTM. File operations wait for a usable key, and a persistent disk error can be reported while recovery is underway.
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS
macOS stat flags, not linux compatiblelock_mtime() { stat -f %m $LOCK || echo 0 }
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
An encrypted backup container retains the result of loading its key file. If all attempts to read the key fail with a disk error, later writes on that container keep returning the cached error even after the file becomes readable.
Start a fresh key load when a caller encounters that disk error. Concurrent callers share the new load, a successful load pins the key for the lifetime of the container, and a permanent key error still propagates. This extends the bounded retries within a single key load introduced in #14236.
The new regression and four adjacent encryption tests passed. An encrypted backup and restore simulation also passed, with all three backup tags completing.