mirror of
https://github.com/DeBrosOfficial/orama.git
synced 2026-08-06 16:29:26 +00:00
Live verification on anchat-test caught two real bugs the sqlite3 unit tests
missed:
1. Eviction ordered by SQLite rowid (insertion order) was WRONG: when an
existing account RE-registers its token (a CONFLICT/UPDATE), its row keeps its
original low rowid, so 'DELETE ... rowid < keeperRowid' evicted only
older-inserted rows and missed newer-inserted stale duplicates. Observed live:
11 accounts on one device token, 0 evictions fired. Fix: evict every OTHER
same-token row in the namespace (id != keeperId) so the just-registered owner
always wins — the ticket's 'one physical token -> one active owner'.
Registrations for a token are serial (one device, one active account, one
in-flight request; a retry CONFLICTs onto the same row), so the naive-delete
concurrency concern that motivated rowid can't occur, and would self-heal.
Adds a regression test seeding pre-existing duplicates + re-registering.
2. The token_fp backfill raced migration 033 at gateway startup ('no such
column') and failed permanently. Retry until the migration applies.