{"record":{"id":"f754929e0bfa6ff3","repo":"influxdata/influxdb","slug":"tried-creating-database-named-0-that-already-exists","errorCode":null,"errorMessage":"tried creating database named '{0}' that already exists","messagePattern":"tried creating database named '(.+?)' that already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"influxdb3_write/src/write_buffer/mod.rs","lineNumber":110,"sourceCode":"    #[error(\"database name error: {0}\")]\n    DatabaseNameError(#[from] DatabaseNameError),\n\n    #[error(\"error from table buffer: {0}\")]\n    TableBufferError(#[from] table_buffer::Error),\n\n    #[error(\"error in last cache: {0}\")]\n    LastCacheError(#[from] last_cache::Error),\n\n    #[error(\"database not found {db_name:?}\")]\n    DatabaseNotFound { db_name: String },\n\n    #[error(\"table not found {table_name:?} in db {db_name:?}\")]\n    TableNotFound { db_name: String, table_name: String },\n\n    #[error(\"tried accessing database that does not exist\")]\n    DbDoesNotExist,\n\n    #[error(\"tried creating database named '{0}' that already exists\")]\n    DatabaseExists(String),\n\n    #[error(\"cannot write to soft-deleted database '{0}' - it is marked for deletion\")]\n    DatabaseDeleted(String),\n\n    #[error(\"tried accessing table that do not exist\")]\n    TableDoesNotExist,\n\n    #[error(\"table '{db_name}.{table_name}' already exists\")]\n    TableAlreadyExists {\n        db_name: Arc<str>,\n        table_name: Arc<str>,\n    },\n\n    #[error(\"tried accessing column with name ({0}) that does not exist\")]\n    ColumnDoesNotExist(String),\n\n    #[error(","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_write/src/write_buffer/mod.rs#L92-L128","documentation":"Thrown when an operation tries to create a database whose name is already taken by an existing database in the catalog. The payload is the conflicting name. It prevents silently reusing or clobbering an existing database's schema and data.","triggerScenarios":"Explicit database-creation requests (API or write-buffer create_database) for a name that already exists; racing duplicate create calls from multiple clients or startup initialization running twice.","commonSituations":"Idempotency mistakes in provisioning scripts run more than once; two services starting up and both creating the same default database; assuming create is upsert-like when it is not.","solutions":["Check existence first and treat create as idempotent (skip if it exists)","Catch the error and fall back to using the existing database","Serialize database creation (single provisioner) to avoid races"],"exampleFix":"// before\ncreate_database(\"metrics\")?; // fails on second run\n// after\nif let Err(WriteBufferError::DatabaseExists(name)) = create_database(\"metrics\") {\n    log::info!(\"database {name} already exists; reusing it\");\n}","handlingStrategy":"try-catch","validationCode":"// idempotent creation\nif !database_exists(name)? {\n    create_database(name)?;\n}","typeGuard":"fn is_database_exists(e: &WriteBufferError) -> bool {\n    matches!(e, WriteBufferError::DatabaseExists(_))\n}","tryCatchPattern":"match create_database(name) {\n    Err(WriteBufferError::DatabaseExists(n)) => info!(\"db {n} already exists, reusing\"),\n    other => other?,\n}","preventionTips":["Make provisioning scripts idempotent (exists-check or tolerate this error)","Serialize database creation through a single provisioner/lock","Treat create as create-if-absent, not upsert","Add a startup race guard when multiple services bootstrap the same database"],"tags":["database","conflict","already-exists","influxdb"],"backgroundTag":"file-already-exists","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}