oxidecomputer / oxidecomputer/omicron

instance creation & the create saga should avoid refetching DB records where possible

Open
#2,945 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug nexus
Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

When Nexus creates an instance in a project, it runs the creation saga, then refetches the instance's record from CRDB and returns the refetched record. But once the instance has moved out of the "Creating" state, it can be stopped and deleted, which could cause instance creation to 404, as described in this comment:

https://github.com/oxidecomputer/omicron/blob/86826161f0a03d367755332949c6883008603de9/nexus/src/app/instance.rs#L180-L224

The create saga itself also refetches records in a mildly dangerous way. If the saga creates an instance but doesn't start it, the saga will have a step that tries to move the instance's state to "Stopped" unconditionally. This is incorrect if the step gets replayed, as described in this comment:

https://github.com/oxidecomputer/omicron/blob/86826161f0a03d367755332949c6883008603de9/nexus/src/app/sagas/instance_create.rs#L1340-L1364

These cases can be fixed by taking advantage of the fact that nexus_db_model::Instances are (now) serializable (at one point they weren't), such that a serialized instance description can be passed from saga step to saga step (or provided as saga output).

This may help address some cases of #1536 (if we don't do a DB fetch, we can't use the wrong key!), but the two issues are distinct and this one won't totally address that one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sections in nexus/src/app/instance.rs (lines 180-224) and nexus/src/app/sagas/instance_create.rs (lines 1340-1364). Trace the instance creation response and saga steps to identify the refetches and replay behavior. Done means serialized Instance records are reused where possible, avoiding the described 404 and unconditional state transition cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.