Skip to content

Add processor graceful shutdown#286

Closed
karenychen wants to merge 1 commit into
mainfrom
codex/processor-close-graceful-shutdown
Closed

Add processor graceful shutdown#286
karenychen wants to merge 1 commit into
mainfrom
codex/processor-close-graceful-shutdown

Conversation

@karenychen

@karenychen karenychen commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add Processor.Close(ctx) as terminal, idempotent shutdown for stopping receives and abandoning messages held by the processor
  • keep inFlightMessages as a small mutex-protected message map; its close(ctx, settler) snapshots tracked messages under RLock, abandons each with a 10-second per-message context, and forgets each message only after abandon succeeds
  • use an internal shutdown context to cancel Start and in-flight handler contexts without requiring the caller to cancel the original start context
  • keep the processor semaphore for receive sizing for now, with a TODO to remove it in a later simplification
  • pause receiving before abandoning by canceling shutdown and waiting for any active receive batch to finish registering messages
  • add unit coverage for inFlightMessages, processor close behavior, the receive-before-close abandonment ordering, abandon timeout context, and keeping failed abandons tracked for retry

Validation

  • go test -run 'TestInFlightMessages|TestProcessorStart|TestProcessorClose' .
  • go test ./...
  • go test -race -run 'TestInFlightMessages|TestProcessor' .
  • git diff --check

Notes

  • Full go test -race ./... still hits pre-existing lock renewer test issues in v2/lockrenewer_test.go; this is logged locally in .issues/019eadca-cd7a-7a63-81c4-ce36450690f1.md.

@karenychen karenychen force-pushed the codex/processor-close-graceful-shutdown branch 6 times, most recently from 488c7d2 to 2130c6f Compare June 18, 2026 02:34
@karenychen karenychen force-pushed the codex/processor-close-graceful-shutdown branch from 2130c6f to 802a7a6 Compare June 18, 2026 02:52
@karenychen karenychen closed this Jun 18, 2026
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