Skip to content

Commit afe202e

Browse files
alex-poorclaude
andcommitted
Correct the record: the page cache was not the leak
`cd8258a` claimed capping `cache_size` fixed the follower's memory growth, on the strength of a fifteen-minute curve that went flat at 130 MB. It did not. Thirty minutes later the same process was at 416 MB and climbing, with 127 MB arriving in a single minute: app t+6..t+15 ~125-130 MB flat <- what was measured app t+38 155 MB app t+43 198 MB app t+48 255 MB app t+54 416 MB That is the exact mistake this repo already warns about in writing — never conclude anything about overnight behaviour from a run shorter than the claim — made on the same day the warning was written down. The arithmetic says the rest on its own. Twenty connections at 2 MiB is forty megabytes of page cache, and the process is at four hundred. The new test here confirms the pragma does reach every pooled connection, so the cap works and the page cache simply was not what grows. The earlier profile that put 85% of allocation there was taken six minutes into a process — still filling caches, like every other capture that night. **The change itself stays.** A bounded page cache and a busy timeout are right whatever the leak turns out to be, and SQLite defaulting to a zero busy timeout on a sixteen-connection pool is a bug waiting for a slow disk. Only the claim was wrong, and only the claim is withdrawn. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d735388 commit afe202e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Does `open_bounded_store` actually apply its pragmas to pooled connections?
2+
//!
3+
//! **THIS TEST EXISTS BECAUSE THE ANSWER MATTERED AND I ASSUMED IT.** Capping
4+
//! `cache_size` was measured as fixing the follower's memory growth on a
5+
//! fifteen-minute window, and thirty minutes later the growth was back — so the
6+
//! first question was whether the pragma reached the pool at all. It does:
7+
//! every connection reports `-2000`. Which means the cap works and the page
8+
//! cache was never the whole story, and that is worth knowing from a test
9+
//! rather than re-deriving it on a phone at midnight.
10+
#[tokio::test]
11+
async fn the_cache_size_pragma_reaches_every_pooled_connection() {
12+
let dir = std::env::temp_dir().join(format!("pragma-check-{}", std::process::id()));
13+
std::fs::create_dir_all(&dir).unwrap();
14+
let url = format!("sqlite://{}", dir.join("t.sqlite").display());
15+
let store = diaswarm_keys::open_bounded_store(&url).await.unwrap();
16+
let pool = store.pool();
17+
for i in 0..4 {
18+
let v: i64 = sqlx::query_scalar("PRAGMA cache_size")
19+
.fetch_one(pool).await.unwrap();
20+
println!("connection {i}: cache_size = {v}");
21+
assert_eq!(v, -2000, "cache_size not applied to pooled connection {i}");
22+
}
23+
}

0 commit comments

Comments
 (0)