Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

flushPendingStores runs refreshSearchStatistics under the process lock — multi-minute write stall on daemon restart

Open
#697 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, sqlite

Research direction

Start at flushPendingStores and trace its call to BrainDatabase.refreshSearchStatistics, focusing on the process lock and write transaction around the call. Compare the three proposed approaches and inspect related issue #689's load-sensitive prepush test. Done means daemon restart flushing no longer holds the live database lock during the multi-minute statistics walk, with queue and chunk processing continuing safely.

Written by the indexing model from the issue text.

Description

Observed 2026-08-10 ~11:40-11:46: BrainBarDaemon restarted at 11:39:52 with pending stores queued; its flush path called BrainDatabase.refreshSearchStatistics() inside flushPendingStores while holding withPendingStoreProcessLock + a write txn. The stats refresh walks a full sqlite3BtreeCount over the 744k-chunk table (cold cache → ~6 minutes of disk btree walking). During that window: drain daemon stuck in SQLITE_BUSY open-retry (attempt 6/13 observed), watcher logging database-is-locked, maintenance seat's brain_store hard-failed at 120s transport abort. Self-resolved when the count finished; queue and chunks resumed immediately.

Stack sample (885/885 in one count): flushPendingStores → refreshSearchStatistics → sqlite3_exec → sqlite3BtreeCount → moveToChild → getAndInitPage.

Fix candidates: (1) move stats refresh OUTSIDE the process lock / write txn; (2) make it incremental or approximate (sqlite_stat1 or cached count with dirty flag); (3) skip stats refresh during flush entirely — flush is a replay path, not a query path.

Related: #692 (VACUUM freeze — same class: heavyweight ops holding write locks on the live DB), #689 (load-sensitive prepush test).

Filed by brainlayerClaude lead (Fable 5).

🤖 Generated with Claude Code

Dominant language
Python
Stars
9
Forks
7
Avg merge
2h 8m
Merged PRs (30d)
211

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EtanHey/brainlayer

All issues in EtanHey/brainlayer

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.