{"record":{"id":"00e6563f9d7e015a","repo":"influxdata/influxdb","slug":"table-db-name-table-name-already-exists","errorCode":null,"errorMessage":"table '{db_name}.{table_name}' already exists","messagePattern":"table '(.+?)\\.(.+?)' already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_write/src/write_buffer/mod.rs","lineNumber":119,"sourceCode":"    #[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(\n        \"updating catalog on delete of last cache failed, you will need to delete the cache \\\n        again on server restart\"\n    )]\n    DeleteLastCache(#[source] CatalogError),\n\n    #[error(\"error from wal: {0}\")]\n    WalError(#[from] influxdb3_wal::Error),\n\n    #[error(\"error in distinct value cache: {0}\")]","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_write/src/write_buffer/mod.rs#L101-L137","documentation":"Thrown when an operation tries to create a table (measurement) that already exists in the database. Tables are keyed by (db_name, table_name) in the catalog, and duplicate creation is rejected to protect the existing schema.","triggerScenarios":"Explicit table-creation APIs called twice; a CREATE TABLE-like operation racing with another writer that created the same measurement concurrently.","commonSituations":"Idempotent setup scripts run repeatedly without checking existence; two services bootstrapping the same schema on startup; retries after a timeout where the first attempt actually succeeded.","solutions":["Check for existence first and skip creation if the table is present","Treat this error as success in idempotent bootstrap code","Serialize schema setup so only one process creates tables","Use distinct table names per service if isolation is intended"],"exampleFix":"// before\nwriter.create_table(db, \"cpu\")?;  // panics/errors on re-run\n// after\nif !catalog.table_exists(db, \"cpu\") {\n    writer.create_table(db, \"cpu\")?;\n}","handlingStrategy":"try-catch","validationCode":"if !catalog.table_exists(db_name, table_name) {\n    create_table(db_name, table_name)?;\n}","typeGuard":"fn is_table_already_exists(err: &WriteBufferError) -> bool {\n    matches!(err, WriteBufferError::TableAlreadyExists { .. })\n}","tryCatchPattern":"match create_table(db, table) {\n    Err(WriteBufferError::TableAlreadyExists { .. }) => Ok(()), // idempotent\n    other => other,\n}","preventionTips":["Make schema bootstrap idempotent (check-then-create or swallow Exists)","Use distributed locks/leadership election for one-time schema setup","Handle retries: a timeout may still have created the table"],"tags":["table","already-exists","schema","influxdb3"],"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"}