Skip to content

libsql-server: Don't fail namespace load on corrupt stats file#2255

Open
penberg wants to merge 1 commit into
mainfrom
server-safe-stats
Open

libsql-server: Don't fail namespace load on corrupt stats file#2255
penberg wants to merge 1 commit into
mainfrom
server-safe-stats

Conversation

@penberg

@penberg penberg commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

If the server loses power, the stats file can end up empty because the stats persist loop did not sync the file to disk before renaming it over the old one. On restart, the stats file failed to parse, which errored out namespace load, and took the whole server down:

Error: Internal Error: `EOF while parsing a value at line 1 column 0`

Caused by:
    EOF while parsing a value at line 1 column 0

Stats are disposable telemetry, so fall back to default stats with a warning when the stats file does not parse, and sync the stats file to disk before renaming it to close the truncation window.

Fixes #2254

If the server loses power, the stats file can end up empty because
the stats persist loop did not sync the file to disk before renaming
it over the old one. On restart, the stats file failed to parse,
which errored out namespace load, and took the whole server down:

    Error: Internal Error: `EOF while parsing a value at line 1 column 0`

    Caused by:
        EOF while parsing a value at line 1 column 0

Stats are disposable telemetry, so fall back to default stats with a
warning when the stats file does not parse, and sync the stats file
to disk before renaming it to close the truncation window.

Fixes #2254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database getting corrupted on power loss

1 participant