bug(sync): autosync blocks local writes every cycle while a non-enrolled legacy backlog exists (v3.6.0)
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Read internal/cloud/autosync and internal/store/store.go, especially Manager.push and QuarantineIrreparableSyncMutations. Trace why each poll scans pending cloud mutations for projects that are not enrolled and how that holds the SQLite write lock; the report provides a reproducible large-backlog scenario and an offline server setup. Done when autosync no longer repeatedly blocks local requests on undeliverable backlog rows, while enrolled project sync continues to work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Existing Issue Search
- I searched existing issues and will add evidence to a canonical tracker when applicable.
📝 Observed Consequence
After enabling cloud autosync (one enrolled project), the local engram serve stops responding for most of every 30-second cycle:
- Agent memory writes time out (
mem_save,mem_delete, session registration). One delete was applied but reported as unconfirmed. GET /healthandGET /sync/statustime out (2 s client limit) for about 25 of every 30 seconds.engram doctorfails withmigration: database is locked (5) (SQLITE_BUSY).- The process uses close to one CPU core continuously.
The enrolled project itself syncs correctly.
The store holds 35,239 pending cloud mutations from 85 non-enrolled projects, journaled from 2026-05-20 to 2026-09-13, before cloud was configured on this machine. None are newer.
🔄 Steps to Reproduce
- Take a store with a large backlog of pending
cloudmutations for non-enrolled projects (here: 35,239 rows, ~25 MB of payload, 228 MB database). - Run
engram servewithENGRAM_CLOUD_AUTOSYNC=1, a cloud server and a token. - Poll
GET /healthevery few seconds across the first poll cycles.
No network is needed: I reproduced it on a copy of the store with ENGRAM_CLOUD_SERVER=https://127.0.0.1:1 (unreachable).
✅ Expected Behavior
A backlog that autosync never delivers should not block local writes on every cycle.
❌ Actual Behavior
On the store copy with the unreachable server, /health timed out (>2 s) when the first poll cycle ran, at about 40 s. The process had used 14.3 s of CPU by then.
The same copy with only those 35,239 rows changed behaves normally. Same measurement (engram 3.6.0, offline):
| Store copy | /health at the first cycle |
CPU after ~40 s | Autosync phase after the cycle |
|---|---|---|---|
| Unchanged | timeout (>2 s) | 14.3 s | no answer |
Rows moved to target_key='cloud:inbox' |
~0.1 s | 1.9 s | degraded / transport_failed (expected offline) |
Rows set to disposition='superseded' |
~0.1 s | 2.2 s | degraded / transport_failed (expected offline) |
Both changed copies kept every memory table and the sync_mutations row count identical; nothing was deleted. Running engram cloud enroll <project> on them backfilled the project's current state (67 observations, 23 sessions, 47 prompts, 12 relations), which matches its live rows.
Workaround applied on the live store: the inbox variant, in one transaction. Afterwards /health answered all 30 probes over ~65 s, the process used 2.4 s of CPU, autosync reported healthy, and a new memory of the enrolled project saved at once and reached the cloud.
Operating System
Windows
Release Version (Report Context)
3.6.0
Agent / Client
Other
📋 Relevant Logs
[autosync] started (server=https://<redacted>)
[autosync] quarantined 214 irreparable pending mutation(s); inspect with `engram doctor --check sync_mutation_required_fields`
engram: engram: migration: database is locked (5) (SQLITE_BUSY)
/sync/status last_error: "pending cloud sync mutations are blocked because project(s) are not enrolled: … (85 projects)"
💡 Additional Context
Client: Pi with gentle-engram, which starts engram serve with ENGRAM_CLOUD_AUTOSYNC=1. OS: Windows 11 Pro.
Possible cause. This is my reading of the source, not proven by a test:
Manager.pushcallsQuarantineIrreparableSyncMutations(targetKey, "", true)on every cycle: the 30 s poll, plus the debounce after each write.- With an empty project, that scans every pending
cloudrow of every project, including non-enrolled ones. It validates each row insidewithTx, and the store opens transactions with_txlock=immediate, so the write lock is held for the whole scan. - The backlog is never delivered, so the scan repeats every cycle.
internal/cloud/autosyncandinternal/store/store.goare unchanged betweenv3.6.0andmain@9824739.
Related:
- #1896: same symptom, different path (enrolled repair backfill); closed.
- #1013: non-enrolled backlog; list/claim/drop not shipped.
- #1188: inbox.
docs/CLOUD-INBOX-STATE.mdsays legacy migration is not implemented, so moving old rows to the inbox has to be done by hand with SQL.
- Lingua principale
- Go
- Stelle
- 7.1k
- Fork
- 729
- Merge medio
- 10h 51m
- PR unite (30g)
- 277
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Gentleman-Programming/engram
-
status:needs-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Gentleman-Programming/engram#2065 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feat(cli): run engram serve in the background as a daemonForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertastatus:needs-review type:feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Gentleman-Programming/engram#2228 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status:needs-review type:feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
Gentleman-Programming/engram#2203 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feat(store): reduce isolated test fixture startup costForse già presa @dnlrsls l’ha presa 3 giorni fa. Apertastatus:approved type:feature
Gentleman-Programming/engram#2202 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
status:needs-review type:question
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
Gentleman-Programming/engram#2201 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Gentleman-Programming/engram
Issue simili
-
go good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
Response matcher: a changed integer above 2^53 passes because JSON numbers are compared as float64Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
dec2hex rejects integer literals and accepts string literals in SQLForse già presa @NopeCharon l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno