Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ydb/core/testlib/basics/feature_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class TTestFeatureFlagsHolder {
FEATURE_FLAG_SETTER(EnableStreamingQueries)
FEATURE_FLAG_SETTER(EnableSecureScriptExecutions)
FEATURE_FLAG_SETTER(DisableMissingDefaultColumnsInBulkUpsert)
FEATURE_FLAG_SETTER(EnableTopicAutopartitioningForReplication)

#undef FEATURE_FLAG_SETTER
};
Expand Down
13 changes: 7 additions & 6 deletions ydb/core/tx/replication/controller/stream_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,19 @@ IActor* CreateStreamCreator(TReplication* replication, ui64 targetId, const TAct
const auto* target = replication->FindTarget(targetId);
Y_ABORT_UNLESS(target);

const auto& config = replication->GetConfig().GetConsistencySettings();
const auto resolvedTimestamps = config.HasGlobal()
? std::make_optional(TDuration::MilliSeconds(config.GetGlobal().GetCommitIntervalMilliSeconds()))
const auto& config = replication->GetConfig();
const auto& consistency = config.GetConsistencySettings();
const auto resolvedTimestamps = consistency.HasGlobal()
? std::make_optional(TDuration::MilliSeconds(consistency.GetGlobal().GetCommitIntervalMilliSeconds()))
: std::nullopt;
const bool needCreate = !replication->GetConfig().HasTransferSpecific() ||
!replication->GetConfig().GetTransferSpecific().GetTarget().HasConsumerName();
const bool needCreate = !config.HasTransferSpecific() || !config.GetTransferSpecific().GetTarget().HasConsumerName();
const bool supportsTopicAutopartitioning = !consistency.HasGlobal() && AppData()->FeatureFlags.GetEnableTopicAutopartitioningForReplication();

return CreateStreamCreator(ctx.SelfID, replication->GetYdbProxy(),
replication->GetId(), target->GetId(),
target->GetConfig(), target->GetStreamName(), target->GetStreamConsumerName(),
TDuration::Seconds(AppData()->ReplicationConfig.GetRetentionPeriodSeconds()), resolvedTimestamps,
AppData()->FeatureFlags.GetEnableTopicAutopartitioningForReplication(), needCreate);
supportsTopicAutopartitioning, needCreate);
}

IActor* CreateStreamCreator(const TActorId& parent, const TActorId& proxy, ui64 rid, ui64 tid,
Expand Down
45 changes: 45 additions & 0 deletions ydb/core/tx/replication/controller/stream_creator_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,51 @@ Y_UNIT_TEST_SUITE(StreamCreator) {
Y_UNIT_TEST(WithResolvedTimestamps) {
Basic(TDuration::Seconds(10));
}

void TopicAutoPartitioning(bool enabled) {
TEnv env(TFeatureFlags().SetEnableTopicAutopartitioningForCDC(true));
env.GetRuntime().SetLogPriority(NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE);

env.CreateTable("/Root", *MakeTableDescription(TTestTableDescription{
.Name = "Table",
.KeyColumns = {"key"},
.Columns = {
{.Name = "key", .Type = "Uint32"},
{.Name = "value", .Type = "Utf8"},
},
.ReplicationConfig = Nothing(),
}));

env.GetRuntime().Register(CreateStreamCreator(
env.GetSender(), env.GetYdbProxy(), 1 /* rid */, 1 /* tid */,
std::make_shared<TTargetTable::TTableConfig>("/Root/Table", "/Root/Replica"),
"Stream", "replicationConsumer", TDuration::Hours(1), std::nullopt, enabled
));
{
auto ev = env.GetRuntime().GrabEdgeEvent<TEvPrivate::TEvRequestCreateStream>(env.GetSender());
env.GetRuntime().Send(ev->Sender, env.GetSender(), new TEvPrivate::TEvAllowCreateStream());
}
{
auto ev = env.GetRuntime().GrabEdgeEvent<TEvPrivate::TEvCreateStreamResult>(env.GetSender());
UNIT_ASSERT(ev->Get()->IsSuccess());
}

auto desc = env.GetDescription("/Root/Table/Stream/streamImpl");

const auto& pqconfig = desc.GetPathDescription().GetPersQueueGroup().GetPQTabletConfig();
const auto& strategy = pqconfig.GetPartitionStrategy();

if (enabled) {
UNIT_ASSERT_EQUAL(strategy.GetPartitionStrategyType(), NKikimrPQ::TPQTabletConfig::CAN_SPLIT);
} else {
UNIT_ASSERT_EQUAL(strategy.GetPartitionStrategyType(), NKikimrPQ::TPQTabletConfig::DISABLED);
}
}

Y_UNIT_TEST(TopicAutoPartitioning) {
TopicAutoPartitioning(true);
TopicAutoPartitioning(false);
}
}

}
Loading