(here's some background that covers this use-case)
There are a handful of spots in the datastore where we:
- INSERT INTO a table,
- ON CONFLICT, DO NOTHING
- and have a RETURNING clause
Example:
|
let instance: Instance = diesel::insert_into(dsl::instance) |
|
.values(instance) |
|
.on_conflict(dsl::id) |
|
.do_nothing() |
|
.returning(Instance::as_returning()) |
This is valid SQL, but it's a little suspect:
- If there are no conflicts (we're inserting the object with the UUID for the first time) we get the value that we intended to insert.
- However, if there are conflicts, this group of statements does not return any rows. Instead, it results in a
NotFound error from the database.
This means that, especially in situations where we expect idempotency, this statement may return different results if invoked multiple times.
(here's some background that covers this use-case)
There are a handful of spots in the datastore where we:
Example:
omicron/nexus/src/db/datastore.rs
Lines 880 to 884 in 3ae28c7
This is valid SQL, but it's a little suspect:
NotFounderror from the database.This means that, especially in situations where we expect idempotency, this statement may return different results if invoked multiple times.