Skip to content

Occasional database is locked errors when backfilling replica on SQLite #31

@DavidBuchanan314

Description

@DavidBuchanan314

Example:

time=2026-02-13T16:51:34.108Z level=ERROR msg="database is locked" component=opstore error="database is locked" query="INSERT INTO `host_cursors` (`host`,`seq`) VALUES (\"plc.directory\",1897383) ON CONFLICT (`host`) DO UPDATE SET `seq`=`excluded`.`seq`" duration=5.004547649s rows=0 file=/home/david/go/pkg/mod/github.com/orandin/[email protected]/logger.go:163
time=2026-02-13T16:51:34.108Z level=ERROR msg="failed to persist cursor" component=ingestor error="database is locked"

Happens when the cursor update happens at the same time as a batch of ops are getting committed (sqlite is single-writer).

This is mostly harmless, since the cursor is persisted every second, so the next attempt will likely succeed. We could maybe convert it into a warning. Or use application-level locking to make sure there are never any concurrent writers? Or tell Gorm to retry automatically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions