fix(gallery): serialize same-backend upgrades - #11721
Conversation
localai-org-maint-bot
left a comment
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.
|
Review pass on this draft. The underlying race is worth fixing, so it would be a shame to let it rot. Three items, all author-side:
No maintainer action is pending beyond this, so whenever you have time to pick it back up it can move. |
localai-org-maint-bot
left a comment
There was a problem hiding this comment.
The DCO check is failing — commits need a Signed-off-by: Your Name <email> trailer. You can fix this by running:
git rebase --signoff HEAD~<num-commits>
git push --force-with-leaseThe implementation looks solid — the backend operation coordinator with channel-based per-path serialization and the WithSkipIfBackendBusy option for background auto-upgrades is a clean design. Tests are thorough. Once DCO is fixed I'll review the full PR.
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