mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
The vector-search feature, which is already supported in CQL, introduced the somewhat confusing feature of enabling CDC without explicitly enabling CDC: When a vector index is enabled on a table, CDC is "enabled" for it even if the user didn't ask to enable CDC. For this, some code in cdc/log.cc began to use cdc_enabled() instead of checking schema.cdc_options.enabled() directly. This cdc_enabled() function checks if either this enabled() is true, or has_vector_index() is true. But there's another twist to this story: To write with CDC, we also need to create the CDC log table: 1. In CQL, a vector index can only be added on an existing table (with CREATE INDEX), so the hook on_before_update_column_family() is the one that noticed that a vector index was added, and created the CDC log table. 2. But in Alternator, a vector index can be created up-front with a brand-new table (in CreateTable), so the hook for a new table - on_pre_create_column_families(), also needs to create the CDC log table. It already did, but incorrectly checked just the explicit CDC-enabled flag instead of the new cdc_enabled() function that also allows vector index. So this patch just fixes on_pre_create_column_families to use cdc_enabled(). Before this patch, when a vector index will be created in Alternator with CreateTable, an attempt to write to the table (PutItem) will fail because it will try to write to the CDC log, which wasn't created. After this patch, it works. The reproducing test is test_putitem_vectorindex_createtable (introduced in a later patch). Signed-off-by: Nadav Har'El <nyh@scylladb.com>