oxidecomputer / oxidecomputer/omicron
[db] Audit usage of "ON CONFLICT DO NOTHING RETURNING ..."
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
(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
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
NotFounderror from the database.
This means that, especially in situations where we expect idempotency, this statement may return different results if invoked multiple times.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in nexus/src/db/datastore.rs around lines 880-884, then search the datastore for INSERT statements combining ON CONFLICT DO NOTHING with RETURNING. Review each use against the described conflict behavior; the audit is done when all affected usages have been identified and their inconsistent idempotent results are addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100