{"record":{"id":"0b2585df74db74bc","repo":"nautechsystems/nautilus_trader","slug":"latest-anchor","errorCode":null,"errorMessage":"latest anchor","messagePattern":"latest anchor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/event_store/src/writer/mod.rs","lineNumber":1883,"sourceCode":"\n        let writer = EventStoreWriter::spawn(\n            Box::new(wrapper),\n            get_atomic_clock_static(),\n            noop_halt(),\n            WriterConfig::default(),\n        )\n        .expect(\"spawn\");\n\n        writer.submit(entry_draft(10)).expect(\"submit first\");\n        writer.submit(entry_draft(11)).expect(\"submit second\");\n        let anchor = writer\n            .record_snapshot_anchor(\"cache://position-snapshots/P-1/0\", \"blake3:abc\")\n            .expect(\"record anchor\");\n\n        let backend = shared.lock();\n        assert_eq!(anchor.high_watermark, 2);\n        assert_eq!(\n            backend.latest_snapshot_anchor().expect(\"latest anchor\"),\n            Some(anchor),\n        );\n    }\n}\n","sourceCodeStart":1865,"sourceCodeEnd":1888,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/event_store/src/writer/mod.rs#L1865-L1888","documentation":"Test panic from `.expect(\"latest anchor\")` on the backend's `latest_snapshot_anchor()` query, which returns `Result<Option<SnapshotAnchor>, EventStoreError>`. The panic fires either on a backend error or because the assertion compares against `Some(anchor)` and the query returned `None` — i.e. the anchor recorded moments earlier is not visible to the backend query.","triggerScenarios":"`latest_snapshot_anchor` returning `Err(EventStoreError)` (storage/read failure); returning `None` because the anchor was never durably recorded, was recorded on a different backend instance, or the shared wrapper was locked/mutated inconsistently.","commonSituations":"Querying a different backend object than the one the writer owns; madsim/shared-memory visibility issues; reading before the writer thread actually committed the anchor despite the ack.","solutions":["Query the same `SharedMemory` backend instance the writer was spawned with (verify wrapper/shared wiring).","Confirm `record_snapshot_anchor` returned `Ok` and its ack came from the writer thread before asserting.","Handle the `Err` case explicitly to see the backend error instead of panicking on `expect`.","If `None`, check whether the backend's `record_snapshot_anchor` path stores anchors in the queried collection."],"exampleFix":"// before\nassert_eq!(backend.latest_snapshot_anchor().expect(\"latest anchor\"), Some(anchor));\n// after\nlet latest = backend.latest_snapshot_anchor()\n    .unwrap_or_else(|e| panic!(\"latest anchor query failed: {e:?}\"));\nassert!(latest.is_some(), \"anchor must be recorded before latest_snapshot_anchor query\");\nassert_eq!(latest, Some(anchor));","handlingStrategy":"validation","validationCode":"let latest = backend.latest_snapshot_anchor()?;\nassert!(latest.is_some(), \"anchor must exist after record_snapshot_anchor Ok\");","typeGuard":"fn anchor_recorded(r: &Result<Option<SnapshotAnchor>, EventStoreError>) -> bool {\n    matches!(r, Ok(Some(_)))\n}","tryCatchPattern":"match backend.latest_snapshot_anchor() {\n    Ok(Some(anchor)) => verify(anchor),\n    Ok(None) => log::warn!(\"no anchor recorded yet\"),\n    Err(e) => log::error!(\"anchor query failed: {e}\"),\n}","preventionTips":["Query the same backend instance the writer owns.","Only assert visibility after record_snapshot_anchor returned Ok.","Handle Ok(None) as a distinct, expected state rather than an error."],"tags":["rust","snapshot-anchor","backend","query"],"backgroundTag":"record-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}