Skip to content

fix(mcp): synchronize async video job snapshots - #3

Merged
mekjr1 merged 1 commit into
mainfrom
fix/mcp-video-job-race-20260913
Sep 14, 2026
Merged

mekjr1 merged 1 commit into
mainfrom
fix/mcp-video-job-race-20260913

Conversation

@mekjr1

@mekjr1 mekjr1 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Root cause

The async video worker updated mutable VideoJob fields under jobsMu, but get_flow_status released its read lock after retrieving the map pointer and then read those fields unlocked. Linux go test -race ./... caught the worker's status write racing the poller's status read.

Fix

  • Treat jobsMu as the guard for both the jobs map and every mutable VideoJob field.
  • Copy a coherent job snapshot while holding RLock, then build and marshal the poll response after unlocking.
  • Snapshot generation inputs and publish processing/terminal transitions under short locks, with related terminal fields assigned atomically and Status assigned last.
  • Keep generation, downloads, history writes, and filesystem work outside the lock.
  • Strengthen the async MCP test with a channel-gated loopback daemon that proves submission returns while generation is blocked, observes processing, releases the backend, waits boundedly for completion, and verifies request/result/file payloads before cleanup.

Validation

  • go test ./pkg/mcp -run '^TestAsyncVideoSubmitAndPoll$' -count=100
  • go test ./pkg/mcp -count=20
  • go vet ./...
  • go build ./...
  • git diff --check
  • Local go test -race unavailable because this Windows Go environment has CGO_ENABLED=0; the CI Linux race job is authoritative.
  • Local go test ./... reaches all packages but the unchanged pkg/gemini.TestRefreshSession fails because the installed Gemini Desktop app does not expose the required CDP endpoint on port 9223. The same normal suite passes on current-main Linux CI.

@mekjr1
mekjr1 merged commit ddbd6b1 into main Sep 14, 2026
4 checks passed
@mekjr1
mekjr1 deleted the fix/mcp-video-job-race-20260913 branch September 14, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant