fix: feat: stack lock protocol for singleton project stack access (#255)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a77aa19c3f
commit
564b8c90aa
1 changed files with 6 additions and 2 deletions
|
|
@ -98,6 +98,7 @@ stack_lock_acquire() {
|
||||||
lock_file="$(_stack_lock_path "$project")"
|
lock_file="$(_stack_lock_path "$project")"
|
||||||
local deadline
|
local deadline
|
||||||
deadline=$(( $(date -u +%s) + max_wait ))
|
deadline=$(( $(date -u +%s) + max_wait ))
|
||||||
|
local _rc=0
|
||||||
|
|
||||||
mkdir -p "$STACK_LOCK_DIR"
|
mkdir -p "$STACK_LOCK_DIR"
|
||||||
|
|
||||||
|
|
@ -130,17 +131,20 @@ stack_lock_acquire() {
|
||||||
remaining=$(( deadline - $(date -u +%s) ))
|
remaining=$(( deadline - $(date -u +%s) ))
|
||||||
if [ "$remaining" -le 0 ]; then
|
if [ "$remaining" -le 0 ]; then
|
||||||
echo "[stack-lock] timed out waiting for lock on ${project} (held by ${cur_holder})" >&2
|
echo "[stack-lock] timed out waiting for lock on ${project} (held by ${cur_holder})" >&2
|
||||||
return 1
|
_rc=1
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
echo "[stack-lock] ${project} locked by ${cur_holder}, waiting ${STACK_LOCK_POLL_INTERVAL}s (${remaining}s left)..." >&2
|
echo "[stack-lock] ${project} locked by ${cur_holder}, waiting ${STACK_LOCK_POLL_INTERVAL}s (${remaining}s left)..." >&2
|
||||||
sleep "$STACK_LOCK_POLL_INTERVAL"
|
sleep "$STACK_LOCK_POLL_INTERVAL"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "[stack-lock] unexpected status '${status}' for ${project}" >&2
|
echo "[stack-lock] unexpected status '${status}' for ${project}" >&2
|
||||||
return 1
|
_rc=1
|
||||||
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
return "$_rc"
|
||||||
}
|
}
|
||||||
|
|
||||||
# stack_lock_heartbeat <holder_id> <project>
|
# stack_lock_heartbeat <holder_id> <project>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue