Repository navigation
store: Select entity ids as text in FindPossibleDeletionsQuery - #6789
Open
dimitrovmaksim wants to merge 1 commit into
Open
dimitrovmaksim wants to merge 1 commit into
dimitrovmaksim wants to merge 1 commit into
Conversation
dimitrovmaksim
force-pushed
the
fix/entity-changes-mixed-id-types
branch
from
November 18, 2026 15:34
b55bfe5 to
5d05300
Compare
The deletions query returned each id in its column type (text, bytea or int8). Schemas mixing id types made Postgres reject the UNION, and since EntityDeletion reads the id as text, Bytes or Int8 ids failed to decode, or rarely decoded to a wrong id, for any entity updated or deleted at the block, even without mixing. Fixes #6695
dimitrovmaksim
force-pushed
the
fix/entity-changes-mixed-id-types
branch
from
November 18, 2026 15:54
5d05300 to
624bea5
Compare
This branch has not been deployed
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.
Fixes #6695. Supersedes #6709.
Root cause
FindPossibleDeletionsQueryselected eachidin its column type (text,byteaorint8). That broke the index-nodeentityChangesInBlockin two independent ways:UNION ALLbranches disagree on type, so Postgres rejects the query (UNION types bytea and text cannot be matched), as diagnosed in entityChangesInBlock fails with "UNION types bytea and text cannot be matched" on schemas mixing Bytes and String IDs #6695.BytesorInt8ids, even without mixing:EntityDeletionreadsidas text, results arrive in binary format, and diesel decodesTextas UTF-8 over the raw bytes. So an entity updated or deleted at the block fails to decode (invalid utf-8 sequence …,can not convert … to Id::Int8) or, rarely, decodes to a wrong id.Fix
Select the id as text in every branch:
encode(e.id, 'hex')forBytesande.id::textforString/Int8.encodedoesn't depend onbytea_output, andBytes::from_strparses its bare hex.as idis needed becauseencode(...)would otherwise name the columnencode, andEntityDeletionreads columns by name.Scope
Only the read-only
entityChangesInBlockpath changes; indexing and query serving are unaffected. Related: #6742 fixed the same endpoint for immutable entities.Test
find_changes_with_bytes_ids,find_changes_with_int8_idsandfind_changes_with_mixed_id_typesupdate and delete entities, then checkfind_changes. On master each fails: the first two with the decode errors above, the mixed one with theUNIONerror.