Reuse evicted IDs

After evicting an entity, should it be possible to create a new entity with the exact same xt/id?

Asked another way: it’s possible to put an entity with an id that was previously evicted. Is it OK if I rely on this behavior?

Reason for asking: I’m thinking of replacing an evicted user-entity with an “anonymous” entity (user name and email removed, but company name still there) so when I look at the history of other entities, I can still see which company did what change.

Hey @xpekeler reusing evicted IDs is possible currently, however, it may be subject to race conditions if you ‘replace’ the evicted entity too quickly after the eviction, see: Race Condition for Eviction Tombstone · Issue #432 · xtdb/xtdb · GitHub

Also note that you can’t evict and re-put within the same transaction, see: xtdb/tx_test.clj at 7ec4828f48b3fb97ffd1baf4eda22857c9fcb48d · xtdb/xtdb · GitHub and evict then re-put to the same entity in the same transaction is broken · Issue #1337 · xtdb/xtdb · GitHub

Therefore as general advice right now, we would recommend to avoid resurrecting an evicted entity whilst those issues remain unresolved. That said, I’d be happy to try to help you reason about how to avoid the race condition :slight_smile:

Thanks. Waiting for the evict transaction wouldn’t be enough to avoid the race-condition? What else could I be waiting for between eviction and put? (We’re using Postgresql & RocksDB, if that makes a diffeerence)