diff --git a/crates/bft-json-crdt/Cargo.toml b/crates/bft-json-crdt/Cargo.toml index f006b563..c74aa39d 100644 --- a/crates/bft-json-crdt/Cargo.toml +++ b/crates/bft-json-crdt/Cargo.toml @@ -6,8 +6,14 @@ edition = "2021" [lib] crate-type = ["lib"] +# The logging-* features print multi-KB debug dumps on every CRDT op — and +# they execute inside the global CRDT state mutex in the server, so a stalled +# stdout write while holding that lock can pin every tokio worker and freeze +# the whole process (bug 1170). They are development tools: opt in explicitly +# with `--features bft-json-crdt/logging-list` when debugging CRDT internals. +# Never enable them in a production build. [features] -default = ["bft", "logging-list", "logging-json"] +default = ["bft"] logging-list = ["logging-base"] logging-json = ["logging-base"] logging-base = [] diff --git a/server/src/crdt_state/state/tests.rs b/server/src/crdt_state/state/tests.rs index b55d5a12..3e989240 100644 --- a/server/src/crdt_state/state/tests.rs +++ b/server/src/crdt_state/state/tests.rs @@ -330,23 +330,27 @@ fn persist_tx_send_success_emits_no_warn() { }) .into(); - let before_warns = crate::log_buffer::global() - .get_recent_entries( - 1000, - Some("[crdt_persist]"), - Some(&crate::log_buffer::LogLevel::Warn), - ) - .len(); + // Count only warns mentioning THIS test's story: the log buffer is + // process-global, so parallel tests emit their own [crdt_persist] warns + // and a bare count races (flaked when the logging-list feature removal + // changed test timing). + let count_own_warns = || { + crate::log_buffer::global() + .get_recent_entries( + 1000, + Some("[crdt_persist]"), + Some(&crate::log_buffer::LogLevel::Warn), + ) + .iter() + .filter(|e| e.message.contains("676_story_happy_path")) + .count() + }; + + let before_warns = count_own_warns(); apply_and_persist(&mut state, |s| s.crdt.doc.items.insert(ROOT_ID, item_json)); - let after_warns = crate::log_buffer::global() - .get_recent_entries( - 1000, - Some("[crdt_persist]"), - Some(&crate::log_buffer::LogLevel::Warn), - ) - .len(); + let after_warns = count_own_warns(); assert_eq!( after_warns, before_warns,