Skip to content

feature: prevent database writes when the topic is idle - #4

Merged
dkotik merged 1 commit into
masterfrom
noWriteOnEmptyBatch
Sep 22, 2025
Merged

dkotik merged 1 commit into
masterfrom
noWriteOnEmptyBatch

Conversation

@dkotik

@dkotik dkotik commented Sep 19, 2025 •

Copy link
Copy Markdown
Collaborator

The busy waiting loop, that polls the next batches causes a modification to the database (sets the lock).

This causes tools like litestream to write wal files to their replicas every poll interval.

This makes a restore incredibly slow and causes a constant drain on the cpu.

Lock + read operation are in the same transaction. I think I can just cancel the transaction if the batch size is 0 to prevent the unneccessary write.

Here is an example of another attempt to achieve the same result: https://github.com/sandpapersoftware/watermillsqlite

The busy waiting loop, that polls the next batches causes a modification
to the database (sets the lock)
    this causes tools like litestream to write wal files to their
replicas every poll interval
    this makes a restore incredibly slow and causes a constant drain on
the cpu.
@dkotik dkotik self-assigned this Sep 19, 2025
@dkotik dkotik added the enhancement New feature or request label Sep 19, 2025
@dkotik
dkotik merged commit a2a9153 into master Sep 22, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant