fix: retain complete histories with bounded journal capacity and native recovery
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 19:11:45 +01:00
parent da7eb8109c
commit c512bd6fb2
36 changed files with 2556 additions and 38 deletions
+26 -2
View File
@@ -65,8 +65,9 @@ pub fn open(dir: &Path) -> Result<rusqlite::Connection> {
let uid = unsafe { libc::geteuid() };
rmm_privileged_helper::private_path(&path, uid, false)?;
let db = rusqlite::Connection::open(path)?;
db.execute_batch("PRAGMA synchronous=FULL; PRAGMA journal_mode=DELETE; PRAGMA max_page_count=1024; CREATE TABLE IF NOT EXISTS counter(id INTEGER PRIMARY KEY CHECK(id=1),seq INTEGER NOT NULL); INSERT OR IGNORE INTO counter VALUES(1,0); CREATE TABLE IF NOT EXISTS pending(id INTEGER PRIMARY KEY CHECK(id=1),payload BLOB NOT NULL CHECK(length(payload)<=1048576));")?;
db.execute_batch("PRAGMA max_page_count=16384;
rmm_privileged_helper::bounded_journal_capacity(&db)?;
db.execute_batch("PRAGMA synchronous=FULL; PRAGMA journal_mode=DELETE; CREATE TABLE IF NOT EXISTS counter(id INTEGER PRIMARY KEY CHECK(id=1),seq INTEGER NOT NULL); INSERT OR IGNORE INTO counter VALUES(1,0); CREATE TABLE IF NOT EXISTS pending(id INTEGER PRIMARY KEY CHECK(id=1),payload BLOB NOT NULL CHECK(length(payload)<=1048576));")?;
db.execute_batch("
CREATE TABLE IF NOT EXISTS job_attempts(job TEXT NOT NULL, attempt TEXT NOT NULL, offer BLOB NOT NULL,
state TEXT NOT NULL, revision INTEGER NOT NULL DEFAULT 0, grant_id TEXT NOT NULL DEFAULT '',
cancel_requested INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(job,attempt));
@@ -106,6 +107,29 @@ pub fn store_pending(db: &rusqlite::Connection, e: &Envelope) -> Result<()> {
#[cfg(test)]
mod passive_pressure_tests {
#[test]
fn agent_journal_capacity_is_finite_and_preserves_sequence_on_reopen() {
let dir = std::env::temp_dir().join(format!("rmm-capacity-{}", uuid::Uuid::new_v4()));
super::prepare_dir(&dir).unwrap();
let mut db = super::open(&dir).unwrap();
assert_eq!(super::next_sequence(&mut db).unwrap(), 1);
db.execute_batch("PRAGMA max_page_count=16384").unwrap();
drop(db);
let mut db = super::open(&dir).unwrap();
assert_eq!(
db.query_row("PRAGMA page_size", [], |r| r.get::<_, u32>(0))
.unwrap(),
4096
);
assert_eq!(
db.query_row("PRAGMA max_page_count", [], |r| r.get::<_, u32>(0))
.unwrap(),
65536
);
assert_eq!(super::next_sequence(&mut db).unwrap(), 2);
drop(db);
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn pending_durable_traffic_backpressures_collection_without_deletion() {
let db = rusqlite::Connection::open_in_memory().unwrap();