Skip to content

Server: a failed --fast import can invalidate the live DB (fatal index error takes the server down until restart) #82

Description

@jozef2svrcek

Symptom

During a TWIC --fast import (appender-based, not crash-safe), a fatal DuckDB index error occurred and left the database in DuckDB's invalidated state — the whole server then refused all queries ("database has been invalidated … must be restarted prior to being used again") until sudo systemctl restart lpdo-server. The on-disk DB was intact (the failed work rolled back on reopen), but the live server was dead until a manual restart.

The underlying error:

Invalid Input Error: Failed to delete all rows from index. Only deleted 0 out of 1 rows. Chunk: … FLAT INTEGER: [100970] … VARCHAR: ['alvarenga rogerio almeida'] …

i.e. an ART-index delete on a player row (id 100970) failed mid-import.

Two things to fix

  1. Why did the index delete fail? Investigate the import's player/index path — chess-db/src/importer (import), the player dedup/normalise/merge logic, and the players index. The "delete 0 of 1 rows from index" smells like an ART index inconsistency (possibly DuckDB-version-specific, or a dedup/merge touching an index row that's out of sync). Reproduce a fast import that triggers the player path.
  2. A failed import must not poison the live DB. The --fast path bypasses transactional safety (appender bulk insert), so an error invalidates the writer connection for the whole server. Make it fail gracefully — e.g. run it transactionally / staged with checkpoints, or isolate the appender work so a failure rolls back cleanly instead of putting the connection into the fatal state. (serve.rs/jobs.rs already flag fast ops as non-crash-safe.)

Impact

Affects the daemon on all platforms: one failed import → the server is unusable until someone restarts it. Hit during the wizard TWIC import on the new thin-client + system-daemon setup (the GUI close was coincidental — a pure client doesn't stop the daemon).

Relation

Complementary to #81 (clean recovery UI + server-side auto-reopen of the DB connection on the invalidated state — the safety net). This issue is the root cause: prevent the invalidation in the first place. With both fixed, a failed import neither corrupts state nor takes the server down.

Pointers

  • chess-db/src/jobs.rs — the import job (--fast) path.
  • chess-db/src/importer/import(), player handling/dedup.
  • chess-db/src/serve.rs — the single writer connection (ConnActor) that got invalidated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions