Skip to content

No way to read a stopped node's buyer.redb for post-mortem inspection #2084

Closed

Description

@thiras

#2081 made decdn pool list read a node's buyer pools through admin_v1_pools instead of manufacturing an unrelated client store beside them. It deliberately does not fall back to reading from disk when the daemon is unreachable, because falling back to the client store is exactly the defect #2078 was about.

The consequence is that a stopped node's buyer.redb is now readable by nothing. Post-mortem inspection after a crash, or while a host is deliberately down for maintenance, has no route.

Why a disk read is legitimate here

redb holds its process-exclusive lock only for the lifetime of an open Database. Once the daemon exits the lock is released, and redb::ReadOnlyDatabase::open works — its own docs say "Multiple processes may open a ReadOnlyDatabase, but it may not be opened concurrently with a Database". So the impossibility that motivated the admin-RPC route is specific to a running daemon, and the lock itself is what tells the two cases apart: if the read-only open succeeds, no daemon holds the file.

Current behaviour

list_from_daemon (crates/cli/src/commands/pool.rs) hard-errors on any admin-call failure, discriminating only between "the daemon answered and refused" (jsonrpsee Call) and everything else. Connection-refused lands in the latter and produces "Start decdn-node, or pass --data-dir <client dir>" — correct advice for a node you want running, useless for one you are inspecting because it is not.

Suggested direction

On a connection-refused specifically, attempt ReadOnlyDatabase::open against <data_dir>/buyer.redb:

  • Succeeds → render it, labelled distinctly. source=node_store_offline in --json, and a store=<path> (read from disk; no daemon running) line in the table, so the provenance stays unambiguous — the property the whole change exists to preserve.
  • Fails with DatabaseAlreadyOpen → a daemon is holding it, so the admin URL was wrong rather than the daemon being down. Say that instead; it is a strictly better error than the current one.
  • Fails otherwise → today's error.

Note this needs a read-only open path in decdn-incentive; RedbBuyerPoolStore::open uses Database::create, which would take the write lock (and, on a genuinely absent file, create one — the behaviour #2078 was about, so the read-only variant must never create).

Related

The same reasoning applies to decdn pool close --pool / reclaim --pool on a node data dir: they currently report the daemon's row as untouched on the grounds that a running daemon holds the store, but with the daemon stopped the CLI could clear that row honestly instead. Worth deciding alongside this, since both hinge on distinguishing "a daemon owns this dir" from "a daemon is running right now" — a distinction the current classifier does not make, by design.

Activity

  1. added
    kind:feature
    area:cli
    on Sep 20, 2026
  2. moved this from Backlog to In progress in deCDNon Sep 20, 2026
  3. thiras commented on Sep 20, 2026

    @thiras
    ContributorAuthor

    Scoped to `pool list` in #2085. The "Related" half — close --pool / reclaim --pool clearing a stopped daemon's row — is deliberately left out: it needs a write lock on buyer.redb, which is a different capability from the read-only open, and one that races a daemon restarting mid-command. ReadOnlyBuyerPoolStore has no write path on purpose.

    The distinction the issue asks for — "a daemon owns this dir" vs "a daemon is running right now" — does now exist in code (a successful read-only open proves the second is false), so the follow-up has what it needs.

    🤖 Generated with Claude Code

  4. moved this from In progress to Done in deCDNon Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:feature

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions