{"record":{"id":"57c8ecc4eb01ad04","repo":"risingwavelabs/risingwave","slug":"old-sink-does-not-match-replacement-sink","errorCode":null,"errorMessage":"old sink {} does not match replacement sink {}","messagePattern":"old sink (.+?) does not match replacement sink (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/src/controller/streaming_job.rs","lineNumber":521,"sourceCode":"            let StreamingJob::Sink(sink, _) = streaming_job else {\n                bail!(\"replacement sink catalog requires a sink job\")\n            };\n            let (old_sink, old_object) = Sink::find_by_id(*old_sink_id)\n                .find_also_related(Object)\n                .one(&txn)\n                .await?\n                .and_then(|(sink, object)| object.map(|object| (sink, object)))\n                .ok_or_else(|| MetaError::catalog_id_not_found(\"sink\", *old_sink_id))?;\n            let old_streaming_job = StreamingJobModel::find_by_id(old_sink_id.as_job_id())\n                .one(&txn)\n                .await?\n                .ok_or_else(|| MetaError::catalog_id_not_found(\"sink\", *old_sink_id))?;\n            if old_object.obj_type != ObjectType::Sink\n                || old_object.database_id != Some(sink.database_id)\n                || old_object.schema_id != Some(sink.schema_id)\n                || old_sink.name != sink.name\n            {\n                bail!(\n                    \"old sink {} does not match replacement sink {}\",\n                    old_sink_id,\n                    sink.name\n                );\n            }\n            if old_sink.target_table.is_some() || sink.target_table.is_some() {\n                bail!(\"replace sink into table is not supported\");\n            }\n            if old_streaming_job.job_status != JobStatus::Created {\n                bail!(\"sink {} is not ready to be replaced\", old_sink_id);\n            }\n        } else {\n            check_relation_name_duplicate(\n                &streaming_job.name(),\n                streaming_job.database_id(),\n                streaming_job.schema_id(),\n                &txn,\n            )","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/controller/streaming_job.rs#L503-L539","documentation":"When replacing a sink, the old sink must actually match the replacement: same object type (Sink), same database and schema, and same name. This error means the old sink id resolved to an object that differs from the replacement sink on one of those attributes.","triggerScenarios":"CREATE SINK ... REPLACE (or create_job_catalog with replace_sink) where the old sink lives in a different database/schema, has a different name, or is not a sink.","commonSituations":"User renamed the sink in the replacement statement but pointed at the old id; sink moved schemas; typo in the replace target; stale frontend catalog cache.","solutions":["Make the replacement sink use the same name, database, and schema as the sink being replaced.","Verify the old sink id is correct (query rw_catalog / system tables for the sink).","If a different name/location is desired, drop the old sink and create a new one instead of replacing."],"exampleFix":"-- before\nCREATE SINK orders_sink2 AS SELECT ... REPLACE orders_sink;\n-- after\nCREATE SINK orders_sink AS SELECT ... REPLACE orders_sink;","handlingStrategy":"validation","validationCode":"// verify match before replacing\nSELECT obj_type, database_id, schema_id, name\nFROM rw_catalog rw_objects\nWHERE object_id = <old_sink_id>;\n-- ensure name/db/schema equal the replacement sink","typeGuard":null,"tryCatchPattern":"if let Err(e) = catalog.create_job_catalog(job).await {\n    if e.to_string().contains(\"does not match replacement sink\") {\n        // re-resolve old sink id by name from the catalog and retry\n    }\n}","preventionTips":["Always reference the replace target by its current name/db/schema","Refresh the frontend catalog cache before replace DDL"],"tags":["meta","sink","replace"],"backgroundTag":"invalid-argument-value","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"}