Repository navigation
db: add a table of data-plane session attach tokens - #808
Closed
NancyKwongPerplexity wants to merge 1 commit into
Closed
NancyKwongPerplexity wants to merge 1 commit into
NancyKwongPerplexity wants to merge 1 commit into
Conversation
A data-plane session stores one attach token in data_plane_sessions.token_hash, so replaying the session's create with the same idempotency key overwrites it and the token every earlier response returned stops working at once. Add data_plane_session_tokens, one row per token keyed by its hash, with its own expires_at and removed with its session. An index on (session_id, expires_at) serves per-session pruning and the cascade. The existing columns are unchanged. space_ro is fenced from the new token_hash column like data_plane_sessions.token_hash. Nothing reads or writes the table yet; the API starts using it in a following change.
Collaborator
Author
|
closing together with #809: the token table was only needed for that proposal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
data_plane_session_tokenstable so a data-plane session can hold more than one attach token. Today a session stores one token indata_plane_sessions.token_hash. Replaying the session's create with the same idempotency key overwrites that hash, so every token returned earlier stops working at once. Ten concurrent same-key replays leave nine callers holding tokens that fail with a non-retryable 401, and renewing a port session by replay can 401 requests still in flight on the previous token. The stacked change, #809, keeps every minted token valid until its own expiry. This PR adds only the storage, because the repository's migration-isolation check keeps migrations in their own PR.data_plane_session_tokens(token_hash text PRIMARY KEY, session_id text NOT NULL REFERENCES data_plane_sessions ON DELETE CASCADE, expires_at timestamptz NOT NULL, created_at timestamptz NOT NULL DEFAULT now()), with an index on(session_id, expires_at)for per-session pruning and the cascade.space_rois fenced from the newtoken_hashcolumn throughRO_COLUMN_DENYLIST, as it is fromdata_plane_sessions.token_hash.space_usergets DML through default privileges.Nothing reads or writes the table until #809 merges.
Validation
scripts/check-migration-versions.sh,scripts/check-postgres-migrations-isolated.shandscripts/check-postgres-migrations-squawk.shpass (Squawk: 0 issues).cargo nextest run --all-features -p pplx-space-db-migratepasses as part of the full run listed in api: keep earlier attach tokens valid when a session create is replayed #809. That run includesfresh_database_bootstraps_migrates_as_migrator_and_fences, which requires every*token_hashcolumn to be fenced fromspace_ro. With the denylist entry removed, it fails withdata_plane_session_tokens.token_hash holds auth material but is not fenced from space_ro. It passes with the entry in place.docs/installation.md), redeploying from the stacked branch ran thespace-db-migrateJob, which recorded version20261021182104and created the table. The E2E results are in api: keep earlier attach tokens valid when a session create is replayed #809.I did not run the down migration against a populated database.
Severity and risk
Severity: does not apply on its own. This PR is the storage for the fix in #809, which is moderate: replayed or renewed session tokens are rejected with a non-retryable 401.
Risk: low. The migration is additive: one new empty table and an index, no backfill, and no change to existing columns. It takes no lock on
data_plane_sessionsbeyond the foreign-key reference. Roll back with the down migration, together with #809 if that has shipped, since #809 writes the table.Rollout
Deploy this migration before #809. Releases without #809 ignore the table.
Stack
main).AI assistance: Claude Code drafted the code, tests, and this description; the author reviewed them.