{"record":{"id":"4f5a65224cf18e15","repo":"risingwavelabs/risingwave","slug":"0-named-1-already-exists-under-creation","errorCode":null,"errorMessage":"{0} named {1} already exists{under_creation}","messagePattern":"(.+?) named (.+?) already exists(.+?)","errorType":"error_code","errorClass":"MetaError","httpStatus":null,"severity":"error","filePath":"src/meta/src/error.rs","lineNumber":83,"sourceCode":"\n    #[error(\"{0}\")]\n    PermissionDenied(String),\n\n    #[error(\"Invalid worker: {0}, {1}\")]\n    InvalidWorker(WorkerId, String),\n\n    #[error(\"Invalid parameter: {0}\")]\n    InvalidParameter(#[message] String),\n\n    // Used for catalog errors.\n    #[error(\"{0} id not found: {1}\")]\n    #[construct(skip)]\n    CatalogIdNotFound(&'static str, String),\n\n    #[error(\"table_fragment does not exist: id={0}\")]\n    FragmentNotFound(FragmentId),\n\n    #[error(\"{0} named {1} already exists{under_creation}\", under_creation = (.2).map(|_| \" and is still being created\").unwrap_or(\"\"))]\n    Duplicated(\n        &'static str,\n        String,\n        // if under creation, take streaming job id, otherwise None\n        Option<JobId>,\n    ),\n\n    #[error(\"Service unavailable: {0}\")]\n    Unavailable(#[message] String),\n\n    #[error(\"Election failed: {0}\")]\n    Election(#[source] BoxedError),\n\n    #[error(\"Cancelled: {0}\")]\n    Cancelled(String),\n\n    #[error(\"System parameters error: {0}\")]\n    SystemParams(String),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/error.rs#L65-L101","documentation":"A DDL/create operation failed because an object of the given type with the given name already exists in the catalog. The optional third field is a JobId when the existing object is still being created, which appends \" and is still being created\" to the message.","triggerScenarios":"CREATE TABLE/MATERIALIZED VIEW/SOURCE/SINK/DATABASE/SCHEMA with a name that already exists; retried DDL after a partially completed create; creating a job while a same-named one is in CREATION state.","commonSituations":"Idempotency races from job frameworks re-submitting DDL, duplicate names in migration scripts, a previous create left under-creation state after failure or interruption.","solutions":["Use `CREATE ... IF NOT EXISTS` or check existence (`SHOW ...`) before creating.","Drop the existing object first if it is unwanted (`DROP ...`).","If the message says it is still being created, wait for the in-flight job to finish (monitor via `SHOW JOBS`) rather than retrying immediately.","If a stale under-creation job is stuck, cancel it (`CANCEL JOBS`) and clean up before recreating."],"exampleFix":"// before\nCREATE MATERIALIZED VIEW mv_sales AS SELECT ...; -- Duplicated\n// after\nCREATE MATERIALIZED VIEW IF NOT EXISTS mv_sales AS SELECT ...;","handlingStrategy":"validation","validationCode":"let exists = catalog.has_object(kind, name).await?;\nif !exists { create_object(kind, name).await?; }","typeGuard":null,"tryCatchPattern":"match meta_result {\n    Err(MetaError::Duplicated(kind, name, job)) if job.is_some() => { /* wait for in-flight creation */ }\n    Err(MetaError::Duplicated(kind, name, _)) => { /* drop or use IF NOT EXISTS */ }\n    other => other?,\n}","preventionTips":["Prefer `CREATE ... IF NOT EXISTS` for idempotent provisioning.","Make DDL job frameworks idempotent: treat 'already exists' as success when spec matches.","Check `SHOW JOBS` before retrying creates that may be under creation."],"tags":["meta","duplicate","ddl","catalog"],"backgroundTag":"file-already-exists","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}