oxidecomputer / oxidecomputer/omicron
`omdb db instance info`'s query for listing disks does a full-table scan if you pass `--include-deleted`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
this works:
[dogfood]root@oxz_switch0:~# omdb db instance info 49e48fb1-31b8-4d53-b44c-7d2be4715ea4 --all
note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
note: database schema version matches expected (285.0.0)
== INSTANCE ====================================================================
ID: 49e48fb1-31b8-4d53-b44c-7d2be4715ea4
project ID: 0dd597e2-60fe-435a-a8e4-90c8054f9dee
name: ro-test-again
description:
created at: 2026-02-11 22:56:11.665752 UTC
last modified at: 2026-02-11 22:56:11.665752 UTC
== CONFIGURATION ===============================================================
vCPUs: 2
memory: 8 GiB
hostname: ro-test-again
boot disk: Some(ed310d5c-258e-47bc-9ed9-a042700bac53)
auto-restart:
InstanceAutoRestart {
policy: Some(
Never,
),
cooldown: None,
}
== RUNTIME STATE ===============================================================
nexus state: Vmm
(i) external API state: Starting
intended state: running
last updated at: 2026-02-11T22:56:11.665752Z (generation 3)
needs reincarnation: false
karmic status: nirvāṇa (reincarnation disabled)
last reincarnated at: None
active VMM ID: Some(5a402cf7-0864-4b4b-9742-81c7d0c097ef)
target VMM ID: None
migration ID: None
updater lock: UNLOCKED at generation: 1
== ACTIVE VMM ==================================================================
ID: 5a402cf7-0864-4b4b-9742-81c7d0c097ef
instance ID: 49e48fb1-31b8-4d53-b44c-7d2be4715ea4
created at: 2026-02-11 22:56:13.685042 UTC
state: creating
updated at: 2026-02-11T22:56:13.685042Z (generation 1)
propolis address: fd00:1122:3344:101::1:1151:12400
sled ID: 7b862eb6-7f50-4c2f-b9a6-0d12ac913d3c
CPU platform: AmdMilan
== ATTACHED DISKS ==============================================================
# ID SIZE TYPE STATE NAME
0 ed310d5c-258e-47bc-9ed9-a042700bac53 10 GiB crucible attached ro-test-again-vm-attest-proto-vm-rootfs-ba15ea
== VIRTUAL RESOURCES PROVISIONED ===============================================
(i) no virtual resources provisioned for this instance
== VMM HISTORY =================================================================
ID STATE FAILURE_REASON GEN SLED_ID TIME_CREATED TIME_DELETED
5a402cf7-0864-4b4b-9742-81c7d0c097ef creating 1 7b862eb6-7f50-4c2f-b9a6-0d12ac913d3c 2026-02-11T22:56:13.685Z -
[dogfood]root@oxz_switch0:~#
but this doesn't work:
[dogfood]root@oxz_switch0:~# omdb db instance info 49e48fb1-31b8-4d53-b44c-7d2be4715ea4 --all --include-deleted
note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using DNS from system config (typically /etc/resolv.conf)
note: (if this is not right, use --dns-server to specify an alternate DNS server)
note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
note: database schema version matches expected (285.0.0)
== INSTANCE ====================================================================
ID: 49e48fb1-31b8-4d53-b44c-7d2be4715ea4
project ID: 0dd597e2-60fe-435a-a8e4-90c8054f9dee
name: ro-test-again
description:
created at: 2026-02-11 22:56:11.665752 UTC
last modified at: 2026-02-11 22:56:11.665752 UTC
== CONFIGURATION ===============================================================
vCPUs: 2
memory: 8 GiB
hostname: ro-test-again
boot disk: Some(ed310d5c-258e-47bc-9ed9-a042700bac53)
auto-restart:
InstanceAutoRestart {
policy: Some(
Never,
),
cooldown: None,
}
== RUNTIME STATE ===============================================================
nexus state: Vmm
(i) external API state: Starting
intended state: running
last updated at: 2026-02-11T22:56:11.665752Z (generation 3)
needs reincarnation: false
karmic status: nirvāṇa (reincarnation disabled)
last reincarnated at: None
active VMM ID: Some(5a402cf7-0864-4b4b-9742-81c7d0c097ef)
target VMM ID: None
migration ID: None
updater lock: UNLOCKED at generation: 1
== ACTIVE VMM ==================================================================
ID: 5a402cf7-0864-4b4b-9742-81c7d0c097ef
instance ID: 49e48fb1-31b8-4d53-b44c-7d2be4715ea4
created at: 2026-02-11 22:56:13.685042 UTC
state: creating
updated at: 2026-02-11T22:56:13.685042Z (generation 1)
propolis address: fd00:1122:3344:101::1:1151:12400
sled ID: 7b862eb6-7f50-4c2f-b9a6-0d12ac913d3c
CPU platform: AmdMilan
Error: listing attached disks
Caused by:
query `SELECT "disk"."id", "disk"."name", "disk"."description", "disk"."time_created", "disk"."time_modified", "disk"."time_deleted", "disk"."rcgen", "disk"."project_id", "disk"."disk_state", "disk"."attach_instance_id", "disk"."state_generation", "disk"."slot", "disk"."time_state_updated", "disk"."size_bytes", "disk"."block_size", "disk"."disk_type" FROM "disk" WHERE ("disk"."attach_instance_id" = $1) ORDER BY "disk"."time_created" DESC LIMIT $2` contains a full table/index scan which is explicitly disallowed
[dogfood]root@oxz_switch0:~#
...so that's not great!
presumably, when we are filtering out disks WHERE time_deleted IS NULL, this query:
https://github.com/oxidecomputer/omicron/blob/6b1ca22b4066024f8ac2c04bd678d6e09bf50a6f/dev-tools/omdb/src/bin/omdb/db.rs#L5186-L5193
hits an index of disks WHERE time_deleted IS NULL, and when we don't include that filter, it doesn't. we should do something about that.
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 dev-tools/omdb/src/bin/omdb/db.rs at lines 5186-5193, then inspect the disk query and its indexes. Reproduce the issue with omdb db instance info ... --all --include-deleted and check the query plan for the attached-disk listing. Done means the command lists disks with deleted records included without triggering a disallowed full-table or full-index scan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100