{"record":{"id":"3099f1e07d174674","repo":"dbt-labs/dbt-core","slug":"inconsistent-park-state-actual-actual","errorCode":null,"errorMessage":"inconsistent park state; actual = {actual}","messagePattern":"inconsistent park state; actual = (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-runtime/src/park.rs","lineNumber":105,"sourceCode":"\n        // Otherwise we need to coordinate going to sleep\n        let mut m = self.mutex.lock().unwrap();\n\n        match self.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) {\n            Ok(_) => {}\n            Err(NOTIFIED) => {\n                // We must read here, even though we know it will be `NOTIFIED`.\n                // This is because `unpark` may have been called again since we read\n                // `NOTIFIED` in the `compare_exchange` above. We must perform an\n                // acquire operation that synchronizes with that `unpark` to observe\n                // any writes it made before the call to unpark. To do that we must\n                // read from the write it made to `state`.\n                let old = self.state.swap(EMPTY, SeqCst);\n                debug_assert_eq!(old, NOTIFIED, \"park state changed unexpectedly\");\n\n                return;\n            }\n            Err(actual) => panic!(\"inconsistent park state; actual = {actual}\"),\n        }\n\n        loop {\n            m = self.condvar.wait(m).unwrap();\n\n            if self\n                .state\n                .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst)\n                .is_ok()\n            {\n                // got a notification\n                return;\n            }\n\n            // spurious wakeup, go back to sleep\n        }\n    }\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-runtime/src/park.rs#L87-L123","documentation":"This custom Parker (mirroring std's park/unpark) uses an atomic `state` (EMPTY/NOTIFIED) plus a condvar/mutex. When park() observes a state value that is neither EMPTY (freshly unparked with a consumed token) nor NOTIFIED, the internal state machine is corrupt and it panics with the unexpected value. This indicates a bug in the park/unpark coordination, not in user data.","triggerScenarios":"Calling park() when the atomic state holds an unexpected value — caused by concurrent unpark/park racing that violated the state protocol, an unpark without proper NOTIFICATION sequencing, memory-ordering bugs, or the timeout path in park_timeout interleaving with park incorrectly.","commonSituations":"Very high-contentiation wakeups on the blocking pool; a custom runtime modification breaking the park token protocol; a signal/unpark arriving between the state swap and the mutex acquisition in ways the invariant didn't anticipate; running under sanitizers exposing a pre-existing race.","solutions":["Report/minimize the race: this is an internal invariant failure, usually not fixable from user code — capture the `actual` value and a reproduction.","Audit any custom modifications to park.rs or the unpark path for state transitions that skip EMPTY/NOTIFIED.","Verify all state transitions use the documented orderings (SeqCst swaps) and that unpark always sets NOTIFIED before waking the condvar.","As a workaround, pin to a prior runtime version where the park state machine was stable."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// this is an internal panic, not a catchable error; restart the runtime worker\nlet result = std::panic::catch_unwind(AssertUnwindSafe(|| worker_loop()));\nif result.is_err() {\n    eprintln!(\"park state panic; restarting worker\");\n    restart_worker();\n}","preventionTips":["Do not modify park/unpark state transitions without keeping the EMPTY/NOTIFIED protocol intact.","Keep all Parker state swaps at SeqCst ordering as the implementation expects.","Stress-test with many concurrent unparks/timeouts to surface races early.","If reproducible, file a bug with the printed `actual` state value and a minimal reproduction."],"tags":["rust","runtime","panic","concurrency","park"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}