Skip to content

jrag watch: skip client-side graph load when the daemon is alive (transient rc=2 during reindex) #426

Description

@HumanBean17

Context

Documented v1 limitation from PR #424 (jrag watch), spec §10 ("Known limitations & follow-ups").

The 6 jrag read handlers (_cmd_search / _cmd_find* / _cmd_inspect / _cmd_callers / _cmd_callees / _cmd_flow) call _load_graph_or_error on the client before get_payload. _load_graph_or_error opens the ORIGINAL code_graph.lbug read-only. When the watch daemon is alive, get_payload serves from the daemon (which reads a COW file snapshot during a graph reindex), so the client-side load is unnecessary — but it still happens, racing the graph-reindex subprocess writer.

Impact

Under kùzu's single-writer rule, a read-only open during a write may be refused, surfacing a transient rc=2 error for the ~seconds of a graph reindex. Not partial-data — the query result comes from the daemon's snapshot; this is only an error-path race.

Proposal

When is_daemon_alive(index_dir) is true, skip the client-side _load_graph and let the daemon's ERR_STALE_INDEX response drive the cold-fallback error path (cold _load_graph raises _IndexStale → handler renders the rebuild message, byte-identical to today's cold behavior).

Repro

Hard to reproduce deterministically (depends on kùzu's RO-during-RW behavior); manifests as occasional rc=2 from a jrag read command while jrag watch is mid-graph-reindex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions