Skip to content

A hot journal on the presence sidecar no longer stops every command on the board #41

Backlog

Description

@edkog

A process killed while writing the presence sidecar leaves a hot rollback journal. Every later command opens the sidecar read-only, cannot roll the journal back, and fails. The whole board stops until someone opens the sidecar read-write.

rows:
  - P7
env: "Node 26, Ubuntu 26.04 VM, two boards with about 20 seats each; seen on 0.9.4 (twice in one day), the same read-only open is in 0.9.5"
version: "0.9.5"
ran: any pullboard command (status, next, heartbeat) after a pullboard process was killed mid-write to .git/pullboard/board.sqlite.presence.sqlite
cause: "observationRows() and beatSeatFile() in packages/store/src/io/presence.js open the sidecar with new DatabaseSync(file, { readOnly: true }). A read-only connection cannot replay a hot journal (SQLITE_READONLY_ROLLBACK), and the catch only absorbs SQLITE_BUSY, so the error is rethrown."
blocks: "every command on the board; on one board for 82 minutes and on another for 12 minutes, until the sidecar was opened read-write by hand"
forbidden:
  - Deleting the journal file (that keeps a half-written page).
compat:
  - A busy sidecar still falls back to the last known observations (PRESENCE_BUSY).
  - The board file itself is never opened read-write for a presence read.
bar:
  - 1: with a hot journal left on the presence sidecar, a command recovers the sidecar (one read-write open that rolls the journal back) and succeeds [test]
  - 2: a sidecar busy past the timeout still returns the last known observations with one PRESENCE_BUSY warning [test, kept]
check:
  - 1: apps/cli/tests/io/presence.test.js > recovers a hot rollback journal on the presence sidecar
  - 2: apps/cli/tests/io/presence.test.js > busy sidecar keeps last known observations
error: |
  attempt to write a readonly database

Activity

  1. edkog commented on Nov 24, 2026

    @edkog
    Author

    Seen again on 0.9.5, twice in one morning (10:17 and 10:54 UTC) on a board with about 40 seats. Each time show, inbox and fact failed for every seat until a later writer rolled the journal back, and reviewers kept stale reservations meanwhile.

    A second read-only open hits the same error. persistedObservation() (called by heartbeatSeat(), so by every command's own beat) also opens the sidecar with { readOnly: true }, and the heartbeatSeat() catch absorbs only code 5. So a fix in observationRows() alone still leaves every command failing in its heartbeat.

    Repro (Node 26): kill a writer in the middle of a transaction, then open the file read-only:

    import { DatabaseSync } from 'node:sqlite';
    import { spawnSync } from 'node:child_process';
    import fs from 'node:fs';
    const file = fs.mkdtempSync('/tmp/hotj-') + '/p.sqlite';
    new DatabaseSync(file).exec('CREATE TABLE heartbeat(seat TEXT PRIMARY KEY, at TEXT NOT NULL)');
    spawnSync(process.execPath, ['-e', `const {DatabaseSync}=require('node:sqlite');const d=new DatabaseSync(${JSON.stringify(file)});d.exec('PRAGMA cache_size=1;BEGIN');const s=d.prepare('INSERT INTO heartbeat VALUES (?,?)');for(let i=0;i<20000;i++)s.run('seat'+i,'x'.repeat(200));process.kill(process.pid,'SIGKILL')`]);
    // journal left: true
    new DatabaseSync(file, { readOnly: true }).prepare('SELECT 1').get();
    // throws errcode 776 (SQLITE_READONLY_ROLLBACK, low byte 8): "attempt to write a readonly database"
    // one `new DatabaseSync(file)` rolls it back (journal gone, 0 rows), and read-only opens work again

    Workaround we run locally (two changes in packages/store/src/io/presence.js):

    • persistedObservation() returns null on low byte 8. heartbeatSeat() then opens read-write, and that open rolls the journal back. This is the recovery from bar 1.
    • observationRows() treats low byte 8 like BUSY (markBusy plus last known rows), so a read that runs before any beat doesn't crash.

    Bar 1 would also pass against the heartbeatSeat() path: with a hot journal, pullboard show <id> from a seat succeeds and leaves no journal.

  2. added
    See Research
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    See Research

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions