Skip to content

Commit c122675

Browse files
authored
Use granular updates for mediator timecast when available (#8090)
1 parent a5de48c commit c122675

19 files changed

+1041
-187
lines changed

ydb/core/base/domain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ namespace NKikimr {
55

66
TDomainsInfo::TDomain::TDomain(const TString &name, ui32 domainUid, ui64 schemeRootId,
77
TVectorUi64 coordinators, TVectorUi64 mediators, TVectorUi64 allocators,
8-
ui64 domainPlanResolution, const TStoragePoolKinds *poolTypes)
8+
ui64 domainPlanResolution, ui32 timecastBucketsPerMediator,
9+
const TStoragePoolKinds *poolTypes)
910
: DomainUid(domainUid)
1011
, SchemeRoot(schemeRootId)
1112
, Name(name)
1213
, Coordinators(std::move(coordinators))
1314
, Mediators(std::move(mediators))
1415
, TxAllocators(std::move(allocators))
1516
, DomainPlanResolution(domainPlanResolution)
17+
, TimecastBucketsPerMediator(timecastBucketsPerMediator)
1618
, StoragePoolTypes(poolTypes ? *poolTypes : TStoragePoolKinds())
1719
{}
1820

ydb/core/base/domain.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,18 @@ struct TDomainsInfo : public TThrRefBase {
6767
const TVector<ui64> Mediators;
6868
const TVector<ui64> TxAllocators;
6969
const ui64 DomainPlanResolution;
70+
const ui32 TimecastBucketsPerMediator;
7071
const TStoragePoolKinds StoragePoolTypes;
7172

72-
static constexpr ui32 TimecastBucketsPerMediator = 2; // <- any sense in making this configurable? may be for debug?..
73+
static constexpr ui64 DefaultPlanResolution = 500;
74+
static constexpr ui32 DefaultTimecastBucketsPerMediator = 2;
7375

7476
private:
7577
//don't reinterpret any data
7678
TDomain(const TString &name, ui32 domainUid, ui64 schemeRootId,
7779
TVectorUi64 coordinators, TVectorUi64 mediators, TVectorUi64 allocators,
78-
ui64 domainPlanResolution, const TStoragePoolKinds *poolTypes);
80+
ui64 domainPlanResolution, ui32 timecastBucketsPerMediator,
81+
const TStoragePoolKinds *poolTypes);
7982

8083
public:
8184
~TDomain();
@@ -84,8 +87,23 @@ struct TDomainsInfo : public TThrRefBase {
8487
static TDomain::TPtr ConstructEmptyDomain(const TString &name, ui32 domainId = 0)
8588
{
8689
const ui64 schemeRoot = 0;
87-
ui64 planResolution = 500;
88-
return new TDomain(name, domainId, schemeRoot, {}, {}, {}, planResolution, nullptr);
90+
return new TDomain(name, domainId, schemeRoot, {}, {}, {},
91+
DefaultPlanResolution, DefaultTimecastBucketsPerMediator, nullptr);
92+
}
93+
94+
template <typename TUidsContainerUi64>
95+
static TDomain::TPtr ConstructDomainWithExplicitTabletIds(const TString &name, ui32 domainUid, ui64 schemeRoot,
96+
ui64 planResolution, ui32 timecastBucketsPerMediator,
97+
const TUidsContainerUi64 &coordinatorUids,
98+
const TUidsContainerUi64 &mediatorUids,
99+
const TUidsContainerUi64 &allocatorUids,
100+
const TStoragePoolKinds &poolTypes)
101+
{
102+
return new TDomain(name, domainUid, schemeRoot,
103+
TVectorUi64(coordinatorUids.begin(), coordinatorUids.end()),
104+
TVectorUi64(mediatorUids.begin(), mediatorUids.end()),
105+
TVectorUi64(allocatorUids.begin(), allocatorUids.end()),
106+
planResolution, timecastBucketsPerMediator, &poolTypes);
89107
}
90108

91109
template <typename TUidsContainerUi64>
@@ -100,7 +118,7 @@ struct TDomainsInfo : public TThrRefBase {
100118
TVectorUi64(coordinatorUids.begin(), coordinatorUids.end()),
101119
TVectorUi64(mediatorUids.begin(), mediatorUids.end()),
102120
TVectorUi64(allocatorUids.begin(), allocatorUids.end()),
103-
planResolution, &poolTypes);
121+
planResolution, DefaultTimecastBucketsPerMediator, &poolTypes);
104122
}
105123

106124
template <typename TUidsContainerUi64>
@@ -114,7 +132,7 @@ struct TDomainsInfo : public TThrRefBase {
114132
TVectorUi64(coordinatorUids.begin(), coordinatorUids.end()),
115133
TVectorUi64(mediatorUids.begin(), mediatorUids.end()),
116134
TVectorUi64(allocatorUids.begin(), allocatorUids.end()),
117-
planResolution, nullptr);
135+
planResolution, DefaultTimecastBucketsPerMediator, nullptr);
118136
}
119137

120138
ui32 DomainRootTag() const {

ydb/core/base/tx_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ NKikimrSubDomains::TProcessingParams NKikimr::ExtractProcessingParams(const NKik
6969
}
7070

7171
NKikimr::TTimeCastBuckets::TTimeCastBuckets()
72-
: TimecastBucketsPerMediator(TDomainsInfo::TDomain::TimecastBucketsPerMediator)
72+
: TimecastBucketsPerMediator(TDomainsInfo::TDomain::DefaultTimecastBucketsPerMediator)
7373
{}
7474

7575
NKikimr::TTimeCastBuckets::TTimeCastBuckets(ui32 timecastBuckets)

ydb/core/persqueue/pq_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class TPersQueue : public NKeyValue::TKeyValueFlat {
424424
void MediatorTimeCastUnregisterTablet(const TActorContext& ctx);
425425
void Handle(TEvMediatorTimecast::TEvRegisterTabletResult::TPtr& ev, const TActorContext& ctx);
426426

427-
TIntrusivePtr<TMediatorTimecastEntry> MediatorTimeCastEntry;
427+
TMediatorTimecastEntry::TCPtr MediatorTimeCastEntry;
428428

429429
void DeleteExpiredTransactions(const TActorContext& ctx);
430430
void Handle(TEvPersQueue::TEvCancelTransactionProposal::TPtr& ev, const TActorContext& ctx);

ydb/core/protos/feature_flags.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ message TFeatureFlags {
153153
optional bool EnableChangefeedsOnIndexTables = 134 [default = false];
154154
optional bool EnableResourcePoolsCounters = 135 [default = false];
155155
optional bool EnableOptionalColumnsInColumnShard = 136 [default = false];
156+
optional bool EnableGranularTimecast = 137 [default = true];
156157
}

ydb/core/protos/tx_mediator_timecast.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ message TEvGranularWatch {
2929

3030
// The list of tablets the client is currently tracking
3131
repeated fixed64 Tablets = 3 [packed = true];
32+
33+
// The maximum LatestStep observed in the past
34+
// Mediator may avoid sending updates with LatestStep less than MinStep
35+
optional uint64 MinStep = 4;
3236
}
3337

3438
// sent from local timecast to mediator to change the list of tablets

ydb/core/testlib/basics/feature_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class TTestFeatureFlagsHolder {
6363
FEATURE_FLAG_SETTER(EnableResourcePools)
6464
FEATURE_FLAG_SETTER(EnableChangefeedsOnIndexTables)
6565
FEATURE_FLAG_SETTER(EnableBackupService)
66+
FEATURE_FLAG_SETTER(EnableGranularTimecast)
6667

6768
#undef FEATURE_FLAG_SETTER
6869
};

ydb/core/testlib/tablet_helpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ namespace NKikimr {
8888
const ui64 tabletId = ev->Get()->TabletId;
8989
auto& entry = Entries[tabletId];
9090
if (!entry) {
91-
entry = new TMediatorTimecastEntry();
91+
entry = new TMediatorTimecastSharedEntry();
9292
}
9393

94-
ctx.Send(ev->Sender, new TEvMediatorTimecast::TEvRegisterTabletResult(tabletId, entry));
94+
ctx.Send(ev->Sender, new TEvMediatorTimecast::TEvRegisterTabletResult(tabletId, new TMediatorTimecastEntry(entry, entry)));
9595
}
9696

9797
private:
98-
THashMap<ui64, TIntrusivePtr<TMediatorTimecastEntry>> Entries;
98+
THashMap<ui64, TIntrusivePtr<TMediatorTimecastSharedEntry>> Entries;
9999
};
100100

101101
void SetupMediatorTimecastProxy(TTestActorRuntime& runtime, ui32 nodeIndex, bool useFake = false)

ydb/core/testlib/test_client.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,12 @@ namespace Tests {
503503
if (!planResolution) {
504504
planResolution = Settings->UseRealThreads ? 7 : 500;
505505
}
506+
ui32 timecastBuckets = Settings->DomainTimecastBuckets;
507+
if (!timecastBuckets) {
508+
timecastBuckets = TDomainsInfo::TDomain::DefaultTimecastBucketsPerMediator;
509+
}
506510
auto domain = TDomainsInfo::TDomain::ConstructDomainWithExplicitTabletIds(Settings->DomainName, domainId, ChangeStateStorage(SchemeRoot, domainId),
507-
planResolution,
511+
planResolution, timecastBuckets,
508512
TVector<ui64>{TDomainsInfo::MakeTxCoordinatorIDFixed(1)},
509513
TVector<ui64>{TDomainsInfo::MakeTxMediatorIDFixed(1)},
510514
TVector<ui64>{TDomainsInfo::MakeTxAllocatorIDFixed(1)},

ydb/core/testlib/test_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ namespace Tests {
145145
NKikimrConfig::TCompactionConfig CompactionConfig;
146146
TMap<ui32, TString> NodeKeys;
147147
ui64 DomainPlanResolution = 0;
148+
ui32 DomainTimecastBuckets = 0;
148149
std::shared_ptr<NKikimr::NMsgBusProxy::IPersQueueGetReadSessionsInfoWorkerFactory> PersQueueGetReadSessionsInfoWorkerFactory;
149150
std::shared_ptr<NKikimr::NHttpProxy::IAuthFactory> DataStreamsAuthFactory;
150151
std::shared_ptr<NKikimr::NPQ::TPersQueueMirrorReaderFactory> PersQueueMirrorReaderFactory = std::make_shared<NKikimr::NPQ::TPersQueueMirrorReaderFactory>();
@@ -193,6 +194,7 @@ namespace Tests {
193194
TServerSettings& SetEnableKqpSpilling(bool value) { EnableKqpSpilling = value; return *this; }
194195
TServerSettings& SetEnableForceFollowers(bool value) { EnableForceFollowers = value; return *this; }
195196
TServerSettings& SetDomainPlanResolution(ui64 resolution) { DomainPlanResolution = resolution; return *this; }
197+
TServerSettings& SetDomainTimecastBuckets(ui32 buckets) { DomainTimecastBuckets = buckets; return *this; }
196198
TServerSettings& SetFeatureFlags(const NKikimrConfig::TFeatureFlags& value) { FeatureFlags = value; return *this; }
197199
TServerSettings& SetCompactionConfig(const NKikimrConfig::TCompactionConfig& value) { CompactionConfig = value; return *this; }
198200
TServerSettings& SetEnableDbCounters(bool value) { FeatureFlags.SetEnableDbCounters(value); return *this; }

0 commit comments

Comments
 (0)