Repository navigation
Description
Summary
Nothing watches the size of the collab database. Two measured events show how fast it can grow. The 2026-11-09 MCP session (#726) added 58.5 MB. On 2026-11-07, it grew 199.1 MB with no MCP write. The disk is shared with every other database on the cluster. This issue adds a panel, a size rule and a growth rule. It also checked that server error output reaches Loki (done, 2026-11-10).
The storage-at-scale review of 2026-11-10 found this gap. The maintainer ruled it on 2026-11-10 ("yes"). Related: #726, #704, #707, #571.
The collab database moved to London, on PostgreSQL 18.6, on 2026-11-11. Every reading in the 2026-11-10 comment comes from the old cluster.
Benchmark
| Field | Value |
|---|---|
| Metric | (a) Rules and panels that watch database size, count. (b) sum(pg_database_size_bytes) on the collab cluster, B. (c) pg_stat_user_tables_size_bytes{relname="Documents"}, B. (d) Largest 24 h growth of (b), B |
| Before | (a) 0 rules, 0 panels at HEAD 0b302b222. (b), (c) on the London cluster: context only, shown on AP 80. Old cluster, 2026-11-10 (comment): collab database 458,370,000 B; 7 other databases 2,366,930,600 B in total; Documents 446,406,656 B. (d) Old cluster: 199,221,248 B (2026-11-07), the largest 24 h growth in 13 days (review read, 2026-11-11). Source: the growth-rule backtest, peak at 2026-11-07 18:39Z. The 2026-11-10 comment gives the same event as +199.1 MB from 11:07Z to 23:07Z |
| After | (a) 3 rules, live since 2026-11-12 (Measured). 1 panel, AP 80, live since 2026-11-16 13:43Z (Measured). Step 5: 25 of 25 at the old 128 MiB bar (Measured). The re-run at 256 MiB is owed |
| Condition | Production postgres-exporter v0.17.0 against the London cluster (PostgreSQL 18.6, moved 2026-11-11). Disk size from the DigitalOcean console on the read day. pg_database_size_bytes leaves out WAL |
| How to run | (b) sum(pg_database_size_bytes) and count by (datname) (pg_database_size_bytes) in Grafana Explore. (c) pg_stat_user_tables_size_bytes{relname="Documents"}. (d) max_over_time((sum(pg_database_size_bytes) - sum(pg_database_size_bytes offset 24h))[13d:1h]). Loki reads use hour-sized windows, one at a time, each with a timeout (#712 ruling 2026-11-11) |
| Pass rule | (a) 3 rules, 1 panel. Every step 5 promtool case passes. (b), (c) context only, no bar; the size and growth rules watch them. (d) growth-rule backtest: 0 firings outside a real growth event. Revert rule: if a rule fires with no real growth, run the Rollback |
| Guard | dep-postgres-down still pages when the exporter stops. Rule count: the count before this change + 3 (one size rule per severity since 79f91596b). If this ships with other rule changes, the #753 want for that deploy is the check. Depends on #753 |
| Owner | Agent in the repo: rules, panel, step 5 fire test. Maintainer: console read, production readings, deploy after #753 |
| Claim | Internal: "Database growth now pages before the disk fills." Storage-per-pad claims belong to #726 |
Facts
Read from code on 2026-11-10, unless a line says otherwise.
- No alert rule or dashboard under
scripts/observability/readspg_database_size_bytes. The only Postgres rule isdep-postgres-down, onpg_up(scripts/observability/grafana/provisioning/alerting/rules-deps.yml). - The Postgres panels live in
scripts/observability/grafana/provisioning/dashboards/json/app-performance.json. They show connections, cache hits and transactions, but no size. postgres-exporterv0.17.0 runs with--no-collector.wal, as the read-onlymetrics_readerlogin withpg_read_all_stats. It exportspg_database_size_byteson production (2026-11-10 comment).- It also exports
pg_stat_user_tables_size_bytes, the table's total size with its indexes and TOAST data. So the panel needs no custom query (2026-11-10 comment). - The
Documentssize read 185 MB across all versions on 2026-09-05 (apps/hocuspocus.server/CLAUDE.md), and 446,406,656 B on 2026-11-10. - On 2026-11-09, one MCP session wrote about 110 full snapshot rows of 1 to 4 MiB in 40 minutes (Cut MCP write time on large pads and stop its four false alerts #726). The database grew 58.5 MB in that session. The retention reaper never thins a row younger than 30 days (
apps/hocuspocus.server/src/lib/retention.ts). - On 2026-11-07, between 11:07Z and 23:07Z, the collab database grew 199.1 MB with no MCP write. Find the cause of the +199.1 MB collab database growth on 2026-11-07 #761 owns the cause.
pg_database_size_bytesleaves out WAL. So the 60 % and 80 % byte values subtract the WAL size, or the rules fire late.- A dump and restore can shrink the size. So the growth rule reads a negative 24 h delta on the move day, and stays Normal.
- Alloy reads container logs through the Docker logs API (
scripts/observability/alloy/config.alloy). It parses pino JSON for thelevellabel, so a plain-text line arrives with nolevel. - A lost store lock leaves only one upstream
console.errorline, "Caught error during storeDocumentHooks", and no persist metric moves. So every "no lost save" reading depends on that line reaching Loki. It does (step 0 below).
What to build
Left, 2026-11-16. Steps 0, 2, 3 and 7 are done. Left: step 1, the step 4 bar change, the step 5 re-run, one step 6 deploy, and the AP 80 check in production Grafana.
- Done, 2026-11-10: the Loki check. Plain-text
hocuspocus-serveroutput reaches Loki, and no follow-up for log shipping is needed. See the 2026-11-10 comment. A re-run uses hour-sized windows, one at a time, each with a timeout (Cut Loki self-logs and bound its queries, so Loki stays under 80 % of its memory #712 ruling 2026-11-11).[7d]instant queries caused the Cut Loki self-logs and bound its queries, so Loki stays under 80 % of its memory #712 memory peak, and after Cut Loki self-logs and bound its queries, so Loki stays under 80 % of its memory #712 Loki refuses them. - Maintainer, read-only. In the DigitalOcean console, confirm the London cluster disk is still 60 GiB. The live bars (35,591,815,168 B and 48,476,717,056 B) are 60 % and 80 % of 64,424,509,440 B minus
max_wal_size3,062,890,496 B (ruled 2026-11-12). Only a changed disk size changes them. If the disk is not 60 GiB, recompute both bars and post them with the read date. - Agent in the repo. The panel. In
app-performance.json, beside the Postgres panels, add a panel forpg_database_size_bytesperdatname, pluspg_stat_user_tables_size_bytes{relname="Documents"}. No custom query. - Agent in the repo. Rule 1, size. In
rules-deps.yml:sum(pg_database_size_bytes), warning above the 60 % byte value, critical above the 80 % byte value, from step 1. SetnoDataState: OK, becausedep-postgres-downalready pages when the exporter stops. The summary states that WAL is left out. - Agent in the repo. Rule 2, growth. In
rules-deps.yml:sum(pg_database_size_bytes) - sum(pg_database_size_bytes offset 24h) > <bar>, warning,noDataState: OK. The bar is ruled at 256 MiB (Decision 3). The live rule still readsparams: [134217728](rules-deps.yml:296). Change it to268435456in one line, and the title to 256 MiB. Fix the summary: at 256 MiB the 2026-11-07 event (199,221,248 B) does not fire this rule, so the summary must not cite it as an example. The backtest reads 0 firings at 256 MiB. - Agent in the repo. Fire test. The repo has no local Prometheus and Grafana stack. So use the Keep health checks out of the API error and latency alerts #710 step 6 method:
promtool test rules, with a temporary rule file and synthetic series. It needs no production access. Cases: the size rule goes Firing above its warning and critical byte values, and stays Normal below them. The growth rule goes Firing on a 24 h rise above the ruled bar, and stays Normal on a negative delta (the move-day case). After the step 4 change, re-run the existing script, which reads the bar from the file. Flip the expected state to Normal for the cases between 128 and 256 MiB: the 150 MiB step, the 2026-11-07 shape and the 2026-11-13 shape. Post the before and after. - Maintainer, observability deploy, after Fail the observability deploy when Grafana or its provisioned rules do not load #753. Commit through the
commit-reviewskill with a(build): observabilitysubject and push. - Done, 2026-11-10: the first reading (old cluster). See the 2026-11-10 comment. It also gave Cut MCP write time on large pads and stop its four false alerts #726 its storage baseline.
Decisions
The owner is the maintainer. Decisions 1 and 2 are ruled (2026-11-10 and 2026-11-11 comments). Decision 3 is ruled (2026-11-16 ruling).
- Alert thresholds. Recommended: warning when the collab database passes 60 % of the disk that the cluster gives it, and critical at 80 %. The exporter cannot read a managed disk size, so the maintainer reads it in the DigitalOcean console, and the rule uses fixed byte values. Other: alert on growth instead, for example more than 2 GiB in 24 hours. Ruled 2026-11-11: the size rule sums every database on the cluster, because the disk is shared. The growth rule was added in the 2026-11-11 milestone review (approved). Its bar is Decision 3.
- Table sizes. Recommended: one custom exporter query that returns
pg_total_relation_sizeforDocumentsand for its TOAST table. First check that v0.17.0 still supports custom queries (--extend.query-path). If it does not, ship the database size only, and record the table sizes by hand in the Cut MCP write time on large pads and stop its four false alerts #726 reads. Other: the database size only. Resolved 2026-11-10:pg_stat_user_tables_size_bytesalready coversDocuments, so no custom query is needed. - Growth-rule bar. Ruled 2026-11-16: 256 MiB in 24 hours. Accepted trade: the 2026-11-07 event (199,221,248 B), which started Find the cause of the +199.1 MB collab database growth on 2026-11-07 #761, does not fire this rule. The size rules still cover the disk.
Acceptance criteria
- The Loki check result is posted here (2026-11-10 comment).
- The step 1 disk-size check is posted (London cluster confirmed at 60 GiB, 2026-11-24).
- The panel shows the size of each database and the
Documentssize. - Decision 3, the growth-rule bar, is ruled (256 MiB, 2026-11-16).
- The growth rule reads
268435456inrules-deps.yml, with a summary that does not cite the 2026-11-07 event as a firing case. - Every step 5
promtoolcase passes, for the size rule and the growth rule. - Grafana holds the count before this change + 3 rules.
- The first production reading is posted here (old cluster, 2026-11-10).
Rollback
Revert the rule and panel commit and run the observability deploy.
Out of scope
- Any change to retention or to the storage design. That waits for the readings from this issue and from Cut MCP write time on large pads and stop its four false alerts #726.
- The cause of the 2026-11-07 growth. Find the cause of the +199.1 MB collab database growth on 2026-11-07 #761 owns it.
Activity
HMarzban commentedon Nov 10, 2026
Maintainer ruling, 2026-11-10
Answer: "yes" to both recommendations.
pg_total_relation_sizeforDocumentsand for its TOAST table, if postgres-exporter v0.17.0 still supports custom queries. If it does not, ship the database size only, and record the table sizes by hand in the Cut MCP write time on large pads and stop its four false alerts #726 reads.No open decision is left on this issue.
HMarzban commentedon Nov 11, 2026
Measured, 2026-11-10: the Loki check and the first size reading
Read-only, through the Grafana data-source proxy, on 2026-11-10 from 16:59Z to 17:20Z.
Step 1: plain-text output reaches Loki
sum(count_over_time({service="hocuspocus-server"} !~ "^\\{" [7d]))returned 320 lines. The newest ones are startup output from the 2026-11-09 20:16:15Z deploy, with nolevellabel. One example is BullMQ'sIMPORTANT! Eviction policy is volatile-lru. It should be "noeviction".Caught error during storeDocumentHooksappears 0 times from 2026-10-11 to 2026-11-10. The query ran in five chunks, and each chunk read 1,467 to 5,155 lines, so the empty result is real. One 30-day query returned empty after exactly 30 s, so the chunks replaced it.Step 4: the first size reading
postgres-exporteralready exportspg_database_size_bytes, so this reading needed no deploy.prod_docsplusprod_docsplusgrew by 266.4 MB in 7 days. Two events explain almost all of it:postgres-exporteralready exportspg_stat_user_tables_size_bytes, the table's total size with its indexes and TOAST data. ForDocumentsit reads 446,406,656 B now and 180,297,728 B 7 days earlier. So the panel can use it directly.Maintainer ruling, 2026-11-11: the rule reads every database
The first ruling put the rule on the collab database alone. The disk is shared, though. 7 other databases on the cluster hold about 2.37 GB, and WAL uses more.
pg_database_size_bytesover all databases, with the same byte thresholds.[-]Watch the collab database size, and check that server error output reaches Loki[/-][+]Alert before the shared collab Postgres cluster fills its disk[/+]fix(observability): alert on collab Postgres disk use and growth
fix(observability): split the Postgres size alert by severity
docs(changelog): make the v2.3.6 alert and dependency lines exact
HMarzban commentedon Nov 12, 2026
Measured, 2026-11-12: production after the observability deploy. Run 43224277563 (
(build): observability,f61647754). Steps 1 to 8 passed, including "Deploy stack" at 13:08:16Z. A newer push cancelled the last step, Verify, during its wait, so its checks were read by hand, read-only, at about 13:12Z.dep-postgres-db-size(warning above 35,591,815,168 B),dep-postgres-db-size-critical(critical above 48,476,717,056 B) anddep-postgres-db-growth(warning above 128 MiB in 24 h) are live, 0 in error health, and none fires.79f91596b).HMarzban commentedon Nov 13, 2026
Measured, 2026-11-13: first live fire of
dep-postgres-db-growth, with a known cause.The #726 London before-2 session (Measured) wrote about 104 version rows of a 3.5 MB scratch pad between 05:30Z and 06:05Z. The rule was not in that session's silence.
for: 5mhold worked: Pending at 05:54:30Z, Alerting at 05:59:30Z.Next step: the #726 after session adds
dep-postgres-db-growthto its silence. No change to the rule.HMarzban commentedon Nov 14, 2026
Moved to v2.3.7 at the v2.3.6 release audit. Rules are live, but the London reading, the panel check and 4 weekly London size reads are not posted.
HMarzban commentedon Nov 14, 2026
Measured, 2026-11-12: growth-rule backtest (posted 2026-11-14)
This is the backtest behind the
dep-postgres-db-growthbar of 128 MiB. The CHANGELOG and commit0a1dff17cquote it ("over 15 days of history it fires once"). It was taken on 2026-11-12 and kept locally, so it is posted here for the record.Setup. Production Prometheus, read-only, HEAD
cfac48d87. The 24 h delta ofsum(pg_database_size_bytes)on the collab cluster, 1 min step, from 2026-10-29 00:01Z to 2026-11-12 11:50Z: 20,870 points with no gap. These points are from the old cluster, before the 2026-11-11 London move.max_over_time((sum - sum offset 24h)[13d:1h]), reads 199,221,248 B. The peak is at 2026-11-07 18:39Z.for)Reading. At 128 MiB the rule fires once, during the real 2026-11-07 growth event. With
for: 5mit fires at 17:11Z, 4 h 33 min after the first big minute, and clears at 13:36Z on 2026-11-08. It stays Normal on the #726 MCP window, which peaks at 65,350,488 B (2026-11-10 07:43Z), a margin of 2.05 times. Outside those two windows, every daily peak is at most 4,342,152 B.Next. The 4 weekly London size reads in this issue check the bar on the new cluster.
HMarzban commentedon Nov 16, 2026
Measured, 2026-11-16
This covers step 5, the fire test for the size rules and the growth rule. It uses the #710 step 6 method:
promtool test rules, a temporary rule file and synthetic series. It read no production data.What changed
rules-deps.ymlare as of79f91596b, at HEAD3bd5ca1c0.dep-postgres-db-size,dep-postgres-db-size-criticalanddep-postgres-db-growthfromrules-deps.yml. It takes each rule's query (A), bar (C),forand group interval. It checks that B isreduce last.(<A>) > <bar>,for: 5m, evaluated every 1 min. That is the same as Grafana's instant query,lastreduce andgtthreshold.Before and after
promtoolinprom/prometheus:v3.12.0, local, 2026-11-16Time to Firing per case. Onset is the first minute that should page.
pg_database_size_bytesseries (exporter down)Reading:
pg_database_size_bytesseries 24 h back. With less history, the query returns no data, and the rule stays Normal. The size rules still cover that window.Sabotage
The same assert tests ran against a rule file with the warning bar moved to 48,476,717,056 B and the growth bar moved to 268,435,456 B.
promtoolfailed (exit 1) on all 7 rule checks that need those bars: 2 warning cases, the critical-bar control, and 4 growth cases. So the test can fail.Gates
promtool check rules rules.yml(prom/prometheus:v3.12.0): pass, 3 rules.promtool test rules test-assert.yml(prom/prometheus:v3.12.0): pass, 25 of 25.Limits
promtooltests Prometheus evaluation of the same query and bar. It does not run Grafana's alert engine. The live 2026-11-13 fire gives the Grafana side for the growth rule.Left
6a99bee10(the step 2 panel, committed locally, not pushed yet) with(build): observability. Owner: maintainer.fix(observability): correct the app dashboard panels
HMarzban commentedon Nov 16, 2026
Measured, 2026-11-16
This covers step 2, the panel, committed in
6a99bee10.What changed
pg_database_size_bytesperdatname, andpg_stat_user_tables_size_bytes{relname="Documents"}. There is no custom query.Before and after
app-performance.json, 2026-11-16Gates
bunx prettier --check app-performance.json: pass.python3 -m json.tool(the CI step): pass.promtool check rules: pass.--network none: AP 80 is present, and ids are unique. Pass.Left
Documentssize in production Grafana. Owner: maintainer, after the deploy.promtoolfire test for the size and growth rules. Owner: agent, next batch.(build): observability. Owner: maintainer.After the deploy
Deployed with
(build): observability(288d4d260, run 43878530215, 2026-11-16 13:43Z). AP 80 is live on the app dashboard (74 panels). The step 5 fire test is posted separately.HMarzban commentedon Nov 16, 2026
Maintainer ruling, 2026-11-16
Answered by the maintainer in the 2026-11-16 working session; posted by the agent.
docs(changelog): record the v2.3.7 work of 2026-11-16
HMarzban commentedon Nov 16, 2026
Review, 2026-11-16 (maintainer approved).
params: [134217728]to268435456and fix the growth rule summary. At 256 MiB the 2026-11-07 event no longer fires it.79f91596bsplit.fix(observability): raise the database growth bar to 256 MiB
HMarzban commentedon Nov 17, 2026
Measured, 2026-11-17
This covers step 4, the growth bar change, and the step 5 re-run at the new bar. It read no production data.
What changed
rules-deps.yml, ruledep-postgres-db-growth, at HEAD5aa56e1d1plus this change:params: [134217728]is nowparams: [268435456](256 MiB), as ruled on 2026-11-16.rules-deps.yml. Its case list changed in four places:Before and after
rules-deps.ymlat HEAD5aa56e1d1(128 MiB). After: the changed file.promtoolinprom/prometheus:v3.12.0, local, 2026-11-17The 3 before misses are the flipped cases. At 128 MiB each one fires.
Reading:
Sabotage
The same assert tests ran against a rule file with the warning bar moved to 48,476,717,056 B and the growth bar moved back to 134,217,728 B.
promtoolfailed (exit 1) on 7 rule checks. They are 3 warning checks (2 warning cases, the critical-bar control) and 4 growth controls (150 MiB, 2026-11-07, 2026-11-13, exactly 268,435,456 B). So the test can fail.Gates
bun fmt --check rules-deps.yml: pass.Bun.YAML.parse: pass. Rules inrules-deps.yml: 8 before, 8 after.promtool check rules rules.yml(prom/prometheus:v3.12.0): pass, 3 rules.promtool test rules test-assert.yml(prom/prometheus:v3.12.0): pass, 27 of 27.Limits
promtooltests Prometheus evaluation of the same query and bar. It does not run Grafana's alert engine.Left
ccdbb89b3, deployed by(build): observability(run 44027220672, 2026-11-17).HMarzban commentedon Nov 24, 2026
Measured, 2026-11-24: live AP 80 panel and
256 MiBrules in production GrafanaQuestion: Did the
45393ece7observability deploy put AP 80 and all 3256 MiB-threshold database rules live cleanly?Setup. Production Grafana API and Prometheus, read-only,
2026-11-24 07:15Z.Result:
67(allhealth=ok).dep-postgres-db-size(> 60 %):state=inactive,health=ok.dep-postgres-db-size-critical(> 80 %):state=inactive,health=ok.dep-postgres-db-growth("Postgres databases grew more than 256 MiB in 24h"):state=inactive,health=ok."Postgres Size by Database + Documents Table"is live ondocsplus-app-performance.2026-11-24:sum(pg_database_size_bytes) = 2,871,506,424B across8databases;prod_docsplus = 511,186,623B;pg_stat_user_tables_size_bytes{relname="Documents"} = 500,097,024B.CHANGELOG.md:188typo (128 MiB->256 MiB) is fixed locally onmain(uncommitted).Next step: Maintainer confirms in the DigitalOcean console that the London cluster disk is still
60 GiB(Step 1) and closes#727.HMarzban commentedon Nov 24, 2026
Update, 2026-11-24: root changelog corrected and committed (
fdb1af6e8)Committed
CHANGELOG.md(fdb1af6e8) fixing both#727documentation mismatches:128 MiB -> 256 MiB.0firings, since2026-11-07's199.1 MBevent sits under256 MiB).Next step: Maintainer confirms in the DigitalOcean console that the London cluster disk stays
60 GiB(Step 1) and closes#727.docs(changelog): update #727 bar and #803/#746 notes
HMarzban commentedon Nov 24, 2026
Closed, 2026-11-24: London cluster disk confirmed at 60 GiB
The maintainer checked the DigitalOcean console on 2026-11-24 and confirmed the London Managed PostgreSQL 18 cluster (
4 GB RAM,2 vCPU, LON1) still has a 60 GiB disk. The byte thresholds inrules-deps.ymltherefore stay unchanged (60 %=38,654,705,664 B/ warning at35,591,815,168 B;80 %=51,539,607,552 B/ critical at48,476,717,056 B).60 GiB(unchanged)dep-postgres-db-size,dep-postgres-db-size-critical,dep-postgres-db-growthat256 MiB)state=inactive,health=ok(67rules total, allhealth=ok)Postgres Size by Database + Documents Table)docsplus-app-performance;sum(pg_database_size_bytes) = 2,871,506,424 B(2.87 GB) across 8 databases vs38.65 GB(60 %) /35.59 GBwarning barCHANGELOG.md(256 MiBbar and backtest text)fdb1af6e8All acceptance checks are complete. Closing #727.