Skip to content

Reduce sequence-assignment allocator round trips - #1373

Draft
JackWilb wants to merge 8 commits into
devfrom
codex/1322-reduce-allocator-round-trips
Draft

Reduce sequence-assignment allocator round trips#1373
JackWilb wants to merge 8 commits into
devfrom
codex/1322-reduce-allocator-round-trips

Conversation

@JackWilb

Copy link
Copy Markdown
Contributor

Summary

  • reserve Firebase assignments with one bounded rejected-slot query followed by one transaction, without the duplicated participant/allocator pre-reads
  • retry a bounded candidate conflict so concurrent starts preserve rejected-slot reuse order without double claims
  • add a single atomic Supabase allocate_sequence_assignment RPC that commits allocator state, reusable-slot claims, and the participant assignment together
  • retain lazy legacy assignment/allocator handling and the bounded Supabase compare-and-swap fallback for deployments that have not installed the RPC yet
  • document provider operation bounds, deployment requirements, and live-trace limitations

Why

The bounded allocator from #1311 still serialized provider reads before its atomic reservation step. Firebase read participant and allocator state before reading them again in the transaction, while Supabase separately selected, claimed, reserved, and created rows. Those extra request/response cycles remained on fresh participant startup.

This change moves Supabase allocation into one database transaction and removes Firebase's duplicated document pre-read phase while preserving atomic assignment, FIFO rejected-slot reuse, legacy compatibility, bounded contention failure, and startup recovery when participant-data persistence fails after assignment.

Stack dependency

This PR targets dev but is stacked on #1311 because dev does not yet contain the bounded allocator that #1322 optimizes. The #1322 implementation is isolated in commit 086a1c5b; merge #1311 first so this PR's review diff collapses to the allocator round-trip changes.

Deployment

  • Apply supabase/migrations/20260730000000_allocate_sequence_assignment.sql before enabling the one-RPC Supabase path.
  • Deploy firestore.indexes.json to each Firebase project so rejected candidates can be selected deterministically by assignment timestamp.

Validation

  • yarn unittest --run — 2,054 passed, 1 skipped
  • focused storage/provider suite — 218 passed
  • yarn typecheck
  • yarn lint
  • yarn build
  • git diff --check
  • PostgreSQL 15 migration smoke for fresh allocation, rejected reuse, returning assignment recovery, and legacy index lookup

Live before/after HAR capture was unavailable because the development environment does not have authenticated Firebase and Supabase study credentials. SEQUENCE_ASSIGNMENT_ALLOCATION.md records the expected provider-operation traces and the production verification still needed after deploying the migration and index.

Closes #1322.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

A preview of 8044ab2 is uploaded and can be seen here:

https://revisit.dev/study/PR1373

Changes may take a few minutes to propagate.

@JackWilb JackWilb linked an issue Jul 31, 2026 that may be closed by this pull request
8 tasks
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.

Reduce bounded sequence-assignment allocator round trips

1 participant