fix(gallery): serialize same-backend upgrades - #11721
Draft
poorpaper wants to merge 1 commit into
Draft
Conversation
localai-org-maint-bot
requested changes
Aug 25, 2026
localai-org-maint-bot
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for tracking down the same-path race. The coordinator shape looks reasonable, and the focused gallery tests pass locally, but this needs a few changes before it is ready:
core/gallery/backend_operation_internal_test.goimplements all cases with stdlibtestingassertions (t.Fatalf, etc.). LocalAI requires Ginkgo v2/Gomega for Go tests, andforbidigoenforces this in lint. Please convert these cases to the package’s existing Ginkgo suite instead of adding a standalone stdlib-style suite.- Please add a focused
LocalBackendManager.UpgradeBackendregression test covering the newop.ID == ""contract: an empty-ID background operation must use the non-blocking option, while an explicit non-empty-ID operation must wait. That boundary is what connectsUpgradeCheckerto the coordinator and is currently only implied by the direct coordinator tests. - DCO is
ACTION_REQUIRED. Please amend the commit yourself with your ownSigned-off-bytrailer and force-push it; maintainers/automation cannot provide that legal attestation for you.
I verified git diff --check and go test ./core/gallery -run "TestBackendOperationCoordinator|TestUpgradeBackendUsesResolvedConcretePath" -count=1 on head 6c5b6ab36a37db0de62f07ffbda02ca011682e5d.
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.
Summary
Problem
In standalone mode, manual upgrades run through the serialized GalleryService
worker, while UpgradeChecker can invoke BackendManager.UpgradeBackend directly.
This allows both paths to upgrade the same backend concurrently. Because both
invocations reuse and remove the same
<backend>.upgrade-tmpand<backend>.backuppaths, one invocation can delete the other one's extractiondirectory or rollback backup. This can cause extraction failures and leave the
previously installed backend missing.
Background auto-upgrades now back off when the same resolved backend is already
being upgraded. Explicit upgrades remain serialized and context-cancellable.
Testing
go test ./core/gallery -run "TestBackendOperationCoordinator|TestUpgradeBackendUsesResolvedConcretePath" -count=20go test ./core/gallery -count=1go test ./core/application ./core/services/galleryop -run "^$" -count=1Fixes #11720