{"record":{"id":"5b2e72fd6273b3e4","repo":"nautechsystems/nautilus_trader","slug":"submit-accepted","errorCode":null,"errorMessage":"submit accepted","messagePattern":"submit accepted","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/event_store/src/writer/mod.rs","lineNumber":1328,"sourceCode":"        captured_halt: (HaltCallback, Arc<Mutex<Vec<HaltReason>>>),\n    ) {\n        // A writer-thread halt latches the shared flag; post-halt submits must\n        // reject rather than be accepted and silently dropped.\n        let (halt, captured) = captured_halt;\n        let config = WriterConfig {\n            max_batch_entries: 1,\n            ..WriterConfig::default()\n        };\n\n        let writer = EventStoreWriter::spawn(\n            Box::new(DiskFailureBackend::default()),\n            get_atomic_clock_static(),\n            halt,\n            config,\n        )\n        .expect(\"spawn\");\n\n        writer.submit(entry_draft(10)).expect(\"submit accepted\");\n\n        let mut waited = Duration::ZERO;\n        while waited < Duration::from_secs(2) {\n            if !captured.lock().is_empty() {\n                break;\n            }\n            std::thread::sleep(Duration::from_millis(5));\n            waited += Duration::from_millis(5);\n        }\n\n        let reasons = captured.lock();\n        assert_eq!(reasons.len(), 1, \"writer-thread halt did not fire\");\n        assert!(\n            matches!(reasons.first(), Some(HaltReason::BackendDisk(_))),\n            \"was {:?}\",\n            reasons.first(),\n        );\n        drop(reasons);","sourceCodeStart":1310,"sourceCodeEnd":1346,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/event_store/src/writer/mod.rs#L1310-L1346","documentation":"Test panic from `.expect(\"submit accepted\")` at crates/event_store/src/writer/mod.rs:1328. It fires when `writer.submit(entry_draft(10))` returns `Err` immediately after spawn. In this test the backend is `DiskFailureBackend`, whose `append_batch` fails; submit should still return `Ok` because acceptance only requires enqueuing into the channel — a rejection means the channel is full, the writer thread already died and latched halt, or the run state prevents appends.","triggerScenarios":"Submitting to a writer whose channel is saturated, whose writer thread has already halted (latched flag makes later submits return `SubmitError::Closed`), or whose run was never opened / already sealed on the backend.","commonSituations":"Backpressure stalls with tiny `channel_capacity` + long backend operations; running tests on slow CI where the disk-failure halt fires before the submit lands; forgetting to call `open_run` on the shared backend.","solutions":["Submit promptly after `spawn` and ensure the halt threshold is generous relative to test timing so the first submit is accepted before any halt can latch.","Match on the `SubmitError` (`Closed` vs `HaltSignaled`) instead of expect to identify whether the writer thread died before the submit.","Verify `open_run(manifest(...))` was called on the backend the writer was spawned with.","Increase `channel_capacity` so the first submit cannot be rejected for a full buffer."],"exampleFix":"// before\nwriter.submit(entry_draft(10)).expect(\"submit accepted\");\n// after\nwriter\n    .submit(entry_draft(10))\n    .expect(\"first submit must be accepted before any halt can latch\");","handlingStrategy":"retry","validationCode":"// Ensure no halt has latched before submitting\nassert!(captured.lock().is_empty(), \"halt already fired; submits will be refused\");","typeGuard":"match writer.submit(entry_draft(10)) {\n    Ok(_) => {},\n    Err(SubmitError::Closed) => eprintln!(\"writer halted; not accepting\"),\n    Err(e) => eprintln!(\"submit rejected: {e:?}\"),\n}","tryCatchPattern":"writer.submit(entry_draft(10))\n    .unwrap_or_else(|e| panic!(\"first submit rejected: {e:?}\"));","preventionTips":["Submit immediately after spawn, before halt timers can fire.","Open the run on the backend before spawning the writer.","Size channel_capacity >= 1 for the first submit.","On CI, widen halt_threshold to absorb scheduling delays."],"tags":["rust","panic","backpressure","submit-rejected"],"backgroundTag":"internal-invariant-violation","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"}