bug(cloud): dashboard read model is rebuilt from full history after every write (~30 s first load)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, postgresql
- Domain
- backend, performance
Research direction
Read internal/cloud/cloudstore/cloudstore.go for invalidateDashboardReadModel in WriteChunk and InsertMutationBatch, then follow loadDashboardNeutralReadModel into dashboard_queries.go to understand the full rebuild. Compare incremental updates and serving the last good model during a background rebuild; measure dashboard latency after writes against the reported ~32 seconds. Done means dashboard requests stay interactive as history grows.
Written by the indexing model from the issue text.
Description
Existing Issue Search
- I searched existing issues and will add evidence to a canonical tracker when applicable.
Related: #1832 (measured read-model rebuild cost; measurement only, broader strategies deferred), #1930 / #1931 (OOM and single-flight, fixed — memory is fine here, latency is not).
📝 Observed Consequence
On a small team deployment (6 managed users, autosync on), the first dashboard request after any sync write takes ~30 s. With several active agents a write arrives every few minutes, so most dashboard visits hit a cold rebuild. Browsers and users give up first: the login redirect to /dashboard/ looks like "nothing happens" and nginx logs 499 (client closed) for the first attempts.
🔄 Steps to Reproduce
- Run
engram cloud serve3.6.0 with a team-sized history (here:cloud_mutations421,529 rows / 542 MB,cloud_chunks2,667 rows / 475 MB, 60 projects). - Let any client push (autosync
WriteChunkorInsertMutationBatch); both invalidate the dashboard read model. - Log in at
/dashboard/loginand follow the redirect to/dashboard/.
✅ Expected Behavior
Dashboard pages stay interactive (a few seconds at most) regardless of write frequency, e.g. by applying new chunks/mutations incrementally to the cached read model, or by serving the last good model while a rebuild runs in the background (stale-while-revalidate), instead of a full history rebuild on the request path.
❌ Actual Behavior
Each write discards the whole permission-neutral read model (invalidateDashboardReadModel in WriteChunk / InsertMutationBatch, internal/cloud/cloudstore/cloudstore.go), and the next request rebuilds it from every chunk and mutation (loadDashboardNeutralReadModel → full build, dashboard_queries.go). Measured:
| Request | Latency |
|---|---|
POST /dashboard/login |
0.06 s |
first GET /dashboard/ after a write |
~32 s (two earlier attempts ended as 499) |
| same pages once warm | 0.03–0.06 s |
Rebuild cost grows with history, not with live state: the deployment above has ~56k distinct entities but 421k mutation rows.
Operating System
Linux
Release Version (Report Context)
v3.6.0 (Homebrew binary, engram cloud serve, PostgreSQL 16, systemd, nginx TLS in front)
Agent / Client
Engram Cloud dashboard (browser)
📋 Relevant Logs
nginx access (times are request completion):
07:23:47 "POST /dashboard/login" 303
07:24:10 "GET /dashboard/" 499
07:24:10 "POST /dashboard/login" 303
07:24:22 "GET /dashboard/" 499
07:24:22 "POST /dashboard/login" 303
07:24:54 "GET /dashboard/" 200
engram cloud serve:
07:24:54 dashboard: templ render error: context canceled
07:24:54 dashboard: templ render error: context canceled
💡 Additional Context
#1832 asked whether history-scaling cost stays material enough to justify a broader read-model strategy. This is field evidence that it does for a 6-user team after one week of history. Happy to run a patched build or share more timings.
- Dominant language
- Go
- Stars
- 7.1k
- Forks
- 729
- Avg merge
- 9h 44m
- Merged PRs (30d)
- 278
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Gentleman-Programming/engram
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Gentleman-Programming/engram#2206 ·
Maintainers usually reply within 1 day
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Gentleman-Programming/engram#2205 ·
Maintainers usually reply within 1 day
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Gentleman-Programming/engram#2204 ·
Maintainers usually reply within 1 day
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Gentleman-Programming/engram#2138 · 1 comment ·
Maintainers usually reply within 1 day
-
status:needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Gentleman-Programming/engram#2065 ·
Maintainers usually reply within 1 day
All issues in Gentleman-Programming/engram
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
schema-drift
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stefanhoth/paperless-ngx-cli#61 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
slavakurilyak/awesome-ai-agents#888 ·
Maintainers usually reply within 1 day
-
enhancement nav-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
kind/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day