In StoreSql.setTransaction we do getTransaction() then insertInto(). Under concurrency, two callers can both pass the existence check and one will hit a DB uniqueness error. That’s fine functionally, but:
- the thrown error will likely be a raw DB error, not the nice "already exists" message
- it’s better to enforce "insert-only" at the DB layer (e.g., INSERT ... ON CONFLICT DO NOTHING/RAISE) and map to a consistent error.
In StoreSql.setTransaction we do
getTransaction()theninsertInto(). Under concurrency, two callers can both pass the existence check and one will hit a DB uniqueness error. That’s fine functionally, but: