Skip to content

Commit a0defd7

Browse files
authored
refactor: remove dual-write — silo-only mutations (#135)
refactor: remove dual-write — silo-only mutations when BitmapSilo present
2 parents 7dc7208 + bf46ade commit a0defd7

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/engine/concurrent_engine.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,17 +650,22 @@ impl ConcurrentEngine {
650650
}
651651
Ok(dicts)
652652
}
653-
/// Load the current snapshot (lock-free, zero refcount ops).
653+
/// Route mutation ops to the BitmapSilo ops log (primary path) or the legacy
654+
/// coalescer channel (fallback for tests without a silo).
654655
///
655-
/// Returns a Guard that derefs to Arc<InnerEngine>. Unlike `load_full()`,
656-
/// Send mutation ops to BOTH the coalescer channel AND the BitmapSilo ops log.
657-
/// During Phase 2→4 transition, both paths receive the ops. Phase 4 removes
658-
/// the coalescer, leaving only the silo ops log.
656+
/// When a BitmapSilo is present, ops go ONLY to the silo — the coalescer is
657+
/// NOT also notified. Filter/sort/alive reads all go through the silo
658+
/// (get_effective_bitmap, frozen_top_n, alive OnceCell), so the in-memory
659+
/// coalescer/flush-thread path is no longer needed for production writes.
660+
///
661+
/// The coalescer fallback is kept for tests that construct a ConcurrentEngine
662+
/// without a silo. It is deprecated and will be removed once all tests are
663+
/// migrated to the silo path.
659664
pub(crate) fn send_mutation_ops(&self, ops: Vec<MutationOp>) -> Result<()> {
660665
// Bump epoch counters so stale cache entries are detected on next query.
661666
self.bump_field_epochs(&ops);
662-
// Write to BitmapSilo ops log (the V3 path)
663667
if let Some(ref silo_arc) = self.bitmap_silo {
668+
// Silo present: write ONLY to the BitmapSilo ops log.
664669
let silo = silo_arc.read();
665670
for op in &ops {
666671
match op {
@@ -685,9 +690,9 @@ impl ConcurrentEngine {
685690
MutationOp::DeferredAlive { .. } => {} // handled separately
686691
}
687692
}
688-
}
689-
// Also send to coalescer for tests without a silo (transitional)
690-
if self.bitmap_silo.is_none() {
693+
} else {
694+
// No silo: fall back to the legacy coalescer channel (test path only).
695+
// DEPRECATED — remove once all tests use a BitmapSilo.
691696
self.sender.send_batch(ops).map_err(|_| {
692697
crate::error::BitdexError::CapacityExceeded("coalescer channel disconnected".to_string())
693698
})?;

0 commit comments

Comments
 (0)