Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions crates/engram-chunk-store/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,6 @@ mod tests {
) -> Result<(), MetaError> {
Ok(())
}
async fn assign_session_sandbox(
&self,
_id: SessionId,
_sandbox_id: Option<SandboxId>,
) -> Result<Option<u64>, MetaError> {
Ok(None)
}
async fn upsert_host(
&self,
_host: engram_core::types::HostRecord,
Expand Down
7 changes: 0 additions & 7 deletions crates/engram-coordinator/src/api/enabled_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,13 +1390,6 @@ mod tests {
) -> Result<(), MetaError> {
unreachable!()
}
async fn assign_session_sandbox(
&self,
_: engram_core::SessionId,
_: Option<engram_core::SandboxId>,
) -> Result<Option<u64>, MetaError> {
unreachable!()
}
async fn upsert_host(
&self,
_: engram_core::types::host::HostRecord,
Expand Down
5 changes: 2 additions & 3 deletions crates/engram-coordinator/src/api/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,7 @@ async fn resume_from_fc_snapshot(
// `session.live_disk_manifest` is `None` when:
// - The session never went through Phase B (non-NBD host /
// never had a publish land).
// - The session is mid-eviction and `assign_session_sandbox(None)`
// cleared the column (commit 3's load-bearing race fix).
// - The session is mid-eviction and the detach cleared the column.
//
// In both `None` cases the resolver falls back to the
// snapshot's manifest, preserving the pre-Phase-B behaviour.
Expand Down Expand Up @@ -2148,7 +2147,7 @@ async fn bind_resumed_session(
/// FlushScheduler's live-manifest publisher uses to attach session_id
/// to the publish RPC. The coordinator-side binding is NOT updated
/// here — it lives only in `sessions.sandbox_id` (Postgres), written by
/// the caller via `assign_session_sandbox` BEFORE this call, so every
/// the caller through a guarded binding write BEFORE this call, so every
/// replica's `/exec` / `/shell` / `/prompt` resolves the new sandbox by
/// reading that row ([`AppState::resolve_sandbox`]).
///
Expand Down
7 changes: 0 additions & 7 deletions crates/engram-coordinator/src/boot_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,6 @@ mod tests {
) -> Result<(), MetaError> {
unimplemented!()
}
async fn assign_session_sandbox(
&self,
_: engram_core::SessionId,
_: Option<engram_core::SandboxId>,
) -> Result<Option<u64>, MetaError> {
unimplemented!()
}
async fn upsert_host(&self, _: HostRecord) -> Result<(), MetaError> {
unimplemented!()
}
Expand Down
7 changes: 0 additions & 7 deletions crates/engram-coordinator/src/host_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,6 @@ mod tests {
) -> Result<(), engram_core::MetaError> {
Ok(())
}
async fn assign_session_sandbox(
&self,
_: engram_core::SessionId,
_: Option<SandboxId>,
) -> Result<Option<u64>, engram_core::MetaError> {
Ok(None)
}
async fn host_for_sandbox(
&self,
sandbox_id: SandboxId,
Expand Down
60 changes: 30 additions & 30 deletions crates/engram-coordinator/src/idle_evictor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
assert_eq!(
Expand All @@ -1965,7 +1965,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, None)
.fenced_assign_sandbox(session_id, 0, None, None)
.await
.unwrap();
assert_eq!(state.resolve_sandbox(session_id).await, None);
Expand Down Expand Up @@ -2160,7 +2160,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -2290,7 +2290,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -2551,7 +2551,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -2776,7 +2776,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -2996,7 +2996,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3061,7 +3061,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3327,7 +3327,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3425,7 +3425,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3469,7 +3469,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3519,7 +3519,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
*mini.fail_next_record_snapshot.lock() = true;
Expand Down Expand Up @@ -3674,7 +3674,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3734,7 +3734,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -3787,7 +3787,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -3859,7 +3859,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -3921,7 +3921,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -3975,7 +3975,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -4051,7 +4051,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -4137,7 +4137,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state
Expand Down Expand Up @@ -4204,7 +4204,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
let host_id = state.host_registry.host_of(sandbox_id).expect("routed");
Expand Down Expand Up @@ -4443,7 +4443,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -4697,7 +4697,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();
{
Expand Down Expand Up @@ -4891,7 +4891,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -4949,7 +4949,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -5002,7 +5002,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -5054,7 +5054,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -5127,7 +5127,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -5227,7 +5227,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down Expand Up @@ -5293,7 +5293,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(session_id, Some(sandbox_id))
.fenced_assign_sandbox(session_id, 0, Some(sandbox_id), None)
.await
.unwrap();

Expand Down
24 changes: 4 additions & 20 deletions crates/engram-coordinator/src/reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,10 @@ async fn flip_missing(
}
}

// Clear sandbox_id so coord routing and a future restart's
// `repopulate_routing` don't try to talk to the dead sandbox.
//
// Issue #211: this MUST be a compare-and-swap on the EXACT sandbox
// that struck out, not a blind `WHERE id = $1` clear. A live
// migration's `rebind_session` can land a FRESH sandbox onto this
// row between our strike-out decision and this clear; a blind null
// would wipe that healthy binding and drive a just-migrated session
// to HostLost→Idle/Dead. With the CAS, if the row no longer points
// at the struck-out sandbox we abort the whole flip (the binding
// moved on — the session is not orphaned). When `sandbox_id` is
// None (the row already had no binding) we fall back to the blind
// clear: there is nothing for a rebind to have replaced.
let clear_result = match sandbox_id {
Some(struck) => {
meta.assign_session_sandbox_guarded(session_id, None, Some(Some(struck)), &[])
.await
}
None => meta.assign_session_sandbox(session_id, None).await,
};
// Clear only if the current binding still matches, including an absent binding.
let clear_result = meta
.assign_session_sandbox_guarded(session_id, None, Some(sandbox_id), &[])
.await;
if let Err(e) = clear_result {
if matches!(e, engram_core::MetaError::Conflict(_)) {
tracing::info!(
Expand Down
2 changes: 1 addition & 1 deletion crates/engram-coordinator/src/session_verbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ mod tests {
state
.services
.meta
.assign_session_sandbox(id, Some(sandbox_id))
.fenced_assign_sandbox(id, 0, Some(sandbox_id), None)
.await
.unwrap();
state
Expand Down
Loading
Loading