diff options
| author | Ilnaz Nizametdinov <[email protected]> | 2024-07-25 17:40:51 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-25 17:40:51 +0300 |
| commit | bbafb6741e65bd9f23284eebfd40fa89595a2564 (patch) | |
| tree | e3d7f79422256875af6f02073b9b965548cd61ea | |
| parent | e5a42a27eb29d02906852ab35e62ecac0ff6550e (diff) | |
EnableChangefeedsOnIndexTables feature flag (#7085)
11 files changed, 61 insertions, 15 deletions
diff --git a/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp b/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp index ad1c6f58a3a..cac8556af6c 100644 --- a/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp +++ b/ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp @@ -4385,7 +4385,9 @@ Y_UNIT_TEST_SUITE(KqpScheme) { } Y_UNIT_TEST(ChangefeedOnIndexTable) { - TKikimrRunner kikimr(TKikimrSettings().SetPQConfig(DefaultPQConfig())); + TKikimrRunner kikimr(TKikimrSettings() + .SetPQConfig(DefaultPQConfig()) + .SetEnableChangefeedsOnIndexTables(true)); auto db = kikimr.GetTableClient(); auto session = db.CreateSession().GetValueSync().GetSession(); diff --git a/ydb/core/protos/feature_flags.proto b/ydb/core/protos/feature_flags.proto index f4c7cdf59a4..e6ef174af5c 100644 --- a/ydb/core/protos/feature_flags.proto +++ b/ydb/core/protos/feature_flags.proto @@ -146,4 +146,5 @@ message TFeatureFlags { optional bool EnableSingleCompositeActionGroup = 131 [default = false]; optional bool EnableResourcePoolsOnServerless = 132 [default = false]; optional bool EnableVectorIndex = 133 [default = false]; + optional bool EnableChangefeedsOnIndexTables = 134 [default = false]; } diff --git a/ydb/core/testlib/basics/feature_flags.h b/ydb/core/testlib/basics/feature_flags.h index 1270874e4a0..25426b836d7 100644 --- a/ydb/core/testlib/basics/feature_flags.h +++ b/ydb/core/testlib/basics/feature_flags.h @@ -61,6 +61,7 @@ public: FEATURE_FLAG_SETTER(EnableCMSRequestPriorities) FEATURE_FLAG_SETTER(EnableTableDatetime64) FEATURE_FLAG_SETTER(EnableResourcePools) + FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables) #undef FEATURE_FLAG_SETTER }; diff --git a/ydb/core/tx/replication/controller/dst_creator_ut.cpp b/ydb/core/tx/replication/controller/dst_creator_ut.cpp index 48ed4b8d4bc..805cd2b1e3b 100644 --- a/ydb/core/tx/replication/controller/dst_creator_ut.cpp +++ b/ydb/core/tx/replication/controller/dst_creator_ut.cpp @@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(DstCreator) { } void WithIndex(const TString& replicatedPath, NKikimrSchemeOp::EIndexType indexType) { - TEnv env; + TEnv env(TFeatureFlags().SetEnableChangefeedsOnIndexTables(true)); env.GetRuntime().SetLogPriority(NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE); const auto tableDesc = TTestTableDescription{ diff --git a/ydb/core/tx/replication/service/table_writer_ut.cpp b/ydb/core/tx/replication/service/table_writer_ut.cpp index 65c2c710e2a..5b1b3de7b16 100644 --- a/ydb/core/tx/replication/service/table_writer_ut.cpp +++ b/ydb/core/tx/replication/service/table_writer_ut.cpp @@ -39,10 +39,7 @@ Y_UNIT_TEST_SUITE(LocalTableWriter) { } Y_UNIT_TEST(SupportedTypes) { - auto featureFlags = TFeatureFlags(); - featureFlags.SetEnableTableDatetime64(true); - - TEnv env(featureFlags); + TEnv env(TFeatureFlags().SetEnableTableDatetime64(true)); env.GetRuntime().SetLogPriority(NKikimrServices::REPLICATION_SERVICE, NLog::PRI_DEBUG); env.CreateTable("/Root", *MakeTableDescription(TTestTableDescription{ diff --git a/ydb/core/tx/replication/ut_helpers/test_env.h b/ydb/core/tx/replication/ut_helpers/test_env.h index 6920d0f2e92..c9517b48667 100644 --- a/ydb/core/tx/replication/ut_helpers/test_env.h +++ b/ydb/core/tx/replication/ut_helpers/test_env.h @@ -10,6 +10,9 @@ namespace NKikimr::NReplication::NTestHelpers { +class TFeatureFlags: public TTestFeatureFlagsHolder<TFeatureFlags> { +}; + template <bool UseDatabase = true> class TEnv { static constexpr char DomainName[] = "Root"; @@ -63,7 +66,7 @@ public: TEnv(const TFeatureFlags& featureFlags, bool init = true) : Settings(Tests::TServerSettings(PortManager.GetPort(), {}, MakePqConfig()) .SetDomainName(DomainName) - .SetFeatureFlags(featureFlags) + .SetFeatureFlags(featureFlags.FeatureFlags) ) , Server(Settings) , Client(Settings) diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp index 70d77a5efe2..9f917c5d1cc 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp @@ -808,8 +808,15 @@ ISubOperation::TPtr RejectOnTablePathChecks(const TOperationId& opId, const TPat if (checks) { if (!tablePath.IsInsideTableIndexPath()) { checks.IsCommonSensePath(); - } else if (!tablePath.Parent().IsTableIndex(NKikimrSchemeOp::EIndexTypeGlobal)) { - return CreateReject(opId, NKikimrScheme::StatusPreconditionFailed, "Cannot add changefeed to index table"); + } else { + if (!tablePath.Parent().IsTableIndex(NKikimrSchemeOp::EIndexTypeGlobal)) { + return CreateReject(opId, NKikimrScheme::StatusPreconditionFailed, + "Cannot add changefeed to index table"); + } + if (!AppData()->FeatureFlags.GetEnableChangefeedsOnIndexTables()) { + return CreateReject(opId, NKikimrScheme::StatusPreconditionFailed, + "Changefeed on index table is not supported yet"); + } } } diff --git a/ydb/core/tx/schemeshard/ut_cdc_stream/ut_cdc_stream.cpp b/ydb/core/tx/schemeshard/ut_cdc_stream/ut_cdc_stream.cpp index 8d2a9cd9250..560b63103c6 100644 --- a/ydb/core/tx/schemeshard/ut_cdc_stream/ut_cdc_stream.cpp +++ b/ydb/core/tx/schemeshard/ut_cdc_stream/ut_cdc_stream.cpp @@ -1200,9 +1200,38 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) { } } + Y_UNIT_TEST(StreamOnIndexTableNegative) { + TTestBasicRuntime runtime; + TTestEnv env(runtime, TTestEnvOptions().EnableChangefeedsOnIndexTables(false)); + ui64 txId = 100; + + TestCreateIndexedTable(runtime, ++txId, "/MyRoot", R"( + TableDescription { + Name: "Table" + Columns { Name: "key" Type: "Uint64" } + Columns { Name: "indexed" Type: "Uint64" } + KeyColumnNames: ["key"] + } + IndexDescription { + Name: "Index" + KeyColumnNames: ["indexed"] + } + )"); + env.TestWaitNotification(runtime, txId); + + TestCreateCdcStream(runtime, ++txId, "/MyRoot/Table/Index", R"( + TableName: "indexImplTable" + StreamDescription { + Name: "Stream" + Mode: ECdcStreamModeKeysOnly + Format: ECdcStreamFormatProto + } + )", {NKikimrScheme::StatusPreconditionFailed}); + } + Y_UNIT_TEST(StreamOnIndexTable) { TTestBasicRuntime runtime; - TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true)); + TTestEnv env(runtime, TTestEnvOptions().EnableChangefeedsOnIndexTables(true)); ui64 txId = 100; TestCreateIndexedTable(runtime, ++txId, "/MyRoot", R"( @@ -1298,7 +1327,7 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) { Y_UNIT_TEST(StreamOnBuildingIndexTable) { TTestBasicRuntime runtime; - TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true)); + TTestEnv env(runtime, TTestEnvOptions().EnableChangefeedsOnIndexTables(true)); ui64 txId = 100; TestCreateTable(runtime, ++txId, "/MyRoot", R"( @@ -1350,7 +1379,7 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) { Y_UNIT_TEST(DropIndexWithStream) { TTestBasicRuntime runtime; - TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true)); + TTestEnv env(runtime, TTestEnvOptions().EnableChangefeedsOnIndexTables(true)); ui64 txId = 100; TestCreateIndexedTable(runtime, ++txId, "/MyRoot", R"( @@ -1393,7 +1422,7 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) { Y_UNIT_TEST(DropTableWithIndexWithStream) { TTestBasicRuntime runtime; - TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true)); + TTestEnv env(runtime, TTestEnvOptions().EnableChangefeedsOnIndexTables(true)); ui64 txId = 100; TestCreateIndexedTable(runtime, ++txId, "/MyRoot", R"( diff --git a/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ut_cdc_stream_reboots.cpp b/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ut_cdc_stream_reboots.cpp index cd6f40640d8..47209679f22 100644 --- a/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ut_cdc_stream_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_cdc_stream_reboots/ut_cdc_stream_reboots.cpp @@ -10,7 +10,9 @@ Y_UNIT_TEST_SUITE(TCdcStreamWithRebootsTests) { template <typename T> void CreateStream(const TMaybe<NKikimrSchemeOp::ECdcStreamState>& state = Nothing(), bool vt = false, bool onIndex = false) { T t; - t.GetTestEnvOptions().EnableChangefeedInitialScan(true); + t.GetTestEnvOptions() + .EnableChangefeedInitialScan(true) + .EnableChangefeedsOnIndexTables(true); t.Run([&](TTestActorRuntime& runtime, bool& activeZone) { { @@ -290,7 +292,9 @@ Y_UNIT_TEST_SUITE(TCdcStreamWithRebootsTests) { template <typename T> void DropStream(const TMaybe<NKikimrSchemeOp::ECdcStreamState>& state = Nothing(), bool onIndex = false) { T t; - t.GetTestEnvOptions().EnableChangefeedInitialScan(true); + t.GetTestEnvOptions() + .EnableChangefeedInitialScan(true) + .EnableChangefeedsOnIndexTables(true); t.Run([&](TTestActorRuntime& runtime, bool& activeZone) { const TString path = !onIndex ? "/MyRoot" : "/MyRoot/Table/Index"; diff --git a/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp b/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp index e4987a33d45..217194a7844 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp @@ -542,6 +542,7 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe app.SetEnableServerlessExclusiveDynamicNodes(opts.EnableServerlessExclusiveDynamicNodes_); app.SetEnableAddColumsWithDefaults(opts.EnableAddColumsWithDefaults_); app.SetEnableReplaceIfExistsForExternalEntities(opts.EnableReplaceIfExistsForExternalEntities_); + app.SetEnableChangefeedsOnIndexTables(opts.EnableChangefeedsOnIndexTables_); app.ColumnShardConfig.SetDisabledOnSchemeShard(false); diff --git a/ydb/core/tx/schemeshard/ut_helpers/test_env.h b/ydb/core/tx/schemeshard/ut_helpers/test_env.h index 36a9d36888c..388b50caa57 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/test_env.h +++ b/ydb/core/tx/schemeshard/ut_helpers/test_env.h @@ -65,6 +65,7 @@ namespace NSchemeShardUT_Private { OPTION(std::optional<bool>, EnableAddColumsWithDefaults, std::nullopt); OPTION(std::optional<bool>, EnableReplaceIfExistsForExternalEntities, std::nullopt); OPTION(std::optional<TString>, GraphBackendType, std::nullopt); + OPTION(std::optional<bool>, EnableChangefeedsOnIndexTables, std::nullopt); #undef OPTION }; |
