Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/test-push-worker-registration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ source "$SCRIPT"
)
trap 'rm -rf "$TEST_DIR"' EXIT

# Deterministic coordinator contract: a live worker can republish after cleanup.
(
root="$TEST_DIR/republish-tracking"; mkdir -m 0700 "$root"
state_file="$root/worker.state"; : > "$state_file"
ACTIVE_WORKERS=([424242]=12345)
ACTIVE_WORKER_STATE_FILES=([424242]="$state_file")
ACTIVE_WORKER_STATE_STARTS=([424242]=12345)
worker_session_state_maybe_cleanup_failed() { return 0; }
cleanup_calls=0
cleanup_worker_session_state_file() { cleanup_calls=$((cleanup_calls + 1)); rm -f -- "$1"; }
cleanup_active_failed_worker_sessions
[[ ${ACTIVE_WORKER_STATE_FILES[424242]:-} == "$state_file" && ${ACTIVE_WORKER_STATE_STARTS[424242]:-} == 12345 ]] || fail "active cleanup lost live publisher tracking"
: > "$state_file"
ACTIVE_WORKERS=()
job_is_active() { return 1; }
cleanup_published_worker_sessions
assert_eq 2 "$cleanup_calls" "post-reap fallback handles republished state"
[[ ! -e $state_file && ${#ACTIVE_WORKER_STATE_FILES[@]} == 0 && ${#ACTIVE_WORKER_STATE_STARTS[@]} == 0 ]] || fail "republished state remains"
pass "live publisher tracking survives successful active cleanup"
)

setup_fixture() {
local root="$1"
CURRENT_FIXTURE_ROOT=$root
Expand Down
5 changes: 3 additions & 2 deletions tools/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1309,8 +1309,9 @@ cleanup_active_failed_worker_sessions() {
cleanup_worker_session_state_file "$file" "$worker_pid" "$worker_start" true || status=$?
case "$status" in
0)
unset 'ACTIVE_WORKER_STATE_FILES[$worker_pid]'
unset 'ACTIVE_WORKER_STATE_STARTS[$worker_pid]'
# The accepted worker may publish again until it has been reaped.
# Keep its identity/path for the final post-reap cleanup pass.
:
;;
"$WORKER_SESSION_STATE_TRANSIENT_STATUS"|"$WORKER_SESSION_STATE_NOT_READY_STATUS"|"$MANAGED_LEADER_REAP_PENDING_STATUS")
;;
Expand Down