[#1025] Stop a restore which cannot lock its backend instead of completing it - #1027
Open
vharseko wants to merge 1 commit into
Open
[#1025] Stop a restore which cannot lock its backend instead of completing it#1027vharseko wants to merge 1 commit into
vharseko wants to merge 1 commit into
Conversation
…end instead of completing it RestoreTask guarded the restore with `if (verifyOnly || lockBackend(backend))` and had no else branch: when the backend lock was refused the whole restore block was skipped, errorsEncountered stayed false, the backend was re-enabled, the listeners were told the restore succeeded and the task ended in COMPLETED_SUCCESSFULLY - the restore CLI exited 0 right after printing the lock error. A refused lock now ends the task in STOPPED_BY_ERROR through the finally which re-enables the backend and reports the failure to the listeners, the way BackupTask and ImportTask already treat it. Fixes OpenIdentityPlatform#1025.
vharseko
force-pushed
the
issues/1025-restore-lock-failure
branch
from
September 11, 2026 13:56
ad67ade to
3e600a7
Compare
Member
Author
|
@maximthomas rebased onto |
vharseko
requested review from
maximthomas
and removed request for
maximthomas
September 11, 2026 14:12
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.
Fixes #1025.
Rebased onto
masterafter #969 (e86f702f8e) landed; the branch is the single commit3e600a73a1, its content unchanged from the originalad67ade1e9(same patch-id).The bug
RestoreTask.runTask()guarded the restore withif (verifyOnly || lockBackend(backend))and had noelse. When the backend lock was refused - another process holds it, or the lock file cannot be created - the whole restore block was skipped,errorsEncounteredstayedfalse, thefinallyre-enabled the backend and told the listeners the restore succeeded, and the task returnedgetFinalTaskState(), i.e.COMPLETED_SUCCESSFULLY. TherestoreCLI printed theERR_RESTOREDB_CANNOT_LOCK_BACKENDline from the task log and exited 0 right after it.The change
A refused lock ends the task the way
BackupTaskandImportTaskalready end theirs, and the way #969 already ends a faileddisableBackend():The return passes through the
finally, which re-enables the backend and notifiesprocessRestoreEnd(..., false). The rest of theRestoreTaskhunk is the de-indentation of the formerifbody -?w=1shows the five real lines.restore --verifyOnlyis unaffected: it never takes the lock.Test
TestBackupAndRestore.testRestoreEndsInErrorWhenTheBackendCannotBeLocked- self-contained: it backsuserRootup into a temporary directory, takes a shared lock on the backend's lock file and restores from that backup.LockFileManagerreference-counts shared locks, so the task'sdisableBackend()releases the backend's own reference but not the test's, and the exclusive lock the restore needs is refused withERR_FILELOCKER_LOCK_EXCLUSIVE_REJECTED_BY_SHARED. Asserted:STOPPED_BY_ERROR, one begin and one end notification,successful == falseat the end notification, anduserRootregistered again afterwards.Before the change the test fails with
expected [STOPPED_BY_ERROR] but found [COMPLETED_SUCCESSFULLY], the task log carrying the refused-lock error. It also runs the restore half of #969'sfinally- thebackendDisabledre-enable and the!errorsEncounterednotification - which the review of #969 noted no test executed.Run:
TestBackupAndRestore13/13,TestImportAndExport14/14,PrivilegeTestCase185/185,ReSyncTest2/2,LDIFBackendTestCase22/22.