Skip to content

Commit e7e0f75

Browse files
committed
feat(sqlite-storage): address US-060, US-061, US-062 review gaps
1 parent 7469437 commit e7e0f75

File tree

16 files changed

+612
-293
lines changed

16 files changed

+612
-293
lines changed

engine/CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ Use `test-snapshot-gen` to generate and load RocksDB snapshots of the full UDB K
5555
- `sqlite-storage` `get_pages(...)` should keep META, cold PIDX loads, and DELTA/SHARD blob fetches inside one `db.run(...)` transaction, then decode each unique blob once and evict stale cached PIDX rows that now need SHARD fallback.
5656
- `sqlite-storage` fast-path commits should update an already-cached PIDX in memory after the store write, but must not load PIDX from store just to mutate it or the one-RTT path is gone.
5757
- `sqlite-storage` fast-path cutoffs should use raw dirty-page bytes, and slow-path finalize must accept larger encoded DELTA blobs because UniversalDB chunks logical values internally.
58-
- `sqlite-storage` staged commits should scan a stage-specific prefix like `stage_chunk_prefix(stage_id)` and delete the staged chunk keys in the same `atomic_write` that promotes DELTA, PIDX, and META.
5958
- `sqlite-storage` compaction should choose shard passes from the live PIDX scan, then delete DELTA blobs by comparing all existing delta keys against the remaining global PIDX references so multi-shard and overwritten deltas only disappear when every page ref is gone.
6059
- `sqlite-storage` compaction must re-read META inside its write transaction and fence on `generation` plus `head_txid` before updating `materialized_txid` or quota fields, so takeover and commits cannot rewind the head.
6160
- `sqlite-storage` metrics should record compaction pass duration and totals in `compaction/worker.rs`, while shard outcome metrics such as folded pages, deleted deltas, delta gauge updates, and lag stay in `compaction/shard.rs` to avoid double counting.

engine/packages/pegboard-envoy/src/sqlite_runtime.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ pub async fn shared_engine(ctx: &StandaloneCtx) -> Result<Arc<SqliteEngine>> {
2121
tracing::info!("initializing shared sqlite dispatch runtime");
2222

2323
let (engine, compaction_rx) = SqliteEngine::new(Arc::clone(&db), subspace.clone());
24-
tokio::spawn(CompactionCoordinator::run(compaction_rx, db, subspace));
24+
let engine = Arc::new(engine);
25+
tokio::spawn(CompactionCoordinator::run(
26+
compaction_rx,
27+
Arc::clone(&engine),
28+
));
2529

26-
Ok(Arc::new(engine))
30+
Ok(engine)
2731
})
2832
.await
2933
.cloned()

engine/packages/pegboard-envoy/src/ws_to_tunnel_task.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,7 @@ async fn handle_sqlite_commit_stage(
848848
{
849849
Ok(result) => Ok(protocol::SqliteCommitStageResponse::SqliteCommitStageOk(
850850
protocol::SqliteCommitStageOk {
851-
chunk_idx_committed: result
852-
.chunk_idx_committed
853-
.try_into()
854-
.context("sqlite stage chunk index exceeded u16")?,
851+
chunk_idx_committed: result.chunk_idx_committed,
855852
},
856853
)),
857854
Err(err) => match sqlite_storage_error(&err) {

engine/packages/pegboard-outbound/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ async fn shared_sqlite_engine(ctx: &StandaloneCtx) -> Result<Arc<SqliteEngine>>
3737
SQLITE_ENGINE
3838
.get_or_try_init(|| async move {
3939
let (engine, compaction_rx) = SqliteEngine::new(Arc::clone(&db), subspace.clone());
40-
tokio::spawn(CompactionCoordinator::run(compaction_rx, db, subspace));
40+
let engine = Arc::new(engine);
41+
tokio::spawn(CompactionCoordinator::run(
42+
compaction_rx,
43+
Arc::clone(&engine),
44+
));
4145

42-
Ok(Arc::new(engine))
46+
Ok(engine)
4347
})
4448
.await
4549
.cloned()

0 commit comments

Comments
 (0)