{"record":{"id":"378c80be725ef513","repo":"dbt-labs/dbt-core","slug":"failed-to-initialize-default-multi-threaded-tokio","errorCode":null,"errorMessage":"failed to initialize default multi-threaded tokio runtime","messagePattern":"failed to initialize default multi-threaded tokio runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/dbt-main/src/main_impl.rs","lineNumber":178,"sourceCode":"            .enable_all()\n            .thread_stack_size(FS_DEFAULT_STACK_SIZE)\n            .worker_threads(1)\n            .max_blocking_threads(1)\n            .on_thread_start(move || on_tokio_thread_start(&dbt_rt_handle))\n            .on_thread_stop(on_tokio_thread_stop)\n            .build()\n            .expect(\"failed to initialize 'single-worker' tokio runtime\")\n    } else {\n        let dbt_rt_handle = dbt_rt.handle().clone();\n        // Multi-threaded runtime: use default (max parallelism)\n        tokio::runtime::Builder::new_multi_thread()\n            .enable_all()\n            .max_blocking_threads(FS_DEFAULT_MAX_BLOCKING_THREADS)\n            .thread_stack_size(FS_DEFAULT_STACK_SIZE)\n            .on_thread_start(move || on_tokio_thread_start(&dbt_rt_handle))\n            .on_thread_stop(on_tokio_thread_stop)\n            .build()\n            .expect(\"failed to initialize default multi-threaded tokio runtime\")\n    };\n\n    // If execution panics, exit with a status 2 (but not if RUST_BACKTRACE is\n    // set to 1, in which case we want to see the backtrace):\n    if arg.exit_process_on_panic && std::env::var(\"RUST_BACKTRACE\").unwrap_or_default() != \"1\" {\n        std::panic::set_hook(Box::new(|info| {\n            eprintln!(\"{} {}\", RED.apply_to(format!(\"{PANIC}:\")), info);\n            let _ = io::stdout().flush();\n            let _ = io::stderr().flush();\n\n            std::process::exit(2);\n        }));\n    }\n\n    let cst = feature_stack.cli.cancellation_token_source.clone();\n    let fail_fast = feature_stack.cli.fail_fast.clone();\n    let token = cst.token();\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-main/src/main_impl.rs#L160-L196","documentation":"`run_cli_with_code` builds the default multi-threaded tokio runtime when multi-thread mode is enabled; `.build()` failure panics with this message. As with the single-worker path, the only realistic cause is the OS failing to create worker threads (thread/pid limits, OOM, oversized stacks).","triggerScenarios":"`run_cli` → `run_cli_with_code` selects the multi-thread branch and `tokio::runtime::Builder::new_multi_thread().build()` fails because worker threads cannot be spawned (ulimit, cgroup pids, memory exhaustion) or `FS_DEFAULT_MAX_BLOCKING_THREADS`/stack size settings are unusable.","commonSituations":"High-core-count machines spawning many worker threads in a constrained container; heavy parallel dbt load; low `ulimit -u`; invalid huge FS_DEFAULT_STACK_SIZE.","solutions":["Raise ulimit -u / container pids limit","Increase container memory or reduce FS_DEFAULT_MAX_BLOCKING_THREADS / stack size","Lower parallelism (e.g. --threads) or run on a less constrained machine","Set RUST_BACKTRACE=1 and report if it persists on a normal machine"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let rt = tokio::runtime::Builder::new_multi_thread()\n    .enable_all().build()\n    .unwrap_or_else(|e| panic!(\"runtime init failed: {e}; check ulimit -u and memory\"));","preventionTips":["Raise thread/pid limits on high-core machines","Reduce FS_DEFAULT_MAX_BLOCKING_THREADS in constrained containers","Leave memory headroom for per-core worker stacks","Retry after freeing memory if under transient pressure"],"tags":["tokio","runtime","thread-spawn","startup"],"backgroundTag":"resource-exhaustion","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}