Skip to content

Add VTGate sequence range caching - #245

Draft
ramnov wants to merge 1 commit into
release-23.0-githubfrom
copilot/vtgate-sequence-cache
Draft

ramnov wants to merge 1 commit into
release-23.0-githubfrom
copilot/vtgate-sequence-cache

Conversation

@ramnov

@ramnov ramnov commented Sep 25, 2026

Copy link
Copy Markdown

What's this?

Adds an opt-in, in-memory VTGate cache for VSchema auto_increment sequences. The goal is to avoid a sequence-primary RPC on every insert, especially when VTGate and the sequence primary are in different regions.

How it works

  • Reserves ID blocks through the existing NEXT N sequence path; VTTablet is unchanged.
  • Keeps an independent, concurrency-safe cache per VTGate process and sequence.
  • Serves cache hits locally and reserves a new contiguous block when the current range cannot satisfy an insert.
  • Adds --enable-sequence-cache and --sequence-cache-size flags plus per-sequence metrics.
  • Leaves background prefetch and reset/migration invalidation out of this initial proof of concept.

Testing

  • Sequence cache unit tests, including concurrent allocation and refill failures
  • Linux race detector
  • VTGate enabled/disabled sequence integration tests
  • VTGate engine insert tests
  • Size generator verification

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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