{"record":{"id":"a40201790c5fc734","repo":"nautechsystems/nautilus_trader","slug":"open","errorCode":null,"errorMessage":"open","messagePattern":"open","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/event_store/src/writer/mod.rs","lineNumber":1110,"sourceCode":"        }\n\n        let final_hwm = writer.close(run_ended_draft()).expect(\"close\");\n\n        // 6 submits + 1 RunEnded == 7 entries, batch=2 -> 4 commits (3 size-driven + 1 close).\n        assert_eq!(final_hwm, 7);\n        assert_eq!(appends_seen.load(Ordering::SeqCst), 4);\n    }\n\n    #[rstest]\n    fn submit_signals_halt_when_stalled_past_threshold(\n        captured_halt: (HaltCallback, Arc<Mutex<Vec<HaltReason>>>),\n    ) {\n        // Channel capacity 1 with a backend gate held closed forces a stall: the first\n        // submit fills the buffer, the writer thread blocks inside append_batch, and a\n        // subsequent submit can never enqueue before the halt threshold fires.\n        let (halt, captured) = captured_halt;\n        let inner = Arc::new(Mutex::new(MemoryBackend::new()));\n        inner.lock().open_run(manifest(\"run-halt\")).expect(\"open\");\n\n        let gate = Arc::new((Mutex::new(false), parking_lot::Condvar::new()));\n        let appends_seen = Arc::new(AtomicUsize::new(0));\n        let backend = BlockingBackend::new(\n            Arc::clone(&inner),\n            Arc::clone(&gate),\n            Arc::clone(&appends_seen),\n        );\n\n        let halt_threshold = Duration::from_millis(50);\n        let config = WriterConfig {\n            channel_capacity: 1,\n            max_batch_entries: 1,\n            max_batch_latency: Duration::from_millis(1),\n            halt_threshold,\n        };\n\n        let clock = get_atomic_clock_static();","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/event_store/src/writer/mod.rs#L1092-L1128","documentation":"MemoryBackend::open_run initializes a run with the given manifest and is a precondition for spawning a writer that can commit entries. The expect at writer/mod.rs:1110 (test submit_signals_halt_when_stalled_past_threshold) panics if open_run returns Err. The library errors when the run cannot be opened, e.g. it is already open or the manifest is invalid.","triggerScenarios":"Calling inner.lock().open_run(manifest(\"run-halt\")) on a MemoryBackend whose run is already open (double open), or with a manifest that fails validation, immediately before constructing a BlockingBackend for the halt-stall test.","commonSituations":"Reusing a shared MemoryBackend across tests without resetting it; setting up a gated backend for backpressure tests and forgetting the run is already open; invalid run manifest fields.","solutions":["Use a fresh MemoryBackend per test so open_run is called exactly once per backend instance","Inspect the EventStoreError from open_run — an 'already open' error means close/seal the prior run or discard the backend","Validate the RunManifest fields before calling open_run"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let m = backend.manifest().map_err(|e| format!(\"cannot probe run state: {e}\"))?;\nif m.status != RunStatus::Open {\n    backend.open_run(manifest(\"run-halt\")).map_err(|e| format!(\"open_run failed: {e}\"))?;\n}","typeGuard":"fn run_openable(m: &RunManifest) -> bool {\n    matches!(m.status, RunStatus::None | RunStatus::Ended | RunStatus::Sealed)\n}","tryCatchPattern":"if let Err(e) = backend.open_run(manifest(\"run-halt\")) {\n    eprintln!(\"open_run failed: {e:?}\");\n}","preventionTips":["Use a fresh backend instance per test","Check run status before calling open_run to avoid double-open","Validate RunManifest fields in test fixtures"],"tags":["rust","panic","event-store","test-setup"],"backgroundTag":"file-already-exists","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"}