{"record":{"id":"d5e3b71fefc7b6aa","repo":"nautechsystems/nautilus_trader","slug":"record-anchor","errorCode":null,"errorMessage":"record anchor","messagePattern":"record anchor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/event_store/src/writer/mod.rs","lineNumber":1878,"sourceCode":"        let (wrapper, shared) = SharedMemory::new();\n        shared\n            .lock()\n            .open_run(manifest(\"run-anchor\"))\n            .expect(\"open\");\n\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":1860,"sourceCodeEnd":1888,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/event_store/src/writer/mod.rs#L1860-L1888","documentation":"Test panic from `.expect(\"record anchor\")` on `EventStoreWriter::record_snapshot_anchor`, which returns `EventStoreError::Closed` if halted/shut down, a Backend stall error if enqueue or the ack round-trip exceeds `halt_threshold`, or a backend error while persisting the anchor. The method flushes pending entries first, then records the anchor at the durable high-watermark so it never points past committed state.","triggerScenarios":"Calling after a halt fired or the writer closed; the ack channel timing out because the writer thread cannot commit pending entries within `halt_threshold`; the ack channel disconnecting (writer thread died); the backend rejecting the anchor write.","commonSituations":"Recording an anchor while earlier submits are still pending and the backend is slow; calling on a halted writer; anchor blob_ref/content_hash handling triggering a backend persistence error.","solutions":["Ensure no halt was fired and the writer is still open before calling `record_snapshot_anchor`.","Increase `halt_threshold` if flushing pending entries legitimately needs longer than the ack timeout.","Check the returned `EventStoreError` string (\"stalled\", \"ack channel disconnected\", backend error) to locate the failing stage.","Verify the backend's anchor persistence path (e.g. `record_snapshot_anchor` implementation) succeeds for the given blob_ref."],"exampleFix":"// before\nlet anchor = writer.record_snapshot_anchor(\"cache://position-snapshots/P-1/0\", \"blake3:abc\")\n    .expect(\"record anchor\");\n// after\nlet anchor = writer.record_snapshot_anchor(\"cache://position-snapshots/P-1/0\", \"blake3:abc\")\n    .unwrap_or_else(|e| panic!(\"record anchor failed: {e:?}\"));","handlingStrategy":"retry","validationCode":"if halted.load(Ordering::Acquire) { return Err(EventStoreError::Closed); }\n// ensure no outstanding submits likely to exceed halt_threshold before anchoring","typeGuard":null,"tryCatchPattern":"match writer.record_snapshot_anchor(blob_ref, hash) {\n    Ok(anchor) => cache.store(anchor),\n    Err(EventStoreError::Closed) => log::warn!(\"writer halted/closed; anchor skipped\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Record anchors only while the writer is healthy and unhalted.","Keep halt_threshold larger than worst-case flush + ack latency.","Inspect the error text to distinguish enqueue stall vs ack timeout vs backend write failure."],"tags":["rust","snapshot","writer","ack-timeout"],"backgroundTag":"request-timeout","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"}