SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

datastore: fix two inserts in tx state with unique idx

Open Centril opened this issue 8 months ago • 0 comments

Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/2601.

This fixes two bugs, where if you:

  1. define a table with struct T { #[unique] x: u32 }
  2. insert T { x: 42 } twice => bug 1, will panic but shouldn't.
  3. find row for 42 => empty iterator => bug 2

API and ABI breaking changes

There was a bug where inserting twice caused a unique constraint violation, but again, it's a bug.

Expected complexity level and risk

4 - the datastore is getting messy.

Testing

  • The test test_set_semantics was buggy and is now fixed.
  • A regression test add_twice_and_find_issue_2601 is added for bug 2.

Centril avatar Apr 14 '25 20:04 Centril