mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-02 06:05:53 +00:00
Fix an issue where executing a CREATE TABLE IF NOT EXISTS statement with CDC enabled fails with an error if the table already exists. Instead, the query should succeed and be a no-op. This regression was introduced by commitfed1048059. Previously, when executing the query, we would first check if the table exists in do_prepare_new_column_families_announcement. If it did, we would throw an already_exists_exception, which was handled correctly; otherwise, we would continue and create the CDC table in the before_create_column_families notification. The order of operations was changed infed1048059, causing the regression. Now, we first create the CDC schema and add it to the schema list for creation, and then check for each of them if they already exist. The problem is that when we create the CDC schema in on_pre_create_column_families, it also checks if the CDC table already exists. If it does, it throws an invalid_request_exception, which is not caught and handled as expected. This patch restores the previous order of operations: we first check if the tables exist, and only then add the CDC schema in pre_create. Fixes scylladb/scylladb#26142