Skip to content

Modern Docker Management, Designed for Everyone

fix: serialize concurrent per-container updates to prevent stranded recreate (#3541)

Tai Nguyencf20dd555756
diff --git a/backend/internal/services/updater_service.go b/backend/internal/services/updater_service.go
index c88b58730..2278a0ac5 100644
--- a/backend/internal/services/updater_service.go
+++ b/backend/internal/services/updater_service.go
@@ -9,6 +9,7 @@ import (
"maps"
"slices"
"strings"
+ "sync"
"time"
"emperror.dev/errors"
@@ -37,6 +38,11 @@ import (
type UpdaterService struct {
deps updaterDependenciesInternal
engine *updater.Service
+ // updateMu serializes per-container updates. docker compose's recreate
+ // pipeline is not concurrency-safe for sibling containers sharing a
+ // namespace. ponytail: global lock ceiling — all updates serialize; fine
+ // for a UI, upgrade to per-project if batch throughput ever matters.
+ updateMu sync.Mutex
}
type updaterDependenciesInternal struct {
@@ -400,6 +406,9 @@ func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID
s.completeAutoUpdateActivityInternal(ctx, activityID, out, err)
}()
+ s.updateMu.Lock()
+ defer s.updateMu.Unlock()
+
moduleResult, engineErr := s.engineInternal().UpdateContainer(ctx, containerID, updater.Options{})
if moduleResult != nil {
out = resultFromModuleInternal(moduleResult)