{"record":{"id":"a94e593ed0230681","repo":"neondatabase/neon","slug":"initdb-failed-with-status-status","errorCode":null,"errorMessage":"initdb failed with status {status}","messagePattern":"initdb failed with status (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"control_plane/src/storage_controller.rs","lineNumber":423,"sourceCode":"                ];\n                tracing::info!(\n                    \"Initializing storage controller database with args: {:?}\",\n                    initdb_args\n                );\n\n                // Initialize empty database\n                let initdb_path = pg_bin_dir.join(\"initdb\");\n                let mut child = Command::new(&initdb_path)\n                    .envs(vec![\n                        (\"LD_LIBRARY_PATH\".to_owned(), pg_lib_dir.to_string()),\n                        (\"DYLD_LIBRARY_PATH\".to_owned(), pg_lib_dir.to_string()),\n                    ])\n                    .args(initdb_args)\n                    .spawn()\n                    .expect(\"Failed to spawn initdb\");\n                let status = child.wait().await?;\n                if !status.success() {\n                    anyhow::bail!(\"initdb failed with status {status}\");\n                }\n            };\n\n            // Write a minimal config file:\n            // - Specify the port, since this is chosen dynamically\n            // - Switch off fsync, since we're running on lightweight test environments and when e.g. scale testing\n            //   the storage controller we don't want a slow local disk to interfere with that.\n            //\n            // NB: it's important that we rewrite this file on each start command so we propagate changes\n            // from `LocalEnv`'s config file (`.neon/config`).\n            tokio::fs::write(\n                &pg_data_path.join(\"postgresql.conf\"),\n                format!(\"port = {postgres_port}\\nfsync=off\\n\"),\n            )\n            .await?;\n\n            println!(\"Starting storage controller database...\");\n            let db_start_args = [","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/control_plane/src/storage_controller.rs#L405-L441","documentation":"The storage controller initializes its private postgres cluster by spawning initdb with LD_LIBRARY_PATH/DYLD_LIBRARY_PATH pointing at the built pg lib dir. A non-zero initdb exit is reported bare — initdb's own stderr is not captured into the message.","triggerScenarios":"The target pgdata directory (base_data_dir/storage_controller_db) already contains files, initdb cannot load required shared libraries from pg_lib_dir, insufficient disk space, bad permissions, or unsupported locale arguments.","commonSituations":"Retrying storcon start after a failed first run without cleaning storage_controller_db, a pg build whose libs are not where pg_lib_dir points, read-only or full filesystems.","solutions":["Run initdb manually with the same args and env against a temp dir to see its real error output","Remove the leftover storage_controller_db directory before re-initializing","Verify <pg_distrib_dir>/v<major>/lib contains the shared libraries","Check disk space and write permissions on base_data_dir"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let pgdata = env.base_data_dir.join(\"storage_controller_db\");\nif pgdata.exists() {\n    anyhow::ensure!(\n        std::fs::read_dir(&pgdata)?.next().is_none(),\n        \"pgdata not empty; remove storage_controller_db before re-init\"\n    );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always clean storage_controller_db after a failed start","Smoke-test initdb manually after rebuilding postgres","Keep the pg lib dir layout versioned (v<major>/lib) so LD_LIBRARY_PATH resolves"],"tags":["rust","storage-controller","postgres","initdb","subprocess"],"backgroundTag":"initdb-failed","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}