Skip to content

Fix _get_server_keys_json invalidations over replication as JSON#19966

Open
erikjohnston wants to merge 2 commits into
developfrom
erikj/portdb6-pr1-storage-type-correctness
Open

Fix _get_server_keys_json invalidations over replication as JSON#19966
erikjohnston wants to merge 2 commits into
developfrom
erikj/portdb6-pr1-storage-type-correctness

Conversation

@erikjohnston

@erikjohnston erikjohnston commented Jul 15, 2026

Copy link
Copy Markdown
Member

The cache key of _get_server_keys_json is a single argument which is itself a (server_name, key_id) tuple, and store_server_keys_response passed that nested tuple straight into the cache invalidation stream.
psycopg2 quietly serialises the inner tuple as a Postgres record, so the keys column of cache_invalidation_stream_by_instance ended up holding the record literal as a single string (e.g. {"(srv,ed25519:abc)"}) — which never matches the real cache key on the receiving side, i.e. the
invalidation has always been a silent no-op on workers. The native Rust backend's stricter parameter conversion turns the same nested tuple into a loud TypeError: unsupported parameter type for postgres: tuple.

Fix it the same way #18899 did for _get_e2e_cross_signing_signatures_for_device, which has the same nested-tuple key shape: invalidate the local cache directly, JSON-encode the key for the replication row, and decode it again in process_replication_rows.

Found as part of the the effort to port the database pool to Rust.

@erikjohnston erikjohnston changed the title Erikj/portdb6 pr1 storage type correctness Storage type correctness: user-directory temp position & server-keys cache invalidation Jul 15, 2026
erikjohnston and others added 2 commits July 15, 2026 16:03
The cache key of `_get_server_keys_json` is a single argument which is
itself a `(server_name, key_id)` tuple, and `store_server_keys_response`
passed that nested tuple straight into the cache invalidation stream.
psycopg2 quietly serialises the inner tuple as a Postgres *record*, so the
`keys` column of `cache_invalidation_stream_by_instance` ended up holding
the record literal as a single string (e.g. `{"(srv,ed25519:abc)"}`) — which
never matches the real cache key on the receiving side, i.e. the
invalidation has always been a silent no-op on workers. The native Rust
backend's stricter parameter conversion turns the same nested tuple into a
loud `TypeError: unsupported parameter type for postgres: tuple`.

Fix it the same way #18899 did for
`_get_e2e_cross_signing_signatures_for_device`, which has the same
nested-tuple key shape: invalidate the local cache directly, JSON-encode the
key for the replication row, and decode it again in
`process_replication_rows`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZdvuLkg7Lm7wDtPQzDnJx
@erikjohnston
erikjohnston force-pushed the erikj/portdb6-pr1-storage-type-correctness branch from 2b4c689 to 6f02259 Compare July 15, 2026 15:04
@erikjohnston erikjohnston changed the title Storage type correctness: user-directory temp position & server-keys cache invalidation Send _get_server_keys_json invalidations over replication as JSON Jul 15, 2026
@erikjohnston
erikjohnston marked this pull request as ready for review July 16, 2026 08:45
@erikjohnston
erikjohnston requested a review from a team as a code owner July 16, 2026 08:45
@erikjohnston erikjohnston changed the title Send _get_server_keys_json invalidations over replication as JSON Fix _get_server_keys_json invalidations over replication as JSON Jul 16, 2026
@MadLittleMods MadLittleMods added the A-Workers (includes replication) label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Workers (includes replication)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants