fix: hold the deploy lock across git-from-directory and harden the advisory lock

git-from-directory updated the deploy branch before taking the deploy
lock and rolled it back after releasing it. The lock is now held for the
whole update, build, and rollback, and the rollback only moves the branch
if it still points at the commit that was created.

A failed lock attempt and apps:lock both truncated the lock file,
dropping the build id of the in-progress deploy that builds:cancel and
builds:output read. Releasing the lock unlocked before removing the
file, so a waiter could end up holding a lock on a deleted file while
another deploy locked a new one. The file is now removed before
unlocking, and acquiring retries when the locked file is no longer the
one at the lock path.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-10-11 16:21:13 -04:00
1 parent 7955e8ee06
commit 11c4e908d5
8 files changed
+312 -56

No files matched your search

+1 -1
View File
@@ -279,7 +279,7 @@ cmd-git-sync() {
fi
local APP_ROOT="$DOKKU_ROOT/$APP"
local APP_DEPLOY_LOCK_FILE="$DOKKU_LIB_ROOT/data/apps/$APP/.deploy.lock"
local APP_DEPLOY_LOCK_FILE="$(app_deploy_lock_file "$APP")"
local fetch_exit_code=0
dokku_setup_build_capture "$APP" "git:sync"