diff options
author | Evgeniy Ivanov <eivanov89@yandex-team.ru> | 2022-02-10 16:52:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:52:12 +0300 |
commit | a670f41cf5912d624c5429fb11a7762d4f58f1a9 (patch) | |
tree | ab7fbbf3253d4c0e2793218f09378908beb025fb | |
parent | 7d93fa56803c7e4a0364d8b9f6f436447848f5bd (diff) | |
download | ydb-a670f41cf5912d624c5429fb11a7762d4f58f1a9.tar.gz |
Restoring authorship annotation for Evgeniy Ivanov <eivanov89@yandex-team.ru>. Commit 2 of 2.
684 files changed, 17638 insertions, 17638 deletions
diff --git a/ydb/core/actorlib_impl/long_timer.cpp b/ydb/core/actorlib_impl/long_timer.cpp index 27cd12b44a5..e3b139579fb 100644 --- a/ydb/core/actorlib_impl/long_timer.cpp +++ b/ydb/core/actorlib_impl/long_timer.cpp @@ -56,14 +56,14 @@ public: } } - static TActorId Create( - const TActivationContext &ctx, - TDuration delta, - TAutoPtr<IEventHandle> ev, - ui32 poolId, - ISchedulerCookie *cookie, - const TActorId& parentId) - { + static TActorId Create( + const TActivationContext &ctx, + TDuration delta, + TAutoPtr<IEventHandle> ev, + ui32 poolId, + ISchedulerCookie *cookie, + const TActorId& parentId) + { if (delta.Seconds() < ThresholdSec) { // direct scheduling w/o creating actor ctx.ExecutorThread.Schedule(delta, ev, cookie); return TActorId(); @@ -71,39 +71,39 @@ public: TMonotonic now = ctx.Monotonic(); TMonotonic signalTime = now + delta; - ui64 semirandomNumber = parentId.LocalId(); - const TActorId timerActorID = ctx.ExecutorThread.ActorSystem->Register(new TLongTimer(now, signalTime, ev, cookie), TMailboxType::HTSwap, poolId, semirandomNumber, parentId); + ui64 semirandomNumber = parentId.LocalId(); + const TActorId timerActorID = ctx.ExecutorThread.ActorSystem->Register(new TLongTimer(now, signalTime, ev, cookie), TMailboxType::HTSwap, poolId, semirandomNumber, parentId); ctx.ExecutorThread.Schedule(TDuration::Seconds(ThresholdSec), new IEventHandle(timerActorID, timerActorID, new TEvents::TEvWakeup())); return timerActorID; } - - static TActorId Create( - TDuration delta, - TAutoPtr<IEventHandle> ev, - ui32 poolId, - ISchedulerCookie *cookie) - { - if (delta.Seconds() < ThresholdSec) { // direct scheduling w/o creating actor - TActivationContext::Schedule(delta, ev, cookie); - return TActorId(); - } - - TMonotonic now = TActivationContext::Monotonic(); - TMonotonic signalTime = now + delta; - const TActorId timerActorID = TActivationContext::Register(new TLongTimer(now, signalTime, ev, cookie), TActorId(), TMailboxType::HTSwap, poolId); - TActivationContext::Schedule(TDuration::Seconds(ThresholdSec), new IEventHandle(timerActorID, timerActorID, new TEvents::TEvWakeup())); - - return timerActorID; - } + + static TActorId Create( + TDuration delta, + TAutoPtr<IEventHandle> ev, + ui32 poolId, + ISchedulerCookie *cookie) + { + if (delta.Seconds() < ThresholdSec) { // direct scheduling w/o creating actor + TActivationContext::Schedule(delta, ev, cookie); + return TActorId(); + } + + TMonotonic now = TActivationContext::Monotonic(); + TMonotonic signalTime = now + delta; + const TActorId timerActorID = TActivationContext::Register(new TLongTimer(now, signalTime, ev, cookie), TActorId(), TMailboxType::HTSwap, poolId); + TActivationContext::Schedule(TDuration::Seconds(ThresholdSec), new IEventHandle(timerActorID, timerActorID, new TEvents::TEvWakeup())); + + return timerActorID; + } }; TActorId CreateLongTimer(const TActorContext &ctx, TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId, ISchedulerCookie *cookie) { - return TLongTimer::Create(ctx, delta, ev, poolId, cookie, ctx.SelfID); + return TLongTimer::Create(ctx, delta, ev, poolId, cookie, ctx.SelfID); +} + +TActorId CreateLongTimer(TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId, ISchedulerCookie *cookie) { + return TLongTimer::Create(delta, ev, poolId, cookie); } -TActorId CreateLongTimer(TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId, ISchedulerCookie *cookie) { - return TLongTimer::Create(delta, ev, poolId, cookie); } - -} diff --git a/ydb/core/actorlib_impl/long_timer.h b/ydb/core/actorlib_impl/long_timer.h index 213525af914..9b04c301217 100644 --- a/ydb/core/actorlib_impl/long_timer.h +++ b/ydb/core/actorlib_impl/long_timer.h @@ -5,7 +5,7 @@ namespace NActors { TActorId CreateLongTimer(const TActorContext &ctx, TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId = 0, ISchedulerCookie *cookie = nullptr); -// uses TlsActivationContext, note that by default we use current pool -TActorId CreateLongTimer(TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId = Max<ui32>(), ISchedulerCookie *cookie = nullptr); - +// uses TlsActivationContext, note that by default we use current pool +TActorId CreateLongTimer(TDuration delta, TAutoPtr<IEventHandle> ev, ui32 poolId = Max<ui32>(), ISchedulerCookie *cookie = nullptr); + } diff --git a/ydb/core/base/appdata.h b/ydb/core/base/appdata.h index 867a72df10c..c666f7468c0 100644 --- a/ydb/core/base/appdata.h +++ b/ydb/core/base/appdata.h @@ -145,7 +145,7 @@ struct TAppData { NKikimrConfig::THiveConfig HiveConfig; NKikimrConfig::TDataShardConfig DataShardConfig; NKikimrConfig::TMeteringConfig MeteringConfig; - NKikimrConfig::TCompactionConfig CompactionConfig; + NKikimrConfig::TCompactionConfig CompactionConfig; bool EnforceUserTokenRequirement = false; bool AllowHugeKeyValueDeletes = true; // delete when all clients limit deletes per request bool EnableKqpSpilling = false; @@ -154,7 +154,7 @@ struct TAppData { TVector<TString> AdministrationAllowedSIDs; // users/groups which allowed to perform administrative tasks TVector<TString> DefaultUserSIDs; TString AllAuthenticatedUsers; - TResourceProfilesPtr ResourceProfiles; + TResourceProfilesPtr ResourceProfiles; TProgramShouldContinue * const KikimrShouldContinue; bool EnableIntrospection = true; diff --git a/ydb/core/base/blobstorage.h b/ydb/core/base/blobstorage.h index 015ba2163b0..a2faee326e5 100644 --- a/ydb/core/base/blobstorage.h +++ b/ydb/core/base/blobstorage.h @@ -1147,9 +1147,9 @@ struct TEvBlobStorage { TString ErrorReason; mutable NLWTrace::TOrbit Orbit; - // to measure blobstorage->client hop - TInstant Sent; - + // to measure blobstorage->client hop + TInstant Sent; + TEvGetResult(NKikimrProto::EReplyStatus status, ui32 sz, ui32 groupId) : Status(status) , ResponseSz(sz) diff --git a/ydb/core/base/counters.cpp b/ydb/core/base/counters.cpp index 05928d4ebbf..b192fa36a1d 100644 --- a/ydb/core/base/counters.cpp +++ b/ydb/core/base/counters.cpp @@ -19,7 +19,7 @@ static const THashSet<TString> DATABASE_SERVICES TString("kqp"), TString("processing"), TString("proxy"), - TString("followers"), + TString("followers"), TString("sqs"), TString("storage_pool_stat"), TString("tablets"), diff --git a/ydb/core/base/hive.h b/ydb/core/base/hive.h index 84e798de7bb..7464c76699d 100644 --- a/ydb/core/base/hive.h +++ b/ydb/core/base/hive.h @@ -543,12 +543,12 @@ namespace NKikimr { struct TEvRequestHiveInfo : TEventPB<TEvRequestHiveInfo, NKikimrHive::TEvRequestHiveInfo, EvRequestHiveInfo> { TEvRequestHiveInfo() = default; - TEvRequestHiveInfo(bool returnFollowers) { - Record.SetReturnFollowers(returnFollowers); + TEvRequestHiveInfo(bool returnFollowers) { + Record.SetReturnFollowers(returnFollowers); } - TEvRequestHiveInfo(ui64 tabletId, bool returnFollowers) { + TEvRequestHiveInfo(ui64 tabletId, bool returnFollowers) { Record.SetTabletID(tabletId); - Record.SetReturnFollowers(returnFollowers); + Record.SetReturnFollowers(returnFollowers); } }; diff --git a/ydb/core/base/resource_profile.h b/ydb/core/base/resource_profile.h index 4f1cf7c4b87..113b1dd65e3 100644 --- a/ydb/core/base/resource_profile.h +++ b/ydb/core/base/resource_profile.h @@ -68,7 +68,7 @@ public: } }; -using TResourceProfilesPtr = TIntrusivePtr<TResourceProfiles>; - - +using TResourceProfilesPtr = TIntrusivePtr<TResourceProfiles>; + + } // namespace NKikimr diff --git a/ydb/core/base/shared_quota.h b/ydb/core/base/shared_quota.h index 9fc674b0c25..a565954bb54 100644 --- a/ydb/core/base/shared_quota.h +++ b/ydb/core/base/shared_quota.h @@ -72,6 +72,6 @@ private: NMonitoring::TDynamicCounters::TCounterPtr SizeCounter; }; -using TSharedQuotaPtr = TIntrusivePtr<TSharedQuota>; - +using TSharedQuotaPtr = TIntrusivePtr<TSharedQuota>; + } // namespace NKikimr diff --git a/ydb/core/base/statestorage.h b/ydb/core/base/statestorage.h index 24131bc208a..9b3e3b6b1b7 100644 --- a/ydb/core/base/statestorage.h +++ b/ydb/core/base/statestorage.h @@ -38,11 +38,11 @@ struct TEvStateStorage { EvReplicaLookup = EvLock + 2 * 512, EvReplicaUpdate, EvReplicaLock, - EvReplicaLeaderDemoted, + EvReplicaLeaderDemoted, EvReplicaDumpRequest, EvReplicaDump, - EvReplicaRegFollower, - EvReplicaUnregFollower, + EvReplicaRegFollower, + EvReplicaUnregFollower, EvReplicaDelete, EvReplicaCleanup, @@ -113,19 +113,19 @@ struct TEvStateStorage { struct TEvUpdate : public TEventLocal<TEvUpdate, EvUpdate> { const ui64 TabletID; const ui64 Cookie; - const TActorId ProposedLeader; - const TActorId ProposedLeaderTablet; + const TActorId ProposedLeader; + const TActorId ProposedLeaderTablet; const ui32 ProposedGeneration; const ui32 ProposedStep; const ui32 SignatureSz; const TArrayHolder<ui64> Signature; const TProxyOptions ProxyOptions; - TEvUpdate(ui64 tabletId, ui64 cookie, const TActorId &leader, const TActorId &leaderTablet, ui32 gen, ui32 step, const ui64 *sig, ui32 sigsz, const TProxyOptions &proxyOptions = TProxyOptions()) + TEvUpdate(ui64 tabletId, ui64 cookie, const TActorId &leader, const TActorId &leaderTablet, ui32 gen, ui32 step, const ui64 *sig, ui32 sigsz, const TProxyOptions &proxyOptions = TProxyOptions()) : TabletID(tabletId) , Cookie(cookie) - , ProposedLeader(leader) - , ProposedLeaderTablet(leaderTablet) + , ProposedLeader(leader) + , ProposedLeaderTablet(leaderTablet) , ProposedGeneration(gen) , ProposedStep(step) , SignatureSz(sigsz) @@ -139,8 +139,8 @@ struct TEvStateStorage { TStringStream str; str << "{EvUpdate TabletID: " << TabletID; str << " Cookie: " << Cookie; - str << " ProposedLeader: " << ProposedLeader.ToString(); - str << " ProposedLeaderTablet: " << ProposedLeaderTablet.ToString(); + str << " ProposedLeader: " << ProposedLeader.ToString(); + str << " ProposedLeaderTablet: " << ProposedLeaderTablet.ToString(); str << " ProposedGeneration: " << ProposedGeneration; str << " ProposedStep: " << ProposedStep; str << " SignatureSz: " << SignatureSz; @@ -177,11 +177,11 @@ struct TEvStateStorage { struct TEvCleanup : TEventLocal<TEvCleanup, EvCleanup> { const ui64 TabletID; - const TActorId ProposedLeader; + const TActorId ProposedLeader; - TEvCleanup(ui64 tabletId, TActorId proposedLeader) + TEvCleanup(ui64 tabletId, TActorId proposedLeader) : TabletID(tabletId) - , ProposedLeader(proposedLeader) + , ProposedLeader(proposedLeader) {} }; @@ -206,16 +206,16 @@ struct TEvStateStorage { struct TEvLock : public TEventLocal<TEvLock, EvLock> { const ui64 TabletID; const ui64 Cookie; - const TActorId ProposedLeader; + const TActorId ProposedLeader; const ui32 ProposedGeneration; const ui32 SignatureSz; const TArrayHolder<ui64> Signature; const TProxyOptions ProxyOptions; - TEvLock(ui64 tabletId, ui64 cookie, const TActorId &leader, ui32 gen, const ui64 *sig, ui32 sigsz, const TProxyOptions &proxyOptions = TProxyOptions()) + TEvLock(ui64 tabletId, ui64 cookie, const TActorId &leader, ui32 gen, const ui64 *sig, ui32 sigsz, const TProxyOptions &proxyOptions = TProxyOptions()) : TabletID(tabletId) , Cookie(cookie) - , ProposedLeader(leader) + , ProposedLeader(leader) , ProposedGeneration(gen) , SignatureSz(sigsz) , Signature(new ui64[sigsz]) @@ -228,7 +228,7 @@ struct TEvStateStorage { TStringStream str; str << "{EvLock TabletID: " << TabletID; str << " Cookie: " << Cookie; - str << " ProposedLeader: " << ProposedLeader.ToString(); + str << " ProposedLeader: " << ProposedLeader.ToString(); str << " ProposedGeneration: " << ProposedGeneration; str << " SignatureSz: " << SignatureSz; if (SignatureSz) { @@ -257,29 +257,29 @@ struct TEvStateStorage { const NKikimrProto::EReplyStatus Status; const ui64 TabletID; const ui64 Cookie; - const TActorId CurrentLeader; - const TActorId CurrentLeaderTablet; + const TActorId CurrentLeader; + const TActorId CurrentLeaderTablet; const ui32 CurrentGeneration; const ui32 CurrentStep; const bool Locked; const ui64 LockedFor; const ui32 SignatureSz; TArrayHolder<ui64> Signature; - TVector<std::pair<TActorId, TActorId>> Followers; + TVector<std::pair<TActorId, TActorId>> Followers; - TEvInfo(NKikimrProto::EReplyStatus status, ui64 tabletId, ui64 cookie, const TActorId &leader, const TActorId &leaderTablet, ui32 gen, ui32 step, bool locked, ui64 lockedFor, const ui64 *sig, ui32 sigsz, const TMap<TActorId, TActorId> &followers) + TEvInfo(NKikimrProto::EReplyStatus status, ui64 tabletId, ui64 cookie, const TActorId &leader, const TActorId &leaderTablet, ui32 gen, ui32 step, bool locked, ui64 lockedFor, const ui64 *sig, ui32 sigsz, const TMap<TActorId, TActorId> &followers) : Status(status) , TabletID(tabletId) , Cookie(cookie) - , CurrentLeader(leader) - , CurrentLeaderTablet(leaderTablet) + , CurrentLeader(leader) + , CurrentLeaderTablet(leaderTablet) , CurrentGeneration(gen) , CurrentStep(step) , Locked(locked) , LockedFor(lockedFor) , SignatureSz(sigsz) , Signature(new ui64[sigsz]) - , Followers(followers.begin(), followers.end()) + , Followers(followers.begin(), followers.end()) { MakeFilteredSignatureCopy(sig, sigsz, Signature.Get()); } @@ -289,8 +289,8 @@ struct TEvStateStorage { str << "{EvInfo Status: " << (ui32)Status; str << " TabletID: " << TabletID; str << " Cookie: " << Cookie; - str << " CurrentLeader: " << CurrentLeader.ToString(); - str << " CurrentLeaderTablet: " << CurrentLeaderTablet.ToString(); + str << " CurrentLeader: " << CurrentLeader.ToString(); + str << " CurrentLeaderTablet: " << CurrentLeaderTablet.ToString(); str << " CurrentGeneration: " << CurrentGeneration; str << " CurrentStep: " << CurrentStep; str << " Locked: " << (Locked ? "true" : "false"); @@ -303,10 +303,10 @@ struct TEvStateStorage { } str << "}"; } - if (!Followers.empty()) { - str << " Followers: ["; - for (auto it = Followers.begin(); it != Followers.end(); ++it) { - if (it != Followers.begin()) { + if (!Followers.empty()) { + str << " Followers: ["; + for (auto it = Followers.begin(); it != Followers.end(); ++it) { + if (it != Followers.begin()) { str << ','; } str << '{' << it->first.ToString() << ',' << it->second.ToString() << '}'; @@ -347,9 +347,9 @@ struct TEvStateStorage { } }; - struct TEvReplicaLeaderDemoted : public TEventPB<TEvReplicaLeaderDemoted, NKikimrStateStorage::TEvReplicaLeaderDemoted, EvReplicaLeaderDemoted> { - TEvReplicaLeaderDemoted() {} - TEvReplicaLeaderDemoted(ui64 tabletId, ui64 signature) + struct TEvReplicaLeaderDemoted : public TEventPB<TEvReplicaLeaderDemoted, NKikimrStateStorage::TEvReplicaLeaderDemoted, EvReplicaLeaderDemoted> { + TEvReplicaLeaderDemoted() {} + TEvReplicaLeaderDemoted(ui64 tabletId, ui64 signature) { Record.SetTabletID(tabletId); Record.SetSignature(signature); @@ -396,27 +396,27 @@ struct TEvStateStorage { TVector<std::pair<TActorId, TAutoPtr<TEvReplicaDump>>> ReplicasDumps; }; - struct TEvReplicaRegFollower : public TEventPB<TEvReplicaRegFollower, NKikimrStateStorage::TEvRegisterFollower, EvReplicaRegFollower> { - TEvReplicaRegFollower() + struct TEvReplicaRegFollower : public TEventPB<TEvReplicaRegFollower, NKikimrStateStorage::TEvRegisterFollower, EvReplicaRegFollower> { + TEvReplicaRegFollower() {} - TEvReplicaRegFollower(ui64 tabletId, TActorId follower, TActorId tablet, bool isCandidate) + TEvReplicaRegFollower(ui64 tabletId, TActorId follower, TActorId tablet, bool isCandidate) { Record.SetTabletID(tabletId); - ActorIdToProto(follower, Record.MutableFollower()); - ActorIdToProto(tablet, Record.MutableFollowerTablet()); + ActorIdToProto(follower, Record.MutableFollower()); + ActorIdToProto(tablet, Record.MutableFollowerTablet()); Record.SetCandidate(isCandidate); } }; - struct TEvReplicaUnregFollower : public TEventPB<TEvReplicaUnregFollower, NKikimrStateStorage::TEvUnregisterFollower, EvReplicaUnregFollower> { - TEvReplicaUnregFollower() + struct TEvReplicaUnregFollower : public TEventPB<TEvReplicaUnregFollower, NKikimrStateStorage::TEvUnregisterFollower, EvReplicaUnregFollower> { + TEvReplicaUnregFollower() {} - TEvReplicaUnregFollower(ui64 tabletId, const TActorId &follower) + TEvReplicaUnregFollower(ui64 tabletId, const TActorId &follower) { Record.SetTabletID(tabletId); - ActorIdToProto(follower, Record.MutableFollower()); + ActorIdToProto(follower, Record.MutableFollower()); } }; @@ -518,8 +518,8 @@ IActor* CreateStateStorageProxy(const TIntrusivePtr<TStateStorageInfo> &info, co IActor* CreateStateStorageProxyStub(); IActor* CreateStateStorageReplica(const TIntrusivePtr<TStateStorageInfo> &info, ui32 replicaIndex); IActor* CreateStateStorageMonitoringActor(ui64 targetTablet, const TActorId &sender, const TString &query); -IActor* CreateStateStorageTabletGuardian(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation); -IActor* CreateStateStorageFollowerGuardian(ui64 tabletId, const TActorId &follower); // created as followerCandidate +IActor* CreateStateStorageTabletGuardian(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation); +IActor* CreateStateStorageFollowerGuardian(ui64 tabletId, const TActorId &follower); // created as followerCandidate IActor* CreateStateStorageBoardReplica(const TIntrusivePtr<TStateStorageInfo> &, ui32); IActor* CreateSchemeBoardReplica(const TIntrusivePtr<TStateStorageInfo>&, ui32); IActor* CreateBoardLookupActor(const TString &path, const TActorId &owner, ui32 groupId, EBoardLookupMode mode, bool sub, bool useNodeSubscriptions); diff --git a/ydb/core/base/statestorage_event_filter.cpp b/ydb/core/base/statestorage_event_filter.cpp index e2737ea327b..75d772e3a11 100644 --- a/ydb/core/base/statestorage_event_filter.cpp +++ b/ydb/core/base/statestorage_event_filter.cpp @@ -8,8 +8,8 @@ void RegisterStateStorageEventScopes(const std::shared_ptr<TEventFilter>& filter TEvStateStorage::EvReplicaUpdate, TEvStateStorage::EvReplicaLock, TEvStateStorage::EvReplicaDumpRequest, - TEvStateStorage::EvReplicaRegFollower, - TEvStateStorage::EvReplicaUnregFollower, + TEvStateStorage::EvReplicaRegFollower, + TEvStateStorage::EvReplicaUnregFollower, TEvStateStorage::EvReplicaDelete, TEvStateStorage::EvReplicaCleanup, @@ -19,7 +19,7 @@ void RegisterStateStorageEventScopes(const std::shared_ptr<TEventFilter>& filter }; static const ui32 eventsFromSystemToPeer[] = { - TEvStateStorage::EvReplicaLeaderDemoted, + TEvStateStorage::EvReplicaLeaderDemoted, TEvStateStorage::EvReplicaDump, TEvStateStorage::EvReplicaInfo, diff --git a/ydb/core/base/statestorage_guardian.cpp b/ydb/core/base/statestorage_guardian.cpp index d6f2f4a3d63..f1df97896b5 100644 --- a/ydb/core/base/statestorage_guardian.cpp +++ b/ydb/core/base/statestorage_guardian.cpp @@ -18,11 +18,11 @@ namespace NKikimr { namespace NStateStorageGuardian { struct TGuardedInfo; -struct TFollowerInfo; +struct TFollowerInfo; struct TEvPrivate { enum EEv { - EvRefreshFollowerState = EventSpaceBegin(TKikimrEvents::ES_PRIVATE), + EvRefreshFollowerState = EventSpaceBegin(TKikimrEvents::ES_PRIVATE), EvEnd }; @@ -30,38 +30,38 @@ struct TEvPrivate { static_assert(EvEnd < EventSpaceEnd(TKikimrEvents::ES_PRIVATE), "expect EvEnd < EventSpaceEnd(TKikimrEvents::ES_PRIVATE)"); - struct TEvRefreshFollowerState : public TEventLocal<TEvRefreshFollowerState, EvRefreshFollowerState> { - TIntrusiveConstPtr<TFollowerInfo> FollowerInfo; + struct TEvRefreshFollowerState : public TEventLocal<TEvRefreshFollowerState, EvRefreshFollowerState> { + TIntrusiveConstPtr<TFollowerInfo> FollowerInfo; - TEvRefreshFollowerState(const TIntrusivePtr<TFollowerInfo> &info) - : FollowerInfo(info) + TEvRefreshFollowerState(const TIntrusivePtr<TFollowerInfo> &info) + : FollowerInfo(info) {} }; }; struct TGuardedInfo : public TAtomicRefCount<TGuardedInfo> { const ui64 TabletID; - const TActorId Leader; - const TActorId TabletLeader; + const TActorId Leader; + const TActorId TabletLeader; const ui32 Generation; - TGuardedInfo(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation) + TGuardedInfo(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation) : TabletID(tabletId) - , Leader(leader) - , TabletLeader(tabletLeader) + , Leader(leader) + , TabletLeader(tabletLeader) , Generation(generation) {} }; -struct TFollowerInfo : public TAtomicRefCount<TGuardedInfo> { +struct TFollowerInfo : public TAtomicRefCount<TGuardedInfo> { const ui64 TabletID; - const TActorId Follower; + const TActorId Follower; const TActorId Tablet; const bool IsCandidate; - TFollowerInfo(ui64 tabletId, TActorId follower, TActorId tablet, bool isCandidate) + TFollowerInfo(ui64 tabletId, TActorId follower, TActorId tablet, bool isCandidate) : TabletID(tabletId) - , Follower(follower) + , Follower(follower) , Tablet(tablet) , IsCandidate(isCandidate) {} @@ -105,8 +105,8 @@ class TReplicaGuardian : public TActorBootstrapped<TReplicaGuardian> { void UpdateInfo() { TAutoPtr<TEvStateStorage::TEvReplicaUpdate> req(new TEvStateStorage::TEvReplicaUpdate()); req->Record.SetTabletID(Info->TabletID); - ActorIdToProto(Info->Leader, req->Record.MutableProposedLeader()); - ActorIdToProto(Info->TabletLeader, req->Record.MutableProposedLeaderTablet()); + ActorIdToProto(Info->Leader, req->Record.MutableProposedLeader()); + ActorIdToProto(Info->TabletLeader, req->Record.MutableProposedLeaderTablet()); req->Record.SetProposedGeneration(Info->Generation); req->Record.SetProposedStep(0); req->Record.SetSignature(Signature); @@ -133,7 +133,7 @@ class TReplicaGuardian : public TActorBootstrapped<TReplicaGuardian> { } void Demoted() { - Send(Info->Leader, new TEvTablet::TEvDemoted(false)); + Send(Info->Leader, new TEvTablet::TEvDemoted(false)); return PassAway(); } @@ -150,11 +150,11 @@ class TReplicaGuardian : public TActorBootstrapped<TReplicaGuardian> { if (gen > Info->Generation) { return Demoted(); } else if (gen == Info->Generation) { - const TActorId leader = ActorIdFromProto(record.GetCurrentLeader()); - const TActorId tabletLeader = ActorIdFromProto(record.GetCurrentLeaderTablet()); - if (!leader || leader == Info->Leader && !tabletLeader) { + const TActorId leader = ActorIdFromProto(record.GetCurrentLeader()); + const TActorId tabletLeader = ActorIdFromProto(record.GetCurrentLeaderTablet()); + if (!leader || leader == Info->Leader && !tabletLeader) { return UpdateInfo(); - } else if (leader != Info->Leader || tabletLeader != Info->TabletLeader) { + } else if (leader != Info->Leader || tabletLeader != Info->TabletLeader) { return Demoted(); // hack around cluster restarts } else { Become(&TThis::StateCalm); @@ -228,18 +228,18 @@ public: } }; -class TFollowerGuardian : public TActorBootstrapped<TFollowerGuardian> { - TIntrusiveConstPtr<TFollowerInfo> Info; +class TFollowerGuardian : public TActorBootstrapped<TFollowerGuardian> { + TIntrusiveConstPtr<TFollowerInfo> Info; const TActorId Replica; const TActorId Guard; TInstant DowntimeFrom; - void RefreshInfo(TEvPrivate::TEvRefreshFollowerState::TPtr &ev) { - Info = ev->Get()->FollowerInfo; + void RefreshInfo(TEvPrivate::TEvRefreshFollowerState::TPtr &ev) { + Info = ev->Get()->FollowerInfo; } - void UpdateInfo(TEvPrivate::TEvRefreshFollowerState::TPtr &ev) { + void UpdateInfo(TEvPrivate::TEvRefreshFollowerState::TPtr &ev) { RefreshInfo(ev); UpdateInfo(); } @@ -257,7 +257,7 @@ class TFollowerGuardian : public TActorBootstrapped<TFollowerGuardian> { void MakeRequest() { Send( Replica, - new TEvStateStorage::TEvReplicaRegFollower(Info->TabletID, Info->Follower, Info->Tablet, Info->IsCandidate), + new TEvStateStorage::TEvReplicaRegFollower(Info->TabletID, Info->Follower, Info->Tablet, Info->IsCandidate), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); Become(&TThis::StateCalm); } @@ -274,7 +274,7 @@ class TFollowerGuardian : public TActorBootstrapped<TFollowerGuardian> { } void PassAway() override { - Send(Replica, new TEvStateStorage::TEvReplicaUnregFollower(Info->TabletID, Info->Follower)); + Send(Replica, new TEvStateStorage::TEvReplicaUnregFollower(Info->TabletID, Info->Follower)); if (Replica.NodeId() != SelfId().NodeId()) Send(TActivationContext::InterconnectProxy(Replica.NodeId()), new TEvents::TEvUnsubscribe()); @@ -299,7 +299,7 @@ public: return NKikimrServices::TActivity::SS_REPLICA_GUARDIAN; } - TFollowerGuardian(TFollowerInfo *info, const TActorId replica, const TActorId guard) + TFollowerGuardian(TFollowerInfo *info, const TActorId replica, const TActorId guard) : Info(info) , Replica(replica) , Guard(guard) @@ -312,7 +312,7 @@ public: STATEFN(StateCalm) { switch (ev->GetTypeRewrite()) { - hFunc(TEvPrivate::TEvRefreshFollowerState, UpdateInfo); + hFunc(TEvPrivate::TEvRefreshFollowerState, UpdateInfo); cFunc(TEvStateStorage::TEvReplicaProbeConnected::EventType, MakeRequest); cFunc(TEvStateStorage::TEvReplicaProbeDisconnected::EventType, Gone); cFunc(TEvents::TEvUndelivered::EventType, SomeSleep); @@ -325,7 +325,7 @@ public: STATEFN(StateSleep) { switch (ev->GetTypeRewrite()) { - hFunc(TEvPrivate::TEvRefreshFollowerState, RefreshInfo); + hFunc(TEvPrivate::TEvRefreshFollowerState, RefreshInfo); cFunc(TEvents::TEvPoisonPill::EventType, PassAway); cFunc(TEvents::TEvWakeup::EventType, UpdateInfo); @@ -337,15 +337,15 @@ public: class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { TIntrusivePtr<TGuardedInfo> Info; - TIntrusivePtr<TFollowerInfo> FollowerInfo; + TIntrusivePtr<TFollowerInfo> FollowerInfo; TVector<std::pair<TActorId, TActorId>> ReplicaGuardians; // replica -> guardian, position dependant so vector ui32 ReplicasOnlineThreshold; - THolder<TFollowerTracker> FollowerTracker; + THolder<TFollowerTracker> FollowerTracker; TActorId Launcher() const { - return Info ? Info->Leader : FollowerInfo->Follower; + return Info ? Info->Leader : FollowerInfo->Follower; } void HandlePoison() { @@ -383,7 +383,7 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { if (Info) updatedReplicaGuardians.emplace_back(replica, RegisterWithSameMailbox(new TReplicaGuardian(Info.Get(), replica, SelfId()))); else - updatedReplicaGuardians.emplace_back(replica, RegisterWithSameMailbox(new TFollowerGuardian(FollowerInfo.Get(), replica, SelfId()))); + updatedReplicaGuardians.emplace_back(replica, RegisterWithSameMailbox(new TFollowerGuardian(FollowerInfo.Get(), replica, SelfId()))); } } @@ -395,8 +395,8 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { ReplicaGuardians.swap(updatedReplicaGuardians); ReplicasOnlineThreshold = (ReplicaGuardians.size() == 1) ? 0 : 1; - if (!FollowerTracker || !inspectCurrent) // would notify on first change - FollowerTracker.Reset(new TFollowerTracker(replicaSz)); + if (!FollowerTracker || !inspectCurrent) // would notify on first change + FollowerTracker.Reset(new TFollowerTracker(replicaSz)); Become(&TThis::StateCalm); } @@ -431,7 +431,7 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { } void SendResolveRequest(TDuration delay) { - const ui64 tabletId = Info ? Info->TabletID : FollowerInfo->TabletID; + const ui64 tabletId = Info ? Info->TabletID : FollowerInfo->TabletID; const ui64 stateStorageGroup = StateStorageGroupFromTabletID(tabletId); const TActorId proxyActorID = MakeStateStorageProxyID(stateStorageGroup); @@ -460,7 +460,7 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { } void Handle(TEvStateStorage::TEvReplicaInfo::TPtr &ev) { - Y_VERIFY(FollowerTracker); + Y_VERIFY(FollowerTracker); const NKikimrStateStorage::TEvInfo &record = ev->Get()->Record; const TActorId guardian = ev->Sender; @@ -469,18 +469,18 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { continue; TVector<TActorId> reported; - reported.reserve(record.FollowerSize() + record.FollowerCandidatesSize()); - for (const auto &x : record.GetFollower()) { + reported.reserve(record.FollowerSize() + record.FollowerCandidatesSize()); + for (const auto &x : record.GetFollower()) { reported.emplace_back(ActorIdFromProto(x)); } - for (const auto &x : record.GetFollowerCandidates()) { + for (const auto &x : record.GetFollowerCandidates()) { reported.emplace_back(ActorIdFromProto(x)); } Sort(reported); - if (FollowerTracker->Merge(idx, reported)) { - const auto &merged = FollowerTracker->GetMerged(); + if (FollowerTracker->Merge(idx, reported)) { + const auto &merged = FollowerTracker->GetMerged(); // reuse reported so in many cases no allocation happens reported.clear(); @@ -490,24 +490,24 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { reported.emplace_back(xpair.first); } - Send(Launcher(), new TEvTablet::TEvFollowerListRefresh(std::move(reported))); + Send(Launcher(), new TEvTablet::TEvFollowerListRefresh(std::move(reported))); } break; } } - bool RefreshFollowerInfo(TEvTablet::TEvFollowerUpdateState::TPtr &ev) { + bool RefreshFollowerInfo(TEvTablet::TEvFollowerUpdateState::TPtr &ev) { const auto *msg = ev->Get(); - const ui64 tabletId = FollowerInfo->TabletID; + const ui64 tabletId = FollowerInfo->TabletID; - Y_VERIFY(msg->FollowerActor == FollowerInfo->Follower); + Y_VERIFY(msg->FollowerActor == FollowerInfo->Follower); - const bool hasChanges = msg->TabletActor != FollowerInfo->Tablet || msg->IsCandidate != FollowerInfo->IsCandidate; + const bool hasChanges = msg->TabletActor != FollowerInfo->Tablet || msg->IsCandidate != FollowerInfo->IsCandidate; if (hasChanges) { - FollowerInfo = new TFollowerInfo( + FollowerInfo = new TFollowerInfo( tabletId, - msg->FollowerActor, + msg->FollowerActor, msg->TabletActor, msg->IsCandidate ); @@ -516,13 +516,13 @@ class TTabletGuardian : public TActorBootstrapped<TTabletGuardian> { return hasChanges; } - void UpdateFollowerInfo(TEvTablet::TEvFollowerUpdateState::TPtr &ev) { - if (!RefreshFollowerInfo(ev)) + void UpdateFollowerInfo(TEvTablet::TEvFollowerUpdateState::TPtr &ev) { + if (!RefreshFollowerInfo(ev)) return; for (auto &xpair : ReplicaGuardians) { const TActorId guardian = xpair.second; - Send(guardian, new TEvPrivate::TEvRefreshFollowerState(FollowerInfo)); + Send(guardian, new TEvPrivate::TEvRefreshFollowerState(FollowerInfo)); } } public: @@ -535,8 +535,8 @@ public: , ReplicasOnlineThreshold(0) {} - TTabletGuardian(TFollowerInfo *info) - : FollowerInfo(info) + TTabletGuardian(TFollowerInfo *info) + : FollowerInfo(info) , ReplicasOnlineThreshold(0) {} @@ -546,7 +546,7 @@ public: STATEFN(StateResolve) { switch (ev->GetTypeRewrite()) { - hFunc(TEvTablet::TEvFollowerUpdateState, UpdateFollowerInfo); + hFunc(TEvTablet::TEvFollowerUpdateState, UpdateFollowerInfo); hFunc(TEvStateStorage::TEvResolveReplicasList, Handle); hFunc(TEvStateStorage::TEvReplicaInfo, Handle); hFunc(TEvents::TEvUndelivered, Handle); @@ -558,7 +558,7 @@ public: STATEFN(StateCalm) { switch (ev->GetTypeRewrite()) { - hFunc(TEvTablet::TEvFollowerUpdateState, UpdateFollowerInfo); + hFunc(TEvTablet::TEvFollowerUpdateState, UpdateFollowerInfo); hFunc(TEvStateStorage::TEvResolveReplicasList, Handle); hFunc(TEvStateStorage::TEvReplicaInfo, Handle); hFunc(TEvents::TEvUndelivered, Handle); @@ -571,14 +571,14 @@ public: } -IActor* CreateStateStorageTabletGuardian(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation) { - TIntrusivePtr<NStateStorageGuardian::TGuardedInfo> info = new NStateStorageGuardian::TGuardedInfo(tabletId, leader, tabletLeader, generation); +IActor* CreateStateStorageTabletGuardian(ui64 tabletId, const TActorId &leader, const TActorId &tabletLeader, ui32 generation) { + TIntrusivePtr<NStateStorageGuardian::TGuardedInfo> info = new NStateStorageGuardian::TGuardedInfo(tabletId, leader, tabletLeader, generation); return new NStateStorageGuardian::TTabletGuardian(info.Get()); } -IActor* CreateStateStorageFollowerGuardian(ui64 tabletId, const TActorId &follower) { - TIntrusivePtr<NStateStorageGuardian::TFollowerInfo> followerInfo = new NStateStorageGuardian::TFollowerInfo(tabletId, follower, TActorId(), true); - return new NStateStorageGuardian::TTabletGuardian(followerInfo.Get()); +IActor* CreateStateStorageFollowerGuardian(ui64 tabletId, const TActorId &follower) { + TIntrusivePtr<NStateStorageGuardian::TFollowerInfo> followerInfo = new NStateStorageGuardian::TFollowerInfo(tabletId, follower, TActorId(), true); + return new NStateStorageGuardian::TTabletGuardian(followerInfo.Get()); } } diff --git a/ydb/core/base/statestorage_guardian_impl.h b/ydb/core/base/statestorage_guardian_impl.h index 92b5dc9426a..0bdda91eadb 100644 --- a/ydb/core/base/statestorage_guardian_impl.h +++ b/ydb/core/base/statestorage_guardian_impl.h @@ -6,9 +6,9 @@ namespace NKikimr { namespace NStateStorageGuardian { -struct TFollowerTracker { - TVector<TVector<TActorId>> Reported; // reported followers by replica index - TMap<TActorId, ui32> Merged; // follower -> referenced by +struct TFollowerTracker { + TVector<TVector<TActorId>> Reported; // reported followers by replica index + TMap<TActorId, ui32> Merged; // follower -> referenced by bool AddMerged(TActorId x) { auto itPair = Merged.emplace(x, 1); @@ -22,7 +22,7 @@ struct TFollowerTracker { bool DelMerged(TActorId x) { auto it = Merged.find(x); - Y_VERIFY(it != Merged.end(), "follower tracker consistency broken"); + Y_VERIFY(it != Merged.end(), "follower tracker consistency broken"); if (it->second == 1) { Merged.erase(it); @@ -33,7 +33,7 @@ struct TFollowerTracker { } } public: - TFollowerTracker(ui32 replicas) + TFollowerTracker(ui32 replicas) : Reported(replicas) {} diff --git a/ydb/core/base/statestorage_guardian_impl_ut.cpp b/ydb/core/base/statestorage_guardian_impl_ut.cpp index 5db431260c9..00638ab480c 100644 --- a/ydb/core/base/statestorage_guardian_impl_ut.cpp +++ b/ydb/core/base/statestorage_guardian_impl_ut.cpp @@ -7,25 +7,25 @@ namespace NKikimr { namespace NStateStorageGuardian { Y_UNIT_TEST_SUITE(TGuardianImpl) { - Y_UNIT_TEST(FollowerTracker) { - TFollowerTracker tracker(2); + Y_UNIT_TEST(FollowerTracker) { + TFollowerTracker tracker(2); { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == true); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; - UNIT_ASSERT(tracker.Merge(1, followers) == false); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; + UNIT_ASSERT(tracker.Merge(1, followers) == false); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == false); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == false); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1) }; - UNIT_ASSERT(tracker.Merge(1, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1) }; + UNIT_ASSERT(tracker.Merge(1, followers) == true); } auto merged = tracker.GetMerged(); @@ -35,26 +35,26 @@ namespace NKikimr { UNIT_ASSERT(merged.FindPtr(TActorId(1, 1, 10, 1)) == nullptr); } - Y_UNIT_TEST(FollowerTrackerDuplicates) { - TFollowerTracker tracker(1); + Y_UNIT_TEST(FollowerTrackerDuplicates) { + TFollowerTracker tracker(1); { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1), TActorId(1, 1, 10, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == true); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 10, 1), TActorId(1, 1, 10, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 10, 1), TActorId(1, 1, 10, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == true); UNIT_ASSERT(tracker.GetMerged().size() == 2); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 11, 1), TActorId(1, 1, 11, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 11, 1), TActorId(1, 1, 11, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == true); UNIT_ASSERT(tracker.GetMerged().size() == 2); } { - TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1) }; - UNIT_ASSERT(tracker.Merge(0, followers) == true); + TVector<TActorId> followers = { TActorId(1, 1, 1, 1), TActorId(1, 1, 5, 1) }; + UNIT_ASSERT(tracker.Merge(0, followers) == true); UNIT_ASSERT(tracker.GetMerged().size() == 2); } } diff --git a/ydb/core/base/statestorage_impl.h b/ydb/core/base/statestorage_impl.h index cf68f7b9d23..2a2aa22f6a7 100644 --- a/ydb/core/base/statestorage_impl.h +++ b/ydb/core/base/statestorage_impl.h @@ -21,13 +21,13 @@ struct TEvStateStorage::TEvReplicaInfo : public TEventPB<TEvStateStorage::TEvRep Record.SetStatus(status); } - TEvReplicaInfo(ui64 tabletId, const TActorId ¤tLeader, const TActorId ¤tLeaderTablet, ui32 currentGeneration, ui32 currentStep, bool locked, ui64 lockedFor) + TEvReplicaInfo(ui64 tabletId, const TActorId ¤tLeader, const TActorId ¤tLeaderTablet, ui32 currentGeneration, ui32 currentStep, bool locked, ui64 lockedFor) { Record.SetStatus(NKikimrProto::OK); Record.SetTabletID(tabletId); - ActorIdToProto(currentLeader, Record.MutableCurrentLeader()); - ActorIdToProto(currentLeaderTablet, Record.MutableCurrentLeaderTablet()); + ActorIdToProto(currentLeader, Record.MutableCurrentLeader()); + ActorIdToProto(currentLeaderTablet, Record.MutableCurrentLeaderTablet()); Record.SetCurrentGeneration(currentGeneration); Record.SetCurrentStep(currentStep); if (locked) { @@ -40,11 +40,11 @@ struct TEvStateStorage::TEvReplicaInfo : public TEventPB<TEvStateStorage::TEvRep TStringStream str; str << "{EvReplicaInfo Status: " << (ui32)Record.GetStatus(); str << " TabletID: " << Record.GetTabletID(); - if (Record.HasCurrentLeader()) { - str << " CurrentLeader: " << ActorIdFromProto(Record.GetCurrentLeader()).ToString(); + if (Record.HasCurrentLeader()) { + str << " CurrentLeader: " << ActorIdFromProto(Record.GetCurrentLeader()).ToString(); } - if (Record.HasCurrentLeaderTablet()) { - str << " CurrentLeaderTablet: " << ActorIdFromProto(Record.GetCurrentLeaderTablet()).ToString(); + if (Record.HasCurrentLeaderTablet()) { + str << " CurrentLeaderTablet: " << ActorIdFromProto(Record.GetCurrentLeaderTablet()).ToString(); } if (Record.HasCurrentGeneration()) { str << " CurrentGeneration: " << Record.GetCurrentGeneration(); @@ -237,10 +237,10 @@ struct TEvStateStorage::TEvReplicaCleanup : public TEventPB<TEvStateStorage::TEv TEvReplicaCleanup() {} - TEvReplicaCleanup(ui64 tabletId, TActorId proposedLeader) + TEvReplicaCleanup(ui64 tabletId, TActorId proposedLeader) { Record.SetTabletID(tabletId); - ActorIdToProto(proposedLeader, Record.MutableProposedLeader()); + ActorIdToProto(proposedLeader, Record.MutableProposedLeader()); } }; diff --git a/ydb/core/base/statestorage_monitoring.cpp b/ydb/core/base/statestorage_monitoring.cpp index 4722901125e..5bcc3ec67fa 100644 --- a/ydb/core/base/statestorage_monitoring.cpp +++ b/ydb/core/base/statestorage_monitoring.cpp @@ -14,9 +14,9 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni TActorId ActorID; TInstant ReplyTime; - TActorId CurrentLeader; - TActorId CurrentLeaderTablet; - TVector<TActorId> Followers; + TActorId CurrentLeader; + TActorId CurrentLeaderTablet; + TVector<TActorId> Followers; ui32 CurrentGeneration; ui64 ConfigContentHash; bool Locked; @@ -25,8 +25,8 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni TReplicaInfo(const TActorId &x) : ActorID(x) , ReplyTime(TInstant::MicroSeconds(Max<ui64>())) - , CurrentLeader() - , CurrentLeaderTablet() + , CurrentLeader() + , CurrentLeaderTablet() , CurrentGeneration(Max<ui32>()) , ConfigContentHash(0) , Locked(false) @@ -68,8 +68,8 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni TABLEHEAD() { TABLER() { TABLEH() { str << "NodeId";} - TABLEH() { str << "Leader";} - TABLEH() { str << "Followers"; } + TABLEH() { str << "Leader";} + TABLEH() { str << "Followers"; } TABLEH() { str << "Locked";} TABLEH() { str << "Generation";} TABLEH() { str << "Reply time";} @@ -95,10 +95,10 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni TABLED() { str << "-"; } TABLED() { str << replica.ConfigContentHash; } } else { - TABLED() {str << replica.CurrentLeader;} + TABLED() {str << replica.CurrentLeader;} TABLED() { - if (replica.Followers) - for (auto &s : replica.Followers) + if (replica.Followers) + for (auto &s : replica.Followers) str << s << "; "; else str << "-"; @@ -161,10 +161,10 @@ class TStateStorageMonitoringActor : public TActorBootstrapped<TStateStorageMoni --WaitingForReplicas; if (record.GetStatus() == NKikimrProto::OK) { - if (record.HasCurrentLeader()) - xinfo.CurrentLeader = ActorIdFromProto(record.GetCurrentLeader()); - if (record.HasCurrentLeaderTablet()) - xinfo.CurrentLeaderTablet = ActorIdFromProto(record.GetCurrentLeaderTablet()); + if (record.HasCurrentLeader()) + xinfo.CurrentLeader = ActorIdFromProto(record.GetCurrentLeader()); + if (record.HasCurrentLeaderTablet()) + xinfo.CurrentLeaderTablet = ActorIdFromProto(record.GetCurrentLeaderTablet()); xinfo.CurrentGeneration = record.HasCurrentGeneration() ? record.GetCurrentGeneration() : 0; xinfo.Locked = record.HasLocked() ? record.GetLocked() : false; xinfo.LockedFor = record.HasLockedFor() ? record.GetLockedFor() : 0; diff --git a/ydb/core/base/statestorage_proxy.cpp b/ydb/core/base/statestorage_proxy.cpp index 461e3dbd9d4..13d396cb0f1 100644 --- a/ydb/core/base/statestorage_proxy.cpp +++ b/ydb/core/base/statestorage_proxy.cpp @@ -38,8 +38,8 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { TEvStateStorage::TProxyOptions ProxyOptions; ui32 SuggestedGeneration; ui32 SuggestedStep; - TActorId SuggestedLeader; - TActorId SuggestedLeaderTablet; + TActorId SuggestedLeader; + TActorId SuggestedLeaderTablet; TActorId Source; ui32 Replicas; @@ -51,14 +51,14 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { ui32 RepliesAfterReply; ui32 SignaturesMerged; - TActorId ReplyLeader; - TActorId ReplyLeaderTablet; + TActorId ReplyLeader; + TActorId ReplyLeaderTablet; ui32 ReplyGeneration; ui32 ReplyStep; bool ReplyLocked; ui64 ReplyLockedFor; - TMap<TActorId, TActorId> Followers; + TMap<TActorId, TActorId> Followers; void SelectRequestReplicas(TStateStorageInfo *info) { THolder<TStateStorageInfo::TSelection> selection(new TStateStorageInfo::TSelection()); @@ -94,7 +94,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { } void Reply(NKikimrProto::EReplyStatus status) { - Send(Source, new TEvStateStorage::TEvInfo(status, TabletID, Cookie, ReplyLeader, ReplyLeaderTablet, ReplyGeneration, ReplyStep, ReplyLocked, ReplyLockedFor, Signature.Get(), Replicas, Followers)); + Send(Source, new TEvStateStorage::TEvInfo(status, TabletID, Cookie, ReplyLeader, ReplyLeaderTablet, ReplyGeneration, ReplyStep, ReplyLocked, ReplyLockedFor, Signature.Get(), Replicas, Followers)); } void ReplyAndDie(NKikimrProto::EReplyStatus status) { @@ -112,22 +112,22 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { struct TCloneUpdateEventOp { const TEvStateStorage::TEvUpdate * const Ev; - const bool UpdateLeaderTablet; + const bool UpdateLeaderTablet; mutable ui32 Idx; TCloneUpdateEventOp(const TEvStateStorage::TEvUpdate *ev) : Ev(ev) - , UpdateLeaderTablet(!!ev->ProposedLeaderTablet) + , UpdateLeaderTablet(!!ev->ProposedLeaderTablet) , Idx(0) {} IEventBase* operator()(ui64 cookie) const { THolder<TEvStateStorage::TEvReplicaUpdate> req(new TEvStateStorage::TEvReplicaUpdate()); req->Record.SetTabletID(Ev->TabletID); - ActorIdToProto(Ev->ProposedLeader, req->Record.MutableProposedLeader()); + ActorIdToProto(Ev->ProposedLeader, req->Record.MutableProposedLeader()); - if (UpdateLeaderTablet) - ActorIdToProto(Ev->ProposedLeaderTablet, req->Record.MutableProposedLeaderTablet()); + if (UpdateLeaderTablet) + ActorIdToProto(Ev->ProposedLeaderTablet, req->Record.MutableProposedLeaderTablet()); req->Record.SetProposedGeneration(Ev->ProposedGeneration); req->Record.SetProposedStep(Ev->ProposedStep); @@ -152,7 +152,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { IEventBase* operator()(ui64 cookie) const { THolder<TEvStateStorage::TEvReplicaLock> req(new TEvStateStorage::TEvReplicaLock()); req->Record.SetTabletID(Ev->TabletID); - ActorIdToProto(Ev->ProposedLeader, req->Record.MutableProposedLeader()); + ActorIdToProto(Ev->ProposedLeader, req->Record.MutableProposedLeader()); req->Record.SetProposedGeneration(Ev->ProposedGeneration); req->Record.SetSignature(Ev->Signature[Idx]); @@ -197,24 +197,24 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { if (status == NKikimrProto::OK) { const ui32 gen = record.GetCurrentGeneration(); const ui32 step = record.GetCurrentStep(); - const TActorId leader = ActorIdFromProto(record.GetCurrentLeader()); + const TActorId leader = ActorIdFromProto(record.GetCurrentLeader()); if (gen < ReplyGeneration || (gen == ReplyGeneration && step < ReplyStep)) { ReplicaSelection->MergeReply(TStateStorageInfo::TSelection::StatusOutdated, &ReplyStatus, cookie, false); } else { - const bool reset = gen > ReplyGeneration || step > ReplyStep || leader != ReplyLeader; - const TActorId replyLeaderTablet = ActorIdFromProto(record.GetCurrentLeaderTablet()); + const bool reset = gen > ReplyGeneration || step > ReplyStep || leader != ReplyLeader; + const TActorId replyLeaderTablet = ActorIdFromProto(record.GetCurrentLeaderTablet()); ReplyGeneration = gen; ReplyStep = step; - if (ReplyLeader != leader) { - ReplyLeader = leader; - ReplyLeaderTablet = replyLeaderTablet; - } else if (!ReplyLeaderTablet) { - ReplyLeaderTablet = replyLeaderTablet; + if (ReplyLeader != leader) { + ReplyLeader = leader; + ReplyLeaderTablet = replyLeaderTablet; + } else if (!ReplyLeaderTablet) { + ReplyLeaderTablet = replyLeaderTablet; } else { - Y_VERIFY(ReplyLeaderTablet == replyLeaderTablet || !replyLeaderTablet); + Y_VERIFY(ReplyLeaderTablet == replyLeaderTablet || !replyLeaderTablet); } // todo: accurate handling of locked flag @@ -229,8 +229,8 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { Y_FAIL(); } - for (ui32 i = 0, end = record.FollowerSize(); i < end; ++i) { - Followers[ActorIdFromProto(record.GetFollower(i))] = ActorIdFromProto(record.GetFollowerTablet(i)); + for (ui32 i = 0, end = record.FollowerSize(); i < end; ++i) { + Followers[ActorIdFromProto(record.GetFollower(i))] = ActorIdFromProto(record.GetFollowerTablet(i)); } } @@ -266,8 +266,8 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { PrepareInit(msg, false); - SuggestedLeader = msg->ProposedLeader; - SuggestedLeaderTablet = msg->ProposedLeaderTablet; + SuggestedLeader = msg->ProposedLeader; + SuggestedLeaderTablet = msg->ProposedLeaderTablet; SuggestedGeneration = msg->ProposedGeneration; SuggestedStep = msg->ProposedStep; @@ -288,7 +288,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { PrepareInit(msg, false); - SuggestedLeader = msg->ProposedLeader; + SuggestedLeader = msg->ProposedLeader; SuggestedGeneration = msg->ProposedGeneration; SuggestedStep = 0; @@ -378,7 +378,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { return; case TStateStorageInfo::TSelection::StatusOk: { - const bool race = (ReplyLeader != SuggestedLeader || ReplyGeneration != SuggestedGeneration); + const bool race = (ReplyLeader != SuggestedLeader || ReplyGeneration != SuggestedGeneration); const NKikimrProto::EReplyStatus status = race ? NKikimrProto::RACE : NKikimrProto::OK; ReplyAndDie(status); } @@ -403,7 +403,7 @@ class TStateStorageProxyRequest : public TActor<TStateStorageProxyRequest> { return; case TStateStorageInfo::TSelection::StatusOk: { - const bool race = (ReplyLeader != SuggestedLeader || ReplyGeneration != SuggestedGeneration); // step overrun is consumed + const bool race = (ReplyLeader != SuggestedLeader || ReplyGeneration != SuggestedGeneration); // step overrun is consumed const NKikimrProto::EReplyStatus status = race ? NKikimrProto::RACE : NKikimrProto::OK; ReplyAndSig(status); } @@ -750,16 +750,16 @@ class TStateStorageProxy : public TActor<TStateStorageProxy> { TActivationContext::Register(new TStateStorageDeleteRequest(ev->Sender, Info, ev->Get()->TabletID)); } - void SpreadCleanupRequest(const TStateStorageInfo::TSelection &selection, ui64 tabletId, TActorId proposedLeader) { + void SpreadCleanupRequest(const TStateStorageInfo::TSelection &selection, ui64 tabletId, TActorId proposedLeader) { for (ui32 i = 0; i < selection.Sz; ++i) - Send(selection.SelectedReplicas[i], new TEvStateStorage::TEvReplicaCleanup(tabletId, proposedLeader)); + Send(selection.SelectedReplicas[i], new TEvStateStorage::TEvReplicaCleanup(tabletId, proposedLeader)); } void Handle(TEvStateStorage::TEvCleanup::TPtr &ev) { const auto *msg = ev->Get(); THolder<TStateStorageInfo::TSelection> selection(new TStateStorageInfo::TSelection()); Info->SelectReplicas(msg->TabletID, selection.Get()); - SpreadCleanupRequest(*selection, msg->TabletID, msg->ProposedLeader); + SpreadCleanupRequest(*selection, msg->TabletID, msg->ProposedLeader); } void Handle(TEvStateStorage::TEvResolveReplicas::TPtr &ev) { diff --git a/ydb/core/base/statestorage_replica.cpp b/ydb/core/base/statestorage_replica.cpp index b8014cc1420..aca41acb16a 100644 --- a/ydb/core/base/statestorage_replica.cpp +++ b/ydb/core/base/statestorage_replica.cpp @@ -34,29 +34,29 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { }; }; - struct TFollowerEntryInfo { - TActorId FollowerSys; - TActorId FollowerTablet; + struct TFollowerEntryInfo { + TActorId FollowerSys; + TActorId FollowerTablet; bool Candidate = false; - TFollowerEntryInfo() = default; - TFollowerEntryInfo(TActorId sys, TActorId tablet, bool candidate) - : FollowerSys(sys) - , FollowerTablet(tablet) + TFollowerEntryInfo() = default; + TFollowerEntryInfo(TActorId sys, TActorId tablet, bool candidate) + : FollowerSys(sys) + , FollowerTablet(tablet) , Candidate(candidate) {} }; struct TEntry { TTabletState::ETabletState TabletState; - TActorId CurrentLeader; - TActorId CurrentLeaderTablet; + TActorId CurrentLeader; + TActorId CurrentLeaderTablet; TActorId CurrentGuardian; ui32 CurrentGeneration; ui32 CurrentStep; ui64 LockedFrom; - TMap<TActorId, TFollowerEntryInfo> Followers; // guardian -> follower actors + TMap<TActorId, TFollowerEntryInfo> Followers; // guardian -> follower actors TEntry() : TabletState(TTabletState::Unknown) @@ -69,7 +69,7 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { typedef TMap<ui64, TEntry> TTablets; TTablets Tablets; - TMap<ui32, std::map<ui64, ui64>> FollowerIndex; // node, tablet, refcounter + TMap<ui32, std::map<ui64, ui64>> FollowerIndex; // node, tablet, refcounter ui64 Signature() const { return SelfId().LocalId(); @@ -83,22 +83,22 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { void NotifyWithTabletInfo(const TActorId &recp, ui64 tabletId, ui64 cookie, const TEntry *entry) { THolder<TEvStateStorage::TEvReplicaInfo> msg; - if (entry && entry->CurrentLeader) { + if (entry && entry->CurrentLeader) { const bool locked = (entry->TabletState == TTabletState::Locked); auto now = TActivationContext::Now(); const ui64 lockedFor = (locked && (now.MicroSeconds() > entry->LockedFrom)) ? (now.MicroSeconds() - entry->LockedFrom) : 0; - msg.Reset(new TEvStateStorage::TEvReplicaInfo(tabletId, entry->CurrentLeader, entry->CurrentLeaderTablet, entry->CurrentGeneration, entry->CurrentStep, locked, lockedFor)); - if (entry->Followers.size()) { - msg->Record.MutableFollowerTablet()->Reserve(entry->Followers.size()); - msg->Record.MutableFollower()->Reserve(entry->Followers.size()); - for (const auto &xpair : entry->Followers) { - const TFollowerEntryInfo &followerInfo = xpair.second; - if (followerInfo.Candidate) { - ActorIdToProto(followerInfo.FollowerSys, msg->Record.AddFollowerCandidates()); + msg.Reset(new TEvStateStorage::TEvReplicaInfo(tabletId, entry->CurrentLeader, entry->CurrentLeaderTablet, entry->CurrentGeneration, entry->CurrentStep, locked, lockedFor)); + if (entry->Followers.size()) { + msg->Record.MutableFollowerTablet()->Reserve(entry->Followers.size()); + msg->Record.MutableFollower()->Reserve(entry->Followers.size()); + for (const auto &xpair : entry->Followers) { + const TFollowerEntryInfo &followerInfo = xpair.second; + if (followerInfo.Candidate) { + ActorIdToProto(followerInfo.FollowerSys, msg->Record.AddFollowerCandidates()); } else { - ActorIdToProto(followerInfo.FollowerSys, msg->Record.AddFollower()); - ActorIdToProto(followerInfo.FollowerTablet, msg->Record.AddFollowerTablet()); + ActorIdToProto(followerInfo.FollowerSys, msg->Record.AddFollower()); + ActorIdToProto(followerInfo.FollowerTablet, msg->Record.AddFollowerTablet()); } } } @@ -119,36 +119,36 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { Send(recp, msg.Release()); } - bool EraseFollowerAndNotify(ui64 tabletId, TEntry &tabletEntry, TActorId followerGuardian) { - if (!tabletEntry.Followers.erase(followerGuardian)) + bool EraseFollowerAndNotify(ui64 tabletId, TEntry &tabletEntry, TActorId followerGuardian) { + if (!tabletEntry.Followers.erase(followerGuardian)) return false; if (tabletEntry.CurrentGuardian) - NotifyWithTabletInfo(followerGuardian, tabletId, 0, &tabletEntry); + NotifyWithTabletInfo(followerGuardian, tabletId, 0, &tabletEntry); return true; } - void ForgetFollower(ui64 tabletId, TActorId followerGuardian) { + void ForgetFollower(ui64 tabletId, TActorId followerGuardian) { auto tabletIt = Tablets.find(tabletId); if (tabletIt == Tablets.end()) return; - const bool erased = EraseFollowerAndNotify(tabletId, tabletIt->second, followerGuardian); + const bool erased = EraseFollowerAndNotify(tabletId, tabletIt->second, followerGuardian); if (!erased) return; - const ui32 followerNodeId = followerGuardian.NodeId(); - auto *followerIndex = FollowerIndex.FindPtr(followerNodeId); - if (followerIndex == nullptr) + const ui32 followerNodeId = followerGuardian.NodeId(); + auto *followerIndex = FollowerIndex.FindPtr(followerNodeId); + if (followerIndex == nullptr) return; - auto it = followerIndex->find(tabletId); - if (it == followerIndex->end()) + auto it = followerIndex->find(tabletId); + if (it == followerIndex->end()) return; if (--it->second == 0) - followerIndex->erase(it); + followerIndex->erase(it); } void PassAway() override { @@ -161,11 +161,11 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { if (entry.CurrentGuardian) Send(entry.CurrentGuardian, new TEvStateStorage::TEvReplicaShutdown()); - for (auto &spair : entry.Followers) { - const TActorId followerGuardian = spair.first; - if (followerGuardian.NodeId() != selfNode) - nodesToUnsubscribe.insert(followerGuardian.NodeId()); - Send(followerGuardian, new TEvStateStorage::TEvReplicaShutdown()); + for (auto &spair : entry.Followers) { + const TActorId followerGuardian = spair.first; + if (followerGuardian.NodeId() != selfNode) + nodesToUnsubscribe.insert(followerGuardian.NodeId()); + Send(followerGuardian, new TEvStateStorage::TEvReplicaShutdown()); } } @@ -197,8 +197,8 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { info.SetTabletID(it.first); info.SetCurrentGeneration(it.second.CurrentGeneration); info.SetCurrentStep(it.second.CurrentStep); - ActorIdToProto(it.second.CurrentLeader, info.MutableCurrentLeader()); - ActorIdToProto(it.second.CurrentLeaderTablet, info.MutableCurrentLeaderTablet()); + ActorIdToProto(it.second.CurrentLeader, info.MutableCurrentLeader()); + ActorIdToProto(it.second.CurrentLeaderTablet, info.MutableCurrentLeaderTablet()); if (it.second.TabletState == TTabletState::Locked) { info.SetLockedFor(TActivationContext::Now().MicroSeconds() - it.second.LockedFrom); } @@ -217,14 +217,14 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { if (tabletIt != Tablets.end()) x = &tabletIt->second; - const TActorId proposedLeader = ActorIdFromProto(msg->Record.GetProposedLeader()); + const TActorId proposedLeader = ActorIdFromProto(msg->Record.GetProposedLeader()); const ui32 proposedGeneration = msg->Record.GetProposedGeneration(); const ui32 proposedStep = msg->Record.GetProposedStep(); const bool allow = CheckSignature(msg) && (!x || (proposedGeneration > x->CurrentGeneration) - || (proposedGeneration == x->CurrentGeneration && proposedLeader == x->CurrentLeader && proposedStep >= x->CurrentStep) + || (proposedGeneration == x->CurrentGeneration && proposedLeader == x->CurrentLeader && proposedStep >= x->CurrentStep) ); if (allow) { @@ -232,15 +232,15 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { tabletIt = Tablets.insert(std::make_pair(tabletId, TEntry())).first; x = &tabletIt->second; - if (x->CurrentLeader && proposedLeader != x->CurrentLeader) - Send(x->CurrentLeader, new TEvStateStorage::TEvReplicaLeaderDemoted(tabletId, Signature())); + if (x->CurrentLeader && proposedLeader != x->CurrentLeader) + Send(x->CurrentLeader, new TEvStateStorage::TEvReplicaLeaderDemoted(tabletId, Signature())); x->CurrentGeneration = proposedGeneration; x->CurrentStep = proposedStep; - x->CurrentLeader = proposedLeader; + x->CurrentLeader = proposedLeader; - if (msg->Record.HasProposedLeaderTablet()) - x->CurrentLeaderTablet = ActorIdFromProto(msg->Record.GetProposedLeaderTablet()); + if (msg->Record.HasProposedLeaderTablet()) + x->CurrentLeaderTablet = ActorIdFromProto(msg->Record.GetProposedLeaderTablet()); if (msg->Record.GetIsGuardian()) x->CurrentGuardian = ev->Sender; @@ -257,14 +257,14 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { BLOG_D("Replica::Handle ev: " << ev->Get()->ToString()); const ui64 tabletId = record.GetTabletID(); Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); - const TActorId proposedLeader = ActorIdFromProto(record.GetProposedLeader()); + const TActorId proposedLeader = ActorIdFromProto(record.GetProposedLeader()); auto tabletIt = Tablets.find(tabletId); - if (tabletIt == Tablets.end() || tabletIt->second.CurrentLeader != proposedLeader) + if (tabletIt == Tablets.end() || tabletIt->second.CurrentLeader != proposedLeader) return; - if (tabletIt->second.Followers) { - BLOG_ERROR("trying to cleanup entry with attached followers. Suspicious! TabletId: " << tabletId); + if (tabletIt->second.Followers) { + BLOG_ERROR("trying to cleanup entry with attached followers. Suspicious! TabletId: " << tabletId); return; } @@ -284,9 +284,9 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { return; } - for (auto &sp : tabletIt->second.Followers) { - const ui32 followerNodeId = sp.first.NodeId(); - if (auto *x = FollowerIndex.FindPtr(followerNodeId)) + for (auto &sp : tabletIt->second.Followers) { + const ui32 followerNodeId = sp.first.NodeId(); + if (auto *x = FollowerIndex.FindPtr(followerNodeId)) x->erase(tabletId); } @@ -305,19 +305,19 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { TEntry &x = Tablets[tabletId]; const ui32 proposedGeneration = msg->Record.GetProposedGeneration(); - const TActorId proposedLeader = ActorIdFromProto(msg->Record.GetProposedLeader()); + const TActorId proposedLeader = ActorIdFromProto(msg->Record.GetProposedLeader()); const bool allow = (proposedGeneration > x.CurrentGeneration - || (x.TabletState == TTabletState::Locked && proposedGeneration == x.CurrentGeneration && proposedLeader == x.CurrentLeader)); + || (x.TabletState == TTabletState::Locked && proposedGeneration == x.CurrentGeneration && proposedLeader == x.CurrentLeader)); if (allow) { - if (x.CurrentLeader && proposedLeader != x.CurrentLeader) - Send(x.CurrentLeader, new TEvStateStorage::TEvReplicaLeaderDemoted(tabletId, Signature())); + if (x.CurrentLeader && proposedLeader != x.CurrentLeader) + Send(x.CurrentLeader, new TEvStateStorage::TEvReplicaLeaderDemoted(tabletId, Signature())); x.CurrentGeneration = proposedGeneration; x.CurrentStep = 0; - x.CurrentLeader = proposedLeader; - x.CurrentLeaderTablet = TActorId(); + x.CurrentLeader = proposedLeader; + x.CurrentLeaderTablet = TActorId(); x.CurrentGuardian = TActorId(); x.TabletState = TTabletState::Locked; x.LockedFrom = TActivationContext::Now().MicroSeconds(); @@ -329,35 +329,35 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { } } - void Handle(TEvStateStorage::TEvReplicaRegFollower::TPtr &ev) { - const NKikimrStateStorage::TEvRegisterFollower &record = ev->Get()->Record; + void Handle(TEvStateStorage::TEvReplicaRegFollower::TPtr &ev) { + const NKikimrStateStorage::TEvRegisterFollower &record = ev->Get()->Record; const ui64 tabletId = record.GetTabletID(); Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); - TEntry &x = Tablets[tabletId]; // could lead to creation of zombie entries when follower exist w/o leader so we must filter on info + TEntry &x = Tablets[tabletId]; // could lead to creation of zombie entries when follower exist w/o leader so we must filter on info - const TActorId follower = ActorIdFromProto(record.GetFollower()); - const TActorId tablet = ActorIdFromProto(record.GetFollowerTablet()); + const TActorId follower = ActorIdFromProto(record.GetFollower()); + const TActorId tablet = ActorIdFromProto(record.GetFollowerTablet()); const bool isCandidate = record.HasCandidate() && record.GetCandidate(); - auto insIt = x.Followers.emplace(ev->Sender, TFollowerEntryInfo(follower, tablet, isCandidate)); - TFollowerEntryInfo &followerInfo = insIt.first->second; + auto insIt = x.Followers.emplace(ev->Sender, TFollowerEntryInfo(follower, tablet, isCandidate)); + TFollowerEntryInfo &followerInfo = insIt.first->second; if (insIt.second == false) { // already known - Y_VERIFY(insIt.first->second.FollowerSys == follower); + Y_VERIFY(insIt.first->second.FollowerSys == follower); - const bool hasChanges = (followerInfo.FollowerTablet != tablet) || (followerInfo.Candidate != isCandidate); + const bool hasChanges = (followerInfo.FollowerTablet != tablet) || (followerInfo.Candidate != isCandidate); if (!hasChanges) return; - followerInfo.Candidate = isCandidate; - followerInfo.FollowerTablet = tablet; + followerInfo.Candidate = isCandidate; + followerInfo.FollowerTablet = tablet; } else { // new entry - auto indIt = FollowerIndex[follower.NodeId()].insert(std::make_pair(tabletId, 1)); + auto indIt = FollowerIndex[follower.NodeId()].insert(std::make_pair(tabletId, 1)); if (indIt.second == false) ++indIt.first->second; // and now send ping to detect lost unreg event and subscribe to session - Send(ev->Sender, // ping replica guardian, not tablet as follower could be promoted to leader + Send(ev->Sender, // ping replica guardian, not tablet as follower could be promoted to leader new TEvTablet::TEvPing(tabletId, 0), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession, tabletId); @@ -367,19 +367,19 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { NotifyWithTabletInfo(x.CurrentGuardian, tabletId, 0, &x); } - void Handle(TEvStateStorage::TEvReplicaUnregFollower::TPtr &ev) { - const TEvStateStorage::TEvReplicaUnregFollower *msg = ev->Get(); + void Handle(TEvStateStorage::TEvReplicaUnregFollower::TPtr &ev) { + const TEvStateStorage::TEvReplicaUnregFollower *msg = ev->Get(); const ui64 tabletId = msg->Record.GetTabletID(); Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); - ForgetFollower(tabletId, ev->Sender); + ForgetFollower(tabletId, ev->Sender); } void Handle(TEvents::TEvUndelivered::TPtr &ev) { const ui64 tabletId = ev->Cookie; Y_VERIFY_DEBUG(StateStorageGroupFromTabletID(tabletId) == Info->StateStorageGroup); - ForgetFollower(tabletId, ev->Sender); + ForgetFollower(tabletId, ev->Sender); } void Handle(TEvents::TEvPing::TPtr &ev) { @@ -389,20 +389,20 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { void Handle(TEvInterconnect::TEvNodeDisconnected::TPtr &ev) { const ui32 nodeId = ev->Get()->NodeId; - auto *followerIndex = FollowerIndex.FindPtr(nodeId); - if (followerIndex == nullptr) + auto *followerIndex = FollowerIndex.FindPtr(nodeId); + if (followerIndex == nullptr) return; - for (const auto &xpair : *followerIndex) { + for (const auto &xpair : *followerIndex) { const ui64 tabletId = xpair.first; if (auto *x = Tablets.FindPtr(tabletId)) { bool changed = false; - for (auto it = x->Followers.begin(); it != x->Followers.end();) { + for (auto it = x->Followers.begin(); it != x->Followers.end();) { if (it->first.NodeId() == nodeId) { changed = true; - it = x->Followers.erase(it); + it = x->Followers.erase(it); } else ++it; @@ -413,7 +413,7 @@ class TStateStorageReplica : public TActor<TStateStorageReplica> { } } - followerIndex->clear(); + followerIndex->clear(); } public: @@ -435,8 +435,8 @@ public: hFunc(TEvStateStorage::TEvReplicaDumpRequest, Handle); hFunc(TEvStateStorage::TEvReplicaUpdate, Handle); hFunc(TEvStateStorage::TEvReplicaLock, Handle); - hFunc(TEvStateStorage::TEvReplicaRegFollower, Handle); - hFunc(TEvStateStorage::TEvReplicaUnregFollower, Handle); + hFunc(TEvStateStorage::TEvReplicaRegFollower, Handle); + hFunc(TEvStateStorage::TEvReplicaUnregFollower, Handle); hFunc(TEvStateStorage::TEvReplicaDelete, Handle); hFunc(TEvStateStorage::TEvReplicaCleanup, Handle); hFunc(TEvents::TEvPing, Handle); diff --git a/ydb/core/base/tablet.h b/ydb/core/base/tablet.h index 06f7b5442c1..602e39c6000 100644 --- a/ydb/core/base/tablet.h +++ b/ydb/core/base/tablet.h @@ -43,13 +43,13 @@ struct TEvTablet { EvCommitResult, EvPing, EvDemoted, - EvNewFollowerAttached, - EvFBoot, - EvFUpdate, - EvUnused, - EvFAuxUpdate, - EvFollowerGcApplied, // from leader to user tablet when all known followers reported consumed gc barrier - EvFollowerSyncComplete, // from leader to user tablet when all old followers are touched and synced + EvNewFollowerAttached, + EvFBoot, + EvFUpdate, + EvUnused, + EvFAuxUpdate, + EvFollowerGcApplied, // from leader to user tablet when all known followers reported consumed gc barrier + EvFollowerSyncComplete, // from leader to user tablet when all old followers are touched and synced EvCutTabletHistory, EvUpdateConfig, @@ -58,11 +58,11 @@ struct TEvTablet { EvPong, EvPreCommit, EvTabletActive, - EvPromoteToLeader, - EvFGcAck, // from user tablet to follower + EvPromoteToLeader, + EvFGcAck, // from user tablet to follower EvTabletDead = EvBoot + 1024, - EvFollowerUpdateState, // notifications to guardian + EvFollowerUpdateState, // notifications to guardian EvFeatures, // from user tablet to sys tablet, notify on supported features EvTabletStop, // from local to sys tablet, from sys tablet to user tablet EvTabletStopped, // from user tablet to sys tablet, ready to die now @@ -78,19 +78,19 @@ struct TEvTablet { EvLocalReadColumns, EvLocalReadColumnsResponse, - // from outside to leader - EvFollowerAttach = EvBoot + 2048, - EvFollowerDetach, - EvFollowerListRefresh, // from guardian to leader + // from outside to leader + EvFollowerAttach = EvBoot + 2048, + EvFollowerDetach, + EvFollowerListRefresh, // from guardian to leader EvReserved_00, - EvFollowerGcAck, // from follower to leader + EvFollowerGcAck, // from follower to leader - // from leader to follower - EvFollowerUpdate = EvBoot + 2560, - EvFollowerAuxUpdate, + // from leader to follower + EvFollowerUpdate = EvBoot + 2560, + EvFollowerAuxUpdate, EvReserved_01, - EvFollowerDisconnect, - EvFollowerRefresh, // from leader to follower + EvFollowerDisconnect, + EvFollowerRefresh, // from leader to follower // utilitary EvCheckBlobstorageStatusResult = EvBoot + 3072, @@ -184,8 +184,8 @@ struct TEvTablet { const TActorId Launcher; TIntrusivePtr<TTabletStorageInfo> TabletStorageInfo; - TResourceProfilesPtr ResourceProfiles; - TSharedQuotaPtr TxCacheQuota; + TResourceProfilesPtr ResourceProfiles; + TSharedQuotaPtr TxCacheQuota; NMetrics::TTabletThroughputRawValue GroupReadBytes; NMetrics::TTabletIopsRawValue GroupReadOps; @@ -196,8 +196,8 @@ struct TEvTablet { TDependencyGraph *dependencyGraph, const TActorId& launcher, TIntrusivePtr<TTabletStorageInfo> info, - TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr, + TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr, NMetrics::TTabletThroughputRawValue&& read = NMetrics::TTabletThroughputRawValue(), NMetrics::TTabletIopsRawValue&& readOps = NMetrics::TTabletIopsRawValue()) : TabletID(tabletId) @@ -217,21 +217,21 @@ struct TEvTablet { const ui64 TabletID; const ui32 Generation; const TActorId UserTabletActor; - const bool Follower; + const bool Follower; - TEvRestored(ui64 tabletId, ui32 generation, const TActorId &userTabletActor, bool follower) + TEvRestored(ui64 tabletId, ui32 generation, const TActorId &userTabletActor, bool follower) : TabletID(tabletId) , Generation(generation) , UserTabletActor(userTabletActor) - , Follower(follower) + , Follower(follower) {} }; - struct TEvNewFollowerAttached : public TEventLocal<TEvNewFollowerAttached, EvNewFollowerAttached> { - const ui32 TotalFollowers; + struct TEvNewFollowerAttached : public TEventLocal<TEvNewFollowerAttached, EvNewFollowerAttached> { + const ui32 TotalFollowers; - TEvNewFollowerAttached(ui32 totalFollowers) - : TotalFollowers(totalFollowers) + TEvNewFollowerAttached(ui32 totalFollowers) + : TotalFollowers(totalFollowers) {} }; @@ -243,7 +243,7 @@ struct TEvTablet { const TVector<ui32> DependsOn; const bool IsSnapshot; bool IsTotalSnapshot; - bool WaitFollowerGcAck; + bool WaitFollowerGcAck; TCommitInfo(ui64 tabletId, ui32 gen, ui32 step, const TVector<ui32> &dependsOn, bool isSnapshot) : TabletID(tabletId) @@ -252,7 +252,7 @@ struct TEvTablet { , DependsOn(dependsOn) , IsSnapshot(isSnapshot) , IsTotalSnapshot(false) - , WaitFollowerGcAck(false) + , WaitFollowerGcAck(false) {} }; @@ -267,7 +267,7 @@ struct TEvTablet { TVector<TLogoBlobID> GcLeft; TString EmbeddedLogBody; - TString FollowerAux; + TString FollowerAux; TEvCommit(ui64 tabletId, ui32 gen, ui32 step, const TVector<ui32> &dependsOn, bool isSnapshot , bool preCommited = false @@ -279,10 +279,10 @@ struct TEvTablet { }; struct TEvAux : public TEventLocal<TEvAux, EvAux> { - TString FollowerAux; + TString FollowerAux; - TEvAux(TString followerAux) - : FollowerAux(std::move(followerAux)) + TEvAux(TString followerAux) + : FollowerAux(std::move(followerAux)) {} }; @@ -302,11 +302,11 @@ struct TEvTablet { {} }; - struct TEvPromoteToLeader : public TEventLocal<TEvPromoteToLeader, EvPromoteToLeader> { + struct TEvPromoteToLeader : public TEventLocal<TEvPromoteToLeader, EvPromoteToLeader> { const ui32 SuggestedGeneration; TIntrusivePtr<TTabletStorageInfo> TabletStorageInfo; - TEvPromoteToLeader(ui32 suggestedGeneration, TIntrusivePtr<TTabletStorageInfo> info) + TEvPromoteToLeader(ui32 suggestedGeneration, TIntrusivePtr<TTabletStorageInfo> info) : SuggestedGeneration(suggestedGeneration) , TabletStorageInfo(info) {} @@ -386,14 +386,14 @@ struct TEvTablet { {} }; - struct TEvFollowerUpdateState : public TEventLocal<TEvFollowerUpdateState, EvFollowerUpdateState> { + struct TEvFollowerUpdateState : public TEventLocal<TEvFollowerUpdateState, EvFollowerUpdateState> { const bool IsCandidate; - const TActorId FollowerActor; + const TActorId FollowerActor; const TActorId TabletActor; - TEvFollowerUpdateState(bool isCandidate, TActorId followerActor, TActorId tabletActor) + TEvFollowerUpdateState(bool isCandidate, TActorId followerActor, TActorId tabletActor) : IsCandidate(isCandidate) - , FollowerActor(followerActor) + , FollowerActor(followerActor) , TabletActor(tabletActor) {} }; @@ -416,8 +416,8 @@ struct TEvTablet { struct TEvPong : public TEventPB<TEvPong, NKikimrTabletBase::TEvPong, EvPong> { enum EFlags { FlagBoot = 1, - FlagLeader = 2, - FlagFollower = 4, + FlagLeader = 2, + FlagFollower = 4, }; TEvPong() @@ -493,107 +493,107 @@ struct TEvTablet { {} }; - struct TEvFollowerAttach : public TEventPB<TEvFollowerAttach, NKikimrTabletBase::TEvFollowerAttach, EvFollowerAttach> { - TEvFollowerAttach() + struct TEvFollowerAttach : public TEventPB<TEvFollowerAttach, NKikimrTabletBase::TEvFollowerAttach, EvFollowerAttach> { + TEvFollowerAttach() {} - TEvFollowerAttach(ui64 tabletId, ui32 followerAttempt) + TEvFollowerAttach(ui64 tabletId, ui32 followerAttempt) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); } }; - struct TEvFollowerUpdate : public TEventPB<TEvFollowerUpdate, NKikimrTabletBase::TEvFollowerUpdate, EvFollowerUpdate> { - TEvFollowerUpdate() + struct TEvFollowerUpdate : public TEventPB<TEvFollowerUpdate, NKikimrTabletBase::TEvFollowerUpdate, EvFollowerUpdate> { + TEvFollowerUpdate() {} - TEvFollowerUpdate(ui64 tabletId, ui32 followerAttempt, ui64 streamCounter) + TEvFollowerUpdate(ui64 tabletId, ui32 followerAttempt, ui64 streamCounter) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); Record.SetStreamCounter(streamCounter); } }; - struct TEvFollowerAuxUpdate : public TEventPB<TEvFollowerAuxUpdate, NKikimrTabletBase::TEvFollowerAuxUpdate, EvFollowerAuxUpdate> { - TEvFollowerAuxUpdate() = default; + struct TEvFollowerAuxUpdate : public TEventPB<TEvFollowerAuxUpdate, NKikimrTabletBase::TEvFollowerAuxUpdate, EvFollowerAuxUpdate> { + TEvFollowerAuxUpdate() = default; - TEvFollowerAuxUpdate(ui64 tabletId, ui32 followerAttempt, ui64 streamCounter) + TEvFollowerAuxUpdate(ui64 tabletId, ui32 followerAttempt, ui64 streamCounter) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); Record.SetStreamCounter(streamCounter); } }; - struct TEvFollowerDetach : public TEventPB<TEvFollowerDetach, NKikimrTabletBase::TEvFollowerDetach, EvFollowerDetach> { - TEvFollowerDetach() + struct TEvFollowerDetach : public TEventPB<TEvFollowerDetach, NKikimrTabletBase::TEvFollowerDetach, EvFollowerDetach> { + TEvFollowerDetach() {} - TEvFollowerDetach(ui64 tabletId, ui32 followerAttempt) + TEvFollowerDetach(ui64 tabletId, ui32 followerAttempt) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); } }; - struct TEvFollowerListRefresh : public TEventLocal<TEvFollowerListRefresh, EvFollowerListRefresh> { - TVector<TActorId> FollowerList; + struct TEvFollowerListRefresh : public TEventLocal<TEvFollowerListRefresh, EvFollowerListRefresh> { + TVector<TActorId> FollowerList; - TEvFollowerListRefresh(TVector<TActorId> &&followers) - : FollowerList(std::move(followers)) + TEvFollowerListRefresh(TVector<TActorId> &&followers) + : FollowerList(std::move(followers)) {} }; - struct TEvFollowerDisconnect : public TEventPB<TEvFollowerDisconnect, NKikimrTabletBase::TEvFollowerDisconnect, EvFollowerDisconnect> { - TEvFollowerDisconnect() + struct TEvFollowerDisconnect : public TEventPB<TEvFollowerDisconnect, NKikimrTabletBase::TEvFollowerDisconnect, EvFollowerDisconnect> { + TEvFollowerDisconnect() {} - TEvFollowerDisconnect(ui64 tabletId, ui32 followerAttempt) + TEvFollowerDisconnect(ui64 tabletId, ui32 followerAttempt) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); } }; - struct TEvFollowerRefresh : public TEventPB<TEvFollowerRefresh, NKikimrTabletBase::TEvFollowerRefresh, EvFollowerRefresh> { - TEvFollowerRefresh() + struct TEvFollowerRefresh : public TEventPB<TEvFollowerRefresh, NKikimrTabletBase::TEvFollowerRefresh, EvFollowerRefresh> { + TEvFollowerRefresh() {} - TEvFollowerRefresh(ui64 tabletId, ui32 generation) + TEvFollowerRefresh(ui64 tabletId, ui32 generation) { Record.SetTabletId(tabletId); Record.SetGeneration(generation); } }; - struct TEvFollowerGcAck : public TEventPB<TEvFollowerGcAck, NKikimrTabletBase::TEvFollowerGcAck, EvFollowerGcAck> { - TEvFollowerGcAck() + struct TEvFollowerGcAck : public TEventPB<TEvFollowerGcAck, NKikimrTabletBase::TEvFollowerGcAck, EvFollowerGcAck> { + TEvFollowerGcAck() {} - TEvFollowerGcAck(ui64 tabletId, ui32 followerAttempt, ui32 generation, ui32 step) + TEvFollowerGcAck(ui64 tabletId, ui32 followerAttempt, ui32 generation, ui32 step) { Record.SetTabletId(tabletId); - Record.SetFollowerAttempt(followerAttempt); + Record.SetFollowerAttempt(followerAttempt); Record.SetGeneration(generation); Record.SetStep(step); } }; - struct TFUpdateBody { + struct TFUpdateBody { const bool IsSnapshot; const ui32 Step; TString EmbeddedBody; TVector<std::pair<TLogoBlobID, TString>> References; TString AuxPayload; - bool NeedFollowerGcAck; + bool NeedFollowerGcAck; - TFUpdateBody(const TEvFollowerUpdate &upd) + TFUpdateBody(const TEvFollowerUpdate &upd) : IsSnapshot(upd.Record.GetIsSnapshot()) , Step(upd.Record.GetStep()) - , NeedFollowerGcAck(upd.Record.HasNeedGCApplyAck() ? upd.Record.GetNeedGCApplyAck() : false) + , NeedFollowerGcAck(upd.Record.HasNeedGCApplyAck() ? upd.Record.GetNeedGCApplyAck() : false) { const auto &r = upd.Record; if (r.HasBody()) @@ -608,49 +608,49 @@ struct TEvTablet { } } - TFUpdateBody(TString auxUpdate) + TFUpdateBody(TString auxUpdate) : IsSnapshot(false) , Step(0) - , AuxPayload(std::move(auxUpdate)) - , NeedFollowerGcAck(false) + , AuxPayload(std::move(auxUpdate)) + , NeedFollowerGcAck(false) {} }; - struct TEvFBoot : public TEventLocal<TEvFBoot, EvFBoot> { - // boot new round of follower + struct TEvFBoot : public TEventLocal<TEvFBoot, EvFBoot> { + // boot new round of follower const ui64 TabletID; - const ui32 FollowerID; + const ui32 FollowerID; const ui32 Generation; const TActorId Launcher; - // must be present one of: or loaded graph or snapshot follower update + // must be present one of: or loaded graph or snapshot follower update TIntrusivePtr<TDependencyGraph> DependencyGraph; - THolder<TFUpdateBody> Update; + THolder<TFUpdateBody> Update; TIntrusivePtr<TTabletStorageInfo> TabletStorageInfo; - TResourceProfilesPtr ResourceProfiles; - TSharedQuotaPtr TxCacheQuota; + TResourceProfilesPtr ResourceProfiles; + TSharedQuotaPtr TxCacheQuota; - TEvFBoot(ui64 tabletID, ui32 followerID, ui32 generation, TActorId launcher, const TEvFollowerUpdate &upd, - TIntrusivePtr<TTabletStorageInfo> info, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr) + TEvFBoot(ui64 tabletID, ui32 followerID, ui32 generation, TActorId launcher, const TEvFollowerUpdate &upd, + TIntrusivePtr<TTabletStorageInfo> info, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr) : TabletID(tabletID) - , FollowerID(followerID) + , FollowerID(followerID) , Generation(generation) , Launcher(launcher) - , Update(new TFUpdateBody(upd)) + , Update(new TFUpdateBody(upd)) , TabletStorageInfo(info) , ResourceProfiles(profiles) , TxCacheQuota(txCacheQuota) {} - TEvFBoot(ui64 tabletID, ui32 followerID, ui32 generation, TActorId launcher, TDependencyGraph *dependencyGraph, - TIntrusivePtr<TTabletStorageInfo> info, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr) + TEvFBoot(ui64 tabletID, ui32 followerID, ui32 generation, TActorId launcher, TDependencyGraph *dependencyGraph, + TIntrusivePtr<TTabletStorageInfo> info, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr) : TabletID(tabletID) - , FollowerID(followerID) + , FollowerID(followerID) , Generation(generation) , Launcher(launcher) , DependencyGraph(dependencyGraph) @@ -660,44 +660,44 @@ struct TEvTablet { {} }; - struct TEvFUpdate : public TEventLocal<TEvFUpdate, EvFUpdate> { - THolder<TFUpdateBody> Update; + struct TEvFUpdate : public TEventLocal<TEvFUpdate, EvFUpdate> { + THolder<TFUpdateBody> Update; - TEvFUpdate(const TEvFollowerUpdate &upd) - : Update(new TFUpdateBody(upd)) + TEvFUpdate(const TEvFollowerUpdate &upd) + : Update(new TFUpdateBody(upd)) {} }; - struct TEvFAuxUpdate : public TEventLocal<TEvFAuxUpdate, EvFAuxUpdate> { + struct TEvFAuxUpdate : public TEventLocal<TEvFAuxUpdate, EvFAuxUpdate> { const TString AuxUpdate; - TEvFAuxUpdate(const TString &auxUpdate) + TEvFAuxUpdate(const TString &auxUpdate) : AuxUpdate(auxUpdate) {} }; - struct TEvFollowerGcApplied : public TEventLocal<TEvFollowerGcApplied, EvFollowerGcApplied> { + struct TEvFollowerGcApplied : public TEventLocal<TEvFollowerGcApplied, EvFollowerGcApplied> { const ui64 TabletID; const ui32 Generation; const ui32 Step; - const TDuration FollowerSyncDelay; + const TDuration FollowerSyncDelay; - TEvFollowerGcApplied(ui64 tabletId, ui32 gen, ui32 step, TDuration followerSyncDelay) + TEvFollowerGcApplied(ui64 tabletId, ui32 gen, ui32 step, TDuration followerSyncDelay) : TabletID(tabletId) , Generation(gen) , Step(step) - , FollowerSyncDelay(followerSyncDelay) + , FollowerSyncDelay(followerSyncDelay) {} }; - struct TEvFollowerSyncComplete : public TEventLocal<TEvFollowerSyncComplete, EvFollowerSyncComplete> {}; + struct TEvFollowerSyncComplete : public TEventLocal<TEvFollowerSyncComplete, EvFollowerSyncComplete> {}; - struct TEvFGcAck : public TEventLocal<TEvFGcAck, EvFGcAck> { + struct TEvFGcAck : public TEventLocal<TEvFGcAck, EvFGcAck> { const ui64 TabletID; const ui32 Generation; const ui32 Step; - TEvFGcAck(ui64 tabletId, ui32 gen, ui32 step) + TEvFGcAck(ui64 tabletId, ui32 gen, ui32 step) : TabletID(tabletId) , Generation(gen) , Step(step) @@ -733,9 +733,9 @@ struct TEvTablet { }; struct TEvUpdateConfig : TEventLocal<TEvUpdateConfig, EvUpdateConfig> { - TResourceProfilesPtr ResourceProfiles; + TResourceProfilesPtr ResourceProfiles; - TEvUpdateConfig(TResourceProfilesPtr profiles) + TEvUpdateConfig(TResourceProfilesPtr profiles) : ResourceProfiles(profiles) {} }; diff --git a/ydb/core/base/tablet_killer.cpp b/ydb/core/base/tablet_killer.cpp index 0cc9fb2e834..d46e2c5c895 100644 --- a/ydb/core/base/tablet_killer.cpp +++ b/ydb/core/base/tablet_killer.cpp @@ -15,23 +15,23 @@ private: void Handle(TEvStateStorage::TEvInfo::TPtr &ev, const TActorContext &ctx) { TEvStateStorage::TEvInfo *msg = ev->Get(); - TActorId LeaderActor; + TActorId LeaderActor; if (NodeId == 0) { - LeaderActor = msg->CurrentLeader; + LeaderActor = msg->CurrentLeader; } else { - if (msg->CurrentLeader && msg->CurrentLeader.NodeId() == NodeId) { - LeaderActor = msg->CurrentLeader; + if (msg->CurrentLeader && msg->CurrentLeader.NodeId() == NodeId) { + LeaderActor = msg->CurrentLeader; } else { - for (const auto& pr : msg->Followers) { + for (const auto& pr : msg->Followers) { if (pr.first.NodeId() == NodeId) { - LeaderActor = pr.first; + LeaderActor = pr.first; break; } } } } - if (LeaderActor && msg->CurrentGeneration <= MaxGeneration) - ctx.Send(LeaderActor, new TEvents::TEvPoisonPill()); + if (LeaderActor && msg->CurrentGeneration <= MaxGeneration) + ctx.Send(LeaderActor, new TEvents::TEvPoisonPill()); return Die(ctx); } public: diff --git a/ydb/core/base/tablet_pipe.h b/ydb/core/base/tablet_pipe.h index 164aed2edfc..a0420b86724 100644 --- a/ydb/core/base/tablet_pipe.h +++ b/ydb/core/base/tablet_pipe.h @@ -54,13 +54,13 @@ namespace NKikimr { struct TEvConnectResult : public TEventPB<TEvConnectResult, NKikimrTabletPipe::TEvConnectResult, EvConnectResult> { TEvConnectResult() {} - TEvConnectResult(NKikimrProto::EReplyStatus status, ui64 tabletId, const TActorId& clientId, const TActorId& serverId, bool leader) + TEvConnectResult(NKikimrProto::EReplyStatus status, ui64 tabletId, const TActorId& clientId, const TActorId& serverId, bool leader) { Record.SetStatus(status); Record.SetTabletId(tabletId); ActorIdToProto(clientId, Record.MutableClientId()); ActorIdToProto(serverId, Record.MutableServerId()); - Record.SetLeader(leader); + Record.SetLeader(leader); } }; @@ -114,12 +114,12 @@ namespace NKikimr { }; struct TEvClientConnected : public TEventLocal<TEvClientConnected, EvClientConnected> { - TEvClientConnected(ui64 tabletId, NKikimrProto::EReplyStatus status, const TActorId& clientId, const TActorId& serverId, bool leader, bool dead) + TEvClientConnected(ui64 tabletId, NKikimrProto::EReplyStatus status, const TActorId& clientId, const TActorId& serverId, bool leader, bool dead) : TabletId(tabletId) , Status(status) , ClientId(clientId) , ServerId(serverId) - , Leader(leader) + , Leader(leader) , Dead(dead) {} @@ -127,7 +127,7 @@ namespace NKikimr { const NKikimrProto::EReplyStatus Status; const TActorId ClientId; const TActorId ServerId; - const bool Leader; + const bool Leader; const bool Dead; }; @@ -194,17 +194,17 @@ namespace NKikimr { }; struct TEvActivate : public TEventLocal<TEvActivate, EvActivate> { - TEvActivate(ui64 tabletId, const TActorId& ownerId, const TActorId& recipientId, bool leader) + TEvActivate(ui64 tabletId, const TActorId& ownerId, const TActorId& recipientId, bool leader) : TabletId(tabletId) , OwnerId(ownerId) , RecipientId(recipientId) - , Leader(leader) + , Leader(leader) {} const ui64 TabletId; const TActorId OwnerId; const TActorId RecipientId; - const bool Leader; + const bool Leader; }; struct TEvShutdown : public TEventLocal<TEvShutdown, EvShutdown> { @@ -282,10 +282,10 @@ namespace NKikimr { // Creates and activated server, returns serverId. // Created server will forward messages to the specified recipent. virtual TActorId Accept(TEvTabletPipe::TEvConnect::TPtr &ev, - TActorIdentity owner, TActorId recipient, bool leader = true) = 0; + TActorIdentity owner, TActorId recipient, bool leader = true) = 0; // Rejects connect with an error. - virtual void Reject(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, NKikimrProto::EReplyStatus status, bool leader = true) = 0; + virtual void Reject(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, NKikimrProto::EReplyStatus status, bool leader = true) = 0; // Stop all servers, gracefully notifying clients. virtual void Stop(TActorIdentity owner) = 0; @@ -299,7 +299,7 @@ namespace NKikimr { // Activates all inactive servers, created by Enqueue. // All activated servers will forward messages to the specified recipent. - virtual void Activate(TActorIdentity owner, TActorId recipientId, bool leader = true) = 0; + virtual void Activate(TActorIdentity owner, TActorId recipientId, bool leader = true) = 0; // Cleanup resources after reset virtual void Erase(TEvTabletPipe::TEvServerDestroyed::TPtr &ev) = 0; @@ -344,8 +344,8 @@ namespace NKikimr { struct TClientConfig { bool ConnectToUserTablet = false; - bool AllowFollower = false; - bool ForceFollower = false; + bool AllowFollower = false; + bool ForceFollower = false; bool ForceLocal = false; bool PreferLocal = false; bool CheckAliveness = false; @@ -387,7 +387,7 @@ namespace NKikimr { IActor* CreateServer(ui64 tabletId, const TActorId& clientId, const TActorId& interconnectSession, ui32 features, ui64 connectCookie); // Promotes server actor to the active state. - void ActivateServer(ui64 tabletId, TActorId serverId, TActorIdentity owner, TActorId recipientId, bool leader); + void ActivateServer(ui64 tabletId, TActorId serverId, TActorIdentity owner, TActorId recipientId, bool leader); // Destroys server actor. void CloseServer(TActorIdentity owner, TActorId serverId); diff --git a/ydb/core/base/tablet_pipecache.h b/ydb/core/base/tablet_pipecache.h index 8c4f9207180..d3a519c9bd5 100644 --- a/ydb/core/base/tablet_pipecache.h +++ b/ydb/core/base/tablet_pipecache.h @@ -92,6 +92,6 @@ struct TPipePeNodeCacheConfig : public TAtomicRefCount<TPipePeNodeCacheConfig>{ }; IActor* CreatePipePeNodeCache(const TIntrusivePtr<TPipePeNodeCacheConfig> &config); -TActorId MakePipePeNodeCacheID(bool allowFollower); +TActorId MakePipePeNodeCacheID(bool allowFollower); } diff --git a/ydb/core/base/tablet_resolver.h b/ydb/core/base/tablet_resolver.h index 2ebfd73a6fb..24744cef478 100644 --- a/ydb/core/base/tablet_resolver.h +++ b/ydb/core/base/tablet_resolver.h @@ -35,23 +35,23 @@ struct TEvTabletResolver { struct TResolveFlags { EResolvePrio LocalNodePrio; EResolvePrio LocalDcPrio; - EResolvePrio FollowerPrio; + EResolvePrio FollowerPrio; TResolveFlags() : LocalNodePrio(EResolvePrio::ResPrioAllow) , LocalDcPrio(EResolvePrio::ResPrioPrefer) - , FollowerPrio(EResolvePrio::ResPrioDisallow) + , FollowerPrio(EResolvePrio::ResPrioDisallow) {} static constexpr ui32 MaxTabletPriority() { return 4; } - ui32 GetTabletPriority(bool isLocalNode, bool isLocalDc, bool isFollower) const { + ui32 GetTabletPriority(bool isLocalNode, bool isLocalDc, bool isFollower) const { if (isLocalNode && (LocalNodePrio == EResolvePrio::ResPrioDisallow) || isLocalDc && (LocalDcPrio == EResolvePrio::ResPrioDisallow) || - isFollower && (FollowerPrio == EResolvePrio::ResPrioDisallow) || + isFollower && (FollowerPrio == EResolvePrio::ResPrioDisallow) || !isLocalNode && (LocalNodePrio == EResolvePrio::ResPrioForce) || !isLocalDc && (LocalDcPrio == EResolvePrio::ResPrioForce) || - !isFollower && (FollowerPrio == EResolvePrio::ResPrioForce)) + !isFollower && (FollowerPrio == EResolvePrio::ResPrioForce)) { return 0; } @@ -61,22 +61,22 @@ struct TEvTabletResolver { prio |= 2; if (isLocalDc && (LocalDcPrio == EResolvePrio::ResPrioPrefer)) prio |= 8; - if (isFollower && (FollowerPrio == EResolvePrio::ResPrioPrefer)) + if (isFollower && (FollowerPrio == EResolvePrio::ResPrioPrefer)) prio |= 4; return prio; } - bool AllowFollower() const { return FollowerPrio != EResolvePrio::ResPrioDisallow; } + bool AllowFollower() const { return FollowerPrio != EResolvePrio::ResPrioDisallow; } - void SetAllowFollower(bool flag, bool allowMeansPrefer = true) { - FollowerPrio = EResolvePrio::ResPrioDisallow; + void SetAllowFollower(bool flag, bool allowMeansPrefer = true) { + FollowerPrio = EResolvePrio::ResPrioDisallow; if (flag) - FollowerPrio = (allowMeansPrefer ? EResolvePrio::ResPrioPrefer : EResolvePrio::ResPrioAllow); + FollowerPrio = (allowMeansPrefer ? EResolvePrio::ResPrioPrefer : EResolvePrio::ResPrioAllow); } - void SetForceFollower(bool flag) { + void SetForceFollower(bool flag) { if (flag) - FollowerPrio = EResolvePrio::ResPrioForce; + FollowerPrio = EResolvePrio::ResPrioForce; } void SetPreferLocal(bool flag) { @@ -93,7 +93,7 @@ struct TEvTabletResolver { TStringStream str; str << (ui32) LocalNodePrio << ':' << (ui32) LocalDcPrio << ':' - << (ui32) FollowerPrio; + << (ui32) FollowerPrio; return str.Str(); } }; diff --git a/ydb/core/blobstorage/base/blobstorage_events.h b/ydb/core/blobstorage/base/blobstorage_events.h index 6022321bb7b..ef170a085d8 100644 --- a/ydb/core/blobstorage/base/blobstorage_events.h +++ b/ydb/core/blobstorage/base/blobstorage_events.h @@ -281,9 +281,9 @@ namespace NKikimr { Record.SetNodeId(nodeId); Record.SetGroupId(groupId); Record.SetLifeCyclePhase(lifeCyclePhase); - Record.SetMainKeyId(mainKeyId); + Record.SetMainKeyId(mainKeyId); Record.SetEncryptedGroupKey(encryptedGroupKey); - Record.SetMainKeyVersion(mainKeyVersion); + Record.SetMainKeyVersion(mainKeyVersion); Record.SetGroupKeyNonce(groupKeyNonce); } @@ -429,12 +429,12 @@ namespace NKikimr { struct TEvBlobStorage::TEvRestartPDisk : TEventLocal<TEvRestartPDisk, EvRestartPDisk> { const ui32 PDiskId; - NPDisk::TKey MainKey; + NPDisk::TKey MainKey; TIntrusivePtr<TPDiskConfig> Config; TEvRestartPDisk(const ui32& pdiskId, const NPDisk::TKey& mainKey, const TIntrusivePtr<TPDiskConfig>& config) : PDiskId(pdiskId) - , MainKey(mainKey) + , MainKey(mainKey) , Config(config) {} }; diff --git a/ydb/core/blobstorage/docs/blob_encryption_v1.graphml b/ydb/core/blobstorage/docs/blob_encryption_v1.graphml index d60f059cf03..e321e25fa34 100644 --- a/ydb/core/blobstorage/docs/blob_encryption_v1.graphml +++ b/ydb/core/blobstorage/docs/blob_encryption_v1.graphml @@ -177,8 +177,8 @@ CypherText=E(Kblob, PlainText)<y:LabelModel><y:SmartNodeLabelModel distance="4.0 <y:Fill color="#FFFF99" color2="#FFFF99" transparent="false"/> <y:BorderStyle color="#000000" type="line" width="1.0"/> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="46.3984375" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="159.361328125" x="4.8193359375" xml:space="preserve" y="8.30078125">Прочесть из файла -KtenantLeader, -Ktenant=H(KtenantLeader)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> +KtenantLeader, +Ktenant=H(KtenantLeader)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> </y:GenericNode> </data> </node> diff --git a/ydb/core/blobstorage/docs/blob_encryption_v2.graphml b/ydb/core/blobstorage/docs/blob_encryption_v2.graphml index 6d617a46a20..2b01d5c88f5 100644 --- a/ydb/core/blobstorage/docs/blob_encryption_v2.graphml +++ b/ydb/core/blobstorage/docs/blob_encryption_v2.graphml @@ -393,7 +393,7 @@ KgroupTenant<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel> <y:Fill color="#FFFF99" color2="#FFFF99" transparent="false"/> <y:BorderStyle color="#000000" type="line" width="1.0"/> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="32.265625" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="182.623046875" x="6.237225160835806" xml:space="preserve" y="0.8756264280420964">Отправить шифрованый ключ -C0=E(KtenantLeader, Ktenant)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> +C0=E(KtenantLeader, Ktenant)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> </y:GenericNode> </data> </node> @@ -440,7 +440,7 @@ C0=E(KtenantLeader, Ktenant)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/ <y:BorderStyle color="#000000" type="line" width="1.0"/> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="46.3984375" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="115.568359375" x="15.974417102011103" xml:space="preserve" y="1.3007812500001137">Вернуть Ktenant=D( -KtenantLeader, C0)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> +KtenantLeader, C0)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> </y:GenericNode> </data> </node> @@ -452,7 +452,7 @@ KtenantLeader, C0)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:Label <y:Fill color="#FFFF99" color2="#FFFF99" transparent="false"/> <y:BorderStyle color="#000000" type="line" width="1.0"/> <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="32.265625" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="183.015625" x="6.040936098335806" xml:space="preserve" y="8.3671875">Расшифровать -Ktenant=D(KtenantLeader, C0)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> +Ktenant=D(KtenantLeader, C0)<y:LabelModel><y:SmartNodeLabelModel distance="4.0"/></y:LabelModel><y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel> </y:GenericNode> </data> </node> diff --git a/ydb/core/blobstorage/dsproxy/dsproxy.h b/ydb/core/blobstorage/dsproxy/dsproxy.h index 3e9d377f4b5..27592e971f9 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy.h @@ -451,11 +451,11 @@ public: Derived().Send(proxyId, new TEvLatencyReport(*LatencyQueueKind, now - RequestStartTime)); } - // KIKIMR-6737 + // KIKIMR-6737 if (ev->Type() == TEvBlobStorage::EvGetResult) { static_cast<TEvBlobStorage::TEvGetResult&>(*ev).Sent = now; - } - + } + // send the reply to original request sender Derived().Send(source, ev.release(), 0, cookie, std::move(traceId)); }; diff --git a/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp b/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp index aeaceae687f..13b1bec3563 100644 --- a/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp +++ b/ydb/core/blobstorage/dsproxy/ut_fat/dsproxy_ut.cpp @@ -4194,8 +4194,8 @@ public: setup1->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(env->ProxyId, bsproxySetup)); TTempDir tempDir; - NPDisk::TKey mainKey = 123; - NPDisk::TKey badMainKey = 124; + NPDisk::TKey mainKey = 123; + NPDisk::TKey badMainKey = 124; for (ui32 failDomainIdx = 0; failDomainIdx < env->FailDomainCount; ++failDomainIdx) { for (ui32 driveIdx = 0; driveIdx < env->DrivesPerFailDomain; ++driveIdx) { ui32 i = env->GetVDiskTestIdx(failDomainIdx, driveIdx); @@ -4217,7 +4217,7 @@ public: if (!SectorMapByPath[filePath]) { SectorMapByPath[filePath].Reset(new NPDisk::TSectorMap(diskSizeBytes)); FormatPDisk(filePath, diskSizeBytes, 4 << 10, chunkSize, pDiskGuid, - 0x123, 0x456, 0x789, isBad ? badMainKey : mainKey, "", false, false, + 0x123, 0x456, 0x789, isBad ? badMainKey : mainKey, "", false, false, SectorMapByPath[filePath]); } @@ -4228,14 +4228,14 @@ public: pDiskConfig->EnableSectorEncryption = !pDiskConfig->SectorMap; TActorSetupCmd pDiskSetup( - CreatePDisk(pDiskConfig.Get(), mainKey, counters), + CreatePDisk(pDiskConfig.Get(), mainKey, counters), TMailboxType::Revolving, 0); setup2->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(pdiskId, pDiskSetup)); TVDiskConfig::TBaseInfo baseInfo( env->VDiskIds[i], pdiskId, - mainKey, + mainKey, i + 1, args.DeviceType, 0, diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp index fbf4895b9fd..054d5be6653 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp @@ -711,7 +711,7 @@ TIntrusivePtr<TBlobStorageGroupInfo> TBlobStorageGroupInfo::Parse(const NKikimrB } bool TBlobStorageGroupInfo::DecryptGroupKey(TBlobStorageGroupInfo::EEncryptionMode encryptionMode, - const TString& /*mainKeyId*/, const TString& encryptedGroupKey, ui64 groupKeyNonce, const TCypherKey& tenantKey, + const TString& /*mainKeyId*/, const TString& encryptedGroupKey, ui64 groupKeyNonce, const TCypherKey& tenantKey, TCypherKey *outGroupKey, ui32 groupId) { switch (encryptionMode) { case TBlobStorageGroupInfo::EEM_NONE: diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h index 83d0b165904..e2d1445be4e 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h @@ -316,7 +316,7 @@ public: static TIntrusivePtr<TBlobStorageGroupInfo> Parse(const NKikimrBlobStorage::TGroupInfo& group, const TEncryptionKey *key, IOutputStream *err); - static bool DecryptGroupKey(TBlobStorageGroupInfo::EEncryptionMode encryptionMode, const TString& mainKeyId, + static bool DecryptGroupKey(TBlobStorageGroupInfo::EEncryptionMode encryptionMode, const TString& mainKeyId, const TString& encryptedGroupKey, ui64 groupKeyNonce, const TCypherKey& tenantKey, TCypherKey *outGroupKey, ui32 groupId); diff --git a/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp b/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp index 8d273b8ed71..e3c74cce7b4 100644 --- a/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp +++ b/ydb/core/blobstorage/nodewarden/blobstorage_node_warden_ut.cpp @@ -256,7 +256,7 @@ void SetupServices(TTestActorRuntime &runtime, TString extraPath, TIntrusivePtr< } ui64 defaultStateStorageGroup = runtime.GetAppData(0).DomainsInfo->GetDefaultStateStorageGroup(DOMAIN_ID); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(defaultStateStorageGroup), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(defaultStateStorageGroup), TTabletTypes::FLAT_BS_CONTROLLER, TBlobStorageGroupType::ErasureMirror3, groupId), &CreateFlatBsController); @@ -477,7 +477,7 @@ Y_UNIT_TEST_SUITE(TBlobStorageWardenTest) { BlockGroup(runtime, sender0, tabletId, groupId, generation++, true); auto stateStorage = runtime.GetAppData().DomainsInfo->GetDefaultStateStorageGroup(DOMAIN_ID); - RebootTablet(runtime, MakeBSControllerID(stateStorage), sender0, sender0.NodeId() - runtime.GetNodeId(0)); + RebootTablet(runtime, MakeBSControllerID(stateStorage), sender0, sender0.NodeId() - runtime.GetNodeId(0)); ++generation; BlockGroup(runtime, sender0, tabletId, groupId, generation++, true, NKikimrProto::EReplyStatus::NO_GROUP); diff --git a/ydb/core/blobstorage/nodewarden/ut_sequence/dsproxy_config_retrieval.cpp b/ydb/core/blobstorage/nodewarden/ut_sequence/dsproxy_config_retrieval.cpp index 498f4b6e7fa..040411e06c3 100644 --- a/ydb/core/blobstorage/nodewarden/ut_sequence/dsproxy_config_retrieval.cpp +++ b/ydb/core/blobstorage/nodewarden/ut_sequence/dsproxy_config_retrieval.cpp @@ -79,7 +79,7 @@ void SetupServices(TTestBasicRuntime& runtime) { runtime.Initialize(app.Unwrap()); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); // setup box and storage pool for testing { diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk.h index c244ab6d341..8e722ce42a0 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk.h @@ -16,7 +16,7 @@ namespace NKikimr { -IActor* CreatePDisk(const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, +IActor* CreatePDisk(const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, const TIntrusivePtr<NMonitoring::TDynamicCounters>& counters); namespace NPDisk { diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp index 6052dda71ec..d92b19c6cca 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp @@ -68,7 +68,7 @@ class TPDiskActor : public TActorBootstrapped<TPDiskActor> { TString StateErrorReason; TIntrusivePtr<TPDiskConfig> Cfg; - TKey MainKey; + TKey MainKey; TList<TInitQueueItem> InitQueue; const TIntrusivePtr<NMonitoring::TDynamicCounters> PDiskCounters; TIntrusivePtr<TPDisk> PDisk; @@ -196,10 +196,10 @@ public: return NKikimrServices::TActivity::PDISK_ACTOR; } - TPDiskActor(const TIntrusivePtr<TPDiskConfig>& cfg, const NPDisk::TKey &mainKey, + TPDiskActor(const TIntrusivePtr<TPDiskConfig>& cfg, const NPDisk::TKey &mainKey, const TIntrusivePtr<NMonitoring::TDynamicCounters>& counters) : Cfg(cfg) - , MainKey(mainKey) + , MainKey(mainKey) , PDiskCounters(GetServiceCounters(counters, "pdisks") ->GetSubgroup("pdisk", Sprintf("%09" PRIu32, (ui32)cfg->PDiskId)) ->GetSubgroup("media", to_lower(cfg->PDiskCategory.TypeStrShort()))) @@ -359,7 +359,7 @@ public: try { FormatPDisk(cfg->GetDevicePath(), 0, cfg->SectorSize, cfg->ChunkSize, - cfg->PDiskGuid, chunkKey, logKey, sysLogKey, actor->MainKey, TString(), false, + cfg->PDiskGuid, chunkKey, logKey, sysLogKey, actor->MainKey, TString(), false, cfg->FeatureFlags.GetTrimEntireDeviceOnStartup(), cfg->SectorMap); actorSystem->Send(pDiskActor, new TEvPDiskFormattingFinished(true, "")); } catch (yexception ex) { @@ -372,7 +372,7 @@ public: FormattingThread->Start(); } else { - SecureWipeBuffer((ui8*)&MainKey, sizeof(MainKey)); + SecureWipeBuffer((ui8*)&MainKey, sizeof(MainKey)); *PDisk->Mon.PDiskState = NKikimrBlobStorage::TPDiskState::InitialFormatReadError; *PDisk->Mon.PDiskBriefState = TPDiskMon::TPDisk::Error; *PDisk->Mon.PDiskDetailedState = TPDiskMon::TPDisk::ErrorPDiskCannotBeInitialised; @@ -395,13 +395,13 @@ public: ui8 *formatSectors = ev->Get()->FormatSectors.Get(); ui32 formatSectorsSize = ev->Get()->FormatSectorsSize; NSan::CheckMemIsInitialized(formatSectors, formatSectorsSize); - bool isFormatOk = PDisk->ReadChunk0Format(formatSectors, MainKey); + bool isFormatOk = PDisk->ReadChunk0Format(formatSectors, MainKey); if (!isFormatOk) { *PDisk->Mon.PDiskDetailedState = TPDiskMon::TPDisk::BootingFormatMagicChecking; PDisk->ErrorStr = "Format is not Ok, now checking for proper magic sector on disk"; CheckMagicSector(formatSectors, formatSectorsSize); } else { - SecureWipeBuffer((ui8*)&MainKey, sizeof(MainKey)); + SecureWipeBuffer((ui8*)&MainKey, sizeof(MainKey)); // Format is read OK LOG_NOTICE_S(*TlsActivationContext, NKikimrServices::BS_PDISK, "PDiskId# " << PDisk->PDiskId << " Successfully read format record# " << PDisk->Format.ToString()); @@ -629,9 +629,9 @@ public: switch (evControl.Action) { case TEvYardControl::PDiskStart: { - auto *mainKey = static_cast<const NPDisk::TKey*>(evControl.Cookie); - Y_VERIFY(mainKey); - MainKey = *mainKey; + auto *mainKey = static_cast<const NPDisk::TKey*>(evControl.Cookie); + Y_VERIFY(mainKey); + MainKey = *mainKey; StartPDiskThread(); ControledStartResult = MakeHolder<IEventHandle>(ev->Sender, SelfId(), new TEvYardControlResult(NKikimrProto::OK, evControl.Cookie, {})); @@ -864,8 +864,8 @@ public: return; } - MainKey = ev->Get()->MainKey; - SecureWipeBuffer((ui8*)&ev->Get()->MainKey, sizeof(ev->Get()->MainKey)); + MainKey = ev->Get()->MainKey; + SecureWipeBuffer((ui8*)&ev->Get()->MainKey, sizeof(ev->Get()->MainKey)); LOG_NOTICE_S(*TlsActivationContext, NKikimrServices::BS_PDISK, "PDiskId# " << PDisk->PDiskId << " Going to restart PDisk since recieved TEvRestartPDisk"); PDisk->Stop(); @@ -1077,15 +1077,15 @@ public: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // PDisk Creation //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -IActor* CreatePDisk(const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, +IActor* CreatePDisk(const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, const TIntrusivePtr<NMonitoring::TDynamicCounters>& counters) { - return new NPDisk::TPDiskActor(cfg, mainKey, counters); + return new NPDisk::TPDiskActor(cfg, mainKey, counters); } void TRealPDiskServiceFactory::Create(const TActorContext &ctx, ui32 pDiskID, - const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) { + const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) { TActorId actorId = ctx.ExecutorThread.RegisterActor( - CreatePDisk(cfg, mainKey, AppData(ctx)->Counters), TMailboxType::ReadAsFilled, poolId); + CreatePDisk(cfg, mainKey, AppData(ctx)->Counters), TMailboxType::ReadAsFilled, poolId); TActorId pDiskServiceId = MakeBlobStoragePDiskID(nodeId, pDiskID); ctx.ExecutorThread.ActorSystem->RegisterLocalService(pDiskServiceId, actorId); } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_factory.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_factory.h index 7265c47e4d5..6d472eab412 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_factory.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_factory.h @@ -13,13 +13,13 @@ namespace NKikimr { class IPDiskServiceFactory : public TThrRefBase { public: virtual void Create(const TActorContext &ctx, ui32 pDiskID, const TIntrusivePtr<TPDiskConfig> &cfg, - const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) = 0; + const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) = 0; }; class TRealPDiskServiceFactory : public IPDiskServiceFactory { public: void Create(const TActorContext &ctx, ui32 pDiskID, const TIntrusivePtr<TPDiskConfig> &cfg, - const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) override; + const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) override; }; } // NKikimr diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp index b6f04bf8f82..d00fc0f2203 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp @@ -100,10 +100,10 @@ TString TPDisk::DynamicStateToString(bool isMultiline) { return str.Str(); } -bool TPDisk::ReadChunk0Format(ui8* formatSectors, const TKey& mainKey) { +bool TPDisk::ReadChunk0Format(ui8* formatSectors, const TKey& mainKey) { TGuard<TMutex> guard(StateMutex); TPDiskStreamCypher cypher(true); // Format record is always encrypted - cypher.SetKey(mainKey); + cypher.SetKey(mainKey); Format.SectorSize = FormatSectorSize; ui32 lastGoodIdx = (ui32)-1; @@ -1280,7 +1280,7 @@ void TPDisk::CommitLogChunks(TCommitLogChunks &req) { // PDisk formatting //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void TPDisk::WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey) { +void TPDisk::WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey) { // Use temporal copy of format to restore from that copy because we can damage 'format' variable // by writing Magic in first bytes const TDiskFormat originalFormat = format; @@ -1290,10 +1290,10 @@ void TPDisk::WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey) { { - // Encrypt chunk0 format record using mainKey + // Encrypt chunk0 format record using mainKey ui64 nonce = 1; - bool encrypt = true; // Always write encrypter format because some tests use wrong main key to initiate errors - TSysLogWriter formatWriter(Mon, *BlockDevice.Get(), Format, nonce, mainKey, BufferPool.Get(), + bool encrypt = true; // Always write encrypter format because some tests use wrong main key to initiate errors + TSysLogWriter formatWriter(Mon, *BlockDevice.Get(), Format, nonce, mainKey, BufferPool.Get(), 0, ReplicationFactor, Format.MagicFormatChunk, 0, nullptr, 0, nullptr, ActorSystem, PDiskId, &DriveModel, Cfg->UseT1ha0HashInFooter, encrypt); @@ -1316,7 +1316,7 @@ void TPDisk::WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey) { void TPDisk::WriteDiskFormat(ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 userAccessibleChunkSizeBytes, - const ui64 &diskGuid, const TKey &chunkKey, const TKey &logKey, const TKey &sysLogKey, const TKey &mainKey, + const ui64 &diskGuid, const TKey &chunkKey, const TKey &logKey, const TKey &sysLogKey, const TKey &mainKey, TString textMessage, const bool isErasureEncodeUserLog, const bool trimEntireDevice) { TGuard<TMutex> guard(StateMutex); // Prepare format record @@ -1365,7 +1365,7 @@ void TPDisk::WriteDiskFormat(ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 user // Write and apply format record with magic in first bytes format.SetFormatInProgress(true); format.SetHash(); - WriteApplyFormatRecord(format, mainKey); + WriteApplyFormatRecord(format, mainKey); // Prepare initial SysLogRecord memset(&SysLogRecord, 0, sizeof(SysLogRecord)); @@ -1398,7 +1398,7 @@ void TPDisk::WriteDiskFormat(ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 user // Write and apply format record format.SetFormatInProgress(false); format.SetHash(); - WriteApplyFormatRecord(format, mainKey); + WriteApplyFormatRecord(format, mainKey); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h index ec77e55f235..a9b910cb0c1 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h @@ -178,7 +178,7 @@ public: // Initialization TPDisk(const TIntrusivePtr<TPDiskConfig> cfg, const TIntrusivePtr<NMonitoring::TDynamicCounters>& counters); TString DynamicStateToString(bool isMultiline); - bool ReadChunk0Format(ui8* formatSectors, const TKey& mainKey); // Called by actor + bool ReadChunk0Format(ui8* formatSectors, const TKey& mainKey); // Called by actor bool IsFormatMagicValid(ui8 *magicData, ui32 magicDataSize); // Called by actor bool CheckGuid(TString *outReason); // Called by actor bool CheckFormatComplete(); // Called by actor @@ -285,9 +285,9 @@ public: void EventUndelivered(TUndelivered &req); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // PDisk formatting - void WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey); + void WriteApplyFormatRecord(TDiskFormat format, const TKey &mainKey); void WriteDiskFormat(ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 userAccessibleChunkSizeBytes, const ui64 &diskGuid, - const TKey &chunkKey, const TKey &logKey, const TKey &sysLogKey, const TKey &mainKey, + const TKey &chunkKey, const TKey &logKey, const TKey &sysLogKey, const TKey &mainKey, TString textMessage, const bool isErasureEncodeUserLog, const bool trimEntireDevice); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Owner initialization diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.cpp index f8a04562d78..152deec9997 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.cpp @@ -51,7 +51,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void FormatPDisk(TString path, ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 userAccessibleChunkSizeBytes, const ui64 &diskGuid, const NPDisk::TKey &chunkKey, const NPDisk::TKey &logKey, const NPDisk::TKey &sysLogKey, - const NPDisk::TKey &mainKey, TString textMessage, const bool isErasureEncodeUserLog, bool trimEntireDevice, + const NPDisk::TKey &mainKey, TString textMessage, const bool isErasureEncodeUserLog, bool trimEntireDevice, TIntrusivePtr<NPDisk::TSectorMap> sectorMap) { TActorSystemCreator creator; @@ -110,10 +110,10 @@ void FormatPDisk(TString path, ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 us ythrow yexception() << "Device with path# " << path << " is not good, info# " << pDisk->BlockDevice->DebugInfo(); } pDisk->WriteDiskFormat(diskSizeBytes, sectorSizeBytes, userAccessibleChunkSizeBytes, diskGuid, - chunkKey, logKey, sysLogKey, mainKey, textMessage, isErasureEncodeUserLog, trimEntireDevice); + chunkKey, logKey, sysLogKey, mainKey, textMessage, isErasureEncodeUserLog, trimEntireDevice); } -bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDiskInfo &outInfo, +bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDiskInfo &outInfo, const bool doLock, TIntrusivePtr<NPDisk::TSectorMap> sectorMap) { const TIntrusivePtr<NMonitoring::TDynamicCounters> counters(new NMonitoring::TDynamicCounters); auto mon = std::make_unique<TPDiskMon>(counters, 0, nullptr); @@ -148,7 +148,7 @@ bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDis NPDisk::TReqId(NPDisk::TReqId::ReadFormatInfo, 0), {}); NPDisk::TPDiskStreamCypher cypher(true); // Format record is always encrypted - cypher.SetKey(mainKey); + cypher.SetKey(mainKey); bool isOk = false; alignas(16) NPDisk::TDiskFormat format; for (ui32 recordIdx = 0; recordIdx < NPDisk::ReplicationFactor; ++recordIdx) { @@ -216,7 +216,7 @@ bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDis } TStringStream str; - str << "Error parsing format record, make sure you use the correct MainKey. Path# \"" << path << "\""; + str << "Error parsing format record, make sure you use the correct MainKey. Path# \"" << path << "\""; outInfo.ErrorReason = str.Str(); return false; } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.h index f09f2e958ca..89b8f6418e9 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_tools.h @@ -42,11 +42,11 @@ void ObliterateDisk(TString path); void FormatPDisk(TString path, ui64 diskSizeBytes, ui32 sectorSizeBytes, ui32 userAccessibleChunkSizeBytes, const ui64 &diskGuid, const NPDisk::TKey &chunkKey, const NPDisk::TKey &logKey, - const NPDisk::TKey &sysLogKey, const NPDisk::TKey &mainKey, TString textMessage, + const NPDisk::TKey &sysLogKey, const NPDisk::TKey &mainKey, TString textMessage, const bool isErasureEncodeUserLog = false, const bool trimEntireDevice = false, TIntrusivePtr<NPDisk::TSectorMap> sectorMap = nullptr); -bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDiskInfo &outInfo, +bool ReadPDiskFormatInfo(const TString &path, const NPDisk::TKey &mainKey, TPDiskInfo &outInfo, const bool doLock = false, TIntrusivePtr<NPDisk::TSectorMap> sectorMap = nullptr); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp index 4a29805225a..b49b5bd206f 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp @@ -100,7 +100,7 @@ public: } auto mainCounters = TIntrusivePtr<NMonitoring::TDynamicCounters>(new NMonitoring::TDynamicCounters()); - IActor* pDiskActor = CreatePDisk(cfg.Get(), MainKey, mainCounters); + IActor* pDiskActor = CreatePDisk(cfg.Get(), MainKey, mainCounters); PDiskActor = Runtime->Register(pDiskActor); } @@ -112,7 +112,7 @@ public: if (!PDisk) { // To be sure that pdisk actor is in StateOnline TestResponce<NPDisk::TEvYardControlResult>( - new NPDisk::TEvYardControl(NPDisk::TEvYardControl::PDiskStart, &MainKey), + new NPDisk::TEvYardControl(NPDisk::TEvYardControl::PDiskStart, &MainKey), NKikimrProto::OK); const auto evControlRes = TestResponce<NPDisk::TEvYardControlResult>( @@ -211,7 +211,7 @@ public: new NPDisk::TEvYardInit(3, vDiskID, testCtx.TestCtx.PDiskGuid), NKikimrProto::CORRUPTED); testCtx.TestResponce<NPDisk::TEvYardControlResult>( - new NPDisk::TEvYardControl(NPDisk::TEvYardControl::PDiskStart, reinterpret_cast<void*>(&testCtx.MainKey)), + new NPDisk::TEvYardControl(NPDisk::TEvYardControl::PDiskStart, reinterpret_cast<void*>(&testCtx.MainKey)), NKikimrProto::OK); testCtx.TestResponce<NPDisk::TEvYardInitResult>( new NPDisk::TEvYardInit(3, vDiskID, testCtx.TestCtx.PDiskGuid), diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/env.h b/ydb/core/blobstorage/ut_blobstorage/lib/env.h index 5baf3edec56..1cc05f00bf0 100644 --- a/ydb/core/blobstorage/ut_blobstorage/lib/env.h +++ b/ydb/core/blobstorage/ut_blobstorage/lib/env.h @@ -42,7 +42,7 @@ struct TEnvironmentSetup { {} void Create(const TActorContext& ctx, ui32 pdiskId, const TIntrusivePtr<TPDiskConfig>& cfg, - const NPDisk::TKey& /*mainKey*/, ui32 poolId, ui32 nodeId) override { + const NPDisk::TKey& /*mainKey*/, ui32 poolId, ui32 nodeId) override { const auto key = std::make_pair(nodeId, pdiskId); TIntrusivePtr<TPDiskMockState>& state = Env.PDiskMockStates[key]; if (!state) { @@ -262,8 +262,8 @@ struct TEnvironmentSetup { } void SetupTablet() { - Runtime->CreateTestBootstrapper( - TTestActorSystem::CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, Settings.Erasure.GetErasure(), GroupId), + Runtime->CreateTestBootstrapper( + TTestActorSystem::CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, Settings.Erasure.GetErasure(), GroupId), &CreateFlatBsController, Settings.ControllerNodeId); diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.cpp b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.cpp index 00188678c43..cc24115b3f0 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.cpp @@ -26,7 +26,7 @@ namespace NKikimr { NMonitoring::TDynamicCounters::TCounterPtr MovedPatchResMsgsPtr; TEvBlobStorage::TEvVMovedPatch::TPtr Event; - TActorId LeaderId; + TActorId LeaderId; TOutOfSpaceStatus OOSStatus; @@ -38,14 +38,14 @@ namespace NKikimr { TVDiskContextPtr VCtx; public: - TVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMovedPatch::TPtr &ev, + TVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMovedPatch::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr movedPatchResMsgsPtr, ui64 incarnationGuid, const TVDiskContextPtr &vCtx) : TActorBootstrapped() , SkeletonFrontIDPtr(skeletonFrontIDPtr) , MovedPatchResMsgsPtr(movedPatchResMsgsPtr) , Event(ev) - , LeaderId(leaderId) + , LeaderId(leaderId) , OOSStatus(oosStatus) , IncarnationGuid(incarnationGuid) , VCtx(vCtx) @@ -196,12 +196,12 @@ namespace NKikimr { } // NPrivate - IActor* CreateSkeletonVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, + IActor* CreateSkeletonVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMovedPatch::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr counterPtr, ui64 incarnationGuid, const TVDiskContextPtr &vCtx) { - return new NPrivate::TVMovedPatchActor(leaderId, oosStatus, ev, skeletonFrontIDPtr, + return new NPrivate::TVMovedPatchActor(leaderId, oosStatus, ev, skeletonFrontIDPtr, counterPtr, incarnationGuid, vCtx); } diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.h b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.h index b6f5ef15fd5..91f8109385b 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.h +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmovedpatch_actor.h @@ -6,7 +6,7 @@ namespace NKikimr { -IActor* CreateSkeletonVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, +IActor* CreateSkeletonVMovedPatchActor(TActorId leaderId, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMovedPatch::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr multiPutResMsgsPtr, ui64 incarnationGuid, const TVDiskContextPtr &vCtx); diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.cpp b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.cpp index 75529d677de..ac7dcd7d58a 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.cpp @@ -38,13 +38,13 @@ namespace NKikimr { NMonitoring::TDynamicCounters::TCounterPtr MultiPutResMsgsPtr; TEvBlobStorage::TEvVMultiPut::TPtr Event; - TActorId LeaderId; + TActorId LeaderId; TOutOfSpaceStatus OOSStatus; const ui64 IncarnationGuid; public: - TBufferVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, + TBufferVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMultiPut::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr multiPutResMsgsPtr, ui64 incarnationGuid) @@ -54,7 +54,7 @@ namespace NKikimr { , SkeletonFrontIDPtr(skeletonFrontIDPtr) , MultiPutResMsgsPtr(multiPutResMsgsPtr) , Event(ev) - , LeaderId(leaderId) + , LeaderId(leaderId) , OOSStatus(oosStatus) , IncarnationGuid(incarnationGuid) { @@ -172,11 +172,11 @@ namespace NKikimr { } // NPrivate - IActor* CreateSkeletonVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, + IActor* CreateSkeletonVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMultiPut::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr counterPtr, ui64 incarnationGuid) { - return new NPrivate::TBufferVMultiPutActor(leaderId, statuses, oosStatus, ev, + return new NPrivate::TBufferVMultiPutActor(leaderId, statuses, oosStatus, ev, skeletonFrontIDPtr, counterPtr, incarnationGuid); } diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.h b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.h index 687de4b920b..1eebe004567 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.h +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.h @@ -23,7 +23,7 @@ struct TEvVMultiPutItemResult : TEventLocal<TEvVMultiPutItemResult, TEvBlobStora {} }; -IActor* CreateSkeletonVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, +IActor* CreateSkeletonVMultiPutActor(TActorId leaderId, const TBatchedVec<NKikimrProto::EReplyStatus> &statuses, TOutOfSpaceStatus oosStatus, TEvBlobStorage::TEvVMultiPut::TPtr &ev, TActorIDPtr skeletonFrontIDPtr, NMonitoring::TDynamicCounters::TCounterPtr multiPutResMsgsPtr, ui64 incarnationGuid); diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.cpp b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.cpp index 4b89e94778a..b04e8d6d8fe 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.cpp @@ -95,7 +95,7 @@ namespace NKikimr::NPrivate { const TIntrusivePtr<TVPatchCtx> VPatchCtx; TString VDiskLogPrefix; - TActorId LeaderId; + TActorId LeaderId; const ui64 IncarnationGuid; @@ -117,7 +117,7 @@ namespace NKikimr::NPrivate { ui64 WaitedXorDiffCount = 0; public: - TSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, + TSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, TEvBlobStorage::TEvVPatchStart::TPtr &ev, TInstant now, TActorIDPtr skeletonFrontIDPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchFoundPartsMsgsPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchResMsgsPtr, @@ -130,7 +130,7 @@ namespace NKikimr::NPrivate { , VPatchResMsgsPtr(vPatchResMsgsPtr) , VPatchCtx(vPatchCtx) , VDiskLogPrefix(vDiskLogPrefix) - , LeaderId(leaderId) + , LeaderId(leaderId) , IncarnationGuid(incarnationGuid) , GType(gType) { @@ -585,7 +585,7 @@ namespace NKikimr::NPrivate { } void ConfirmDying(bool forceDeath) { - Send(LeaderId, new TEvVPatchDyingRequest(PatchedBlobId)); + Send(LeaderId, new TEvVPatchDyingRequest(PatchedBlobId)); if (forceDeath) { PassAway(); } else { @@ -670,13 +670,13 @@ namespace NKikimr::NPrivate { namespace NKikimr { - IActor* CreateSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, + IActor* CreateSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, TEvBlobStorage::TEvVPatchStart::TPtr &ev, TInstant now, TActorIDPtr skeletonFrontIDPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchFoundPartsMsgsPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchResMsgsPtr, const TIntrusivePtr<TVPatchCtx> &vPatchCtx, const TString &vDiskLogPrefix, ui64 incarnationGuid) { - return new NPrivate::TSkeletonVPatchActor(leaderId, gType, ev, now, skeletonFrontIDPtr, + return new NPrivate::TSkeletonVPatchActor(leaderId, gType, ev, now, skeletonFrontIDPtr, vPatchFoundPartsMsgsPtr, vPatchResMsgsPtr, vPatchCtx, vDiskLogPrefix, incarnationGuid); } diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.h b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.h index 099ac415408..8c2c0d658c3 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.h +++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_vpatch_actor.h @@ -31,7 +31,7 @@ struct TVPatchCtx : public TThrRefBase, TNonCopyable { TVPatchCtx() = default; }; -IActor* CreateSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, TEvBlobStorage::TEvVPatchStart::TPtr &ev, +IActor* CreateSkeletonVPatchActor(TActorId leaderId, const TBlobStorageGroupType &gType, TEvBlobStorage::TEvVPatchStart::TPtr &ev, TInstant now, TActorIDPtr skeletonFrontIDPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchFoundPartsMsgsPtr, const NMonitoring::TDynamicCounters::TCounterPtr &vPatchResMsgsPtr, const TIntrusivePtr<TVPatchCtx> &vPatchCtx, const TString &vDiskLogPrefix, ui64 incarnationGuid); diff --git a/ydb/core/client/client_ut.cpp b/ydb/core/client/client_ut.cpp index f93de006455..b94c722588b 100644 --- a/ydb/core/client/client_ut.cpp +++ b/ydb/core/client/client_ut.cpp @@ -61,13 +61,13 @@ struct TTestTables { bool Sharded = false; bool OutOfOrder = false; bool SoftUpdates = false; - ui32 FollowerCount = 0; + ui32 FollowerCount = 0; - TOpts(EVariant var = OneShard_NoOpts, ui32 numFollowers = 0) + TOpts(EVariant var = OneShard_NoOpts, ui32 numFollowers = 0) : Sharded(false) , OutOfOrder(false) , SoftUpdates(false) - , FollowerCount(numFollowers) + , FollowerCount(numFollowers) { switch (var) { case OneShard_NoOpts: @@ -99,10 +99,10 @@ struct TTestTables { } }; - TTestTables(TClient& client, EVariant var, ui32 numFollowers = 0) + TTestTables(TClient& client, EVariant var, ui32 numFollowers = 0) : Client(client) { - TOpts opts(var, numFollowers); + TOpts opts(var, numFollowers); NKikimrSchemeOp::TTableDescription tableSimple; { tableSimple.SetName("Simple"); @@ -119,8 +119,8 @@ struct TTestTables { if (opts.Sharded) tableSimple.SetUniformPartitionsCount(10); - if (opts.FollowerCount) - tableSimple.MutablePartitionConfig()->SetFollowerCount(opts.FollowerCount); + if (opts.FollowerCount) + tableSimple.MutablePartitionConfig()->SetFollowerCount(opts.FollowerCount); if (opts.OutOfOrder) { tableSimple.MutablePartitionConfig()->MutablePipelineConfig()->SetNumActiveTx(8); @@ -276,7 +276,7 @@ struct TTxInfo { ui64 TabletId; TActorId ActorId; std::pair<ui32, ui64> GenStep; - bool IsFollower; + bool IsFollower; ui64 TxId; ui64 TxStep; ui32 Status; @@ -288,7 +288,7 @@ struct TTxInfo { Cerr << "TabletId: " << TabletId << " Generation:Step: " << GenStep.first << ":" << GenStep.second << " ActorId: " << ActorId - << " IsFollower: " << (ui32)IsFollower << Endl; + << " IsFollower: " << (ui32)IsFollower << Endl; } void PrintTxInfo() const { @@ -313,7 +313,7 @@ void ExtractResultInfo(const NKikimrMiniKQL::TResult& result, TVector<TTxInfo>& info.TabletId = row["TabletId"]; info.ActorId = TActorId(row["ActorIdRawX1"], row["ActorIdRawX2"]); info.GenStep = std::make_pair(row["Generation"], row["GenStep"]); - info.IsFollower = row["IsFollower"]; + info.IsFollower = row["IsFollower"]; info.TxId = row["TxId"]; info.TxStep = row["TxStep"]; info.Status = row["Status"]; @@ -411,7 +411,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - void ReadWriteViaMiniKQLBody(TClient &client, bool useHead, bool useFollower) { + void ReadWriteViaMiniKQLBody(TClient &client, bool useHead, bool useFollower) { NKikimrMiniKQL::TResult writeRes; const TString writeQuery = R"___( ( @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { )___"; TString readQuery = readQueryTemplate; - SubstGlobal(readQuery, "__HEAD__", !useHead ? (useFollower ? "'follower" : "'online") : "'head"); + SubstGlobal(readQuery, "__HEAD__", !useHead ? (useFollower ? "'follower" : "'online") : "'head"); UNIT_ASSERT(client.FlatQuery(readQuery, readRes)); { @@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { )___"; TString rangeQuery = rangeQueryTemplate; - SubstGlobal(rangeQuery, "__HEAD__", !useHead ? (useFollower ? "'follower" : "'online") : "'head"); + SubstGlobal(rangeQuery, "__HEAD__", !useHead ? (useFollower ? "'follower" : "'online") : "'head"); NKikimrMiniKQL::TResult rangeRes; UNIT_ASSERT(client.FlatQuery(rangeQuery, rangeRes)); @@ -690,11 +690,11 @@ Y_UNIT_TEST_SUITE(TClientTest) { ReadWriteViaMiniKQLBody(client, true, false); } - Y_UNIT_TEST(ReadWriteViaMiniKQLShardedFollower) { + Y_UNIT_TEST(ReadWriteViaMiniKQLShardedFollower) { TPortManager tp; ui16 port = tp.GetPort(2134); - // Currently followers cannot be started at the same node with leader + // Currently followers cannot be started at the same node with leader // so we need 2 nodes auto settings = TServerSettings(port); settings.SetNodeCount(2); @@ -717,7 +717,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - TTestTables tables(client, TTestTables::Sharded_NoOpts, 2); //max followers is 3 + TTestTables tables(client, TTestTables::Sharded_NoOpts, 2); //max followers is 3 ReadWriteViaMiniKQLBody(client, false, true); } } @@ -1461,7 +1461,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - void PrepareTestData(TClient& client, bool allowFollowerPromotion) { + void PrepareTestData(TClient& client, bool allowFollowerPromotion) { client.InitRootScheme(); client.MkDir("/dc-1", "Berkanavt"); client.MkDir("/dc-1/Berkanavt", "tables"); @@ -1471,8 +1471,8 @@ Y_UNIT_TEST_SUITE(TClientTest) { Columns { Name: "key" Type: "Uint64"} Columns { Name: "uint" Type: "Uint64"} KeyColumnNames: ["key"] - PartitionConfig { FollowerCount: 1 AllowFollowerPromotion: %s } - )___", allowFollowerPromotion ? "true": "false")); + PartitionConfig { FollowerCount: 1 AllowFollowerPromotion: %s } + )___", allowFollowerPromotion ? "true": "false")); NKikimrMiniKQL::TResult writeRes; const TString writeQuery = R"___( @@ -1488,7 +1488,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT(client.FlatQuery(writeQuery, writeRes)); } - void CheckRead(TClient& client, bool readFromFollower) { + void CheckRead(TClient& client, bool readFromFollower) { const TString readQuery = Sprintf( R"___( ( @@ -1497,7 +1497,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { (let row (SelectRow '/dc-1/Berkanavt/tables/Simple key columns %s)) (return (AsList (SetResult 'row row))) ) - )___", readFromFollower ? "'follower" : ""); + )___", readFromFollower ? "'follower" : ""); NKikimrMiniKQL::TResult readRes; UNIT_ASSERT(client.FlatQuery(readQuery, readRes)); @@ -1512,21 +1512,21 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - void WaitForLeaderStart(TClient& client, TTestActorRuntime* runtime, ui64 tabletId, const TDuration& timeout) { + void WaitForLeaderStart(TClient& client, TTestActorRuntime* runtime, ui64 tabletId, const TDuration& timeout) { if (client.WaitForTabletAlive(runtime, tabletId, true, timeout)) return; - UNIT_ASSERT(!"Timeout expired while waiting for leader start"); + UNIT_ASSERT(!"Timeout expired while waiting for leader start"); } - void WaitForFollowerStart(TClient& client, TTestActorRuntime* runtime, ui64 tabletId, const TDuration& timeout) { + void WaitForFollowerStart(TClient& client, TTestActorRuntime* runtime, ui64 tabletId, const TDuration& timeout) { if (client.WaitForTabletAlive(runtime, tabletId, false, timeout)) return; - UNIT_ASSERT(!"Timeout expired while waiting for follower start"); + UNIT_ASSERT(!"Timeout expired while waiting for follower start"); } - Y_UNIT_TEST(ReadFromFollower) { + Y_UNIT_TEST(ReadFromFollower) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1541,7 +1541,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { CheckRead(client, true); } - Y_UNIT_TEST(FollowerCacheRefresh) { + Y_UNIT_TEST(FollowerCacheRefresh) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1559,8 +1559,8 @@ Y_UNIT_TEST_SUITE(TClientTest) { client.MarkNodeInHive(server.GetRuntime(), 1, true); const ui64 tabletId = 72075186224037888ull; - WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); // force some rounds of compaction for (ui32 i : xrange(50, 3000)) { @@ -1574,15 +1574,15 @@ Y_UNIT_TEST_SUITE(TClientTest) { UNIT_ASSERT(client.FlatQuery(writeQuery, writeRes)); } - Cout << "Read from leader" << Endl; + Cout << "Read from leader" << Endl; CheckRead(client, false); - Cout << "Read from leader again" << Endl; + Cout << "Read from leader again" << Endl; CheckRead(client, false); - Cout << "Read from follower" << Endl; + Cout << "Read from follower" << Endl; CheckRead(client, true); } - Y_UNIT_TEST(FollowerDrop) { + Y_UNIT_TEST(FollowerDrop) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1596,11 +1596,11 @@ Y_UNIT_TEST_SUITE(TClientTest) { PrepareTestData(client, false); const ui64 tabletId = 72075186224037888ull; - WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.ForceFollower = true; server.GetRuntime()->SendToPipe(tabletId, TActorId(), new TEvents::TEvPoisonPill(), 0, pipeClientConfig); client.AlterTable(TablePlacement, Sprintf( @@ -1609,7 +1609,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { Columns { Name: "key" Type: "Uint64"} Columns { Name: "uint" Type: "Uint64"} KeyColumnNames: ["key"] - PartitionConfig { FollowerCount: 0 } + PartitionConfig { FollowerCount: 0 } )___")); // force some rounds of compaction @@ -1625,7 +1625,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } } - Y_UNIT_TEST(PromoteFollower) { + Y_UNIT_TEST(PromoteFollower) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -1641,39 +1641,39 @@ Y_UNIT_TEST_SUITE(TClientTest) { const ui64 tabletId = 72075186224037888ull; - ui32 leaderNode = client.GetLeaderNode(server.GetRuntime(), tabletId); + ui32 leaderNode = client.GetLeaderNode(server.GetRuntime(), tabletId); - WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - TVector<ui32> followerNodes = client.GetFollowerNodes(server.GetRuntime(), tabletId); - UNIT_ASSERT_VALUES_EQUAL(1, followerNodes.size()); - UNIT_ASSERT_VALUES_UNEQUAL(leaderNode, followerNodes[0]); + TVector<ui32> followerNodes = client.GetFollowerNodes(server.GetRuntime(), tabletId); + UNIT_ASSERT_VALUES_EQUAL(1, followerNodes.size()); + UNIT_ASSERT_VALUES_UNEQUAL(leaderNode, followerNodes[0]); - Cout << "Read from follower" << Endl; + Cout << "Read from follower" << Endl; CheckRead(client, true); - Cout << "Read from leader" << Endl; + Cout << "Read from leader" << Endl; CheckRead(client, false); - Cout << "Disable node, leader should move back" << Endl; - client.MarkNodeInHive(server.GetRuntime(), leaderNode, false); - client.KickNodeInHive(server.GetRuntime(), leaderNode); - WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + Cout << "Disable node, leader should move back" << Endl; + client.MarkNodeInHive(server.GetRuntime(), leaderNode, false); + client.KickNodeInHive(server.GetRuntime(), leaderNode); + WaitForLeaderStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - Cout << "Read from new leader" << Endl; + Cout << "Read from new leader" << Endl; CheckRead(client, false); - ui32 newLeaderNode = client.GetLeaderNode(server.GetRuntime(), tabletId); - UNIT_ASSERT_VALUES_UNEQUAL_C(newLeaderNode, leaderNode, "Leader has moved"); + ui32 newLeaderNode = client.GetLeaderNode(server.GetRuntime(), tabletId); + UNIT_ASSERT_VALUES_UNEQUAL_C(newLeaderNode, leaderNode, "Leader has moved"); - Cout << "Reenable node, follower should start there" << Endl; - client.MarkNodeInHive(server.GetRuntime(), leaderNode, true); - WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); - followerNodes = client.GetFollowerNodes(server.GetRuntime(), tabletId); + Cout << "Reenable node, follower should start there" << Endl; + client.MarkNodeInHive(server.GetRuntime(), leaderNode, true); + WaitForFollowerStart(client, server.GetRuntime(), tabletId, TDuration::Seconds(5)); + followerNodes = client.GetFollowerNodes(server.GetRuntime(), tabletId); CheckRead(client, true); } - void DiagnosticsBody(TClient &client, bool testWrite, bool allowFollower = false) { + void DiagnosticsBody(TClient &client, bool testWrite, bool allowFollower = false) { TString query; if (testWrite) { query = R"(( @@ -1693,7 +1693,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { (SetResult 'res result_) (Diagnostics) )) - ))", allowFollower ? "'follower" : ""); + ))", allowFollower ? "'follower" : ""); } NKikimrMiniKQL::TResult result; @@ -1711,7 +1711,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } UNIT_ASSERT_EQUAL(infos.size(), 1); - UNIT_ASSERT(allowFollower || (infos[0].IsFollower == false)); + UNIT_ASSERT(allowFollower || (infos[0].IsFollower == false)); } } @@ -1862,7 +1862,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { TClient client(settings); server.StartDummyTablets(); - WaitForLeaderStart(client, server.GetRuntime(), ChangeStateStorage(Tests::DummyTablet1, TestDomain), TDuration::Seconds(1)); + WaitForLeaderStart(client, server.GetRuntime(), ChangeStateStorage(Tests::DummyTablet1, TestDomain), TDuration::Seconds(1)); NTabletFlatScheme::TSchemeChanges schemeInitial; TString err; @@ -2052,7 +2052,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { // TODO: check resluts } - void OfflineFollowerContinueWork() { + void OfflineFollowerContinueWork() { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2064,17 +2064,17 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); const TActorId edge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerTablet); + const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerTablet); const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '42)))) @@ -2095,14 +2095,14 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, ui64(10))); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); } { - runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); + runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } @@ -2110,7 +2110,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2118,21 +2118,21 @@ Y_UNIT_TEST_SUITE(TClientTest) { { NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.AllowFollower = true; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.AllowFollower = true; + pipeClientConfig.ForceFollower = true; runtime.Register(NTabletPipe::CreateClient(edge, tabletId, pipeClientConfig)); auto reply = runtime.GrabEdgeEvent<TEvTabletPipe::TEvClientConnected>(edge); - UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Status, NKikimrProto::OK); + UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Status, NKikimrProto::OK); } } - Y_UNIT_TEST(OfflineFollowerContinueWork) { - OfflineFollowerContinueWork(); + Y_UNIT_TEST(OfflineFollowerContinueWork) { + OfflineFollowerContinueWork(); } - void FollowerOfflineBoot() { + void FollowerOfflineBoot() { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2144,45 +2144,45 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); const TActorId edge = runtime.AllocateEdgeActor(); { - const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(leaderId); + const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(leaderId); - runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); + runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } - const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - Y_UNUSED(followerTablet); + const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + Y_UNUSED(followerTablet); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerId); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerId); { NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.AllowFollower = true; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.AllowFollower = true; + pipeClientConfig.ForceFollower = true; pipeClientConfig.RetryPolicy = {.RetryLimitCount = 2}; runtime.Register(NTabletPipe::CreateClient(edge, tabletId, pipeClientConfig)); auto reply = runtime.GrabEdgeEvent<TEvTabletPipe::TEvClientConnected>(edge); - UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Status, NKikimrProto::OK); + UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Status, NKikimrProto::OK); } } - Y_UNIT_TEST(FollowerOfflineBoot) { - FollowerOfflineBoot(); + Y_UNIT_TEST(FollowerOfflineBoot) { + FollowerOfflineBoot(); } - Y_UNIT_TEST(OfflineFollowerLastConfirmedCommitRestored) { + Y_UNIT_TEST(OfflineFollowerLastConfirmedCommitRestored) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2195,16 +2195,16 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); const TActorId edge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '42)))) @@ -2225,7 +2225,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, ui64(10))); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2234,7 +2234,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2252,29 +2252,29 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Kill leader - runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); + // Kill leader + runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } { - // Kill follower - runtime.Send(new IEventHandle(followerTablet, edge, new TEvents::TEvPoisonPill())); + // Kill follower + runtime.Send(new IEventHandle(followerTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } - // Start a new follower (without leader) - const TActorId followerTablet2 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId2 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerTablet2); + // Start a new follower (without leader) + const TActorId followerTablet2 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId2 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerTablet2); { - // Connect pipe to follower (indicates it's up and usable) + // Connect pipe to follower (indicates it's up and usable) NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.AllowFollower = true; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.AllowFollower = true; + pipeClientConfig.ForceFollower = true; pipeClientConfig.RetryPolicy = {.RetryLimitCount = 2}; runtime.Register(NTabletPipe::CreateClient(edge, tabletId, pipeClientConfig)); @@ -2283,10 +2283,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Read row from offline follower + // Read row from offline follower THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId2, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId2, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2305,7 +2305,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } - Y_UNIT_TEST(OfflineFollowerLastUnconfirmedCommitIgnored) { + Y_UNIT_TEST(OfflineFollowerLastUnconfirmedCommitIgnored) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2318,16 +2318,16 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); const TActorId edge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '42)))) @@ -2372,7 +2372,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, ui64(10))); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2381,7 +2381,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { { THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2395,29 +2395,29 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Kill leader - runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); + // Kill leader + runtime.Send(new IEventHandle(leaderTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } { - // Kill follower - runtime.Send(new IEventHandle(followerTablet, edge, new TEvents::TEvPoisonPill())); + // Kill follower + runtime.Send(new IEventHandle(followerTablet, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } - // Start a new follower (without leader) - const TActorId followerTablet2 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId2 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerTablet2); + // Start a new follower (without leader) + const TActorId followerTablet2 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId2 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerTablet2); { - // Connect pipe to follower (indicates it's up and usable) + // Connect pipe to follower (indicates it's up and usable) NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.AllowFollower = true; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.AllowFollower = true; + pipeClientConfig.ForceFollower = true; pipeClientConfig.RetryPolicy = {.RetryLimitCount = 2}; runtime.Register(NTabletPipe::CreateClient(edge, tabletId, pipeClientConfig)); @@ -2426,10 +2426,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Read row from offline follower (unconfirmed commit must be ignored) + // Read row from offline follower (unconfirmed commit must be ignored) THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId2, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId2, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2449,22 +2449,22 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Kill follower 2 - runtime.Send(new IEventHandle(followerTablet2, edge, new TEvents::TEvPoisonPill())); + // Kill follower 2 + runtime.Send(new IEventHandle(followerTablet2, edge, new TEvents::TEvPoisonPill())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } - // Start a new follower (without leader) - const TActorId followerTablet3 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId3 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerTablet3); + // Start a new follower (without leader) + const TActorId followerTablet3 = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId3 = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerTablet3); { - // Connect pipe to follower (indicates it's up and usable) + // Connect pipe to follower (indicates it's up and usable) NTabletPipe::TClientConfig pipeClientConfig; - pipeClientConfig.AllowFollower = true; - pipeClientConfig.ForceFollower = true; + pipeClientConfig.AllowFollower = true; + pipeClientConfig.ForceFollower = true; pipeClientConfig.RetryPolicy = {.RetryLimitCount = 2}; runtime.Register(NTabletPipe::CreateClient(edge, tabletId, pipeClientConfig)); @@ -2473,10 +2473,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { } { - // Read row from offline follower + // Read row from offline follower THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(readQuery); - runtime.Send(new IEventHandle(followerId3, edge, reqRead.Release())); + runtime.Send(new IEventHandle(followerId3, edge, reqRead.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2495,7 +2495,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { } - Y_UNIT_TEST(DeadFollowerDoesNotBlockGc) { + Y_UNIT_TEST(DeadFollowerDoesNotBlockGc) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2509,16 +2509,16 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); - // Start leader on node 1 - const TActorId leaderEdge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(leaderEdge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(leaderEdge)->Get()->UserTabletActor; - Y_UNUSED(leaderTablet); + // Start leader on node 1 + const TActorId leaderEdge = runtime.AllocateEdgeActor(); + const TActorId leaderTablet = runtime.Register(CreateTablet(leaderEdge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(leaderEdge)->Get()->UserTabletActor; + Y_UNUSED(leaderTablet); - auto doLeaderWrite = [&](ui64 key, ui64 value) { + auto doLeaderWrite = [&](ui64 key, ui64 value) { const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '%lu)))) (let update_ '('('v_ui64 (Uint64 '%lu)))) @@ -2528,20 +2528,20 @@ Y_UNIT_TEST_SUITE(TClientTest) { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, key, value)); - runtime.Send(new IEventHandle(leaderId, leaderEdge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, leaderEdge, reqWrite.Release())); - auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(leaderEdge); + auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(leaderEdge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); }; - doLeaderWrite(42, 51); + doLeaderWrite(42, 51); - // Start follower on node 2 - const TActorId followerEdge = runtime.AllocateEdgeActor(1); - const TActorId followerTablet = runtime.Register(CreateTabletFollower(followerEdge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr), 1); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(followerEdge)->Get()->UserTabletActor; + // Start follower on node 2 + const TActorId followerEdge = runtime.AllocateEdgeActor(1); + const TActorId followerTablet = runtime.Register(CreateTabletFollower(followerEdge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr), 1); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(followerEdge)->Get()->UserTabletActor; - auto doFollowerRead = [&](ui64 key) -> TMaybe<ui64> { + auto doFollowerRead = [&](ui64 key) -> TMaybe<ui64> { const char *readQuery = R"__(( (let row_ '('('key (Uint64 '%lu)))) (let select_ '('v_ui64)) @@ -2553,9 +2553,9 @@ Y_UNIT_TEST_SUITE(TClientTest) { THolder<TEvTablet::TEvLocalMKQL> reqRead = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqRead->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(readQuery, key)); - runtime.Send(new IEventHandle(followerId, followerEdge, reqRead.Release()), 1); + runtime.Send(new IEventHandle(followerId, followerEdge, reqRead.Release()), 1); - auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(followerEdge); + auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(followerEdge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); // Cerr << reply->Get()->Record.DebugString() << Endl; const auto res = reply->Get()->Record @@ -2575,17 +2575,17 @@ Y_UNIT_TEST_SUITE(TClientTest) { }; // Perform basic sanity checks - UNIT_ASSERT_VALUES_EQUAL(doFollowerRead(41), Nothing()); - UNIT_ASSERT_VALUES_EQUAL(doFollowerRead(42), 51u); + UNIT_ASSERT_VALUES_EQUAL(doFollowerRead(41), Nothing()); + UNIT_ASSERT_VALUES_EQUAL(doFollowerRead(42), 51u); ui64 detachCounter = 0; ui64 gcWaitCounter = 0; ui64 gcAppliedCounter = 0; auto nemesis = [&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { switch (ev->GetTypeRewrite()) { - case TEvTablet::TEvFollowerDetach::EventType: { - // Drop TEvFollowerDetach and simulate interconnect disconnection - Cerr << "... dropping TEvFollowerDetach" << Endl; + case TEvTablet::TEvFollowerDetach::EventType: { + // Drop TEvFollowerDetach and simulate interconnect disconnection + Cerr << "... dropping TEvFollowerDetach" << Endl; ++detachCounter; runtime.Send( new IEventHandle( @@ -2597,18 +2597,18 @@ Y_UNIT_TEST_SUITE(TClientTest) { } case TEvTablet::TEvCommit::EventType: { const auto* msg = ev->Get<TEvTablet::TEvCommit>(); - if (msg->TabletID == tabletId && msg->WaitFollowerGcAck) { + if (msg->TabletID == tabletId && msg->WaitFollowerGcAck) { Cerr << "... observing TEvCommit at " << msg->Generation << ':' << msg->Step - << " with WaitFollowerGcAck" << Endl; + << " with WaitFollowerGcAck" << Endl; ++gcWaitCounter; } break; } - case TEvTablet::TEvFollowerGcApplied::EventType: { - const auto* msg = ev->Get<TEvTablet::TEvFollowerGcApplied>(); + case TEvTablet::TEvFollowerGcApplied::EventType: { + const auto* msg = ev->Get<TEvTablet::TEvFollowerGcApplied>(); if (msg->TabletID == tabletId) { - Cerr << "... observing TEvFollowerGcApplied at " + Cerr << "... observing TEvFollowerGcApplied at " << msg->Generation << ':' << msg->Step << Endl; ++gcAppliedCounter; @@ -2621,10 +2621,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { runtime.SetObserverFunc(nemesis); { - // Kill follower - Cerr << "... killing follower " << followerTablet << Endl; - runtime.Send(new IEventHandle(followerTablet, followerEdge, new TEvents::TEvPoisonPill()), 1); - auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(followerEdge); + // Kill follower + Cerr << "... killing follower " << followerTablet << Endl; + runtime.Send(new IEventHandle(followerTablet, followerEdge, new TEvents::TEvPoisonPill()), 1); + auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvTabletDead>(followerEdge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->TabletID, tabletId); } @@ -2640,8 +2640,8 @@ Y_UNIT_TEST_SUITE(TClientTest) { } }; - // Wait until follower attempts to detach - waitFor([&](){ return detachCounter > 0; }, "TEvFollowerDetach message"); + // Wait until follower attempts to detach + waitFor([&](){ return detachCounter > 0; }, "TEvFollowerDetach message"); UNIT_ASSERT_VALUES_EQUAL(detachCounter, 1u); // Perform a large number of write transactions @@ -2650,10 +2650,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { gcAppliedCounter = 0; Cerr << "... performing multiple writes" << Endl; for (ui64 key = 1; key <= 1200; ++key) { - doLeaderWrite(key, key); + doLeaderWrite(key, key); } - waitFor([&](){ return gcWaitCounter > 0; }, "WaitForFollowerGcAck commits"); - waitFor([&](){ return gcAppliedCounter >= gcWaitCounter; }, "TEvFollowerGcApplied messages"); + waitFor([&](){ return gcWaitCounter > 0; }, "WaitForFollowerGcAck commits"); + waitFor([&](){ return gcAppliedCounter >= gcWaitCounter; }, "TEvFollowerGcApplied messages"); } Y_UNIT_TEST(ErrorWaitForEarlierCommits) { @@ -2670,15 +2670,15 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); - const TActorId leaderEdge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(leaderEdge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(leaderEdge)->Get()->UserTabletActor; - Y_UNUSED(leaderTablet); + const TActorId leaderEdge = runtime.AllocateEdgeActor(); + const TActorId leaderTablet = runtime.Register(CreateTablet(leaderEdge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(leaderEdge)->Get()->UserTabletActor; + Y_UNUSED(leaderTablet); - auto sendLeaderWrite = [&](ui64 key, ui64 value) -> TActorId { + auto sendLeaderWrite = [&](ui64 key, ui64 value) -> TActorId { const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '%lu)))) (let update_ '('('v_ui64 (Uint64 '%lu)))) @@ -2689,16 +2689,16 @@ Y_UNIT_TEST_SUITE(TClientTest) { TActorId edge = runtime.AllocateEdgeActor(); THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, key, value)); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); return edge; }; - auto waitLeaderReply = [&](const TActorId& edge) { + auto waitLeaderReply = [&](const TActorId& edge) { auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); }; - waitLeaderReply(sendLeaderWrite(42, 42)); + waitLeaderReply(sendLeaderWrite(42, 42)); bool logResultsCapture = true; TVector<THolder<IEventHandle>> logResultsEvents; @@ -2728,11 +2728,11 @@ Y_UNIT_TEST_SUITE(TClientTest) { } }; - auto write43 = sendLeaderWrite(43, 430); + auto write43 = sendLeaderWrite(43, 430); waitFor([&]{ return logResultsEvents.size() >= 1; }, "first log write result"); UNIT_ASSERT_VALUES_EQUAL(logResultsEvents.size(), 1u); - auto write44 = sendLeaderWrite(44, 440); + auto write44 = sendLeaderWrite(44, 440); waitFor([&]{ return logResultsEvents.size() >= 2; }, "second log write result"); UNIT_ASSERT_VALUES_EQUAL(logResultsEvents.size(), 2u); Y_UNUSED(write44); @@ -2751,10 +2751,10 @@ Y_UNIT_TEST_SUITE(TClientTest) { // write43 should succeed! Cerr << "... waiting for first tx result" << Endl; - waitLeaderReply(write43); + waitLeaderReply(write43); } - Y_UNIT_TEST(OfflineFollowerNoGcReorder) { + Y_UNIT_TEST(OfflineFollowerNoGcReorder) { TPortManager tp; ui16 port = tp.GetPort(2134); @@ -2768,19 +2768,19 @@ Y_UNIT_TEST_SUITE(TClientTest) { TTestActorRuntime &runtime = *server.GetRuntime(); const ui64 tabletId = ChangeStateStorage(DummyTablet1, settings.Domain); - TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); - TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); + TIntrusivePtr<TTabletStorageInfo> tabletInfo = CreateTestTabletInfo(tabletId, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletSetupInfo> setupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); const TActorId edge = runtime.AllocateEdgeActor(); - const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); - const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(leaderTablet); + const TActorId leaderTablet = runtime.Register(CreateTablet(edge, tabletInfo.Get(), setupInfo.Get(), 0, nullptr, nullptr)); + const TActorId leaderId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(leaderTablet); - const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); - const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; - Y_UNUSED(followerTablet); - Y_UNUSED(followerId); + const TActorId followerTablet = runtime.Register(CreateTabletFollower(edge, tabletInfo.Get(), setupInfo.Get(), 1, nullptr, nullptr)); + const TActorId followerId = runtime.GrabEdgeEvent<TEvTablet::TEvRestored>(edge)->Get()->UserTabletActor; + Y_UNUSED(followerTablet); + Y_UNUSED(followerId); const char *writeQuery = R"__(( (let row_ '('('key (Uint64 '42)))) @@ -2840,7 +2840,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { for (int i = 0; i < 350; ++i) { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, ui64(i + 10))); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); @@ -2856,7 +2856,7 @@ Y_UNIT_TEST_SUITE(TClientTest) { for (int i = 0; i < 350; ++i) { THolder<TEvTablet::TEvLocalMKQL> reqWrite = MakeHolder<TEvTablet::TEvLocalMKQL>(); reqWrite->Record.MutableProgram()->MutableProgram()->SetText(Sprintf(writeQuery, ui64(i + 10))); - runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); + runtime.Send(new IEventHandle(leaderId, edge, reqWrite.Release())); auto reply = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(edge); UNIT_ASSERT_VALUES_EQUAL(reply->Get()->Record.GetStatus(), 0); diff --git a/ydb/core/client/flat_ut.cpp b/ydb/core/client/flat_ut.cpp index aee8b714727..362c052aa11 100644 --- a/ydb/core/client/flat_ut.cpp +++ b/ydb/core/client/flat_ut.cpp @@ -648,7 +648,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { // Alter and freeze auto res = annoyingClient.AlterTable("/dc-1", R"( Name: "Table" - PartitionConfig { FreezeState: Freeze FollowerCount: 1 } + PartitionConfig { FreezeState: Freeze FollowerCount: 1 } )"); UNIT_ASSERT_VALUES_EQUAL(res, NMsgBusProxy::MSTATUS_ERROR); } @@ -1788,7 +1788,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { return strRes; } - void PrepareSourceTable(TFlatMsgBusClient& annoyingClient, bool withFollowers = false) { + void PrepareSourceTable(TFlatMsgBusClient& annoyingClient, bool withFollowers = false) { const char * table = R"___( Name: "TableOld" Columns { Name: "Key" Type: "Uint32"} @@ -1802,7 +1802,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UniformPartitionsCount: 2 PartitionConfig { - FollowerCount: %d + FollowerCount: %d CompactionPolicy { InMemSizeToSnapshot: 100000 InMemStepsToSnapshot: 2 @@ -1834,7 +1834,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.InitRoot(); annoyingClient.MkDir("/dc-1", "Dir"); - annoyingClient.CreateTable("/dc-1/Dir", Sprintf(table, withFollowers ? 2 : 0)); + annoyingClient.CreateTable("/dc-1/Dir", Sprintf(table, withFollowers ? 2 : 0)); TMersenne<ui64> rnd; NTable::NTest::TRandomString<decltype(rnd)> blobs(rnd); @@ -1845,7 +1845,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { } } - TString ReadFromTable(TFlatMsgBusClient& annoyingClient, TString table, ui32 fromKey = 0, bool follower = false) { + TString ReadFromTable(TFlatMsgBusClient& annoyingClient, TString table, ui32 fromKey = 0, bool follower = false) { const char* readQuery = "(" "(let range1 '('IncFrom '('Key (Uint32 '%d) (Void) )))" @@ -1859,7 +1859,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { TFlatMsgBusClient::TFlatQueryOptions opts; NKikimrClient::TResponse response; - annoyingClient.FlatQueryRaw(Sprintf(readQuery, fromKey, table.data(), follower ? TReadTarget::Follower().GetMode() + annoyingClient.FlatQueryRaw(Sprintf(readQuery, fromKey, table.data(), follower ? TReadTarget::Follower().GetMode() : TReadTarget::Head().GetMode()), opts, response); UNIT_ASSERT_VALUES_EQUAL(response.GetStatus(), NMsgBusProxy::MSTATUS_OK); @@ -2002,7 +2002,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT_NO_DIFF(strResult, strResultOld); } - Y_UNIT_TEST(CopyTableAndAddFollowers) { + Y_UNIT_TEST(CopyTableAndAddFollowers) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port)); @@ -2019,17 +2019,17 @@ Y_UNIT_TEST_SUITE(TFlatTest) { Cerr << "Copy TableOld to Table" << Endl; annoyingClient.CreateTable("/dc-1/Dir", " Name: \"Table\" CopyFromTable: \"/dc-1/Dir/TableOld\"" - " PartitionConfig { FollowerCount: 1 }"); + " PartitionConfig { FollowerCount: 1 }"); - auto fnGetFollowerCount = [&annoyingClient] (const TString& path) { + auto fnGetFollowerCount = [&annoyingClient] (const TString& path) { auto res = annoyingClient.Ls(path); UNIT_ASSERT(res); UNIT_ASSERT(res->Record.HasPathDescription()); UNIT_ASSERT(res->Record.GetPathDescription().HasTable()); - return res->Record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerCount(); + return res->Record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerCount(); }; - UNIT_ASSERT_VALUES_EQUAL(fnGetFollowerCount("/dc-1/Dir/Table"), 1); + UNIT_ASSERT_VALUES_EQUAL(fnGetFollowerCount("/dc-1/Dir/Table"), 1); TString strResultOld = ReadFromTable(annoyingClient, "/dc-1/Dir/TableOld"); TString strResult = ReadFromTable(annoyingClient, "/dc-1/Dir/Table"); @@ -2037,12 +2037,12 @@ Y_UNIT_TEST_SUITE(TFlatTest) { Cout << strResult << Endl; UNIT_ASSERT_NO_DIFF(strResult, strResultOld); - // Make copy of copy and disable followers + // Make copy of copy and disable followers Cerr << "Copy TableOld to Table2" << Endl; annoyingClient.CreateTable("/dc-1/Dir", " Name: \"Table2\" CopyFromTable: \"/dc-1/Dir/Table\"" - " PartitionConfig { FollowerCount: 0 }"); + " PartitionConfig { FollowerCount: 0 }"); - UNIT_ASSERT_VALUES_EQUAL(fnGetFollowerCount("/dc-1/Dir/Table2"), 0); + UNIT_ASSERT_VALUES_EQUAL(fnGetFollowerCount("/dc-1/Dir/Table2"), 0); strResult = ReadFromTable(annoyingClient, "/dc-1/Dir/Table2"); UNIT_ASSERT_NO_DIFF(strResult, strResultOld); @@ -2712,7 +2712,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { annoyingClient.Ls("/dc-1/Dir/TableOld"); } - Y_UNIT_TEST(WriteSplitAndReadFromFollower) { + Y_UNIT_TEST(WriteSplitAndReadFromFollower) { TPortManager pm; ui16 port = pm.GetPort(2134); TServer cleverServer = TServer(TServerSettings(port).SetNodeCount(2)); @@ -2759,7 +2759,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { UNIT_ASSERT(annoyingClient.WaitForTabletAlive(cleverServer.GetRuntime(), tabletId, false, TDuration::Minutes(1))); } - for (ui32 i = 0; i < 20; ++i) { // multiple rounds to move some reads to followers + for (ui32 i = 0; i < 20; ++i) { // multiple rounds to move some reads to followers TString strResultAfter = ReadFromTable(annoyingClient, "/dc-1/Dir/TableOld", 201, true); UNIT_ASSERT_NO_DIFF(strResultAfter, strResult); } @@ -3245,7 +3245,7 @@ Y_UNIT_TEST_SUITE(TFlatTest) { TAutoPtr<NKikimr::NMsgBusProxy::TBusTabletCountersRequest> request(new NKikimr::NMsgBusProxy::TBusTabletCountersRequest()); request->Record.SetTabletID(partitions[0]); - request->Record.SetConnectToFollower(false); + request->Record.SetConnectToFollower(false); TAutoPtr<NBus::TBusMessage> reply; NBus::EMessageStatus status = annoyingClient.SyncCall(request, reply); diff --git a/ydb/core/client/minikql_compile/yql_expr_minikql.cpp b/ydb/core/client/minikql_compile/yql_expr_minikql.cpp index ba9faf5b53e..76f38bf35cb 100644 --- a/ydb/core/client/minikql_compile/yql_expr_minikql.cpp +++ b/ydb/core/client/minikql_compile/yql_expr_minikql.cpp @@ -65,8 +65,8 @@ TReadTarget GetReadTarget(TExprNode* node) { else if (modeStr == "online") { return TReadTarget::Online(); } - else if (modeStr == "follower") { - return TReadTarget::Follower(); + else if (modeStr == "follower") { + return TReadTarget::Follower(); } else { ythrow TNodeException(node) << "Unknown read target mode: " << modeStr; diff --git a/ydb/core/client/server/msgbus_server_db.cpp b/ydb/core/client/server/msgbus_server_db.cpp index 4bf9a28273d..08f3d717864 100644 --- a/ydb/core/client/server/msgbus_server_db.cpp +++ b/ydb/core/client/server/msgbus_server_db.cpp @@ -412,8 +412,8 @@ public: if (readTargetValue == "Head") { readTarget = TReadTarget::Head(); } else - if (readTargetValue == "Follower") { - readTarget = TReadTarget::Follower(); + if (readTargetValue == "Follower") { + readTarget = TReadTarget::Follower(); } } diff --git a/ydb/core/client/server/msgbus_server_local_minikql.cpp b/ydb/core/client/server/msgbus_server_local_minikql.cpp index a3198598e28..42fa4ed9a83 100644 --- a/ydb/core/client/server/msgbus_server_local_minikql.cpp +++ b/ydb/core/client/server/msgbus_server_local_minikql.cpp @@ -11,8 +11,8 @@ namespace { class TMessageBusLocalMKQL : public TMessageBusSecureRequest<TMessageBusSimpleTabletRequest<TMessageBusLocalMKQL, TEvTablet::TEvLocalMKQLResponse, NKikimrServices::TActivity::FRONT_LOCAL_MQKL>> { const NKikimrClient::TLocalMKQL Request; public: - TMessageBusLocalMKQL(TBusMessageContext &msg, const NKikimrClient::TLocalMKQL &request, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) - : TMessageBusSecureRequest(msg, tabletId, withRetry, timeout, connectToFollower) + TMessageBusLocalMKQL(TBusMessageContext &msg, const NKikimrClient::TLocalMKQL &request, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) + : TMessageBusSecureRequest(msg, tabletId, withRetry, timeout, connectToFollower) , Request(request) { SetSecurityToken(static_cast<TBusTabletLocalMKQL*>(msg.GetMessage())->Record.GetSecurityToken()); @@ -59,12 +59,12 @@ IActor* CreateMessageBusLocalMKQL(TBusMessageContext &msg) { if (!record.HasProgram()) return nullptr; - const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; + const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; const ui64 tabletId = record.GetTabletID(); const bool withRetry = record.HasWithRetry() ? record.GetWithRetry() : false; const TDuration timeout = TDuration::MilliSeconds(record.HasTimeout() ? record.GetTimeout() : DefaultTimeout); - return new TMessageBusLocalMKQL(msg, record, tabletId, withRetry, timeout, connectToFollower); + return new TMessageBusLocalMKQL(msg, record, tabletId, withRetry, timeout, connectToFollower); } }} diff --git a/ydb/core/client/server/msgbus_server_local_scheme_tx.cpp b/ydb/core/client/server/msgbus_server_local_scheme_tx.cpp index 13854882103..c1eed46ef99 100644 --- a/ydb/core/client/server/msgbus_server_local_scheme_tx.cpp +++ b/ydb/core/client/server/msgbus_server_local_scheme_tx.cpp @@ -14,8 +14,8 @@ class TMessageBusLocalSchemeTx : public TMessageBusSecureRequest<TMessageBusSimp TEvTablet::TEvLocalSchemeTxResponse, NKikimrServices::TActivity::FRONT_LOCAL_TXRQ>>; NKikimrClient::TLocalSchemeTx Request; public: - TMessageBusLocalSchemeTx(TBusMessageContext &msg, NKikimrClient::TLocalSchemeTx &request, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) - : TMessageBusSecureRequest(msg, tabletId, withRetry, timeout, connectToFollower) + TMessageBusLocalSchemeTx(TBusMessageContext &msg, NKikimrClient::TLocalSchemeTx &request, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) + : TMessageBusSecureRequest(msg, tabletId, withRetry, timeout, connectToFollower) , Request() { Request.Swap(&request); @@ -52,12 +52,12 @@ public: IActor* CreateMessageBusLocalSchemeTx(TBusMessageContext &msg) { auto &record = static_cast<TBusTabletLocalSchemeTx *>(msg.GetMessage())->Record; - const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; + const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; const ui64 tabletId = record.GetTabletID(); const bool withRetry = record.HasWithRetry() ? record.GetWithRetry() : false; const TDuration timeout = TDuration::MilliSeconds(record.HasTimeout() ? record.GetTimeout() : DefaultTimeout); - return new TMessageBusLocalSchemeTx(msg, record, tabletId, withRetry, timeout, connectToFollower); + return new TMessageBusLocalSchemeTx(msg, record, tabletId, withRetry, timeout, connectToFollower); } }} diff --git a/ydb/core/client/server/msgbus_server_pq_metarequest_ut.cpp b/ydb/core/client/server/msgbus_server_pq_metarequest_ut.cpp index 7ff4bf6fb56..237bba147b9 100644 --- a/ydb/core/client/server/msgbus_server_pq_metarequest_ut.cpp +++ b/ydb/core/client/server/msgbus_server_pq_metarequest_ut.cpp @@ -122,8 +122,8 @@ protected: } TActorId StartBalancer(ui64 balancerTabletId) { - TActorId id = CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(balancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), + TActorId id = CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(balancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), &CreatePersQueueReadBalancer); TDispatchOptions options; @@ -148,7 +148,7 @@ protected: UNIT_ASSERT(rec.HasTxId() && rec.GetTxId() == 12345); UNIT_ASSERT(rec.HasOrigin() && result->GetOrigin() == balancerTabletId); - ForwardToTablet(*Runtime, balancerTabletId, EdgeActorId, new TEvents::TEvPoisonPill()); + ForwardToTablet(*Runtime, balancerTabletId, EdgeActorId, new TEvents::TEvPoisonPill()); TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvRestored, 2)); Runtime->DispatchEvents(rebootOptions); @@ -180,8 +180,8 @@ protected: } TActorId StartPQTablet(ui64 tabletId) { - TActorId id = CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(tabletId, TTabletTypes::PERSQUEUE, TErasureType::ErasureNone), + TActorId id = CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(tabletId, TTabletTypes::PERSQUEUE, TErasureType::ErasureNone), &CreatePersQueue); TDispatchOptions options; diff --git a/ydb/core/client/server/msgbus_server_proxy.cpp b/ydb/core/client/server/msgbus_server_proxy.cpp index 4136b10de5b..7f3146d21a7 100644 --- a/ydb/core/client/server/msgbus_server_proxy.cpp +++ b/ydb/core/client/server/msgbus_server_proxy.cpp @@ -130,8 +130,8 @@ TBusResponse* ProposeTransactionStatusToResponse(EResponseStatus status, response->Record.MutableComplainingDataShards()->CopyFrom(result.GetComplainingDataShards()); if (result.UnresolvedKeysSize()) response->Record.MutableUnresolvedKeys()->CopyFrom(result.GetUnresolvedKeys()); - if (result.HasHadFollowerReads()) - response->Record.SetHadFollowerReads(result.GetHadFollowerReads()); + if (result.HasHadFollowerReads()) + response->Record.SetHadFollowerReads(result.GetHadFollowerReads()); if (result.HasTxId()) response->Record.SetTxId(result.GetTxId()); diff --git a/ydb/core/client/server/msgbus_server_s3_listing.cpp b/ydb/core/client/server/msgbus_server_s3_listing.cpp index 5b6db033bcf..3626866322b 100644 --- a/ydb/core/client/server/msgbus_server_s3_listing.cpp +++ b/ydb/core/client/server/msgbus_server_s3_listing.cpp @@ -27,7 +27,7 @@ private: THolder<const NACLib::TUserToken> UserToken; ui32 MaxKeys; TActorId SchemeCache; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; TDuration Timeout; TActorId TimeoutTimerActorId; TAutoPtr<TKeyDesc> KeyRange; @@ -56,7 +56,7 @@ public: , UserToken(std::move(userToken)) , MaxKeys(DEFAULT_MAX_KEYS) , SchemeCache(schemeCache) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) , Timeout(TDuration::Seconds(DEFAULT_TIMEOUT_SEC)) , WaitingResolveReply(false) , Finished(false) @@ -88,7 +88,7 @@ public: void Die(const NActors::TActorContext& ctx) override { Y_VERIFY(Finished); Y_VERIFY(!WaitingResolveReply); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); if (TimeoutTimerActorId) { ctx.Send(TimeoutTimerActorId, new TEvents::TEvPoisonPill()); } @@ -413,7 +413,7 @@ private: LOG_DEBUG_S(ctx, NKikimrServices::MSGBUS_REQUEST, "Sending request to shards " << shardId); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), shardId, true), IEventHandle::FlagTrackDelivery); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), shardId, true), IEventHandle::FlagTrackDelivery); TBase::Become(&TSelf::StateWaitResults); } @@ -447,7 +447,7 @@ private: const auto& shardResponse = ev->Get()->Record; // Notify the cache that we are done with the pipe - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); if (shardResponse.GetStatus() == NKikimrTxDataShard::TError::WRONG_SHARD_STATE) { // Invalidate scheme cache in case of partitioning change diff --git a/ydb/core/client/server/msgbus_server_tablet_counters.cpp b/ydb/core/client/server/msgbus_server_tablet_counters.cpp index 91a5bfefe10..4cae1322582 100644 --- a/ydb/core/client/server/msgbus_server_tablet_counters.cpp +++ b/ydb/core/client/server/msgbus_server_tablet_counters.cpp @@ -11,8 +11,8 @@ class TMessageBusTabletCounters : public TMessageBusSimpleTabletRequest<TMessage NKikimrClient::TTabletCountersRequest Request; public: TMessageBusTabletCounters(TBusMessageContext &msg, NKikimrClient::TTabletCountersRequest &request, ui64 tabletId, - bool withRetry, TDuration timeout, bool connectToFollower) - : TMessageBusSimpleTabletRequest(msg, tabletId, withRetry, timeout, connectToFollower) + bool withRetry, TDuration timeout, bool connectToFollower) + : TMessageBusSimpleTabletRequest(msg, tabletId, withRetry, timeout, connectToFollower) , Request() { Request.Swap(&request); @@ -37,12 +37,12 @@ public: IActor* CreateMessageBusTabletCountersRequest(TBusMessageContext &msg) { auto &record = static_cast<TBusTabletCountersRequest*>(msg.GetMessage())->Record; - const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; + const bool connectToFollower = record.HasConnectToFollower() ? record.GetConnectToFollower() : false; const ui64 tabletId = record.GetTabletID(); const bool withRetry = record.HasWithRetry() ? record.GetWithRetry() : false; const TDuration timeout = TDuration::MilliSeconds(record.HasTimeout() ? record.GetTimeout() : DefaultTimeout); - return new TMessageBusTabletCounters(msg, record, tabletId, withRetry, timeout, connectToFollower); + return new TMessageBusTabletCounters(msg, record, tabletId, withRetry, timeout, connectToFollower); } }} diff --git a/ydb/core/client/server/msgbus_server_test_shard_request.cpp b/ydb/core/client/server/msgbus_server_test_shard_request.cpp index 1f326a0cf94..4776f4da85d 100644 --- a/ydb/core/client/server/msgbus_server_test_shard_request.cpp +++ b/ydb/core/client/server/msgbus_server_test_shard_request.cpp @@ -13,7 +13,7 @@ class TMessageBusTestShardControl : public TMessageBusSimpleTabletRequest<TMessa public: TMessageBusTestShardControl(TBusMessageContext& msg, NKikimrClient::TTestShardControlRequest& record) - : TBase(msg, record.GetTabletId(), true, RequestTimeout, false /* no followers */) + : TBase(msg, record.GetTabletId(), true, RequestTimeout, false /* no followers */) , Request(std::move(record)) {} diff --git a/ydb/core/client/server/msgbus_tabletreq.h b/ydb/core/client/server/msgbus_tabletreq.h index b9ae60d5409..f173ae90976 100644 --- a/ydb/core/client/server/msgbus_tabletreq.h +++ b/ydb/core/client/server/msgbus_tabletreq.h @@ -24,7 +24,7 @@ class TMessageBusTabletRequest : public TActorBootstrapped<TDerived>, public TMe protected: const TDuration Timeout; const bool WithRetry; - const bool ConnectToFollower; + const bool ConnectToFollower; private: TActorId PipeClient; @@ -71,11 +71,11 @@ protected: return Die(ctx); } - TMessageBusTabletRequest(TBusMessageContext &msg, bool withRetry, TDuration timeout, bool connectToFollower) + TMessageBusTabletRequest(TBusMessageContext &msg, bool withRetry, TDuration timeout, bool connectToFollower) : TMessageBusSessionIdentHolder(msg) , Timeout(timeout) , WithRetry(withRetry) - , ConnectToFollower(connectToFollower) + , ConnectToFollower(connectToFollower) { } @@ -90,9 +90,9 @@ public: clientConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); } - if (ConnectToFollower) { - clientConfig.AllowFollower = true; - clientConfig.ForceFollower = true; + if (ConnectToFollower) { + clientConfig.AllowFollower = true; + clientConfig.ForceFollower = true; } std::pair<ui64, TAutoPtr<IEventBase>> reqPair = static_cast<TDerived *>(this)->MakeReqPair(ctx); @@ -124,8 +124,8 @@ class TMessageBusSimpleTabletRequest : public TMessageBusTabletRequest<TDerived, protected: const ui64 TabletID; - TMessageBusSimpleTabletRequest(TBusMessageContext &msg, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) - : TMessageBusTabletRequest<TDerived, TTabletReplyEvent>(msg, withRetry, timeout, connectToFollower) + TMessageBusSimpleTabletRequest(TBusMessageContext &msg, ui64 tabletId, bool withRetry, TDuration timeout, bool connectToFollower) + : TMessageBusTabletRequest<TDerived, TTabletReplyEvent>(msg, withRetry, timeout, connectToFollower) , TabletID(tabletId) {} diff --git a/ydb/core/cms/cluster_info.cpp b/ydb/core/cms/cluster_info.cpp index c0a8bfa2943..a1dc8a0b95f 100644 --- a/ydb/core/cms/cluster_info.cpp +++ b/ydb/core/cms/cluster_info.cpp @@ -401,7 +401,7 @@ void TClusterInfo::AddTablet(ui32 nodeId, const NKikimrWhiteboard::TTabletStateI tablet.TabletId = info.GetTabletId(); tablet.Type = info.GetType(); tablet.State = info.GetState(); - tablet.Leader = info.GetLeader(); + tablet.Leader = info.GetLeader(); tablet.NodeId = nodeId; auto &node = NodeRef(nodeId); diff --git a/ydb/core/cms/cluster_info.h b/ydb/core/cms/cluster_info.h index 6fc2e59210b..af5fe24af80 100644 --- a/ydb/core/cms/cluster_info.h +++ b/ydb/core/cms/cluster_info.h @@ -347,7 +347,7 @@ struct TTabletInfo { ui64 TabletId = 0; EType Type = TTabletTypes::Unknown; EState State = NKikimrWhiteboard::TTabletStateInfo::Created; - bool Leader = false; + bool Leader = false; ui32 NodeId = 0; }; diff --git a/ydb/core/cms/cluster_info_ut.cpp b/ydb/core/cms/cluster_info_ut.cpp index aa6fff2efe4..8b9d3b3d653 100644 --- a/ydb/core/cms/cluster_info_ut.cpp +++ b/ydb/core/cms/cluster_info_ut.cpp @@ -18,13 +18,13 @@ using namespace NKikimrBlobStorage; using namespace NKikimrCms; TTabletStateInfo MakeTabletInfo(ui64 id, TTabletTypes::EType type, - TTabletStateInfo::ETabletState state, bool leader) + TTabletStateInfo::ETabletState state, bool leader) { TTabletStateInfo tablet; tablet.SetTabletId(id); tablet.SetType(type); tablet.SetState(state); - tablet.SetLeader(leader); + tablet.SetLeader(leader); return tablet; } @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(TClusterInfoTest) { UNIT_ASSERT_VALUES_EQUAL(cluster.Tablet(1).TabletId, 1); UNIT_ASSERT_VALUES_EQUAL(cluster.Tablet(1).Type, TTabletTypes::Hive); UNIT_ASSERT_VALUES_EQUAL(cluster.Tablet(1).State, TTabletStateInfo::Active); - UNIT_ASSERT_VALUES_EQUAL(cluster.Tablet(1).Leader, true); + UNIT_ASSERT_VALUES_EQUAL(cluster.Tablet(1).Leader, true); auto now = Now(); cluster.SetTimestamp(now); diff --git a/ydb/core/cms/cms_ut_common.cpp b/ydb/core/cms/cms_ut_common.cpp index 144b3f5cae1..b458fe672ce 100644 --- a/ydb/core/cms/cms_ut_common.cpp +++ b/ydb/core/cms/cms_ut_common.cpp @@ -428,10 +428,10 @@ static void SetupServices(TTestActorRuntime &runtime, runtime.DispatchEvents(options); } - CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); - auto aid = CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeCmsID(0), TTabletTypes::CMS), &CreateCms); + auto aid = CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeCmsID(0), TTabletTypes::CMS), &CreateCms); runtime.EnableScheduleForActor(aid, true); } diff --git a/ydb/core/cms/console/console_ut_configs.cpp b/ydb/core/cms/console/console_ut_configs.cpp index d5c9f79957c..0cb1655281d 100644 --- a/ydb/core/cms/console/console_ut_configs.cpp +++ b/ydb/core/cms/console/console_ut_configs.cpp @@ -2436,8 +2436,8 @@ const ui64 CONFIG_PROXY_TABLET_ID = 0x0000000000840103; void StartConfigProxy(TTenantTestRuntime &runtime) { - auto info = CreateTestTabletInfo(CONFIG_PROXY_TABLET_ID, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(runtime, info, [&runtime](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(CONFIG_PROXY_TABLET_ID, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(runtime, info, [&runtime](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { return new TConfigProxy(tablet, info, runtime.Sender); }); runtime.EnableScheduleForActor(actorId, true); diff --git a/ydb/core/cms/console/console_ut_tenants.cpp b/ydb/core/cms/console/console_ut_tenants.cpp index c7285cdc515..57e4820af72 100644 --- a/ydb/core/cms/console/console_ut_tenants.cpp +++ b/ydb/core/cms/console/console_ut_tenants.cpp @@ -2031,7 +2031,7 @@ Y_UNIT_TEST_SUITE(TConsoleTests) { bool CheckAttrsPresent(TTenantTestRuntime& runtime, const TString& tenantName, THashMap<TString, TString> attrs, bool skipAbsent = false) { auto request = MakeHolder<TEvSchemeShard::TEvDescribeScheme>(tenantName); - ForwardToTablet(runtime, SCHEME_SHARD1_ID, runtime.Sender, request.Release()); + ForwardToTablet(runtime, SCHEME_SHARD1_ID, runtime.Sender, request.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEvent<TEvSchemeShard::TEvDescribeSchemeResult>(handle); diff --git a/ydb/core/cms/json_proxy_operations.h b/ydb/core/cms/json_proxy_operations.h index c27fe313a3c..6bce70054d9 100644 --- a/ydb/core/cms/json_proxy_operations.h +++ b/ydb/core/cms/json_proxy_operations.h @@ -24,8 +24,8 @@ public: TryFromString(cgi.Get("tabletid"), tabletId); } - if (!tabletId && cgi.Has("followerid")) { - TryFromString(cgi.Get("followerid"), tabletId); + if (!tabletId && cgi.Has("followerid")) { + TryFromString(cgi.Get("followerid"), tabletId); } return tabletId; diff --git a/ydb/core/cms/ui/datashard_info.js b/ydb/core/cms/ui/datashard_info.js index f5da90e5a91..f1c8bad40f5 100644 --- a/ydb/core/cms/ui/datashard_info.js +++ b/ydb/core/cms/ui/datashard_info.js @@ -101,7 +101,7 @@ function onDataShardInfoLoaded(data) { $('#tablet-info-mediator').html('<a href="../tablets?TabletID=' + info.Mediator + '">' + info.Mediator + '</a>'); $('#tablet-info-generation').text(info.Generation); - $('#tablet-info-role').text(info.IsFollower ? 'Follower' : 'Leader'); + $('#tablet-info-role').text(info.IsFollower ? 'Follower' : 'Leader'); $('#tablet-info-state').text(info.State + (info.IsActive ? ' (active)' : ' (inactive)')); $('#tablet-info-shared-blobs').text(info.HasSharedBlobs); diff --git a/ydb/core/driver_lib/base_utils/base_utils.h b/ydb/core/driver_lib/base_utils/base_utils.h index e16e04a6701..4809f2824da 100644 --- a/ydb/core/driver_lib/base_utils/base_utils.h +++ b/ydb/core/driver_lib/base_utils/base_utils.h @@ -22,7 +22,7 @@ struct TCmdFormatConfig { NSize::TSize ChunkSize; NSize::TSize SectorSize; ui64 Guid; - ui64 MainKey; + ui64 MainKey; TString TextMessage; TCmdFormatConfig(); @@ -32,7 +32,7 @@ struct TCmdFormatConfig { struct TCmdFormatInfoConfig { TString Path; - ui64 MainKey; + ui64 MainKey; bool IsVerbose; TCmdFormatInfoConfig(); diff --git a/ydb/core/driver_lib/base_utils/format_info.cpp b/ydb/core/driver_lib/base_utils/format_info.cpp index 2b50ed298d9..e5d53a7b803 100644 --- a/ydb/core/driver_lib/base_utils/format_info.cpp +++ b/ydb/core/driver_lib/base_utils/format_info.cpp @@ -14,7 +14,7 @@ int MainFormatInfo(const TCommandConfig &cmdConf, int argc, char** argv) { formatInfoConfig.Parse(argc, argv); TPDiskInfo info; - bool isOk = ReadPDiskFormatInfo(formatInfoConfig.Path, formatInfoConfig.MainKey, info); + bool isOk = ReadPDiskFormatInfo(formatInfoConfig.Path, formatInfoConfig.MainKey, info); if (isOk) { Cout << "Version: " << info.Version << Endl; Cout << "DiskSize: " << info.DiskSize << Endl; @@ -58,7 +58,7 @@ int MainFormatInfo(const TCommandConfig &cmdConf, int argc, char** argv) { } TCmdFormatInfoConfig::TCmdFormatInfoConfig() - : MainKey(0) + : MainKey(0) , IsVerbose(false) {} @@ -68,23 +68,23 @@ void TCmdFormatInfoConfig::Parse(int argc, char **argv) { opts.AddLongOption('p', "pdisk-path", "path to pdisk to read format info").RequiredArgument("PATH").Required() .StoreResult(&Path); - opts.AddLongOption('k', "main-key", "encryption main-key to use while reading").RequiredArgument("NUM") - .Optional().StoreResult(&MainKey); // TODO: make required - opts.AddLongOption("master-key", "obsolete: use main-key").RequiredArgument("NUM") - .Optional().StoreResult(&MainKey); // TODO: remove after migration + opts.AddLongOption('k', "main-key", "encryption main-key to use while reading").RequiredArgument("NUM") + .Optional().StoreResult(&MainKey); // TODO: make required + opts.AddLongOption("master-key", "obsolete: use main-key").RequiredArgument("NUM") + .Optional().StoreResult(&MainKey); // TODO: remove after migration opts.AddLongOption('v', "verbose", "output detailed information for debugging").Optional().NoArgument() .SetFlag(&IsVerbose); opts.AddHelpOption('h'); TOptsParseResult res(&opts, argc, argv); - - // TODO: remove after master->main key migration - bool hasMainOption = res.FindLongOptParseResult("main-key"); - bool hasMasterOption = res.FindLongOptParseResult("master-key"); - bool hasKOption = res.FindCharOptParseResult('k'); - if (!hasMainOption && !hasMasterOption && !hasKOption) - ythrow yexception() << "missing main-key param"; + + // TODO: remove after master->main key migration + bool hasMainOption = res.FindLongOptParseResult("main-key"); + bool hasMasterOption = res.FindLongOptParseResult("master-key"); + bool hasKOption = res.FindCharOptParseResult('k'); + if (!hasMainOption && !hasMasterOption && !hasKOption) + ythrow yexception() << "missing main-key param"; } } diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_disk.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_disk.cpp index ab58d3792f6..a9be370d37f 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_disk.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_disk.cpp @@ -14,20 +14,20 @@ public: bool IsVerbose; bool LockDevice; - ui64 MainKey; + ui64 MainKey; TString Path; virtual void Config(TConfig& config) override { TClientCommand::Config(config); IsVerbose = false; LockDevice = false; - MainKey = 0; + MainKey = 0; config.SetFreeArgsNum(1); SetFreeArgTitle(0, "<PATH>", "Disk path"); - config.Opts->AddLongOption('k', "main-key", "encryption main-key to use while reading").RequiredArgument("NUM") - .Optional().StoreResult(&MainKey); // TODO: make required - config.Opts->AddLongOption("master-key", "obsolete: use main-key").RequiredArgument("NUM") - .Optional().StoreResult(&MainKey); // TODO: remove after migration + config.Opts->AddLongOption('k', "main-key", "encryption main-key to use while reading").RequiredArgument("NUM") + .Optional().StoreResult(&MainKey); // TODO: make required + config.Opts->AddLongOption("master-key", "obsolete: use main-key").RequiredArgument("NUM") + .Optional().StoreResult(&MainKey); // TODO: remove after migration config.Opts->AddLongOption('v', "verbose", "output detailed information for debugging").Optional().NoArgument() .SetFlag(&IsVerbose); config.Opts->AddLongOption('l', "lock", "lock device before reading disk info").Optional().NoArgument() @@ -37,17 +37,17 @@ public: virtual void Parse(TConfig& config) override { TClientCommand::Parse(config); Path = config.ParseResult->GetFreeArgs()[0]; - // TODO: remove after master->main key migration - bool hasMainOption = config.ParseResult->FindLongOptParseResult("main-key"); - bool hasMasterOption = config.ParseResult->FindLongOptParseResult("master-key"); - bool hasKOption = config.ParseResult->FindCharOptParseResult('k'); - if (!hasMainOption && !hasMasterOption && !hasKOption) - ythrow yexception() << "missing main-key param"; + // TODO: remove after master->main key migration + bool hasMainOption = config.ParseResult->FindLongOptParseResult("main-key"); + bool hasMasterOption = config.ParseResult->FindLongOptParseResult("master-key"); + bool hasKOption = config.ParseResult->FindCharOptParseResult('k'); + if (!hasMainOption && !hasMasterOption && !hasKOption) + ythrow yexception() << "missing main-key param"; } virtual int Run(TConfig&) override { TPDiskInfo info; - bool isOk = ReadPDiskFormatInfo(Path, MainKey, info, LockDevice); + bool isOk = ReadPDiskFormatInfo(Path, MainKey, info, LockDevice); if (isOk) { Cout << "Version: " << info.Version << Endl; Cout << "DiskSize: " << info.DiskSize << Endl; @@ -108,13 +108,13 @@ public: NSize::TSize ChunkSize; NSize::TSize SectorSize; ui64 Guid; - ui64 MainKey; + ui64 MainKey; TString TextMessage; bool IsErasureEncode; virtual void Config(TConfig& config) override { TClientCommand::Config(config); - MainKey = 0; + MainKey = 0; DiskSize = 0; ChunkSize = 128 << 20; SectorSize = 4 << 10; @@ -134,11 +134,11 @@ public: .OptionalArgument("BYTES").StoreResult(&SectorSize); config.Opts->AddLongOption('g', "guid", "guid to set while formatting").RequiredArgument("NUM").Required() .StoreResult(&Guid); - config.Opts->AddLongOption('k', "main-key", "encryption main-key to set while formatting.\n" + config.Opts->AddLongOption('k', "main-key", "encryption main-key to set while formatting.\n" "Make sure you use the same master key when you format your pdisks and when you run kikimr.") - .RequiredArgument("NUM").Optional().StoreResult(&MainKey); - config.Opts->AddLongOption("master-key", "obsolete: user main-key") - .RequiredArgument("NUM").Optional().StoreResult(&MainKey); + .RequiredArgument("NUM").Optional().StoreResult(&MainKey); + config.Opts->AddLongOption("master-key", "obsolete: user main-key") + .RequiredArgument("NUM").Optional().StoreResult(&MainKey); config.Opts->AddLongOption('t', "text-message", "text message to store in format sector (up to 4000 characters long)") .OptionalArgument("STR").Optional().StoreResult(&TextMessage); config.Opts->AddLongOption('e', "erasure-encode", "erasure-encode data to recover from single-sector failures") @@ -160,15 +160,15 @@ public: EntropyPool().Read(&ChunkKey, sizeof(NKikimr::NPDisk::TKey)); EntropyPool().Read(&LogKey, sizeof(NKikimr::NPDisk::TKey)); EntropyPool().Read(&SysLogKey, sizeof(NKikimr::NPDisk::TKey)); - bool hasMainOption = config.ParseResult->FindLongOptParseResult("main-key"); - bool hasMasterOption = config.ParseResult->FindLongOptParseResult("master-key"); - bool hasKOption = config.ParseResult->FindCharOptParseResult('k'); - if (!hasMainOption && !hasMasterOption && !hasKOption) - ythrow yexception() << "missing main-key param"; + bool hasMainOption = config.ParseResult->FindLongOptParseResult("main-key"); + bool hasMasterOption = config.ParseResult->FindLongOptParseResult("master-key"); + bool hasKOption = config.ParseResult->FindCharOptParseResult('k'); + if (!hasMainOption && !hasMasterOption && !hasKOption) + ythrow yexception() << "missing main-key param"; } virtual int Run(TConfig&) override { - FormatPDisk(Path, DiskSize, SectorSize, ChunkSize, Guid, ChunkKey, LogKey, SysLogKey, MainKey, TextMessage, + FormatPDisk(Path, DiskSize, SectorSize, ChunkSize, Guid, ChunkKey, LogKey, SysLogKey, MainKey, TextMessage, IsErasureEncode); return 0; } diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_tablet.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_tablet.cpp index 9c281585938..361e757ca1d 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_tablet.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_tablet.cpp @@ -94,7 +94,7 @@ public: virtual void Config(TConfig& config) override { TClientCommand::Config(config); - config.Opts->AddLongOption("follower", "connect to follower").NoArgument(); + config.Opts->AddLongOption("follower", "connect to follower").NoArgument(); config.Opts->AddLongOption("json-ui64-as-string", "json output ui64 as string").NoArgument(); config.Opts->AddLongOption("json-binary-as-base64", "json output binary data in base64").NoArgument(); config.SetFreeArgsNum(1, 2); @@ -126,7 +126,7 @@ public: } } - Request->Record.SetConnectToFollower(config.ParseResult->Has("follower")); + Request->Record.SetConnectToFollower(config.ParseResult->Has("follower")); config.JsonUi64AsText = config.ParseResult->Has("json-ui64-as-string"); config.JsonBinaryAsBase64 = config.ParseResult->Has("json-binary-as-base64"); } @@ -173,7 +173,7 @@ public: virtual void Config(TConfig& config) override { TClientCommand::Config(config); - config.Opts->AddLongOption("follower", "connect to follower"); + config.Opts->AddLongOption("follower", "connect to follower"); config.Opts->AddLongOption("dry-run", "test changes without applying"); config.SetFreeArgsNum(1, 1); SetFreeArgTitle(0, "<SCHEME CHANGES>", "Scheme changes to apply"); @@ -191,8 +191,8 @@ public: ythrow TWithBackTrace<yexception>() << "Invalid scheme changes protobuf passed"; } - if (config.ParseResult->Has("follower")) - Request->Record.SetConnectToFollower(true); + if (config.ParseResult->Has("follower")) + Request->Record.SetConnectToFollower(true); Request->Record.SetDryRun(config.ParseResult->Has("dry-run")); } diff --git a/ydb/core/driver_lib/run/config_parser.cpp b/ydb/core/driver_lib/run/config_parser.cpp index 790abb414a7..bb686562912 100644 --- a/ydb/core/driver_lib/run/config_parser.cpp +++ b/ydb/core/driver_lib/run/config_parser.cpp @@ -134,7 +134,7 @@ void TRunCommandConfigParser::ParseConfigFiles(const NLastGetopt::TOptsParseResu } if (res.Has("feature-flags-file")) { - Y_VERIFY(ParsePBFromFile(res.Get("feature-flags-file"), Config.AppConfig.MutableFeatureFlags(), true)); + Y_VERIFY(ParsePBFromFile(res.Get("feature-flags-file"), Config.AppConfig.MutableFeatureFlags(), true)); } if (res.Has("sqs-file")) { diff --git a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp index fe1714b9775..819c1478d19 100644 --- a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp +++ b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp @@ -1169,9 +1169,9 @@ void TTabletPipePeNodeCachesInitializer::InitializeServices( { auto counters = GetServiceCounters(appData->Counters, "tablets"); - TIntrusivePtr<TPipePeNodeCacheConfig> leaderPipeConfig = new TPipePeNodeCacheConfig(); - leaderPipeConfig->PipeRefreshTime = TDuration::Zero(); - leaderPipeConfig->PipeConfig.RetryPolicy = {.RetryLimitCount = 3}; + TIntrusivePtr<TPipePeNodeCacheConfig> leaderPipeConfig = new TPipePeNodeCacheConfig(); + leaderPipeConfig->PipeRefreshTime = TDuration::Zero(); + leaderPipeConfig->PipeConfig.RetryPolicy = {.RetryLimitCount = 3}; leaderPipeConfig->Counters = counters->GetSubgroup("type", "LEADER_PIPE_CACHE"); TIntrusivePtr<TPipePeNodeCacheConfig> followerPipeConfig = new TPipePeNodeCacheConfig(); @@ -1318,8 +1318,8 @@ void TBootstrapperInitializer::InitializeServices( bi->OtherNodes.push_back(x); if (boot.HasWatchThreshold()) bi->WatchThreshold = TDuration::MilliSeconds(boot.GetWatchThreshold()); - if (boot.HasStartFollowers()) - bi->StartFollowers = boot.GetStartFollowers(); + if (boot.HasStartFollowers()) + bi->StartFollowers = boot.GetStartFollowers(); } setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeBootstrapperID(info->TabletID, bootstrapperNode), TActorSetupCmd(CreateBootstrapper(info.Get(), bi.Get(), standby), TMailboxType::HTSwap, appData->SystemPoolId))); diff --git a/ydb/core/driver_lib/run/run.cpp b/ydb/core/driver_lib/run/run.cpp index 586bd7b15bb..a4f74aa4e0f 100644 --- a/ydb/core/driver_lib/run/run.cpp +++ b/ydb/core/driver_lib/run/run.cpp @@ -205,7 +205,7 @@ public: appData->AllowHugeKeyValueDeletes = Config.GetFeatureFlags().GetAllowHugeKeyValueDeletes(); appData->EnableKqpSpilling = Config.GetTableServiceConfig().GetSpillingServiceConfig().GetLocalFileConfig().GetEnable(); - appData->CompactionConfig = Config.GetCompactionConfig(); + appData->CompactionConfig = Config.GetCompactionConfig(); } }; diff --git a/ydb/core/engine/minikql/flat_local_tx_factory.cpp b/ydb/core/engine/minikql/flat_local_tx_factory.cpp index 8c64de3a299..d23f4d8bc73 100644 --- a/ydb/core/engine/minikql/flat_local_tx_factory.cpp +++ b/ydb/core/engine/minikql/flat_local_tx_factory.cpp @@ -10,19 +10,19 @@ namespace NMiniKQL { using ITransaction = TMiniKQLFactory::ITransaction; -TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalMKQL::TPtr &ev) +TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalMKQL::TPtr &ev) { TLocalMiniKQLProgram program(*ev->Get()); return new TFlatLocalMiniKQL(ev->Sender, program, this); } -TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalSchemeTx::TPtr &ev) +TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalSchemeTx::TPtr &ev) { return new TFlatLocalSchemeTx(ev->Sender, ev); } -TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalReadColumns::TPtr &ev) +TAutoPtr<ITransaction> TMiniKQLFactory::Make(TEvTablet::TEvLocalReadColumns::TPtr &ev) { return new TFlatLocalReadColumns(ev->Sender, ev); } diff --git a/ydb/core/engine/minikql/flat_local_tx_factory.h b/ydb/core/engine/minikql/flat_local_tx_factory.h index 68f515cd13d..200d21b369a 100644 --- a/ydb/core/engine/minikql/flat_local_tx_factory.h +++ b/ydb/core/engine/minikql/flat_local_tx_factory.h @@ -11,9 +11,9 @@ namespace NMiniKQL { struct TMiniKQLFactory : NTabletFlatExecutor::IMiniKQLFactory { using ITransaction = NTabletFlatExecutor::ITransaction; - TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalMKQL::TPtr&) override; - TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalSchemeTx::TPtr&) override; - TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalReadColumns::TPtr &ev) override; + TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalMKQL::TPtr&) override; + TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalSchemeTx::TPtr&) override; + TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalReadColumns::TPtr &ev) override; virtual TRowVersion GetWriteVersion(const TTableId& tableId) const; virtual TRowVersion GetReadVersion(const TTableId& tableId) const; diff --git a/ydb/core/engine/minikql/minikql_engine_host.cpp b/ydb/core/engine/minikql/minikql_engine_host.cpp index e271593495d..36c35f32cc4 100644 --- a/ydb/core/engine/minikql/minikql_engine_host.cpp +++ b/ydb/core/engine/minikql/minikql_engine_host.cpp @@ -476,7 +476,7 @@ public: using TBase = TComputationValue<TIterator<TTableIt>>; public: - TIterator(TMemoryUsageInfo* memInfo, const TSelectRangeLazyRowsList& list, TAutoPtr<TTableIt>&& iter, + TIterator(TMemoryUsageInfo* memInfo, const TSelectRangeLazyRowsList& list, TAutoPtr<TTableIt>&& iter, const TSmallVec<NTable::TTag>& systemColumnTags, ui64 shardId) : TBase(memInfo) , List(list) diff --git a/ydb/core/engine/mkql_engine_flat.h b/ydb/core/engine/mkql_engine_flat.h index 02c260808a1..7bee67584b9 100644 --- a/ydb/core/engine/mkql_engine_flat.h +++ b/ydb/core/engine/mkql_engine_flat.h @@ -124,18 +124,18 @@ public: TDuration ExecLatency; }; - TTabletInfo(ui64 tabletId, const std::pair<ui64, ui64>& actorId, ui32 gen, ui64 step, bool isFollower, TTxInfo&& txInfo) + TTabletInfo(ui64 tabletId, const std::pair<ui64, ui64>& actorId, ui32 gen, ui64 step, bool isFollower, TTxInfo&& txInfo) : TabletId(tabletId) , ActorId(actorId) , TabletGenStep(gen, step) - , IsFollower(isFollower) + , IsFollower(isFollower) , TxInfo(txInfo) {} ui64 TabletId; std::pair<ui64, ui64> ActorId; std::pair<ui32, ui64> TabletGenStep; - bool IsFollower; + bool IsFollower; TTxInfo TxInfo; }; diff --git a/ydb/core/engine/mkql_engine_flat_extfunc.cpp b/ydb/core/engine/mkql_engine_flat_extfunc.cpp index 2777b692c91..414d3aeeb45 100644 --- a/ydb/core/engine/mkql_engine_flat_extfunc.cpp +++ b/ydb/core/engine/mkql_engine_flat_extfunc.cpp @@ -429,7 +429,7 @@ namespace { items[structType->GetMemberIndex("TabletId")] = NUdf::TUnboxedValuePod(info.TabletId); items[structType->GetMemberIndex("Generation")] = NUdf::TUnboxedValuePod(info.TabletGenStep.first); items[structType->GetMemberIndex("GenStep")] = NUdf::TUnboxedValuePod(info.TabletGenStep.second); - items[structType->GetMemberIndex("IsFollower")] = NUdf::TUnboxedValuePod(info.IsFollower); + items[structType->GetMemberIndex("IsFollower")] = NUdf::TUnboxedValuePod(info.IsFollower); items[structType->GetMemberIndex("TxStep")] = NUdf::TUnboxedValuePod(info.TxInfo.StepTxId.first); items[structType->GetMemberIndex("TxId")] = NUdf::TUnboxedValuePod(info.TxInfo.StepTxId.second); @@ -1051,7 +1051,7 @@ TStructType* GetDiagnosticsType(const TTypeEnvironment& env) { std::make_pair("ExecLatency", ui64Type), std::make_pair("GenStep", ui64Type), std::make_pair("Generation", ui32Type), - std::make_pair("IsFollower", boolType), + std::make_pair("IsFollower", boolType), std::make_pair("PrepareArriveTime", ui64Type), std::make_pair("ProposeLatency", ui64Type), std::make_pair("Status", ui32Type), diff --git a/ydb/core/engine/mkql_engine_flat_ut.cpp b/ydb/core/engine/mkql_engine_flat_ut.cpp index 596b955f571..e2b12e2d7a5 100644 --- a/ydb/core/engine/mkql_engine_flat_ut.cpp +++ b/ydb/core/engine/mkql_engine_flat_ut.cpp @@ -49,7 +49,7 @@ namespace { }; struct TShardDbState { - THashMap<ui64, TAutoPtr<NTable::TDatabase>> Dbs; + THashMap<ui64, TAutoPtr<NTable::TDatabase>> Dbs; THashMap<ui64, NTable::TDummyEnv> Envs; THashMap<ui64, ui32> Steps; @@ -4606,7 +4606,7 @@ Value { } } Member { - Name: "IsFollower" + Name: "IsFollower" Type { Kind: Data Data { diff --git a/ydb/core/engine/mkql_keys.cpp b/ydb/core/engine/mkql_keys.cpp index 08fffa6cfe8..05afb89adc2 100644 --- a/ydb/core/engine/mkql_keys.cpp +++ b/ydb/core/engine/mkql_keys.cpp @@ -278,8 +278,8 @@ TReadTarget ExtractFlatReadTarget(TRuntimeNode modeInput) { return TReadTarget::Online(); case TReadTarget::EMode::Head: return TReadTarget::Head(); - case TReadTarget::EMode::Follower: - return TReadTarget::Follower(); + case TReadTarget::EMode::Follower: + return TReadTarget::Follower(); default: THROW TWithBackTrace<yexception>() << "Bad read target mode"; } diff --git a/ydb/core/grpc_services/rpc_describe_table_options.cpp b/ydb/core/grpc_services/rpc_describe_table_options.cpp index d8e6f8d556b..6d77e3cff71 100644 --- a/ydb/core/grpc_services/rpc_describe_table_options.cpp +++ b/ydb/core/grpc_services/rpc_describe_table_options.cpp @@ -132,12 +132,12 @@ private: auto &description = *result.add_replication_policy_presets(); description.set_name(pr.first); auto &labels = *description.mutable_labels(); - if (pr.second.GetFollowerCount()) { - labels["followers"] = ToString(pr.second.GetFollowerCount()); - labels["promotion"] = pr.second.GetAllowFollowerPromotion() ? "enabled" : "disabled"; + if (pr.second.GetFollowerCount()) { + labels["followers"] = ToString(pr.second.GetFollowerCount()); + labels["promotion"] = pr.second.GetAllowFollowerPromotion() ? "enabled" : "disabled"; labels["per_zone"] = pr.second.GetCrossDataCenter() ? "true" : "false"; } else { - labels["followers"] = "disabled"; + labels["followers"] = "disabled"; } } diff --git a/ydb/core/grpc_services/rpc_get_shard_locations.cpp b/ydb/core/grpc_services/rpc_get_shard_locations.cpp index 363d22cd48b..f7088c8eb60 100644 --- a/ydb/core/grpc_services/rpc_get_shard_locations.cpp +++ b/ydb/core/grpc_services/rpc_get_shard_locations.cpp @@ -92,7 +92,7 @@ private: continue; NTabletPipe::TClientConfig clientConfig; - clientConfig.AllowFollower = false; + clientConfig.AllowFollower = false; clientConfig.CheckAliveness = false; clientConfig.RetryPolicy = { .RetryLimitCount = 2, diff --git a/ydb/core/grpc_services/rpc_import_data.cpp b/ydb/core/grpc_services/rpc_import_data.cpp index 2f53776b9bb..8df9b3e2c73 100644 --- a/ydb/core/grpc_services/rpc_import_data.cpp +++ b/ydb/core/grpc_services/rpc_import_data.cpp @@ -107,7 +107,7 @@ class TImportDataRPC: public TRpcRequestActor<TImportDataRPC, TEvImportDataReque } void Handle(TEvTxUserProxy::TEvGetProxyServicesResponse::TPtr& ev) { - LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; + LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; ResolvePath(); } @@ -247,7 +247,7 @@ class TImportDataRPC: public TRpcRequestActor<TImportDataRPC, TEvImportDataReque return; } - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), *shardId, true), IEventHandle::FlagTrackDelivery); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), *shardId, true), IEventHandle::FlagTrackDelivery); Become(&TThis::StateProcessData); } @@ -425,7 +425,7 @@ public: } private: - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; THashMap<TString, TSysTables::TTableColumnInfo> Columns; THolder<TKeyDesc> KeyDesc; diff --git a/ydb/core/grpc_services/rpc_long_tx.cpp b/ydb/core/grpc_services/rpc_long_tx.cpp index 920b340bb4a..442972f9930 100644 --- a/ydb/core/grpc_services/rpc_long_tx.cpp +++ b/ydb/core/grpc_services/rpc_long_tx.cpp @@ -329,7 +329,7 @@ public: , Path(path) , DedupId(dedupId) , LongTxId(longTxId) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) { if (token) { UserToken.emplace(token); @@ -744,7 +744,7 @@ public: , Request(request.Release()) , DatabaseName(Request->GetDatabaseName().GetOrElse(DatabaseFromDomain(AppData()))) , SchemeCache(MakeSchemeCacheID()) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) , TableId(0) , OutChunkNumber(0) { @@ -767,7 +767,7 @@ public: } void PassAway() override { - Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); TBase::PassAway(); } @@ -904,7 +904,7 @@ private: if (ShardChunkCounts.count(shard) && ShardChunkCounts[shard] == ShardChunks[shard].size()) { Waits.erase(shard); ShardChunks[shard].clear(); - Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shard)); + Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shard)); } } @@ -939,7 +939,7 @@ private: private: void SendToTablet(ui64 tabletId, THolder<IEventBase> event) { - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, true), + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, true), IEventHandle::FlagTrackDelivery); } @@ -960,7 +960,7 @@ private: std::unique_ptr<TEvLongTxReadRequest> Request; TString DatabaseName; TActorId SchemeCache; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; std::optional<NACLib::TUserToken> UserToken; TLongTxId LongTxId; TString Path; diff --git a/ydb/core/grpc_services/rpc_read_columns.cpp b/ydb/core/grpc_services/rpc_read_columns.cpp index 066805766cb..4baae606a97 100644 --- a/ydb/core/grpc_services/rpc_read_columns.cpp +++ b/ydb/core/grpc_services/rpc_read_columns.cpp @@ -31,7 +31,7 @@ private: TAutoPtr<TEvReadColumnsRequest> Request; TActorId SchemeCache; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; TDuration Timeout; TActorId TimeoutTimerActorId; bool WaitingResolveReply; @@ -77,7 +77,7 @@ public: : TBase() , Request(request) , SchemeCache(MakeSchemeCacheID()) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) , Timeout(TDuration::Seconds(DEFAULT_TIMEOUT_SEC)) , WaitingResolveReply(false) , Finished(false) @@ -103,7 +103,7 @@ public: void Die(const NActors::TActorContext& ctx) override { Y_VERIFY(Finished); Y_VERIFY(!WaitingResolveReply); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); if (TimeoutTimerActorId) { ctx.Send(TimeoutTimerActorId, new TEvents::TEvPoisonPill()); } @@ -353,7 +353,7 @@ private: LOG_DEBUG_S(ctx, NKikimrServices::MSGBUS_REQUEST, "Sending request to tablet " << tabletId); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.release(), tabletId, true), IEventHandle::FlagTrackDelivery); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.release(), tabletId, true), IEventHandle::FlagTrackDelivery); ++ShardRequestCount; @@ -633,7 +633,7 @@ private: LOG_DEBUG_S(ctx, NKikimrServices::MSGBUS_REQUEST, "Sending request to shards " << shardId); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.release(), shardId, true), IEventHandle::FlagTrackDelivery); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.release(), shardId, true), IEventHandle::FlagTrackDelivery); ++ShardRequestCount; @@ -673,7 +673,7 @@ private: const auto& shardResponse = ev->Get()->Record; // Notify the cache that we are done with the pipe - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); if (shardResponse.GetStatus() != NKikimrTxDataShard::TError::OK) { StatusIds::StatusCode status = Ydb::StatusIds::GENERIC_ERROR; @@ -715,7 +715,7 @@ private: const auto& shardResponse = ev->Get()->Record; // Notify the cache that we are done with the pipe - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); if (shardResponse.GetStatus() != Ydb::StatusIds::SUCCESS) { ReplyWithError((StatusIds::StatusCode)shardResponse.GetStatus(), shardResponse.GetErrorDescription(), ctx); diff --git a/ydb/core/grpc_services/table_profiles.cpp b/ydb/core/grpc_services/table_profiles.cpp index 5b7fc41bfbe..367de4cc89e 100644 --- a/ydb/core/grpc_services/table_profiles.cpp +++ b/ydb/core/grpc_services/table_profiles.cpp @@ -323,7 +323,7 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, replicationPolicy = ReplicationPolicies.at(tableProfile.GetReplicationPolicy()); } if (policy.replicas_count()) - replicationPolicy.SetFollowerCount(policy.replicas_count()); + replicationPolicy.SetFollowerCount(policy.replicas_count()); switch (policy.create_per_availability_zone()) { case Ydb::FeatureFlag::STATUS_UNSPECIFIED: break; @@ -343,10 +343,10 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, case Ydb::FeatureFlag::STATUS_UNSPECIFIED: break; case Ydb::FeatureFlag::ENABLED: - replicationPolicy.SetAllowFollowerPromotion(true); + replicationPolicy.SetAllowFollowerPromotion(true); break; case Ydb::FeatureFlag::DISABLED: - replicationPolicy.SetAllowFollowerPromotion(false); + replicationPolicy.SetAllowFollowerPromotion(false); break; default: code = Ydb::StatusIds::BAD_REQUEST; @@ -418,15 +418,15 @@ bool TTableProfiles::ApplyTableProfile(const Ydb::Table::TableProfile &profile, partitionConfig.AddColumnFamilies()->CopyFrom(family); // Apply replication policy. - if (replicationPolicy.GetFollowerCount()) { - auto& followerGroup = *partitionConfig.AddFollowerGroups(); - followerGroup.SetFollowerCount(replicationPolicy.GetFollowerCount()); + if (replicationPolicy.GetFollowerCount()) { + auto& followerGroup = *partitionConfig.AddFollowerGroups(); + followerGroup.SetFollowerCount(replicationPolicy.GetFollowerCount()); if (replicationPolicy.GetCrossDataCenter()) - followerGroup.SetRequireAllDataCenters(true); + followerGroup.SetRequireAllDataCenters(true); else - followerGroup.SetRequireAllDataCenters(false); - if (replicationPolicy.HasAllowFollowerPromotion()) { - followerGroup.SetAllowLeaderPromotion(replicationPolicy.GetAllowFollowerPromotion()); + followerGroup.SetRequireAllDataCenters(false); + if (replicationPolicy.HasAllowFollowerPromotion()) { + followerGroup.SetAllowLeaderPromotion(replicationPolicy.GetAllowFollowerPromotion()); } } diff --git a/ydb/core/health_check/health_check.cpp b/ydb/core/health_check/health_check.cpp index 489ebcffdfa..7995c58aafc 100644 --- a/ydb/core/health_check/health_check.cpp +++ b/ydb/core/health_check/health_check.cpp @@ -149,8 +149,8 @@ public: if (itCount->Identifiers.size() < settings.MaxTabletIdsStored) { TStringBuilder id; id << info.tabletid(); - if (info.followerid()) { - id << '.' << info.followerid(); + if (info.followerid()) { + id << '.' << info.followerid(); } itCount->Identifiers.emplace_back(id); } @@ -169,7 +169,7 @@ public: TPathId ResourcePathId = {}; TVector<TNodeId> ComputeNodeIds; TVector<TString> StoragePoolNames; - THashMap<std::pair<TTabletId, TFollowerId>, const NKikimrHive::TTabletInfo*> MergedTabletState; + THashMap<std::pair<TTabletId, TFollowerId>, const NKikimrHive::TTabletInfo*> MergedTabletState; THashMap<TNodeId, TNodeTabletState> MergedNodeTabletState; }; @@ -585,13 +585,13 @@ public: void RequestHiveInfo(TTabletId hiveId) { THolder<TEvHive::TEvRequestHiveInfo> request = MakeHolder<TEvHive::TEvRequestHiveInfo>(); - request->Record.SetReturnFollowers(true); + request->Record.SetReturnFollowers(true); RequestTabletPipe(hiveId, "TEvRequestHiveInfo", request.Release()); } void RequestHiveDomainStats(TTabletId hiveId) { THolder<TEvHive::TEvRequestHiveDomainStats> request = MakeHolder<TEvHive::TEvRequestHiveDomainStats>(); - request->Record.SetReturnFollowers(true); + request->Record.SetReturnFollowers(true); request->Record.SetReturnMetrics(true); RequestTabletPipe(hiveId, "TEvRequestHiveDomainStats", request.Release()); } @@ -980,7 +980,7 @@ public: continue; } TDatabaseState& database = itDatabase->second; - auto tabletId = std::make_pair(hiveTablet.GetTabletID(), hiveTablet.GetFollowerID()); + auto tabletId = std::make_pair(hiveTablet.GetTabletID(), hiveTablet.GetFollowerID()); database.MergedTabletState.emplace(tabletId, &hiveTablet); TNodeId nodeId = hiveTablet.GetNodeID(); switch (hiveTablet.GetVolatileState()) { @@ -1212,7 +1212,7 @@ public: return Ydb::Monitoring::StatusFlag::YELLOW; } } else { - if (tabletStateInfo.leader()) { + if (tabletStateInfo.leader()) { return Ydb::Monitoring::StatusFlag::RED; } else { return Ydb::Monitoring::StatusFlag::BLUE; diff --git a/ydb/core/kesus/proxy/ut_helpers.cpp b/ydb/core/kesus/proxy/ut_helpers.cpp index bc9b193de2d..74580d10f71 100644 --- a/ydb/core/kesus/proxy/ut_helpers.cpp +++ b/ydb/core/kesus/proxy/ut_helpers.cpp @@ -16,8 +16,8 @@ void TTestContext::Setup(ui32 nodeCount) { SetupLogging(); SetupTabletServices(); - TActorId bootstrapper = CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + TActorId bootstrapper = CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreateKesusTablet); Runtime->EnableScheduleForActor(bootstrapper); { @@ -49,13 +49,13 @@ void TTestContext::Sleep(ui64 millis) { void TTestContext::RebootTablet() { ui32 nodeIndex = 0; TActorId sender = Runtime->AllocateEdgeActor(nodeIndex); - ForwardToTablet(*Runtime, TabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex); + ForwardToTablet(*Runtime, TabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvTablet::EvBoot); Runtime->DispatchEvents(options); } - InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); + InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); } TActorId TTestContext::GetProxy(ui64 proxyId, ui32 nodeIndex) { diff --git a/ydb/core/kesus/proxy/ut_helpers.h b/ydb/core/kesus/proxy/ut_helpers.h index 42b6854a21f..20bcbac73f6 100644 --- a/ydb/core/kesus/proxy/ut_helpers.h +++ b/ydb/core/kesus/proxy/ut_helpers.h @@ -33,7 +33,7 @@ struct TTestContext { // Sleeps for millis milliseconds using fake time void Sleep(ui64 millis); - // Doesn't sleep unlike NKikikmr::RebootTablet + // Doesn't sleep unlike NKikikmr::RebootTablet void RebootTablet(); // Extremely pedantic version of GrabEdgeEvent diff --git a/ydb/core/kesus/tablet/schema.h b/ydb/core/kesus/tablet/schema.h index 1c536b2c19f..cc2c95e6959 100644 --- a/ydb/core/kesus/tablet/schema.h +++ b/ydb/core/kesus/tablet/schema.h @@ -70,7 +70,7 @@ struct TKesusSchema : NIceDb::Schema { static constexpr ui64 SysParam_NextSessionId = 2; static constexpr ui64 SysParam_NextSemaphoreId = 3; static constexpr ui64 SysParam_NextSemaphoreOrderId = 4; - static constexpr ui64 SysParam_LastLeaderActor = 5; + static constexpr ui64 SysParam_LastLeaderActor = 5; static constexpr ui64 SysParam_SelfCheckPeriodMillis = 6; static constexpr ui64 SysParam_SessionGracePeriodMillis = 7; static constexpr ui64 SysParam_SelfCheckCounter = 8; diff --git a/ydb/core/kesus/tablet/tx_init.cpp b/ydb/core/kesus/tablet/tx_init.cpp index ca2f6adcbb6..1f3f96ff9f3 100644 --- a/ydb/core/kesus/tablet/tx_init.cpp +++ b/ydb/core/kesus/tablet/tx_init.cpp @@ -71,7 +71,7 @@ struct TKesusTablet::TTxInit : public TTxBase { case Schema::SysParam_NextSemaphoreOrderId: Self->NextSemaphoreOrderId = FromString<ui64>(value); break; - case Schema::SysParam_LastLeaderActor: + case Schema::SysParam_LastLeaderActor: Y_VERIFY(PreviousTabletActorID.Parse(value.data(), value.size())); break; case Schema::SysParam_SelfCheckPeriodMillis: @@ -234,7 +234,7 @@ struct TKesusTablet::TTxInit : public TTxBase { Self->QuoterResources.ConstructTrees(); } - Self->PersistSysParam(db, Schema::SysParam_LastLeaderActor, ctx.SelfID.ToString()); + Self->PersistSysParam(db, Schema::SysParam_LastLeaderActor, ctx.SelfID.ToString()); return true; } diff --git a/ydb/core/kesus/tablet/tx_session_attach.cpp b/ydb/core/kesus/tablet/tx_session_attach.cpp index 5604bb4fd95..ca5f4191f2a 100644 --- a/ydb/core/kesus/tablet/tx_session_attach.cpp +++ b/ydb/core/kesus/tablet/tx_session_attach.cpp @@ -249,11 +249,11 @@ void TKesusTablet::Handle(TEvKesus::TEvAttachSession::TPtr& ev) { // nothing in the underlying database is changing, then we may // give ownership to the requesting proxy immediately. This // may be unsafe if another copy of the tablet is up, making us - // a stale leader, and in which case we shouldn't be allowed to + // a stale leader, and in which case we shouldn't be allowed to // make decisions. // However if we assume that only one session uses SessionId at a // time this successful attachment is fine. Eventually proxy - // will reconnect to the new leader anyway and situation where + // will reconnect to the new leader anyway and situation where // two sessions successfully attached is not possible. // Unless they use the same SessionId that is. LOG_DEBUG_S(TActivationContext::AsActorContext(), NKikimrServices::KESUS_TABLET, diff --git a/ydb/core/kesus/tablet/ut_helpers.cpp b/ydb/core/kesus/tablet/ut_helpers.cpp index 7ba62987734..f559800a769 100644 --- a/ydb/core/kesus/tablet/ut_helpers.cpp +++ b/ydb/core/kesus/tablet/ut_helpers.cpp @@ -77,8 +77,8 @@ void TTestContext::Setup(ui32 nodeCount, bool useRealThreads) { SetupLogging(); SetupTabletServices(); - TActorId bootstrapper = CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + TActorId bootstrapper = CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreateKesusTablet); Runtime->EnableScheduleForActor(bootstrapper); { @@ -112,13 +112,13 @@ void TTestContext::Sleep(ui64 millis) { void TTestContext::RebootTablet() { ui32 nodeIndex = 0; TActorId sender = Runtime->AllocateEdgeActor(nodeIndex); - ForwardToTablet(*Runtime, TabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex); + ForwardToTablet(*Runtime, TabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvTablet::EvBoot); Runtime->DispatchEvents(options); } - InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); + InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); ProxyClients.clear(); } diff --git a/ydb/core/kesus/tablet/ut_helpers.h b/ydb/core/kesus/tablet/ut_helpers.h index 00ddb240a1b..8f487a30332 100644 --- a/ydb/core/kesus/tablet/ut_helpers.h +++ b/ydb/core/kesus/tablet/ut_helpers.h @@ -34,7 +34,7 @@ struct TTestContext { // Sleeps for millis milliseconds using fake time void Sleep(ui64 millis); - // Doesn't sleep unlike NKikimr::RebootTablet + // Doesn't sleep unlike NKikimr::RebootTablet void RebootTablet(); // Returns tablet actor for direct manipulation diff --git a/ydb/core/keyvalue/keyvalue_ut.cpp b/ydb/core/keyvalue/keyvalue_ut.cpp index 76e8478dfca..4ae1fcf56a6 100644 --- a/ydb/core/keyvalue/keyvalue_ut.cpp +++ b/ydb/core/keyvalue/keyvalue_ut.cpp @@ -82,8 +82,8 @@ struct TTestContext { SetupLogging(*Runtime); SetupTabletServices(*Runtime); setup(*Runtime); - CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreateKeyValueFlat); TDispatchOptions options; diff --git a/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp b/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp index b9fb75378ca..f8e3cd0c772 100644 --- a/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp +++ b/ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp @@ -956,11 +956,11 @@ private: } private: - struct TScanFreeSpace : public IDestructable { + struct TScanFreeSpace : public IDestructable { ui64 FreeSpace = 0; }; - THolder<IDestructable> GetSourcesState() override { + THolder<IDestructable> GetSourcesState() override { if (ScanData) { auto state = MakeHolder<TScanFreeSpace>(); state->FreeSpace = GetMemoryLimits().ScanBufferSize > ScanData->GetStoredBytes() @@ -971,7 +971,7 @@ private: return nullptr; } - void PollSources(THolder<IDestructable> prev) override { + void PollSources(THolder<IDestructable> prev) override { if (!prev || !ScanData || Shards.empty()) { return; } diff --git a/ydb/core/kqp/executer/kqp_data_executer.cpp b/ydb/core/kqp/executer/kqp_data_executer.cpp index 200cf6f2113..003d4ffa206 100644 --- a/ydb/core/kqp/executer/kqp_data_executer.cpp +++ b/ydb/core/kqp/executer/kqp_data_executer.cpp @@ -113,7 +113,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da ui64 ShardMaxStep = 0; ui64 ReadSize = 0; bool ShardReadLocks = false; - bool Follower = false; + bool Follower = false; }; TMaybe<TDatashardState> DatashardState; @@ -354,9 +354,9 @@ private: { state.State = TShardState::EState::Finished; - YQL_ENSURE(!state.DatashardState->Follower); + YQL_ENSURE(!state.DatashardState->Follower); - Send(MakePipePeNodeCacheID(/* allowFollowers */ false), new TEvPipeCache::TEvForward( + Send(MakePipePeNodeCacheID(/* allowFollowers */ false), new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(TxId), shardId, /* subscribe */ false)); } } @@ -517,7 +517,7 @@ private: state.State = TShardState::EState::Executing; YQL_ENSURE(state.DatashardState.Defined()); - YQL_ENSURE(!state.DatashardState->Follower); + YQL_ENSURE(!state.DatashardState->Follower); aggrMinStep = Max(aggrMinStep, state.DatashardState->ShardMinStep); aggrMaxStep = Min(aggrMaxStep, state.DatashardState->ShardMaxStep); @@ -725,7 +725,7 @@ private: LOG_I("Reattach to shard " << tabletId); - Send(MakePipePeNodeCacheID(UseFollowers), new TEvPipeCache::TEvForward( + Send(MakePipePeNodeCacheID(UseFollowers), new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransactionAttach(tabletId, TxId), tabletId, /* subscribe */ true), 0, ++shardState->ReattachState.Cookie); } @@ -1144,7 +1144,7 @@ private: TShardState shardState; shardState.State = ImmediateTx ? TShardState::EState::Executing : TShardState::EState::Preparing; shardState.DatashardState.ConstructInPlace(); - shardState.DatashardState->Follower = UseFollowers; + shardState.DatashardState->Follower = UseFollowers; if (Deadline) { TDuration timeout = *Deadline - TAppData::TimeProvider->Now(); @@ -1203,7 +1203,7 @@ private: ImmediateTx ? NTxDataShard::TTxFlags::Immediate : 0); } - Send(MakePipePeNodeCacheID(UseFollowers), new TEvPipeCache::TEvForward(ev, shardId, true)); + Send(MakePipePeNodeCacheID(UseFollowers), new TEvPipeCache::TEvForward(ev, shardId, true)); auto result = ShardStates.emplace(shardId, std::move(shardState)); YQL_ENSURE(result.second); @@ -1456,17 +1456,17 @@ private: ImmediateTx = true; } - UseFollowers = Request.IsolationLevel == NKikimrKqp::ISOLATION_LEVEL_READ_STALE; + UseFollowers = Request.IsolationLevel == NKikimrKqp::ISOLATION_LEVEL_READ_STALE; if (datashardTxs.size() > 1) { // Followers only allowed for single shard transactions. // (legacy behaviour, for compatibility with current execution engine) - UseFollowers = false; + UseFollowers = false; } if (Request.Snapshot.IsValid()) { // TODO: KIKIMR-11912 - UseFollowers = false; + UseFollowers = false; } - if (UseFollowers) { + if (UseFollowers) { YQL_ENSURE(ReadOnlyTx); } @@ -1603,7 +1603,7 @@ private: << ", readonly: " << ReadOnlyTx << ", datashardTxs: " << datashardTxs.size() << ", immediate: " << ImmediateTx - << ", useFollowers: " << UseFollowers); + << ", useFollowers: " << UseFollowers); LOG_T("Updating channels after the creation of compute actors"); THashMap<TActorId, THashSet<ui64>> updates; @@ -1749,7 +1749,7 @@ private: TVector<TKqpExecuterTxResult> Results; bool ReadOnlyTx = true; bool ImmediateTx = false; - bool UseFollowers = false; + bool UseFollowers = false; bool TxPlanned = false; TInstant FirstPrepareReply; diff --git a/ydb/core/kqp/executer/kqp_shards_resolver.cpp b/ydb/core/kqp/executer/kqp_shards_resolver.cpp index 9ce7bd4ef5e..506dfcf5730 100644 --- a/ydb/core/kqp/executer/kqp_shards_resolver.cpp +++ b/ydb/core/kqp/executer/kqp_shards_resolver.cpp @@ -113,8 +113,8 @@ private: TEvTabletResolver::TEvForward::TResolveFlags GetResolveFlags() { TEvTabletResolver::TEvForward::TResolveFlags resolveFlags; - resolveFlags.SetAllowFollower(false); - resolveFlags.SetForceFollower(false); + resolveFlags.SetAllowFollower(false); + resolveFlags.SetForceFollower(false); resolveFlags.SetPreferLocal(true); resolveFlags.SetForceLocal(false); diff --git a/ydb/core/kqp/prepare/kqp_query_exec.cpp b/ydb/core/kqp/prepare/kqp_query_exec.cpp index abc28f67a78..bc2d4e94ce9 100644 --- a/ydb/core/kqp/prepare/kqp_query_exec.cpp +++ b/ydb/core/kqp/prepare/kqp_query_exec.cpp @@ -602,7 +602,7 @@ TKqpParamsMap BuildParamsMap(const TVector<NKikimrKqp::TParameterBinding>& bindi readTarget = (ui32)NKikimr::TReadTarget::EMode::Head; break; case NKikimrKqp::ISOLATION_LEVEL_READ_STALE: - readTarget = (ui32)NKikimr::TReadTarget::EMode::Follower; + readTarget = (ui32)NKikimr::TReadTarget::EMode::Follower; break; default: break; diff --git a/ydb/core/kqp/ut/common/kqp_ut_common.h b/ydb/core/kqp/ut/common/kqp_ut_common.h index 6f2cbece2e7..c1d64b65c3e 100644 --- a/ydb/core/kqp/ut/common/kqp_ut_common.h +++ b/ydb/core/kqp/ut/common/kqp_ut_common.h @@ -90,7 +90,7 @@ struct TKikimrSettings: public TTestFeatureFlagsHolder<TKikimrSettings> { TKikimrSettings& SetNodeCount(ui32 value) { NodeCount = value; return *this; } TKikimrSettings& SetWithSampleTables(bool value) { WithSampleTables = value; return *this; } TKikimrSettings& SetKeepSnapshotTimeout(TDuration value) { KeepSnapshotTimeout = value; return *this; } - TKikimrSettings& SetLogStream(IOutputStream* follower) { LogStream = follower; return *this; }; + TKikimrSettings& SetLogStream(IOutputStream* follower) { LogStream = follower; return *this; }; }; diff --git a/ydb/core/kqp/ut/kqp_newengine_ut.cpp b/ydb/core/kqp/ut/kqp_newengine_ut.cpp index 4f060abf194..3737687d8d6 100644 --- a/ydb/core/kqp/ut/kqp_newengine_ut.cpp +++ b/ydb/core/kqp/ut/kqp_newengine_ut.cpp @@ -2067,7 +2067,7 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { AssertSuccessResult(session.ExecuteSchemeQuery(R"( --!syntax_v1 - CREATE TABLE `FollowersKv` ( + CREATE TABLE `FollowersKv` ( Key Uint64, Value String, PRIMARY KEY (Key) @@ -2082,7 +2082,7 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { --!syntax_v1 PRAGMA kikimr.UseNewEngine = "true"; - REPLACE INTO `FollowersKv` (Key, Value) VALUES + REPLACE INTO `FollowersKv` (Key, Value) VALUES (1u, "One"), (11u, "Two"), (21u, "Three"), @@ -2093,11 +2093,11 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { kikimr.GetTestServer().GetRuntime()->SetLogPriority(NKikimrServices::PIPE_CLIENT, NActors::NLog::PRI_DEBUG); //kikimr.GetTestServer().GetRuntime()->SetLogPriority(NKikimrServices::PIPE_SERVER, NActors::NLog::PRI_DEBUG); - // Followers immediate + // Followers immediate auto result = session.ExecuteDataQuery(R"( --!syntax_v1 PRAGMA kikimr.UseNewEngine = "true"; - SELECT * FROM FollowersKv WHERE Key = 21; + SELECT * FROM FollowersKv WHERE Key = 21; )", TTxControl::BeginTx(TTxSettings::StaleRO()).CommitTx()).ExtractValueSync(); AssertSuccessResult(result); @@ -2107,11 +2107,11 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { ] )", FormatResultSetYson(result.GetResultSet(0))); - // Followers distributed + // Followers distributed result = session.ExecuteDataQuery(R"( --!syntax_v1 PRAGMA kikimr.UseNewEngine = "true"; - SELECT * FROM FollowersKv WHERE Value != "One" ORDER BY Key; + SELECT * FROM FollowersKv WHERE Value != "One" ORDER BY Key; )", TTxControl::BeginTx(TTxSettings::StaleRO()).CommitTx()).ExtractValueSync(); AssertSuccessResult(result); @@ -2123,7 +2123,7 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { ] )", FormatResultSetYson(result.GetResultSet(0))); - // No followers immediate + // No followers immediate result = session.ExecuteDataQuery(R"( --!syntax_v1 PRAGMA kikimr.UseNewEngine = "true"; @@ -2137,7 +2137,7 @@ Y_UNIT_TEST_SUITE(KqpNewEngine) { ] )", FormatResultSetYson(result.GetResultSet(0))); - // No followers distributed + // No followers distributed result = session.ExecuteDataQuery(R"( --!syntax_v1 PRAGMA kikimr.UseNewEngine = "true"; diff --git a/ydb/core/mind/bscontroller/config.cpp b/ydb/core/mind/bscontroller/config.cpp index ce405b7cc20..aa7d6efceea 100644 --- a/ydb/core/mind/bscontroller/config.cpp +++ b/ydb/core/mind/bscontroller/config.cpp @@ -889,10 +889,10 @@ namespace NKikimr::NBsController { group->SetEncryptionMode(groupInfo.EncryptionMode.GetOrElse(0)); group->SetLifeCyclePhase(groupInfo.LifeCyclePhase.GetOrElse(0)); - group->SetMainKeyId(groupInfo.MainKeyId.GetOrElse("")); + group->SetMainKeyId(groupInfo.MainKeyId.GetOrElse("")); group->SetEncryptedGroupKey(groupInfo.EncryptedGroupKey.GetOrElse("")); group->SetGroupKeyNonce(groupInfo.GroupKeyNonce.GetOrElse(0)); - group->SetMainKeyVersion(groupInfo.MainKeyVersion.GetOrElse(0)); + group->SetMainKeyVersion(groupInfo.MainKeyVersion.GetOrElse(0)); if (scopeId) { auto *pb = group->MutableAcceptedScope(); diff --git a/ydb/core/mind/bscontroller/config_fit_groups.cpp b/ydb/core/mind/bscontroller/config_fit_groups.cpp index 01ab97a277e..cb8801b0f5f 100644 --- a/ydb/core/mind/bscontroller/config_fit_groups.cpp +++ b/ydb/core/mind/bscontroller/config_fit_groups.cpp @@ -117,17 +117,17 @@ namespace NKikimr { } // create group info - const ui64 MainKeyVersion = 0; + const ui64 MainKeyVersion = 0; ui32 lifeCyclePhase = 0; - TString mainKeyId = ""; + TString mainKeyId = ""; TString encryptedGroupKey = ""; ui64 groupKeyNonce = groupId; // For the first time use groupId, then use low 32 bits of the // NextGroupKeyNonce to produce high 32 bits of the groupKeyNonce. TGroupInfo *groupInfo = State.Groups.ConstructInplaceNewEntry(groupId, groupId, 1, 0, Geometry.GetErasure(), desiredPDiskCategory.GetOrElse(0), StoragePool.VDiskKind, - StoragePool.EncryptionMode.GetOrElse(0), lifeCyclePhase, mainKeyId, encryptedGroupKey, - groupKeyNonce, MainKeyVersion, false, false, StoragePoolId, Geometry.GetNumFailRealms(), + StoragePool.EncryptionMode.GetOrElse(0), lifeCyclePhase, mainKeyId, encryptedGroupKey, + groupKeyNonce, MainKeyVersion, false, false, StoragePoolId, Geometry.GetNumFailRealms(), Geometry.GetNumFailDomainsPerFailRealm(), Geometry.GetNumVDisksPerFailDomain()); // bind group to storage pool diff --git a/ydb/core/mind/bscontroller/impl.h b/ydb/core/mind/bscontroller/impl.h index 59ff1574f9e..ba311a254c3 100644 --- a/ydb/core/mind/bscontroller/impl.h +++ b/ydb/core/mind/bscontroller/impl.h @@ -462,10 +462,10 @@ public: Table::DesiredVDiskCategory::Type DesiredVDiskCategory = NKikimrBlobStorage::TVDiskKind::Default; TMaybe<Table::EncryptionMode::Type> EncryptionMode; // null on old versions TMaybe<Table::LifeCyclePhase::Type> LifeCyclePhase; // null on old versions - TMaybe<Table::MainKeyId::Type> MainKeyId; // null on old versions + TMaybe<Table::MainKeyId::Type> MainKeyId; // null on old versions TMaybe<Table::EncryptedGroupKey::Type> EncryptedGroupKey; // null on old versions TMaybe<Table::GroupKeyNonce::Type> GroupKeyNonce; // null on old versions - TMaybe<Table::MainKeyVersion::Type> MainKeyVersion; // null on old verstions + TMaybe<Table::MainKeyVersion::Type> MainKeyVersion; // null on old verstions bool PersistedDown = false; // the value stored in the database bool SeenOperational = false; @@ -512,10 +512,10 @@ public: Table::DesiredVDiskCategory, Table::EncryptionMode, Table::LifeCyclePhase, - Table::MainKeyId, + Table::MainKeyId, Table::EncryptedGroupKey, Table::GroupKeyNonce, - Table::MainKeyVersion, + Table::MainKeyVersion, Table::SeenOperational > adapter( &TGroupInfo::Generation, @@ -525,10 +525,10 @@ public: &TGroupInfo::DesiredVDiskCategory, &TGroupInfo::EncryptionMode, &TGroupInfo::LifeCyclePhase, - &TGroupInfo::MainKeyId, + &TGroupInfo::MainKeyId, &TGroupInfo::EncryptedGroupKey, &TGroupInfo::GroupKeyNonce, - &TGroupInfo::MainKeyVersion, + &TGroupInfo::MainKeyVersion, &TGroupInfo::SeenOperational ); callback(&adapter); @@ -542,10 +542,10 @@ public: Schema::Group::DesiredVDiskCategory::Type desiredVDiskCategory, Schema::Group::EncryptionMode::Type encryptionMode, Schema::Group::LifeCyclePhase::Type lifeCyclePhase, - Schema::Group::MainKeyId::Type mainKeyId, + Schema::Group::MainKeyId::Type mainKeyId, Schema::Group::EncryptedGroupKey::Type encryptedGroupKey, Schema::Group::GroupKeyNonce::Type groupKeyNonce, - Schema::Group::MainKeyVersion::Type mainKeyVersion, + Schema::Group::MainKeyVersion::Type mainKeyVersion, Schema::Group::Down::Type down, Schema::Group::SeenOperational::Type seenOperational, TBoxStoragePoolId storagePoolId, @@ -560,10 +560,10 @@ public: , DesiredVDiskCategory(desiredVDiskCategory) , EncryptionMode(encryptionMode) , LifeCyclePhase(lifeCyclePhase) - , MainKeyId(mainKeyId) + , MainKeyId(mainKeyId) , EncryptedGroupKey(encryptedGroupKey) , GroupKeyNonce(groupKeyNonce) - , MainKeyVersion(mainKeyVersion) + , MainKeyVersion(mainKeyVersion) , PersistedDown(down) , SeenOperational(seenOperational) , Down(PersistedDown) @@ -1514,7 +1514,7 @@ private: PassAway(); } - void Execute(TAutoPtr<ITransaction> tx) { + void Execute(TAutoPtr<ITransaction> tx) { TTabletExecutedFlat::Execute(tx, TActivationContext::AsActorContext()); } diff --git a/ydb/core/mind/bscontroller/load_everything.cpp b/ydb/core/mind/bscontroller/load_everything.cpp index a45e14564e9..8fa32c53f75 100644 --- a/ydb/core/mind/bscontroller/load_everything.cpp +++ b/ydb/core/mind/bscontroller/load_everything.cpp @@ -184,10 +184,10 @@ public: groups.GetValueOrDefault<Schema::Group::DesiredVDiskCategory>(NKikimrBlobStorage::TVDiskKind::Default), groups.GetValueOrDefault<Schema::Group::EncryptionMode>(), groups.GetValueOrDefault<Schema::Group::LifeCyclePhase>(), - groups.GetValueOrDefault<Schema::Group::MainKeyId>(nullptr), + groups.GetValueOrDefault<Schema::Group::MainKeyId>(nullptr), groups.GetValueOrDefault<Schema::Group::EncryptedGroupKey>(nullptr), groups.GetValueOrDefault<Schema::Group::GroupKeyNonce>(), - groups.GetValueOrDefault<Schema::Group::MainKeyVersion>(), + groups.GetValueOrDefault<Schema::Group::MainKeyVersion>(), groups.GetValueOrDefault<Schema::Group::Down>(), groups.GetValueOrDefault<Schema::Group::SeenOperational>(), storagePoolId, diff --git a/ydb/core/mind/bscontroller/propose_group_key.cpp b/ydb/core/mind/bscontroller/propose_group_key.cpp index 9a3558afc2b..ebca302ee67 100644 --- a/ydb/core/mind/bscontroller/propose_group_key.cpp +++ b/ydb/core/mind/bscontroller/propose_group_key.cpp @@ -10,9 +10,9 @@ protected: ui32 NodeId = 0; ui32 GroupId = 0; ui32 LifeCyclePhase = 0; - TString MainKeyId = ""; + TString MainKeyId = ""; TString EncryptedGroupKey = ""; - ui64 MainKeyVersion = 0; + ui64 MainKeyVersion = 0; ui64 GroupKeyNonce = 0; bool IsAnotherTxInProgress = false; public: @@ -23,9 +23,9 @@ public: NodeId = Proto.GetNodeId(); GroupId = Proto.GetGroupId(); LifeCyclePhase = Proto.GetLifeCyclePhase(); - MainKeyId = Proto.GetMainKeyId(); + MainKeyId = Proto.GetMainKeyId(); EncryptedGroupKey = Proto.GetEncryptedGroupKey(); - MainKeyVersion = Proto.GetMainKeyVersion(); + MainKeyVersion = Proto.GetMainKeyVersion(); GroupKeyNonce = Proto.GetGroupKeyNonce(); } @@ -44,10 +44,10 @@ public: STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK04, "Group LifeCyclePhase does not match ELCP_INITIAL", (GroupId, GroupId), (LifeCyclePhase, group->LifeCyclePhase.GetOrElse(0))); IsAnotherTxInProgress = (group->LifeCyclePhase.GetOrElse(0) == TBlobStorageGroupInfo::ELCP_IN_TRANSITION); - } else if (group->MainKeyVersion.GetOrElse(0) != (MainKeyVersion - 1)) { - STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK05, "Group MainKeyVersion does not match required MainKeyVersion", - (GroupId, GroupId), (MainKeyVersion, group->MainKeyVersion.GetOrElse(0)), - (RequiredMainKeyVersion, MainKeyVersion - 1)); + } else if (group->MainKeyVersion.GetOrElse(0) != (MainKeyVersion - 1)) { + STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK05, "Group MainKeyVersion does not match required MainKeyVersion", + (GroupId, GroupId), (MainKeyVersion, group->MainKeyVersion.GetOrElse(0)), + (RequiredMainKeyVersion, MainKeyVersion - 1)); } else if (EncryptedGroupKey.size() != 32 + sizeof(ui32)) { STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK06, "Group does not accept EncryptedGroupKey size", (GroupId, GroupId), (EncryptedGroupKeySize, EncryptedGroupKey.size()), @@ -64,16 +64,16 @@ public: TGroupInfo *group = Self->FindGroup(GroupId); Y_VERIFY(group); // the existence of this group must have been checked during ReadStep group->LifeCyclePhase = TBlobStorageGroupInfo::ELCP_IN_TRANSITION; - group->MainKeyId = MainKeyId; + group->MainKeyId = MainKeyId; group->EncryptedGroupKey = EncryptedGroupKey; group->GroupKeyNonce = GroupKeyNonce; - group->MainKeyVersion = MainKeyVersion; + group->MainKeyVersion = MainKeyVersion; db.Table<Schema::Group>().Key(GroupId).Update( NIceDb::TUpdate<Schema::Group::LifeCyclePhase>(TBlobStorageGroupInfo::ELCP_IN_USE), - NIceDb::TUpdate<Schema::Group::MainKeyId>(MainKeyId), + NIceDb::TUpdate<Schema::Group::MainKeyId>(MainKeyId), NIceDb::TUpdate<Schema::Group::EncryptedGroupKey>(EncryptedGroupKey), NIceDb::TUpdate<Schema::Group::GroupKeyNonce>(GroupKeyNonce), - NIceDb::TUpdate<Schema::Group::MainKeyVersion>(MainKeyVersion)); + NIceDb::TUpdate<Schema::Group::MainKeyVersion>(MainKeyVersion)); } bool Execute(TTransactionContext &txc, const TActorContext&) override { diff --git a/ydb/core/mind/bscontroller/scheme.h b/ydb/core/mind/bscontroller/scheme.h index ba08473ef02..3b7a425c95c 100644 --- a/ydb/core/mind/bscontroller/scheme.h +++ b/ydb/core/mind/bscontroller/scheme.h @@ -53,16 +53,16 @@ struct Schema : NIceDb::Schema { struct DesiredVDiskCategory : Column<6, NScheme::NTypeIds::Uint64> { using Type = NKikimrBlobStorage::TVDiskKind::EVDiskKind; }; struct EncryptionMode : Column<7, NScheme::NTypeIds::Uint32> { static constexpr Type Default = 0; }; struct LifeCyclePhase : Column<8, NScheme::NTypeIds::Uint32> { static constexpr Type Default = 0; }; - struct MainKeyId : Column<9, NScheme::NTypeIds::String> {}; + struct MainKeyId : Column<9, NScheme::NTypeIds::String> {}; struct EncryptedGroupKey : Column<10, NScheme::NTypeIds::String> {}; struct GroupKeyNonce : Column<11, NScheme::NTypeIds::Uint64> { static constexpr Type Default = 0; }; - struct MainKeyVersion : Column<12, NScheme::NTypeIds::Uint64> { static constexpr Type Default = 0; }; + struct MainKeyVersion : Column<12, NScheme::NTypeIds::Uint64> { static constexpr Type Default = 0; }; struct Down : Column<13, NScheme::NTypeIds::Bool> { static constexpr Type Default = false; }; struct SeenOperational : Column<14, NScheme::NTypeIds::Bool> { static constexpr Type Default = false; }; using TKey = TableKey<ID>; using TColumns = TableColumns<ID, Generation, ErasureSpecies, Owner, DesiredPDiskCategory, DesiredVDiskCategory, - EncryptionMode, LifeCyclePhase, MainKeyId, EncryptedGroupKey, GroupKeyNonce, MainKeyVersion, Down, + EncryptionMode, LifeCyclePhase, MainKeyId, EncryptedGroupKey, GroupKeyNonce, MainKeyVersion, Down, SeenOperational>; }; diff --git a/ydb/core/mind/bscontroller/ut_bscontroller/main.cpp b/ydb/core/mind/bscontroller/ut_bscontroller/main.cpp index 740cc51c6ca..87f7b18fb35 100644 --- a/ydb/core/mind/bscontroller/ut_bscontroller/main.cpp +++ b/ydb/core/mind/bscontroller/ut_bscontroller/main.cpp @@ -229,8 +229,8 @@ struct TEnvironmentSetup { } void SetupTablet() { - const TActorId bootstrapper = CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, TErasureType::ErasureNone, GroupId), + const TActorId bootstrapper = CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, TErasureType::ErasureNone, GroupId), &CreateFlatBsController, NodeId); Runtime->EnableScheduleForActor(bootstrapper); { diff --git a/ydb/core/mind/bscontroller/ut_selfheal/env.h b/ydb/core/mind/bscontroller/ut_selfheal/env.h index 6f261722031..e79bf914a17 100644 --- a/ydb/core/mind/bscontroller/ut_selfheal/env.h +++ b/ydb/core/mind/bscontroller/ut_selfheal/env.h @@ -178,8 +178,8 @@ struct TEnvironmentSetup { } void SetupTablet() { - Runtime->CreateTestBootstrapper( - TTestActorSystem::CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, TErasureType::ErasureNone, GroupId), + Runtime->CreateTestBootstrapper( + TTestActorSystem::CreateTestTabletInfo(TabletId, TTabletTypes::FLAT_BS_CONTROLLER, TErasureType::ErasureNone, GroupId), &CreateFlatBsController, NodeId); diff --git a/ydb/core/mind/configured_tablet_bootstrapper.cpp b/ydb/core/mind/configured_tablet_bootstrapper.cpp index be7bb66c694..008acd2b400 100644 --- a/ydb/core/mind/configured_tablet_bootstrapper.cpp +++ b/ydb/core/mind/configured_tablet_bootstrapper.cpp @@ -86,8 +86,8 @@ class TConfiguredTabletBootstrapper : public TActorBootstrapped<TConfiguredTable } if (config.HasWatchThreshold()) bi->WatchThreshold = TDuration::MilliSeconds(config.GetWatchThreshold()); - if (config.HasStartFollowers()) - bi->StartFollowers = config.GetStartFollowers(); + if (config.HasStartFollowers()) + bi->StartFollowers = config.GetStartFollowers(); } BootstrapperInstance = Register(CreateBootstrapper(storageInfo.Get(), bi.Get(), false), TMailboxType::HTSwap, appData->SystemPoolId); diff --git a/ydb/core/mind/hive/boot_queue.cpp b/ydb/core/mind/hive/boot_queue.cpp index 2fddcef5d74..197aa6b6c57 100644 --- a/ydb/core/mind/hive/boot_queue.cpp +++ b/ydb/core/mind/hive/boot_queue.cpp @@ -1,5 +1,5 @@ #include "boot_queue.h" -#include "leader_tablet_info.h" +#include "leader_tablet_info.h" namespace NKikimr { namespace NHive { diff --git a/ydb/core/mind/hive/boot_queue.h b/ydb/core/mind/hive/boot_queue.h index 6546639d613..a8424770f65 100644 --- a/ydb/core/mind/hive/boot_queue.h +++ b/ydb/core/mind/hive/boot_queue.h @@ -25,7 +25,7 @@ struct TBootQueue { priority = 2; break; default: - if (tablet.IsLeader()) { + if (tablet.IsLeader()) { priority = 1; } break; diff --git a/ydb/core/mind/hive/fill.cpp b/ydb/core/mind/hive/fill.cpp index a4b42cc0fc0..f90fa56f422 100644 --- a/ydb/core/mind/hive/fill.cpp +++ b/ydb/core/mind/hive/fill.cpp @@ -101,9 +101,9 @@ public: for (auto it = Hive->Tablets.begin(); it != Hive->Tablets.end(); ++it) { it->second.UpdateWeight(); tablets.push_back(&it->second); - for (auto& follower : it->second.Followers) { - follower.UpdateWeight(); - tablets.push_back(&follower); + for (auto& follower : it->second.Followers) { + follower.UpdateWeight(); + tablets.push_back(&follower); } } Sort(tablets, [](const TTabletInfo* a, const TTabletInfo* b) -> bool { return a->Weight > b->Weight; }); diff --git a/ydb/core/mind/hive/follower_group.h b/ydb/core/mind/hive/follower_group.h index b827d5825c7..33ab3189ffe 100644 --- a/ydb/core/mind/hive/follower_group.h +++ b/ydb/core/mind/hive/follower_group.h @@ -7,34 +7,34 @@ namespace NKikimr { namespace NHive { -struct TFollowerGroup { - TFollowerGroupId Id = 0; - bool AllowLeaderPromotion = false; +struct TFollowerGroup { + TFollowerGroupId Id = 0; + bool AllowLeaderPromotion = false; bool AllowClientRead = false; bool RequireAllDataCenters = true; TVector<TNodeId> AllowedNodes; TVector<TDataCenterId> AllowedDataCenters; - bool LocalNodeOnly = true; // run follower on the same node as leader - bool RequireDifferentNodes = false; // do not run followers on same nodes as another followers of the same leader - bool FollowerCountPerDataCenter = false; // PER_AZ KIKIMR-10443 + bool LocalNodeOnly = true; // run follower on the same node as leader + bool RequireDifferentNodes = false; // do not run followers on same nodes as another followers of the same leader + bool FollowerCountPerDataCenter = false; // PER_AZ KIKIMR-10443 - TFollowerGroup() = default; - TFollowerGroup(const TFollowerGroup&) = delete; - TFollowerGroup(TFollowerGroup&&) = delete; - TFollowerGroup& operator =(const TFollowerGroup&) = delete; - TFollowerGroup& operator =(TFollowerGroup&&) = delete; + TFollowerGroup() = default; + TFollowerGroup(const TFollowerGroup&) = delete; + TFollowerGroup(TFollowerGroup&&) = delete; + TFollowerGroup& operator =(const TFollowerGroup&) = delete; + TFollowerGroup& operator =(TFollowerGroup&&) = delete; - operator TFollowerGroupId() const { + operator TFollowerGroupId() const { return Id; } - TFollowerGroup& operator =(const NKikimrHive::TFollowerGroup& followerGroup) { - FollowerCount = followerGroup.GetFollowerCount(); - AllowLeaderPromotion = followerGroup.GetAllowLeaderPromotion(); - AllowClientRead = followerGroup.GetAllowClientRead(); - RequireAllDataCenters = followerGroup.GetRequireAllDataCenters(); + TFollowerGroup& operator =(const NKikimrHive::TFollowerGroup& followerGroup) { + FollowerCount = followerGroup.GetFollowerCount(); + AllowLeaderPromotion = followerGroup.GetAllowLeaderPromotion(); + AllowClientRead = followerGroup.GetAllowClientRead(); + RequireAllDataCenters = followerGroup.GetRequireAllDataCenters(); { - const auto& allowedNodes(followerGroup.GetAllowedNodeIDs()); + const auto& allowedNodes(followerGroup.GetAllowedNodeIDs()); std::copy(allowedNodes.begin(), allowedNodes.end(), std::back_inserter(AllowedNodes)); } { @@ -46,30 +46,30 @@ struct TFollowerGroup { } } } - LocalNodeOnly = followerGroup.GetLocalNodeOnly(); - RequireDifferentNodes = followerGroup.GetRequireDifferentNodes(); - FollowerCountPerDataCenter = followerGroup.GetFollowerCountPerDataCenter(); + LocalNodeOnly = followerGroup.GetLocalNodeOnly(); + RequireDifferentNodes = followerGroup.GetRequireDifferentNodes(); + FollowerCountPerDataCenter = followerGroup.GetFollowerCountPerDataCenter(); return *this; } - ui32 GetRawFollowerCount() const { - return FollowerCount; + ui32 GetRawFollowerCount() const { + return FollowerCount; } ui32 GetComputedFollowerCount(ui32 dataCenters) const { - if (FollowerCountPerDataCenter) { + if (FollowerCountPerDataCenter) { return FollowerCount * dataCenters; } else { - return FollowerCount; + return FollowerCount; } } - void SetFollowerCount(ui32 followerCount) { - FollowerCount = followerCount; + void SetFollowerCount(ui32 followerCount) { + FollowerCount = followerCount; } private: - ui32 FollowerCount = 0; + ui32 FollowerCount = 0; }; } // NHive diff --git a/ydb/core/mind/hive/follower_tablet_info.cpp b/ydb/core/mind/hive/follower_tablet_info.cpp index 940c4462cb0..44ba11dc8a0 100644 --- a/ydb/core/mind/hive/follower_tablet_info.cpp +++ b/ydb/core/mind/hive/follower_tablet_info.cpp @@ -1,15 +1,15 @@ -#include "follower_tablet_info.h" -#include "follower_group.h" -#include "leader_tablet_info.h" +#include "follower_tablet_info.h" +#include "follower_group.h" +#include "leader_tablet_info.h" namespace NKikimr { namespace NHive { -TFollowerTabletInfo::TFollowerTabletInfo(TLeaderTabletInfo& leaderTablet, TFollowerId id, TFollowerGroup& followerGroup) - : TTabletInfo(ETabletRole::Follower, leaderTablet.Hive) - , LeaderTablet(leaderTablet) +TFollowerTabletInfo::TFollowerTabletInfo(TLeaderTabletInfo& leaderTablet, TFollowerId id, TFollowerGroup& followerGroup) + : TTabletInfo(ETabletRole::Follower, leaderTablet.Hive) + , LeaderTablet(leaderTablet) , Id(id) - , FollowerGroup(followerGroup) + , FollowerGroup(followerGroup) {} } diff --git a/ydb/core/mind/hive/follower_tablet_info.h b/ydb/core/mind/hive/follower_tablet_info.h index ba71e037eea..730f6ae4a61 100644 --- a/ydb/core/mind/hive/follower_tablet_info.h +++ b/ydb/core/mind/hive/follower_tablet_info.h @@ -2,20 +2,20 @@ #include "hive.h" #include "tablet_info.h" -#include "follower_group.h" +#include "follower_group.h" namespace NKikimr { namespace NHive { -struct TFollowerGroup; +struct TFollowerGroup; -struct TFollowerTabletInfo : TTabletInfo { +struct TFollowerTabletInfo : TTabletInfo { public: - TLeaderTabletInfo& LeaderTablet; - TFollowerId Id; - TFollowerGroup& FollowerGroup; + TLeaderTabletInfo& LeaderTablet; + TFollowerId Id; + TFollowerGroup& FollowerGroup; - TFollowerTabletInfo(TLeaderTabletInfo& leaderTablet, TFollowerId id, TFollowerGroup& followerGroup); + TFollowerTabletInfo(TLeaderTabletInfo& leaderTablet, TFollowerId id, TFollowerGroup& followerGroup); }; } // NHive diff --git a/ydb/core/mind/hive/hive.cpp b/ydb/core/mind/hive/hive.cpp index 9ec6dc0e488..58c64db8323 100644 --- a/ydb/core/mind/hive/hive.cpp +++ b/ydb/core/mind/hive/hive.cpp @@ -17,11 +17,11 @@ TString ETabletStateName(ETabletState value) { } } -TString EFollowerStrategyName(EFollowerStrategy value) { +TString EFollowerStrategyName(EFollowerStrategy value) { switch (value) { - case EFollowerStrategy::Unknown: return "Unknown"; - case EFollowerStrategy::Backup: return "Backup"; - case EFollowerStrategy::Read: return "Read"; + case EFollowerStrategy::Unknown: return "Unknown"; + case EFollowerStrategy::Backup: return "Backup"; + case EFollowerStrategy::Read: return "Read"; default: return Sprintf("%d", static_cast<int>(value)); } } diff --git a/ydb/core/mind/hive/hive.h b/ydb/core/mind/hive/hive.h index b032c36e9fd..cce565aecd6 100644 --- a/ydb/core/mind/hive/hive.h +++ b/ydb/core/mind/hive/hive.h @@ -41,10 +41,10 @@ using TTabletId = ui64; using TTabletCategoryId = ui64; using TNodeId = ui32; using TDataCenterId = TString; -using TFollowerId = ui32; -using TFollowerGroupId = ui32; +using TFollowerId = ui32; +using TFollowerGroupId = ui32; using TStorageGroupId = ui32; -using TFullTabletId = std::pair<TTabletId, TFollowerId>; +using TFullTabletId = std::pair<TTabletId, TFollowerId>; using TObjectId = ui64; // schema object id, used to organize tablets of the same schema object using TOwnerId = ui64; using TResourceRawValues = std::tuple<i64, i64, i64, i64>; // CPU, Memory, Network, Counter @@ -66,13 +66,13 @@ enum class ETabletState : ui64 { TString ETabletStateName(ETabletState value); -enum class EFollowerStrategy : ui32 { +enum class EFollowerStrategy : ui32 { Unknown, Backup, Read, }; -TString EFollowerStrategyName(EFollowerStrategy value); +TString EFollowerStrategyName(EFollowerStrategy value); struct ISubActor { virtual void Cleanup() = 0; diff --git a/ydb/core/mind/hive/hive_events.h b/ydb/core/mind/hive/hive_events.h index acf36113bf2..9e26edc7a83 100644 --- a/ydb/core/mind/hive/hive_events.h +++ b/ydb/core/mind/hive/hive_events.h @@ -29,7 +29,7 @@ struct TEvPrivate { static_assert(EvEnd < EventSpaceEnd(TEvents::ES_PRIVATE), "expect EvEnd < EventSpaceEnd(TEvents::ES_PRIVATE)"); struct TEvKickTablet : TEventLocal<TEvKickTablet, EvKickTablet> { - std::pair<TTabletId, TFollowerId> TabletId; + std::pair<TTabletId, TFollowerId> TabletId; TEvKickTablet(const TTabletInfo& tablet) : TabletId(tablet.GetFullTabletId()) @@ -44,7 +44,7 @@ struct TEvPrivate { ui32 NodeId; TActorId Local; TInstant StartTime; - TMap<ui64,TVector<std::pair<TTabletId, TFollowerId>>> Tablets; + TMap<ui64,TVector<std::pair<TTabletId, TFollowerId>>> Tablets; }; struct TEvBootTablets : TEventLocal<TEvBootTablets, EvBootTablets> {}; diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index 43efe9f725c..58ca2ac3e43 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -159,7 +159,7 @@ void THive::Handle(TEvHive::TEvDeleteOwnerTablets::TPtr& ev) { Execute(CreateDeleteOwnerTablets(ev)); } -void THive::DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet) { +void THive::DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet) { Y_ENSURE_LOG(tablet->IsDeleting(), "tablet " << tablet->Id); Y_ENSURE_LOG(tablet->TabletStorageInfo->Channels.empty() || tablet->TabletStorageInfo->Channels[0].History.empty(), "tablet " << tablet->Id); @@ -358,7 +358,7 @@ void THive::Handle(TEvBlobStorage::TEvControllerSelectGroupsResult::TPtr& ev) { std::sort(tablets.begin(), tablets.end()); tablets.erase(std::unique(tablets.begin(), tablets.end()), tablets.end()); for (TTabletId tabletId : tablets) { - TLeaderTabletInfo* tablet = FindTablet(tabletId); + TLeaderTabletInfo* tablet = FindTablet(tabletId); if (!tablet) { BLOG_ERROR("THive::Handle TEvControllerSelectGroupsResult: tablet# " << tabletId << " not found"); } else { @@ -386,12 +386,12 @@ void THive::Handle(TEvLocal::TEvTabletStatus::TPtr& ev) { TEvLocal::TEvTabletStatus* msg = ev->Get(); NKikimrLocal::TEvTabletStatus& record = msg->Record; BLOG_D("Handle TEvLocal::TEvTabletStatus, TabletId: " << record.GetTabletID()); - if (FindTablet(record.GetTabletID(), record.GetFollowerId()) != nullptr) { + if (FindTablet(record.GetTabletID(), record.GetFollowerId()) != nullptr) { Execute(CreateUpdateTabletStatus( record.GetTabletID(), ev->Sender, record.GetGeneration(), - record.GetFollowerId(), + record.GetFollowerId(), static_cast<TEvLocal::TEvTabletStatus::EStatus>(record.GetStatus()), static_cast<TEvTablet::TEvTabletDead::EReason>(record.GetReason()) )); @@ -413,7 +413,7 @@ void THive::Handle(TEvPrivate::TEvBootTablets::TPtr&) { } TVector<TTabletId> tabletsToReleaseFromParent; for (auto& tab : Tablets) { - TLeaderTabletInfo& tablet = tab.second; + TLeaderTabletInfo& tablet = tab.second; if (tablet.NeedToReleaseFromParent) { BLOG_D("Need to release from parent tablet " << tablet.ToString()); tabletsToReleaseFromParent.push_back(tablet.Id); @@ -575,7 +575,7 @@ void THive::Handle(TEvPrivate::TEvProcessDisconnectNode::TPtr& ev) { auto itCategory = event->Tablets.begin(); if (itCategory != event->Tablets.end()) { BLOG_D("THive::Handle::TEvProcessDisconnectNode: Node " << event->NodeId << " Category " << itCategory->first); - for (std::pair<TTabletId, TFollowerId> tabletId : itCategory->second) { + for (std::pair<TTabletId, TFollowerId> tabletId : itCategory->second) { TTabletInfo* tablet = FindTablet(tabletId); if (tablet != nullptr) { if (tablet->IsAlive()) { @@ -695,7 +695,7 @@ void THive::Handle(TEvPrivate::TEvKickTablet::TPtr &ev) { void THive::Handle(TEvHive::TEvInitiateBlockStorage::TPtr& ev) { TTabletId tabletId = ev->Get()->TabletId; BLOG_D("THive::Handle::TEvInitiateBlockStorage TabletId=" << tabletId); - TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); + TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); if (tablet != nullptr) { if (tablet->IsDeleting()) { if (!tablet->InitiateBlockStorage(std::numeric_limits<ui32>::max())) { @@ -711,7 +711,7 @@ void THive::Handle(TEvHive::TEvInitiateBlockStorage::TPtr& ev) { void THive::Handle(TEvHive::TEvInitiateDeleteStorage::TPtr &ev) { TTabletId tabletId = ev->Get()->TabletId; BLOG_D("THive::Handle::TEvInitiateDeleteStorage TabletId=" << tabletId); - TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); + TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); if (tablet != nullptr) { tablet->InitiateDeleteStorage(); } @@ -721,7 +721,7 @@ void THive::Handle(TEvHive::TEvGetTabletStorageInfo::TPtr& ev) { TTabletId tabletId = ev->Get()->Record.GetTabletID(); BLOG_D("THive::Handle::TEvGetTabletStorageInfo TabletId=" << tabletId); - TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); + TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); if (tablet == nullptr) { // Tablet doesn't exist Send( @@ -788,7 +788,7 @@ void THive::Handle(TEvents::TEvUndelivered::TPtr &ev) { void THive::Handle(TEvHive::TEvReassignTablet::TPtr &ev) { BLOG_D("THive::TEvReassignTablet " << ev->Get()->Record.ShortUtf8DebugString()); - TLeaderTabletInfo* tablet = FindTablet(ev->Get()->Record.GetTabletID()); + TLeaderTabletInfo* tablet = FindTablet(ev->Get()->Record.GetTabletID()); if (tablet != nullptr) { tablet->ChannelProfileReassignReason = ev->Get()->Record.GetReassignReason(); std::bitset<MAX_TABLET_CHANNELS> channelProfileNewGroup; @@ -854,7 +854,7 @@ void THive::DefaultSignalTabletActive(const TActorContext& ctx) { } -void THive::AssignTabletGroups(TLeaderTabletInfo& tablet) { +void THive::AssignTabletGroups(TLeaderTabletInfo& tablet) { ui32 channels = tablet.GetChannelCount(); THashSet<TString> storagePoolsToRefresh; // was this method called for the first time for this tablet? @@ -931,7 +931,7 @@ void THive::RestartBSControllerPipe() { } RequestPoolsInformation(); for (auto it = Tablets.begin(); it != Tablets.end(); ++it) { - TLeaderTabletInfo& tablet(it->second); + TLeaderTabletInfo& tablet(it->second); if (tablet.IsReadyToAssignGroups()) { tablet.ResetTabletGroupsRequests(); tablet.InitiateAssignTabletGroups(); @@ -1056,18 +1056,18 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { std::vector<const NKikimrHive::TDataCentersGroup*> dataCentersGroupsPointers; TArrayRef<const NKikimrHive::TDataCentersGroup*> dataCentersGroups; // std::span - if (tablet.IsLeader()) { - const TLeaderTabletInfo& leader(tablet.GetLeader()); + if (tablet.IsLeader()) { + const TLeaderTabletInfo& leader(tablet.GetLeader()); dataCentersGroups = TArrayRef<const NKikimrHive::TDataCentersGroup*>( - const_cast<const NKikimrHive::TDataCentersGroup**>(leader.DataCentersPreference.GetDataCentersGroups().data()), - leader.DataCentersPreference.GetDataCentersGroups().size()); + const_cast<const NKikimrHive::TDataCentersGroup**>(leader.DataCentersPreference.GetDataCentersGroups().data()), + leader.DataCentersPreference.GetDataCentersGroups().size()); if (dataCentersGroups.empty()) { - dataCentersGroups = GetDefaultDataCentersPreference(leader.Type); + dataCentersGroups = GetDefaultDataCentersPreference(leader.Type); } if (dataCentersGroups.empty()) { - if (leader.Category) { + if (leader.Category) { std::unordered_map<TDataCenterId, ui32> dcTablets; - for (TLeaderTabletInfo* tab : leader.Category->Tablets) { + for (TLeaderTabletInfo* tab : leader.Category->Tablets) { if (tab->IsAlive()) { TDataCenterId dc = tab->Node->GetDataCenter(); dcTablets[dc]++; @@ -1161,8 +1161,8 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { BLOG_TRACE("[FBN] Node " << nodeInfo.Id << " is not allowed" << " to run the tablet " << tablet.ToString() << " node domains " << nodeInfo.ServicedDomains - << " tablet object domain " << tablet.GetLeader().ObjectDomain - << " tablet allowed domains " << tablet.GetLeader().EffectiveAllowedDomains); + << " tablet object domain " << tablet.GetLeader().ObjectDomain + << " tablet allowed domains " << tablet.GetLeader().EffectiveAllowedDomains); } } if (!selectedNodes.empty()) { @@ -1196,8 +1196,8 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { ui32 nodesLeft = Nodes.size(); - if (tablet.IsFollower() && debugState.LeaderNotRunning) { - tablet.BootState = BootStateLeaderNotRunning; + if (tablet.IsFollower() && debugState.LeaderNotRunning) { + tablet.BootState = BootStateLeaderNotRunning; return TBestNodeResult(true); } if (debugState.NodesDead == nodesLeft) { @@ -1222,11 +1222,11 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { } nodesLeft -= debugState.NodesWithSomeoneFromOurFamily; if (debugState.NodesWithoutDomain == nodesLeft) { - tablet.BootState = TStringBuilder() << "Can't find domain " << tablet.GetLeader().EffectiveAllowedDomains; + tablet.BootState = TStringBuilder() << "Can't find domain " << tablet.GetLeader().EffectiveAllowedDomains; return TBestNodeResult(true); } nodesLeft -= debugState.NodesWithoutDomain; - if (tablet.IsFollower() && debugState.NodesFilledWithDatacenterFollowers == nodesLeft) { + if (tablet.IsFollower() && debugState.NodesFilledWithDatacenterFollowers == nodesLeft) { tablet.BootState = BootStateNotEnoughDatacenters; return TBestNodeResult(true); } @@ -1241,8 +1241,8 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { TStringBuilder state; - if (debugState.LeaderNotRunning) { - state << "LeaderNotRunning;"; + if (debugState.LeaderNotRunning) { + state << "LeaderNotRunning;"; } if (debugState.NodesDead) { state << "NodesDead:" << debugState.NodesDead << ";"; @@ -1256,14 +1256,14 @@ THive::TBestNodeResult THive::FindBestNode(const TTabletInfo& tablet) { if (debugState.NodesInDatacentersNotAllowed) { state << "NodesInDatacentersNotAllowed:" << debugState.NodesInDatacentersNotAllowed << ";"; } - if (debugState.NodesWithLeaderNotLocal) { - state << "NodesWithLeaderNotLocal:" << debugState.NodesWithLeaderNotLocal << ";"; + if (debugState.NodesWithLeaderNotLocal) { + state << "NodesWithLeaderNotLocal:" << debugState.NodesWithLeaderNotLocal << ";"; } if (debugState.NodesWithoutDomain) { state << "NodesWithoutDomain:" << debugState.NodesWithoutDomain << ";"; } - if (debugState.NodesFilledWithDatacenterFollowers) { - state << "NodesFilledWithDatacenterFollowers:" << debugState.NodesFilledWithDatacenterFollowers << ";"; + if (debugState.NodesFilledWithDatacenterFollowers) { + state << "NodesFilledWithDatacenterFollowers:" << debugState.NodesFilledWithDatacenterFollowers << ";"; } if (debugState.NodesWithoutResources) { state << "NodesWithoutResources:" << debugState.NodesWithoutResources << ";"; @@ -1303,7 +1303,7 @@ TNodeInfo* THive::FindNode(TNodeId nodeId) { return &it->second; } -TLeaderTabletInfo& THive::GetTablet(TTabletId tabletId) { +TLeaderTabletInfo& THive::GetTablet(TTabletId tabletId) { auto it = Tablets.find(tabletId); if (it == Tablets.end()) { it = Tablets.emplace(std::piecewise_construct, std::tuple<TTabletId>(tabletId), std::tuple<TTabletId, THive&>(tabletId, *this)).first; @@ -1312,39 +1312,39 @@ TLeaderTabletInfo& THive::GetTablet(TTabletId tabletId) { return it->second; } -TLeaderTabletInfo* THive::FindTablet(TTabletId tabletId) { +TLeaderTabletInfo* THive::FindTablet(TTabletId tabletId) { auto it = Tablets.find(tabletId); if (it == Tablets.end() || it->second.IsDeleting()) return nullptr; return &it->second; } -TLeaderTabletInfo* THive::FindTabletEvenInDeleting(TTabletId tabletId) { +TLeaderTabletInfo* THive::FindTabletEvenInDeleting(TTabletId tabletId) { auto it = Tablets.find(tabletId); if (it == Tablets.end()) return nullptr; return &it->second; } -TTabletInfo& THive::GetTablet(TTabletId tabletId, TFollowerId followerId) { - TLeaderTabletInfo& leader = GetTablet(tabletId); - return leader.GetTablet(followerId); +TTabletInfo& THive::GetTablet(TTabletId tabletId, TFollowerId followerId) { + TLeaderTabletInfo& leader = GetTablet(tabletId); + return leader.GetTablet(followerId); } -TTabletInfo* THive::FindTablet(TTabletId tabletId, TFollowerId followerId) { - TLeaderTabletInfo* leader = FindTablet(tabletId); - if (leader == nullptr) { +TTabletInfo* THive::FindTablet(TTabletId tabletId, TFollowerId followerId) { + TLeaderTabletInfo* leader = FindTablet(tabletId); + if (leader == nullptr) { return nullptr; } - return leader->FindTablet(followerId); + return leader->FindTablet(followerId); } -TTabletInfo* THive::FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId) { - TLeaderTabletInfo* leader = FindTabletEvenInDeleting(tabletId); - if (leader == nullptr) { +TTabletInfo* THive::FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId) { + TLeaderTabletInfo* leader = FindTabletEvenInDeleting(tabletId); + if (leader == nullptr) { return nullptr; } - return leader->FindTablet(followerId); + return leader->FindTablet(followerId); } TStoragePoolInfo& THive::GetStoragePool(const TString& name) { @@ -1374,10 +1374,10 @@ TDomainInfo* THive::FindDomain(TSubDomainKey key) { void THive::DeleteTablet(TTabletId tabletId) { auto it = Tablets.find(tabletId); if (it != Tablets.end()) { - TLeaderTabletInfo& tablet(it->second); + TLeaderTabletInfo& tablet(it->second); tablet.BecomeStopped(); - for (TFollowerTabletInfo& follower : tablet.Followers) { - follower.BecomeStopped(); + for (TFollowerTabletInfo& follower : tablet.Followers) { + follower.BecomeStopped(); } ReportDeletedToWhiteboard(tablet); tablet.ReleaseAllocationUnits(); @@ -1405,7 +1405,7 @@ void THive::DeleteTablet(TTabletId tabletId) { } Y_ENSURE_LOG(nt->second.LockedTablets.count(&tablet) == 0, " Deleting tablet found on node " << nt->first << " in locked set"); } - UpdateCounterTabletsTotal(-1 - (tablet.Followers.size())); + UpdateCounterTabletsTotal(-1 - (tablet.Followers.size())); Tablets.erase(it); } } @@ -1566,7 +1566,7 @@ bool THive::IsTabletMoveExpedient(const TTabletInfo& tablet, const TNodeInfo& no return result; } -void THive::FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabletId, const TLeaderTabletInfo *info, const NKikimrHive::TEvRequestHiveInfo &req) { +void THive::FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabletId, const TLeaderTabletInfo *info, const NKikimrHive::TEvRequestHiveInfo &req) { if (info) { auto& tabletInfo = *response.AddTablets(); tabletInfo.SetTabletID(tabletId); @@ -1586,16 +1586,16 @@ void THive::FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabl if (req.GetReturnMetrics()) { tabletInfo.MutableMetrics()->CopyFrom(info->GetResourceValues()); } - if (req.GetReturnFollowers()) { - for (const auto& follower : info->Followers) { - if (req.HasFollowerID() && req.GetFollowerID() != follower.Id) + if (req.GetReturnFollowers()) { + for (const auto& follower : info->Followers) { + if (req.HasFollowerID() && req.GetFollowerID() != follower.Id) continue; NKikimrHive::TTabletInfo& tabletInfo = *response.AddTablets(); tabletInfo.SetTabletID(tabletId); tabletInfo.SetTabletType(info->Type); - tabletInfo.SetFollowerID(follower.Id); - tabletInfo.SetVolatileState(follower.GetVolatileState()); - tabletInfo.SetNodeID(follower.NodeId); + tabletInfo.SetFollowerID(follower.Id); + tabletInfo.SetVolatileState(follower.GetVolatileState()); + tabletInfo.SetNodeID(follower.NodeId); tabletInfo.MutableTabletOwner()->SetOwner(info->Owner.first); tabletInfo.MutableTabletOwner()->SetOwnerIdx(info->Owner.second); tabletInfo.MutableObjectDomain()->CopyFrom(info->ObjectDomain); @@ -1604,7 +1604,7 @@ void THive::FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabl } tabletInfo.SetRestartsPerPeriod(follower.Statistics.RestartTimestampSize()); if (req.GetReturnMetrics()) { - tabletInfo.MutableMetrics()->CopyFrom(follower.GetResourceValues()); + tabletInfo.MutableMetrics()->CopyFrom(follower.GetResourceValues()); } } } @@ -1621,7 +1621,7 @@ void THive::Handle(TEvHive::TEvRequestHiveInfo::TPtr& ev) { if (CheckForForwardTabletRequest(tabletId, forwardRequest)) { response->Record.MutableForwardRequest()->CopyFrom(forwardRequest); } - TLeaderTabletInfo* tablet = FindTablet(tabletId); + TLeaderTabletInfo* tablet = FindTablet(tabletId); if (tablet) { tablet->ActualizeTabletStatistics(now); FillTabletInfo(response->Record, record.GetTabletID(), tablet, record); @@ -1678,7 +1678,7 @@ void THive::Handle(TEvHive::TEvRequestHiveDomainStats::TPtr& ev) { THashMap<TSubDomainKey, TSubDomainStats> subDomainStats; for (auto it = Tablets.begin(); it != Tablets.end(); ++it) { - const TLeaderTabletInfo& tablet = it->second; + const TLeaderTabletInfo& tablet = it->second; TSubDomainKey domain = tablet.ObjectDomain; TSubDomainStats& stats = subDomainStats[domain]; stats.StateCounter[tablet.GetVolatileState()]++; @@ -1786,7 +1786,7 @@ void THive::Handle(TEvHive::TEvLookupTablet::TPtr& ev) { void THive::Handle(TEvHive::TEvLookupChannelInfo::TPtr& ev) { const auto& request(ev->Get()->Record); - const TLeaderTabletInfo* tablet = FindTablet(request.GetTabletID()); + const TLeaderTabletInfo* tablet = FindTablet(request.GetTabletID()); if (tablet == nullptr) { Send(ev->Sender, new TEvHive::TEvChannelInfo(NKikimrProto::ERROR, request.GetTabletID())); return; @@ -1832,7 +1832,7 @@ void THive::Handle(TEvHive::TEvFillNode::TPtr& ev) { void THive::Handle(TEvHive::TEvInitiateTabletExternalBoot::TPtr& ev) { TTabletId tabletId = ev->Get()->Record.GetTabletID(); - TLeaderTabletInfo* tablet = FindTablet(tabletId); + TLeaderTabletInfo* tablet = FindTablet(tabletId); if (!tablet) { Send(ev->Sender, new TEvHive::TEvBootTabletReply(NKikimrProto::EReplyStatus::ERROR), 0, ev->Cookie); @@ -2068,13 +2068,13 @@ static void AggregateDiff(NKikimrTabletBase::TMetrics& aggregate, const NKikimrT } void THive::AggregateMetricsDiff(NKikimrTabletBase::TMetrics& aggregate, const NKikimrTabletBase::TMetrics& before, const NKikimrTabletBase::TMetrics& after, const TTabletInfo* tablet) { - AggregateDiff<&NKikimrTabletBase::TMetrics::SetCPU, &NKikimrTabletBase::TMetrics::GetCPU, &NKikimrTabletBase::TMetrics::ClearCPU>(aggregate, before, after, tablet->GetLeader().Id, "cpu"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetMemory, &NKikimrTabletBase::TMetrics::GetMemory, &NKikimrTabletBase::TMetrics::ClearMemory>(aggregate, before, after, tablet->GetLeader().Id, "memory"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetNetwork, &NKikimrTabletBase::TMetrics::GetNetwork, &NKikimrTabletBase::TMetrics::ClearNetwork>(aggregate, before, after, tablet->GetLeader().Id, "network"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetCounter, &NKikimrTabletBase::TMetrics::GetCounter, &NKikimrTabletBase::TMetrics::ClearCounter>(aggregate, before, after, tablet->GetLeader().Id, "counter"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetStorage, &NKikimrTabletBase::TMetrics::GetStorage, &NKikimrTabletBase::TMetrics::ClearStorage>(aggregate, before, after, tablet->GetLeader().Id, "storage"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetReadThroughput, &NKikimrTabletBase::TMetrics::GetReadThroughput, &NKikimrTabletBase::TMetrics::ClearReadThroughput>(aggregate, before, after, tablet->GetLeader().Id, "read"); - AggregateDiff<&NKikimrTabletBase::TMetrics::SetWriteThroughput, &NKikimrTabletBase::TMetrics::GetWriteThroughput, &NKikimrTabletBase::TMetrics::ClearWriteThroughput>(aggregate, before, after, tablet->GetLeader().Id, "write"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetCPU, &NKikimrTabletBase::TMetrics::GetCPU, &NKikimrTabletBase::TMetrics::ClearCPU>(aggregate, before, after, tablet->GetLeader().Id, "cpu"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetMemory, &NKikimrTabletBase::TMetrics::GetMemory, &NKikimrTabletBase::TMetrics::ClearMemory>(aggregate, before, after, tablet->GetLeader().Id, "memory"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetNetwork, &NKikimrTabletBase::TMetrics::GetNetwork, &NKikimrTabletBase::TMetrics::ClearNetwork>(aggregate, before, after, tablet->GetLeader().Id, "network"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetCounter, &NKikimrTabletBase::TMetrics::GetCounter, &NKikimrTabletBase::TMetrics::ClearCounter>(aggregate, before, after, tablet->GetLeader().Id, "counter"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetStorage, &NKikimrTabletBase::TMetrics::GetStorage, &NKikimrTabletBase::TMetrics::ClearStorage>(aggregate, before, after, tablet->GetLeader().Id, "storage"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetReadThroughput, &NKikimrTabletBase::TMetrics::GetReadThroughput, &NKikimrTabletBase::TMetrics::ClearReadThroughput>(aggregate, before, after, tablet->GetLeader().Id, "read"); + AggregateDiff<&NKikimrTabletBase::TMetrics::SetWriteThroughput, &NKikimrTabletBase::TMetrics::GetWriteThroughput, &NKikimrTabletBase::TMetrics::ClearWriteThroughput>(aggregate, before, after, tablet->GetLeader().Id, "write"); } void THive::DivideMetrics(NKikimrTabletBase::TMetrics& metrics, ui64 divider) { @@ -2140,7 +2140,7 @@ const TVector<i64>& THive::GetTabletTypeAllowedMetricIds(TTabletTypes::EType typ return defaultAllowedMetricIds; } -THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> THive::BuildGroupParametersForChannel(const TLeaderTabletInfo& tablet, ui32 channelId) { +THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> THive::BuildGroupParametersForChannel(const TLeaderTabletInfo& tablet, ui32 channelId) { THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> groupParameters = MakeHolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters>(); Y_VERIFY(channelId < tablet.BoundChannels.size()); const auto& binding = tablet.BoundChannels[channelId]; @@ -2427,7 +2427,7 @@ void THive::Handle(NSysView::TEvSysView::TEvGetTabletsRequest::TPtr& ev) { auto tabletTypeName = TTabletTypes::TypeToStr(tablet.Type); entry->SetTabletId(tabletId); - entry->SetFollowerId(0); + entry->SetFollowerId(0); entry->SetType(tabletTypeName); entry->SetState(ETabletStateName(tablet.State)); @@ -2441,21 +2441,21 @@ void THive::Handle(NSysView::TEvSysView::TEvGetTabletsRequest::TPtr& ev) { entry->SetMemory(resourceValues.GetMemory()); entry->SetNetwork(resourceValues.GetNetwork()); - for (const auto& follower : tablet.Followers) { + for (const auto& follower : tablet.Followers) { auto* entry = record.AddEntries(); ++count; entry->SetTabletId(tabletId); - entry->SetFollowerId(follower.Id); + entry->SetFollowerId(follower.Id); entry->SetType(tabletTypeName); // state is null - entry->SetVolatileState(TTabletInfo::EVolatileStateName(follower.GetVolatileState())); - entry->SetBootState(follower.BootState); + entry->SetVolatileState(TTabletInfo::EVolatileStateName(follower.GetVolatileState())); + entry->SetBootState(follower.BootState); // generation is null - entry->SetNodeId(follower.NodeId); + entry->SetNodeId(follower.NodeId); - const auto& resourceValues = follower.GetResourceValues(); + const auto& resourceValues = follower.GetResourceValues(); entry->SetCPU(resourceValues.GetCPU()); entry->SetMemory(resourceValues.GetMemory()); entry->SetNetwork(resourceValues.GetNetwork()); @@ -2475,7 +2475,7 @@ const TTabletMetricsAggregates& THive::GetDefaultResourceMetricsAggregates() con } bool THive::CheckForForwardTabletRequest(TTabletId tabletId, NKikimrHive::TForwardRequest& forwardRequest) { - const TLeaderTabletInfo* tablet = FindTablet(tabletId); + const TLeaderTabletInfo* tablet = FindTablet(tabletId); if (tablet == nullptr) { TOwnershipKeeper::TOwnerType owner = Keeper.GetOwner(UniqPartFromTabletID(tabletId)); if (owner == TSequencer::NO_OWNER && AreWeSubDomainHive()) { @@ -2555,15 +2555,15 @@ TVector<TNodeId> THive::GetNodesForWhiteboardBroadcast(size_t maxNodesToReturn) return nodes; } -void THive::ReportStoppedToWhiteboard(const TLeaderTabletInfo& tablet) { +void THive::ReportStoppedToWhiteboard(const TLeaderTabletInfo& tablet) { ReportTabletStateToWhiteboard(tablet, NKikimrWhiteboard::TTabletStateInfo::Stopped); } -void THive::ReportDeletedToWhiteboard(const TLeaderTabletInfo& tablet) { +void THive::ReportDeletedToWhiteboard(const TLeaderTabletInfo& tablet) { ReportTabletStateToWhiteboard(tablet, NKikimrWhiteboard::TTabletStateInfo::Deleted); } -void THive::ReportTabletStateToWhiteboard(const TLeaderTabletInfo& tablet, NKikimrWhiteboard::TTabletStateInfo::ETabletState state) { +void THive::ReportTabletStateToWhiteboard(const TLeaderTabletInfo& tablet, NKikimrWhiteboard::TTabletStateInfo::ETabletState state) { ui32 generation = state == NKikimrWhiteboard::TTabletStateInfo::Deleted ? std::numeric_limits<ui32>::max() : tablet.KnownGeneration; TPathId pathId = tablet.GetTenant(); TSubDomainKey tenantId(pathId.OwnerId, pathId.LocalPathId); @@ -2572,16 +2572,16 @@ void THive::ReportTabletStateToWhiteboard(const TLeaderTabletInfo& tablet, NKiki THolder<NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate> event = MakeHolder<NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate>(); event->Record.SetTabletId(tablet.Id); event->Record.SetType(tablet.Type); - event->Record.SetLeader(true); + event->Record.SetLeader(true); event->Record.SetGeneration(generation); event->Record.SetState(state); event->Record.SetHiveId(TabletID()); event->Record.MutableTenantId()->CopyFrom(tenantId); Send(whiteboardId, event.Release()); - for (const TFollowerTabletInfo& follower : tablet.Followers) { + for (const TFollowerTabletInfo& follower : tablet.Followers) { THolder<NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate> event = MakeHolder<NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate>(); - event->Record.SetTabletId(follower.LeaderTablet.Id); - event->Record.SetFollowerId(follower.Id); + event->Record.SetTabletId(follower.LeaderTablet.Id); + event->Record.SetFollowerId(follower.Id); event->Record.SetType(tablet.Type); event->Record.SetGeneration(generation); event->Record.SetState(state); diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h index 9bc85641de5..70c4530fee0 100644 --- a/ydb/core/mind/hive/hive_impl.h +++ b/ydb/core/mind/hive/hive_impl.h @@ -43,9 +43,9 @@ #include "hive_schema.h" #include "domain_info.h" #include "tablet_info.h" -#include "leader_tablet_info.h" -#include "follower_tablet_info.h" -#include "follower_group.h" +#include "leader_tablet_info.h" +#include "follower_tablet_info.h" +#include "follower_group.h" #include "node_info.h" #include "storage_group_info.h" #include "storage_pool_info.h" @@ -306,7 +306,7 @@ protected: TPipeTracker PipeTracker; NTabletPipe::TClientRetryPolicy PipeRetryPolicy; std::unordered_map<TNodeId, TNodeInfo> Nodes; - std::unordered_map<TTabletId, TLeaderTabletInfo> Tablets; + std::unordered_map<TTabletId, TLeaderTabletInfo> Tablets; std::unordered_map<TOwnerIdxType::TValueType, TTabletId> OwnerToTablet; std::unordered_map<TTabletCategoryId, TTabletCategoryInfo> TabletCategories; std::unordered_map<TTabletTypes::EType, TVector<i64>> TabletTypeAllowedMetrics; @@ -381,7 +381,7 @@ protected: TInstant LastResourceChangeReaction; //TDuration ResourceChangeReactionPeriod = TDuration::Seconds(10); TVector<ISubActor*> SubActors; - TResourceProfilesPtr ResourceProfiles; + TResourceProfilesPtr ResourceProfiles; NKikimrLocal::TLocalConfig LocalConfig; bool ReadyForConnections = false; // is Hive ready for incoming connections? ui64 NextTabletUnlockSeqNo = 1; // sequence number for unlock events @@ -404,7 +404,7 @@ protected: TString BootStateStarting = "Starting"; TString BootStateRunning = "Running"; TString BootStateTooManyStarting = "Too many tablets starting"; - TString BootStateLeaderNotRunning = "Leader not running"; + TString BootStateLeaderNotRunning = "Leader not running"; TString BootStateAllNodesAreDead = "All nodes are dead"; TString BootStateAllNodesAreDeadOrDown = "All nodes are dead or down"; TString BootStateNoNodesAllowedToRun = "No nodes allowed to run"; @@ -553,16 +553,16 @@ protected: TNodeInfo* SelectNode(const std::vector<TSelectedNode>& selectedNodes); public: - void AssignTabletGroups(TLeaderTabletInfo& tablet); + void AssignTabletGroups(TLeaderTabletInfo& tablet); TNodeInfo& GetNode(TNodeId nodeId); TNodeInfo* FindNode(TNodeId nodeId); - TLeaderTabletInfo& GetTablet(TTabletId tabletId); - TLeaderTabletInfo* FindTablet(TTabletId tabletId); - TLeaderTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId); // find tablets, even deleting ones - TTabletInfo& GetTablet(TTabletId tabletId, TFollowerId followerId); - TTabletInfo* FindTablet(TTabletId tabletId, TFollowerId followerId); + TLeaderTabletInfo& GetTablet(TTabletId tabletId); + TLeaderTabletInfo* FindTablet(TTabletId tabletId); + TLeaderTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId); // find tablets, even deleting ones + TTabletInfo& GetTablet(TTabletId tabletId, TFollowerId followerId); + TTabletInfo* FindTablet(TTabletId tabletId, TFollowerId followerId); TTabletInfo* FindTablet(const TFullTabletId& tabletId) { return FindTablet(tabletId.first, tabletId.second); } - TTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId); + TTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId); TStoragePoolInfo& GetStoragePool(const TString& name); TStoragePoolInfo* FindStoragePool(const TString& name); TDomainInfo* FindDomain(TSubDomainKey key); @@ -570,9 +570,9 @@ public: void DeleteTablet(TTabletId tabletId); void DeleteNode(TNodeId nodeId); TVector<TNodeId> GetNodesForWhiteboardBroadcast(size_t maxNodesToReturn = 3); - void ReportTabletStateToWhiteboard(const TLeaderTabletInfo& tablet, NKikimrWhiteboard::TTabletStateInfo::ETabletState state); - void ReportStoppedToWhiteboard(const TLeaderTabletInfo& tablet); - void ReportDeletedToWhiteboard(const TLeaderTabletInfo& tablet); + void ReportTabletStateToWhiteboard(const TLeaderTabletInfo& tablet, NKikimrWhiteboard::TTabletStateInfo::ETabletState state); + void ReportStoppedToWhiteboard(const TLeaderTabletInfo& tablet); + void ReportDeletedToWhiteboard(const TLeaderTabletInfo& tablet); TTabletCategoryInfo& GetTabletCategory(TTabletCategoryId tabletCategoryId); void KillNode(TNodeId nodeId, const TActorId& local); void AddToBootQueue(TTabletInfo* tablet); @@ -599,14 +599,14 @@ public: const NKikimrTabletBase::TMetrics& after, NKikimr::NHive::TResourceRawValues deltaRaw, NKikimr::NHive::TResourceNormalizedValues deltaNormalized); - static void FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabletId, const TLeaderTabletInfo* info, const NKikimrHive::TEvRequestHiveInfo& req); + static void FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabletId, const TLeaderTabletInfo* info, const NKikimrHive::TEvRequestHiveInfo& req); void ExecuteStartTablet(TFullTabletId tabletId, const TActorId& local, ui64 cookie, bool external); ui32 GetDataCenters(); ui32 GetRegisteredDataCenters(); void UpdateRegisteredDataCenters(TDataCenterId dataCenterId); void SendPing(const TActorId& local, TNodeId id); void SendReconnect(const TActorId& local); - static THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> BuildGroupParametersForChannel(const TLeaderTabletInfo& tablet, ui32 channelId); + static THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> BuildGroupParametersForChannel(const TLeaderTabletInfo& tablet, ui32 channelId); void KickTablet(const TTabletInfo& tablet); void StopTablet(const TActorId& local, const TTabletInfo& tablet); void StopTablet(const TActorId& local, TFullTabletId tabletId); @@ -755,7 +755,7 @@ public: protected: void ScheduleDisconnectNode(THolder<TEvPrivate::TEvProcessDisconnectNode> event); - void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet); + void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet); void ScheduleUnlockTabletExecution(TNodeInfo& node); TString DebugDomainsActiveNodes() const; TResourceNormalizedValues GetStDevResourceValues() const; diff --git a/ydb/core/mind/hive/hive_impl_ut.cpp b/ydb/core/mind/hive/hive_impl_ut.cpp index f7b844cba3c..077c3eab24c 100644 --- a/ydb/core/mind/hive/hive_impl_ut.cpp +++ b/ydb/core/mind/hive/hive_impl_ut.cpp @@ -31,11 +31,11 @@ Y_UNIT_TEST_SUITE(THiveImplTest) { TIntrusivePtr<TTabletStorageInfo> hiveStorage = new TTabletStorageInfo; hiveStorage->TabletType = TTabletTypes::Hive; THive hive(hiveStorage.Get(), TActorId()); - std::unordered_map<ui64, TLeaderTabletInfo> tablets; + std::unordered_map<ui64, TLeaderTabletInfo> tablets; THPTimer timer; for (ui64 i = 0; i < NUM_TABLETS; ++i) { - TLeaderTabletInfo& tablet = tablets.emplace(std::piecewise_construct, std::tuple<TTabletId>(i), std::tuple<TTabletId, THive&>(i, hive)).first->second; + TLeaderTabletInfo& tablet = tablets.emplace(std::piecewise_construct, std::tuple<TTabletId>(i), std::tuple<TTabletId, THive&>(i, hive)).first->second; tablet.Weight = RandomNumber<double>(); bootQueue.AddToBootQueue(tablet); } diff --git a/ydb/core/mind/hive/hive_schema.h b/ydb/core/mind/hive/hive_schema.h index 82fa15e52b3..6289499cc31 100644 --- a/ydb/core/mind/hive/hive_schema.h +++ b/ydb/core/mind/hive/hive_schema.h @@ -51,13 +51,13 @@ struct Schema : NIceDb::Schema { struct OldTablet : Table<1> { struct ID : Column<0, NScheme::NTypeIds::Uint64> {}; - struct FollowerCount : Column<14, NScheme::NTypeIds::Uint32> { static constexpr ui32 Default = 0; }; - struct AllowFollowerPromotion : Column<15, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; - struct CrossDataCenterFollowers : Column<16, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; - struct CrossDataCenterFollowerCount : Column<18, NScheme::NTypeIds::Uint32> { static constexpr ui32 Default = 0; }; + struct FollowerCount : Column<14, NScheme::NTypeIds::Uint32> { static constexpr ui32 Default = 0; }; + struct AllowFollowerPromotion : Column<15, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; + struct CrossDataCenterFollowers : Column<16, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; + struct CrossDataCenterFollowerCount : Column<18, NScheme::NTypeIds::Uint32> { static constexpr ui32 Default = 0; }; using TKey = TableKey<ID>; - using TColumns = TableColumns<ID, FollowerCount, AllowFollowerPromotion, CrossDataCenterFollowers, CrossDataCenterFollowerCount>; + using TColumns = TableColumns<ID, FollowerCount, AllowFollowerPromotion, CrossDataCenterFollowers, CrossDataCenterFollowerCount>; }; struct Tablet : Table<1> { @@ -65,7 +65,7 @@ struct Schema : NIceDb::Schema { struct Owner : Column<1, NScheme::NTypeIds::PairUi64Ui64> {}; struct KnownGeneration : Column<2, NScheme::NTypeIds::Uint64> {}; struct TabletType : Column<3, NScheme::NTypeIds::Uint64> { using Type = TTabletTypes::EType; }; - struct LeaderNode : Column<4, NScheme::NTypeIds::Uint64> {}; + struct LeaderNode : Column<4, NScheme::NTypeIds::Uint64> {}; struct State : Column<5, NScheme::NTypeIds::Uint64> { using Type = ETabletState; }; struct AllowedNodes : Column<7, NScheme::NTypeIds::String> { using Type = TVector<TNodeId>; }; struct ActorToNotify : Column<11, NScheme::NTypeIds::ActorId> {}; // deprecated because of ActorsToNotify down here @@ -98,7 +98,7 @@ struct Schema : NIceDb::Schema { Owner, KnownGeneration, TabletType, - LeaderNode, + LeaderNode, State, AllowedNodes, ActorToNotify, @@ -121,34 +121,34 @@ struct Schema : NIceDb::Schema { >; }; - struct TabletFollowerGroup : Table<9> { + struct TabletFollowerGroup : Table<9> { struct TabletID : Column<1, Schema::Tablet::ID::ColumnType> {}; struct GroupID : Column<2, NScheme::NTypeIds::Uint32> {}; - struct FollowerCount : Column<3, NScheme::NTypeIds::Uint32> {}; - struct AllowLeaderPromotion : Column<4, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; + struct FollowerCount : Column<3, NScheme::NTypeIds::Uint32> {}; + struct AllowLeaderPromotion : Column<4, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; struct AllowClientRead : Column<5, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; struct AllowedNodes : Column<6, NScheme::NTypeIds::String> { using Type = TVector<TNodeId>; }; struct AllowedDataCenters : Column<7, NScheme::NTypeIds::String> { using Type = TVector<ui32>; }; struct RequireAllDataCenters : Column<8, NScheme::NTypeIds::Bool> {}; struct LocalNodeOnly : Column<9, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; - struct FollowerCountPerDataCenter : Column<10, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; + struct FollowerCountPerDataCenter : Column<10, NScheme::NTypeIds::Bool> { static constexpr bool Default = false; }; struct RequireDifferentNodes : Column<11, NScheme::NTypeIds::Bool> {}; struct AllowedDataCenterIds : Column<12, NScheme::NTypeIds::String> { using Type = TVector<TString>; }; using TKey = TableKey<TabletID, GroupID>; - using TColumns = TableColumns<TabletID, GroupID, FollowerCount, AllowLeaderPromotion, AllowClientRead, + using TColumns = TableColumns<TabletID, GroupID, FollowerCount, AllowLeaderPromotion, AllowClientRead, AllowedNodes, AllowedDataCenters, RequireAllDataCenters, LocalNodeOnly, FollowerCountPerDataCenter, RequireDifferentNodes, AllowedDataCenterIds>; }; - struct TabletFollowerTablet : Table<10> { + struct TabletFollowerTablet : Table<10> { struct TabletID : Column<1, Schema::Tablet::ID::ColumnType> {}; - struct FollowerID : Column<2, NScheme::NTypeIds::Uint32> {}; - struct GroupID : Column<3, Schema::TabletFollowerGroup::GroupID::ColumnType> {}; - struct FollowerNode : Column<4, NScheme::NTypeIds::Uint32> {}; + struct FollowerID : Column<2, NScheme::NTypeIds::Uint32> {}; + struct GroupID : Column<3, Schema::TabletFollowerGroup::GroupID::ColumnType> {}; + struct FollowerNode : Column<4, NScheme::NTypeIds::Uint32> {}; struct Statistics : Column<5, NScheme::NTypeIds::String> { using Type = NKikimrHive::TTabletStatistics; }; - using TKey = TableKey<TabletID, FollowerID>; + using TKey = TableKey<TabletID, FollowerID>; using TColumns = TableColumns<TabletID, GroupID, FollowerID, FollowerNode, Statistics>; }; @@ -216,15 +216,15 @@ struct Schema : NIceDb::Schema { struct Metrics : Table<16> { struct TabletID : Column<1, Tablet::ID::ColumnType> {}; - struct FollowerID : Column<2, TabletFollowerTablet::FollowerID::ColumnType> {}; + struct FollowerID : Column<2, TabletFollowerTablet::FollowerID::ColumnType> {}; struct ProtoMetrics : Column<3, NScheme::NTypeIds::String> { using Type = NKikimrTabletBase::TMetrics; }; struct MaximumCPU : Column<100 + (int)NMetrics::EResource::CPU, NScheme::NTypeIds::String> { using Type = NKikimrMetricsProto::TMaximumValueUI64; }; struct MaximumMemory : Column<100 + (int)NMetrics::EResource::Memory, NScheme::NTypeIds::String> { using Type = NKikimrMetricsProto::TMaximumValueUI64; }; struct MaximumNetwork : Column<100 + (int)NMetrics::EResource::Network, NScheme::NTypeIds::String> { using Type = NKikimrMetricsProto::TMaximumValueUI64; }; - using TKey = TableKey<TabletID, FollowerID>; - using TColumns = TableColumns<TabletID, FollowerID, ProtoMetrics, MaximumCPU, MaximumMemory, MaximumNetwork>; + using TKey = TableKey<TabletID, FollowerID>; + using TColumns = TableColumns<TabletID, FollowerID, ProtoMetrics, MaximumCPU, MaximumMemory, MaximumNetwork>; }; struct TabletTypeMetrics : Table<13> { @@ -291,8 +291,8 @@ struct Schema : NIceDb::Schema { TabletChannelGen, Node, TabletCategory, - TabletFollowerGroup, - TabletFollowerTablet, + TabletFollowerGroup, + TabletFollowerTablet, TabletTypeMetrics, Sequences, Metrics, diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index b2c9fa124fc..0383d49a123 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -88,10 +88,10 @@ namespace { void SetupDomainInfo(TTestActorRuntime &runtime, TAppPrepare &app) { app.ClearDomainsAndHive(); - ui32 domainUid = TTestTxConfig::DomainUid; + ui32 domainUid = TTestTxConfig::DomainUid; ui32 ssId = 0; ui32 planResolution = 50; - ui64 schemeRoot = TTestTxConfig::SchemeShard; + ui64 schemeRoot = TTestTxConfig::SchemeShard; ui64 hive = MakeDefaultHiveID(ssId); auto domain = TDomainsInfo::TDomain::ConstructDomainWithExplicitTabletIds( DOMAIN_NAME, domainUid, schemeRoot, @@ -214,7 +214,7 @@ namespace { for (ui32 nodeIndex = 0; nodeIndex < runtime.GetNodeCount(); ++nodeIndex) { TLocalConfig::TPtr localConfig(new TLocalConfig()); localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo( - &CreateFlatDummyTablet, + &CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); localConfig->TabletClassInfo[TTabletTypes::Hive].SetupInfo = new TTabletSetupInfo( @@ -285,7 +285,7 @@ namespace { runtime.DispatchEvents(options); } - CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); } @@ -420,7 +420,7 @@ void FormatPDiskForTest(TString path, ui64 diskSize, ui32 chunkSize, ui64 guid, } void InitSchemeRoot(TTestBasicRuntime& runtime, const TActorId& sender) { - auto evTx = MakeHolder<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransaction>(1, TTestTxConfig::SchemeShard); + auto evTx = MakeHolder<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransaction>(1, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterSubDomain); transaction->SetWorkingDir("/"); @@ -433,19 +433,19 @@ void InitSchemeRoot(TTestBasicRuntime& runtime, const TActorId& sender) { p->SetName(pool.GetName()); } - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, evTx.Release(), 0, GetPipeConfigWithRetries()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, evTx.Release(), 0, GetPipeConfigWithRetries()); { TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle); - UNIT_ASSERT_VALUES_EQUAL(event->Record.GetSchemeshardId(), TTestTxConfig::SchemeShard); + UNIT_ASSERT_VALUES_EQUAL(event->Record.GetSchemeshardId(), TTestTxConfig::SchemeShard); UNIT_ASSERT_VALUES_EQUAL(event->Record.GetStatus(), NKikimrScheme::EStatus::StatusAccepted); } // there is no coordinators, so transaction is doomed to hung // // auto evSubscribe = MakeHolder<NSchemeShard::TEvSchemeShard::TEvNotifyTxCompletion>(1); -// runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, evSubscribe.Release(), 0, GetPipeConfigWithRetries()); +// runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, evSubscribe.Release(), 0, GetPipeConfigWithRetries()); // { // TAutoPtr<IEventHandle> handle; @@ -637,7 +637,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { void CreateLocal(TTestActorRuntime &runtime, ui32 nodeIndex, TLocalConfig::TPtr localConfig = {}) { if (localConfig == nullptr) { localConfig = new TLocalConfig(); - localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, + localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); } @@ -653,7 +653,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { void CreateLocalForTenant(TTestActorRuntime &runtime, ui32 nodeIndex, const TString& tenant) { TLocalConfig::TPtr localConfig(new TLocalConfig()); localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo( - &CreateFlatDummyTablet, + &CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); localConfig->TabletClassInfo[TTabletTypes::Hive].SetupInfo = new TTabletSetupInfo( @@ -678,7 +678,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { if (handle->Recipient == sender) { UNIT_ASSERT(clientConnectedResult->Status == NKikimrProto::OK); if (roleConnected != nullptr) { - *roleConnected = clientConnectedResult->Leader; + *roleConnected = clientConnectedResult->Leader; } break; } @@ -719,7 +719,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { UNIT_ASSERT(event->Type() == TEvTabletPipe::TEvClientConnected::EventType); UNIT_ASSERT(event->Status == NKikimrProto::OK); if (roleConnected != nullptr) { - *roleConnected = event->Leader; + *roleConnected = event->Leader; } break; } @@ -753,7 +753,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { && (event->Type() == TEvTabletPipe::TEvClientConnected::EventType) && (event->Status == NKikimrProto::OK)) { if (roleConnected != nullptr) { - *roleConnected = event->Leader; + *roleConnected = event->Leader; } return true; } else { @@ -799,7 +799,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); @@ -811,7 +811,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); @@ -834,7 +834,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; TVector<TTabletId> tablets; @@ -860,7 +860,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -926,10 +926,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); InitSchemeRoot(runtime, sender); @@ -944,7 +944,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -988,10 +988,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); @@ -1006,7 +1006,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1099,10 +1099,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); @@ -1118,7 +1118,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1210,10 +1210,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); @@ -1229,7 +1229,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1329,10 +1329,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { static constexpr int TABLETS = 1000; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); InitSchemeRoot(runtime, sender); @@ -1347,7 +1347,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1422,10 +1422,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); setup(runtime); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); InitSchemeRoot(runtime, sender); @@ -1440,7 +1440,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1523,10 +1523,10 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); setup(runtime); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::SchemeShard, TTabletTypes::SchemeShard), &CreateFlatTxSchemeShard); MakeSureTabletIsUp(runtime, hiveTablet, 0); // root hive good - MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good + MakeSureTabletIsUp(runtime, TTestTxConfig::SchemeShard, 0); // root ss good TActorId sender = runtime.AllocateEdgeActor(0); InitSchemeRoot(runtime, sender); @@ -1541,7 +1541,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { tran->SetOperationType(NKikimrSchemeOp::ESchemeOpCreateSubDomain); auto* subd = tran->MutableSubDomain(); subd->SetName("tenant1"); - runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); + runtime.SendToPipe(TTestTxConfig::SchemeShard, sender, x.Release()); TAutoPtr<IEventHandle> handle; auto reply = runtime.GrabEdgeEventRethrow<NSchemeShard::TEvSchemeShard::TEvModifySchemeTransactionResult>(handle, TDuration::MilliSeconds(100)); if (reply) { @@ -1660,7 +1660,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); setup(runtime); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TAutoPtr<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, TTabletTypes::Dummy, BINDED_CHANNELS)); const bool doWaitForResult = false; @@ -1687,7 +1687,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; TAutoPtr<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -1716,7 +1716,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); CreateLocal(runtime, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -1760,7 +1760,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); CreateLocal(runtime, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -1847,7 +1847,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); CreateLocal(runtime, 0); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -1888,7 +1888,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); { @@ -1915,7 +1915,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); { @@ -1944,7 +1944,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; const ui64 count = 100; TSet<ui64> tabletIds; @@ -1965,23 +1965,23 @@ Y_UNIT_TEST_SUITE(THiveTest) { SendDeleteTestOwner(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteOwnerTablets>(testerTablet, 124), 0, NKikimrProto::ALREADY); } - Y_UNIT_TEST(TestDeleteTabletWithFollowers) { + Y_UNIT_TEST(TestDeleteTabletWithFollowers) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(2); - followerGroup->SetRequireDifferentNodes(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(2); + followerGroup->SetRequireDifferentNodes(true); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; MakeSureTabletIsUp(runtime, tabletId, 0, &pipeConfig); MakeSureTabletIsUp(runtime, tabletId, 1, &pipeConfig); @@ -2005,7 +2005,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = 1; - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; const ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, true); MakeSureTabletIsUp(runtime, tabletId, 0); @@ -2030,7 +2030,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; runtime.SendToPipe(hiveTablet, sender, new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, GetPipeConfigWithRetries()); @@ -2052,7 +2052,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // Start local only when transaction is complete { TLocalConfig::TPtr localConfig(new TLocalConfig()); - localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, + localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); TTenantPoolConfig::TPtr tenantPoolConfig = new TTenantPoolConfig(localConfig); @@ -2072,7 +2072,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; { @@ -2111,7 +2111,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui32 nodeIndex = 0; @@ -2152,7 +2152,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); @@ -2191,7 +2191,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); ui32 nodeIndex = 0; TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -2212,17 +2212,17 @@ Y_UNIT_TEST_SUITE(THiveTest) { //TAutoPtr<ITabletScheduledEventsGuard> guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetFollowerCount(1); + ev->Record.SetFollowerCount(1); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); runtime.SendToPipe(hiveTablet, sender, new TEvInterconnect::TEvNodeDisconnected(runtime.GetNodeId(0))); @@ -2245,7 +2245,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // Kill local on node 1 SendKillLocal(runtime, 1); @@ -2272,7 +2272,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // creating tablet ui32 nodeIndex = 0; @@ -2323,7 +2323,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // Kill local on node 1 SendKillLocal(runtime, 1); @@ -2345,7 +2345,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2360,7 +2360,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; TChannelsBindings channlesBinds = {GetDefaultChannelBind("NoExistStoragePool"), @@ -2390,7 +2390,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true, 3); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2412,7 +2412,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true, 3); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2447,7 +2447,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, @@ -2516,7 +2516,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); @@ -2564,7 +2564,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // CreatePDiskAndGroup(runtime, sender); // const ui64 hiveTablet = MakeDefaultHiveID(0); // const ui64 testerTablet = MakeDefaultHiveID(1); -// CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); +// CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // ui32 tabletType = 0; // ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2595,7 +2595,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2617,7 +2617,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TAutoPtr<ITabletScheduledEventsGuard> guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, @@ -2641,7 +2641,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TAutoPtr<ITabletScheduledEventsGuard> guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, senderA); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // Kill local on node 1 SendKillLocal(runtime, 1); @@ -2661,32 +2661,32 @@ Y_UNIT_TEST_SUITE(THiveTest) { } */ - Y_UNIT_TEST(TestFollowers) { + Y_UNIT_TEST(TestFollowers) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(2); - followerGroup->SetRequireDifferentNodes(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(2); + followerGroup->SetRequireDifferentNodes(true); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; MakeSureTabletIsUp(runtime, tabletId, 0, &pipeConfig); MakeSureTabletIsUp(runtime, tabletId, 1, &pipeConfig); MakeSureTabletIsUp(runtime, tabletId, 2, &pipeConfig); } - Y_UNIT_TEST(TestFollowersReconfiguration) { + Y_UNIT_TEST(TestFollowersReconfiguration) { TTestBasicRuntime runtime(3, false); Setup(runtime, true); TVector<ui64> tabletIds; @@ -2694,26 +2694,26 @@ Y_UNIT_TEST_SUITE(THiveTest) { //TAutoPtr<ITabletScheduledEventsGuard> guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, senderA); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(2); - followerGroup->SetRequireDifferentNodes(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(2); + followerGroup->SetRequireDifferentNodes(true); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); WaitForTabletIsUp(runtime, tabletId, 1, &pipeConfig); WaitForTabletIsUp(runtime, tabletId, 2, &pipeConfig); ev.Reset(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetFollowerCount(1); + ev->Record.SetFollowerCount(1); runtime.SendToPipe(hiveTablet, senderA, ev.Release(), 0, GetPipeConfigWithRetries()); { @@ -2723,7 +2723,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } ev.Reset(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetFollowerCount(2); + ev->Record.SetFollowerCount(2); runtime.SendToPipe(hiveTablet, senderA, ev.Release(), 0, GetPipeConfigWithRetries()); { @@ -2733,15 +2733,15 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestFollowerPromotion) { + Y_UNIT_TEST(TestFollowerPromotion) { constexpr int NODES = 3; TTestBasicRuntime runtime(NODES, false); Setup(runtime, true); - + TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -2749,25 +2749,25 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(2); - followerGroup->SetAllowLeaderPromotion(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(2); + followerGroup->SetAllowLeaderPromotion(true); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; std::array<bool, NODES> tabletRolesBefore = {}; for (int i = 0; i < NODES; ++i) { MakeSureTabletIsUp(runtime, tabletId, i, &pipeConfig, &tabletRolesBefore[i]); } - int leaders = std::accumulate(tabletRolesBefore.begin(), tabletRolesBefore.end(), 0, [](int a, bool b) -> int { return b ? a + 1 : a; }); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - int leaderNode = std::find(tabletRolesBefore.begin(), tabletRolesBefore.end(), true) - tabletRolesBefore.begin(); - // killing leader - SendKillLocal(runtime, leaderNode); + int leaders = std::accumulate(tabletRolesBefore.begin(), tabletRolesBefore.end(), 0, [](int a, bool b) -> int { return b ? a + 1 : a; }); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + int leaderNode = std::find(tabletRolesBefore.begin(), tabletRolesBefore.end(), true) - tabletRolesBefore.begin(); + // killing leader + SendKillLocal(runtime, leaderNode); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvTabletStatus); @@ -2775,17 +2775,17 @@ Y_UNIT_TEST_SUITE(THiveTest) { } std::array<bool, NODES> tabletRolesIntermediate = {}; for (int i = 0; i < NODES; ++i) { - if (i != leaderNode) { + if (i != leaderNode) { MakeSureTabletIsUp(runtime, tabletId, i, &pipeConfig, &tabletRolesIntermediate[i]); } else { tabletRolesIntermediate[i] = false; } } - leaders = std::accumulate(tabletRolesIntermediate.begin(), tabletRolesIntermediate.end(), 0, [](int a, bool b) -> int { return b ? a + 1 : a; }); - int followers = std::accumulate(tabletRolesIntermediate.begin(), tabletRolesIntermediate.end(), 0, [](int a, bool b) -> int { return b ? a : a + 1; }); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(followers, 2); - std::unordered_set<std::pair<TTabletId, TFollowerId>> activeTablets; + leaders = std::accumulate(tabletRolesIntermediate.begin(), tabletRolesIntermediate.end(), 0, [](int a, bool b) -> int { return b ? a + 1 : a; }); + int followers = std::accumulate(tabletRolesIntermediate.begin(), tabletRolesIntermediate.end(), 0, [](int a, bool b) -> int { return b ? a : a + 1; }); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(followers, 2); + std::unordered_set<std::pair<TTabletId, TFollowerId>> activeTablets; TActorId senderA = runtime.AllocateEdgeActor(); for (int i = 0; i < NODES; ++i) { TActorId whiteboard = NNodeWhiteboard::MakeNodeWhiteboardServiceId(runtime.GetNodeId(i)); @@ -2795,16 +2795,16 @@ Y_UNIT_TEST_SUITE(THiveTest) { for (const NKikimrWhiteboard::TTabletStateInfo& tabletInfo : response->Record.GetTabletStateInfo()) { if (tabletInfo.GetTabletId() == tabletId && ( tabletInfo.GetState() == NKikimrWhiteboard::TTabletStateInfo::Active || - tabletInfo.GetState() == NKikimrWhiteboard::TTabletStateInfo::ResolveLeader)) + tabletInfo.GetState() == NKikimrWhiteboard::TTabletStateInfo::ResolveLeader)) { - activeTablets.insert({tabletInfo.GetTabletId(), tabletInfo.GetFollowerId()}); + activeTablets.insert({tabletInfo.GetTabletId(), tabletInfo.GetFollowerId()}); } } } UNIT_ASSERT_VALUES_EQUAL(activeTablets.size(), 3); } - Y_UNIT_TEST(TestManyFollowersOnOneNode) { + Y_UNIT_TEST(TestManyFollowersOnOneNode) { TTestBasicRuntime runtime(2, false); Setup(runtime, true); const int nodeBase = runtime.GetNodeId(0); @@ -2812,7 +2812,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -2820,9 +2820,9 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(3); - followerGroup->SetAllowLeaderPromotion(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(3); + followerGroup->SetAllowLeaderPromotion(true); SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); { TDispatchOptions options; @@ -2852,7 +2852,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, MakeHolder<TEvHive::TEvCreateTablet>(testerTablet, 0, tabletType, BINDED_CHANNELS), 0, false); @@ -2882,7 +2882,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -3026,7 +3026,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -3038,7 +3038,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tablets; for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); - ev->Record.SetFollowerCount(3); + ev->Record.SetFollowerCount(3); ev->Record.MutableDataCentersPreference()->AddDataCentersGroups()->AddDataCenter(ToString(1)); ev->Record.MutableDataCentersPreference()->AddDataCentersGroups()->AddDataCenter(ToString(2)); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); @@ -3046,30 +3046,30 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - // checking distribution, all leaders should be on the first node + // checking distribution, all leaders should be on the first node { - std::array<int, NUM_NODES> nodeLeaders = {}; + std::array<int, NUM_NODES> nodeLeaders = {}; std::array<int, NUM_NODES> nodeTablets = {}; { THolder<TEvHive::TEvRequestHiveInfo> request = MakeHolder<TEvHive::TEvRequestHiveInfo>(); - request->Record.SetReturnFollowers(true); + request->Record.SetReturnFollowers(true); runtime.SendToPipe(hiveTablet, senderA, request.Release()); TAutoPtr<IEventHandle> handle; TEvHive::TEvResponseHiveInfo* response = runtime.GrabEdgeEventRethrow<TEvHive::TEvResponseHiveInfo>(handle); for (const NKikimrHive::TTabletInfo& tablet : response->Record.GetTablets()) { - if (tablet.GetFollowerID() == 0) { - nodeLeaders[tablet.GetNodeID() - nodeBase]++; + if (tablet.GetFollowerID() == 0) { + nodeLeaders[tablet.GetNodeID() - nodeBase]++; } nodeTablets[tablet.GetNodeID() - nodeBase]++; - Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() << Endl; + Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() << Endl; } } - UNIT_ASSERT_GT(nodeLeaders[0], 0); - UNIT_ASSERT_GT(nodeLeaders[1], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[2], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[3], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[4], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[5], 0); + UNIT_ASSERT_GT(nodeLeaders[0], 0); + UNIT_ASSERT_GT(nodeLeaders[1], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[2], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[3], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[4], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[5], 0); UNIT_ASSERT_GT(nodeTablets[0], 0); UNIT_ASSERT_GT(nodeTablets[1], 0); UNIT_ASSERT_GT(nodeTablets[2], 0); @@ -3091,7 +3091,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -3103,7 +3103,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tablets; for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); - ev->Record.SetFollowerCount(3); + ev->Record.SetFollowerCount(3); auto* group = ev->Record.MutableDataCentersPreference()->AddDataCentersGroups(); group->AddDataCenter(ToString(1)); group->AddDataCenter(ToString(2)); @@ -3112,30 +3112,30 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - // checking distribution, all leaders should be on the first node + // checking distribution, all leaders should be on the first node { - std::array<int, NUM_NODES> nodeLeaders = {}; + std::array<int, NUM_NODES> nodeLeaders = {}; std::array<int, NUM_NODES> nodeTablets = {}; { THolder<TEvHive::TEvRequestHiveInfo> request = MakeHolder<TEvHive::TEvRequestHiveInfo>(); - request->Record.SetReturnFollowers(true); + request->Record.SetReturnFollowers(true); runtime.SendToPipe(hiveTablet, senderA, request.Release()); TAutoPtr<IEventHandle> handle; TEvHive::TEvResponseHiveInfo* response = runtime.GrabEdgeEventRethrow<TEvHive::TEvResponseHiveInfo>(handle); for (const NKikimrHive::TTabletInfo& tablet : response->Record.GetTablets()) { - if (tablet.GetFollowerID() == 0) { - nodeLeaders[tablet.GetNodeID() - nodeBase]++; + if (tablet.GetFollowerID() == 0) { + nodeLeaders[tablet.GetNodeID() - nodeBase]++; } nodeTablets[tablet.GetNodeID() - nodeBase]++; - Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() << Endl; + Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() << Endl; } } - UNIT_ASSERT_GT(nodeLeaders[0], 0); - UNIT_ASSERT_GT(nodeLeaders[1], 0); - UNIT_ASSERT_GT(nodeLeaders[2], 0); - UNIT_ASSERT_GT(nodeLeaders[3], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[4], 0); - UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[5], 0); + UNIT_ASSERT_GT(nodeLeaders[0], 0); + UNIT_ASSERT_GT(nodeLeaders[1], 0); + UNIT_ASSERT_GT(nodeLeaders[2], 0); + UNIT_ASSERT_GT(nodeLeaders[3], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[4], 0); + UNIT_ASSERT_VALUES_EQUAL(nodeLeaders[5], 0); UNIT_ASSERT_GT(nodeTablets[0], 0); UNIT_ASSERT_GT(nodeTablets[1], 0); UNIT_ASSERT_GT(nodeTablets[2], 0); @@ -3157,7 +3157,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -3174,7 +3174,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsUp(runtime, tabletId, 0); } - // checking distribution, all leaders should be on the first node + // checking distribution, all leaders should be on the first node { std::unordered_map<TString, ui64> dcTablets; { @@ -3184,7 +3184,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TEvHive::TEvResponseHiveInfo* response = runtime.GrabEdgeEventRethrow<TEvHive::TEvResponseHiveInfo>(handle); for (const NKikimrHive::TTabletInfo& tablet : response->Record.GetTablets()) { dcTablets[runtime.LocationCallback(tablet.GetNodeID() - nodeBase).GetDataCenterId()]++; - Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() + Ctest << "tablet " << tablet.GetTabletID() << "." << tablet.GetFollowerID() << " on node " << tablet.GetNodeID() << " on DC " << runtime.LocationCallback(tablet.GetNodeID() - nodeBase).GetDataCenterId() << Endl; } } @@ -3193,7 +3193,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } - Y_UNIT_TEST(TestHiveBalancerWithFollowers) { + Y_UNIT_TEST(TestHiveBalancerWithFollowers) { static const int NUM_NODES = 8; static const int NUM_TABLETS = 24; TTestBasicRuntime runtime(NUM_NODES, false); @@ -3202,7 +3202,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); MakeSureTabletIsUp(runtime, hiveTablet, 0); // create NUM_TABLETS tablets @@ -3211,13 +3211,13 @@ Y_UNIT_TEST_SUITE(THiveTest) { for (int i = 0; i < NUM_TABLETS; ++i) { THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500 + i, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(1); - ev->Record.SetFollowerCount(3); + ev->Record.SetFollowerCount(3); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); tablets.emplace_back(tabletId); MakeSureTabletIsUp(runtime, tabletId, 0); } - // check leader distribution, should be equal number of tablets on every node + // check leader distribution, should be equal number of tablets on every node { std::array<int, NUM_NODES> nodeTablets = {}; { @@ -3242,7 +3242,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { std::array<int, NUM_NODES> nodeTablets = {}; { THolder<TEvHive::TEvRequestHiveInfo> request = MakeHolder<TEvHive::TEvRequestHiveInfo>(); - request->Record.SetReturnFollowers(true); + request->Record.SetReturnFollowers(true); runtime.SendToPipe(hiveTablet, senderA, request.Release()); TAutoPtr<IEventHandle> handle; TEvHive::TEvResponseHiveInfo* response = runtime.GrabEdgeEventRethrow<TEvHive::TEvResponseHiveInfo>(handle); @@ -3260,7 +3260,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { THashMap<ui64, ui64> tabletMetrics; - // report metrics for leaders only + // report metrics for leaders only { for (ui64 tabletId : tablets) { THolder<TEvHive::TEvTabletMetrics> metrics = MakeHolder<TEvHive::TEvTabletMetrics>(); @@ -3311,7 +3311,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { SendKillLocal(runtime, 1); TLocalConfig::TPtr local0 = new TLocalConfig(); { - local0->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, + local0->TabletClassInfo[TTabletTypes::Dummy].SetupInfo = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); local0->TabletClassInfo[TTabletTypes::Dummy].MaxCount = 2; @@ -3327,7 +3327,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId senderA = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvStatus, NUM_NODES); @@ -3379,7 +3379,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3387,8 +3387,8 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetAllowFollowerPromotion(false); - ev->Record.SetFollowerCount(2); + ev->Record.SetAllowFollowerPromotion(false); + ev->Record.SetFollowerCount(2); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 3); @@ -3396,7 +3396,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); pipeConfig.ForceLocal = true; - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); WaitForTabletIsUp(runtime, tabletId, 1, &pipeConfig); @@ -3436,13 +3436,13 @@ Y_UNIT_TEST_SUITE(THiveTest) { WaitForTabletIsUp(runtime, tabletId, 2, &pipeConfig); } - Y_UNIT_TEST(TestFollowersCrossDC_Easy) { + Y_UNIT_TEST(TestFollowersCrossDC_Easy) { TTestBasicRuntime runtime((ui32)9, (ui32)3); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3450,7 +3450,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetCrossDataCenterFollowerCount(2); + ev->Record.SetCrossDataCenterFollowerCount(2); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 7); @@ -3458,43 +3458,43 @@ Y_UNIT_TEST_SUITE(THiveTest) { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; ui32 tabsPerDC[3] = {}; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; tabsPerDC[node % 3]++; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { - followers++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { + followers++; tabsPerDC[node % 3]++; } } } - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(followers, 6); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(followers, 6); UNIT_ASSERT(tabsPerDC[0] >= 2); UNIT_ASSERT(tabsPerDC[1] >= 2); UNIT_ASSERT(tabsPerDC[2] >= 2); } - Y_UNIT_TEST(TestFollowers_LocalNodeOnly) { + Y_UNIT_TEST(TestFollowers_LocalNodeOnly) { TTestBasicRuntime runtime((ui32)9, (ui32)3); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3502,99 +3502,99 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - auto* followerGroup = ev->Record.AddFollowerGroups(); - followerGroup->SetFollowerCount(1); - followerGroup->SetLocalNodeOnly(true); - followerGroup->SetAllowClientRead(true); + auto* followerGroup = ev->Record.AddFollowerGroups(); + followerGroup->SetFollowerCount(1); + followerGroup->SetLocalNodeOnly(true); + followerGroup->SetAllowClientRead(true); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, 2); - ui32 leaderNode = 999; + ui32 leaderNode = 999; { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; - leaderNode = node; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; + leaderNode = node; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; - ui32 followerNode = 999; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; + ui32 followerNode = 999; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { - followers++; - followerNode = node; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { + followers++; + followerNode = node; } } } - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(followers, 1); - UNIT_ASSERT_VALUES_EQUAL(leaderNode, followerNode); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(followers, 1); + UNIT_ASSERT_VALUES_EQUAL(leaderNode, followerNode); } - runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(leaderNode))); - SendKillLocal(runtime, leaderNode); + runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(leaderNode))); + SendKillLocal(runtime, leaderNode); WaitForTabletsBecomeActive(runtime, 2); - ui32 secondLeaderNode = 999; + ui32 secondLeaderNode = 999; { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; - secondLeaderNode = node; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; + secondLeaderNode = node; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; - ui32 followerNode = 999; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; + ui32 followerNode = 999; for (ui32 node = 0; node < 9; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { - followers++; - followerNode = node; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { + followers++; + followerNode = node; } } } - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(followers, 1); - UNIT_ASSERT(leaderNode != secondLeaderNode); - UNIT_ASSERT_VALUES_EQUAL(secondLeaderNode, followerNode); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(followers, 1); + UNIT_ASSERT(leaderNode != secondLeaderNode); + UNIT_ASSERT_VALUES_EQUAL(secondLeaderNode, followerNode); } } - Y_UNIT_TEST(TestFollowersCrossDC_Tight) { + Y_UNIT_TEST(TestFollowersCrossDC_Tight) { static constexpr ui32 NODES = 9; static constexpr ui32 DCS = 3; - static constexpr ui32 FOLLOWERS = NODES / DCS; + static constexpr ui32 FOLLOWERS = NODES / DCS; TTestBasicRuntime runtime(NODES, DCS); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3602,52 +3602,52 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); + ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); WaitForTabletsBecomeActive(runtime, NODES + 1); NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; - ui32 followersPerDC[DCS] = {}; - ui32 leaders = 0; - ui32 followers = 0; + ui32 followersPerDC[DCS] = {}; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { - followers++; - followersPerDC[node % DCS]++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { + followers++; + followersPerDC[node % DCS]++; } } } - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); for (ui32 dc = 0; dc < DCS; ++dc) { - UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); + UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); } } - Y_UNIT_TEST(TestFollowersCrossDC_MovingLeader) { + Y_UNIT_TEST(TestFollowersCrossDC_MovingLeader) { static constexpr ui32 NODES = 9; static constexpr ui32 DCS = 3; - static constexpr ui32 FOLLOWERS = NODES / DCS; + static constexpr ui32 FOLLOWERS = NODES / DCS; TTestBasicRuntime runtime(NODES, DCS); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3655,101 +3655,101 @@ Y_UNIT_TEST_SUITE(THiveTest) { } TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); - ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); + ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); //WaitForTabletsBecomeActive(runtime, 3 * 3 + 1); - ui32 leadersNode = 0; + ui32 leadersNode = 0; { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; - ui32 followersPerDC[DCS] = {}; + ui32 followersPerDC[DCS] = {}; ui32 total = 0; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; - leadersNode = node; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; + leadersNode = node; total++; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { total++; - followers++; - followersPerDC[node % DCS]++; + followers++; + followersPerDC[node % DCS]++; } } } - UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); for (ui32 dc = 0; dc < DCS; ++dc) { - UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); + UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); } } - runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(leadersNode))); + runtime.Register(CreateTabletKiller(tabletId, runtime.GetNodeId(leadersNode))); WaitForTabletsBecomeActive(runtime, 1); { NTabletPipe::TClientConfig pipeConfig; - // we need retry policy to handle possible follower reconnect + // we need retry policy to handle possible follower reconnect pipeConfig.RetryPolicy = {.RetryLimitCount = 2, .MinRetryTime = TDuration::MilliSeconds(100)}; pipeConfig.ForceLocal = true; - ui32 followersPerDC[DCS] = {}; + ui32 followersPerDC[DCS] = {}; ui32 total = 0; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; total++; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { total++; - followers++; - followersPerDC[node % DCS]++; + followers++; + followersPerDC[node % DCS]++; } } } - UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); for (ui32 dc = 0; dc < DCS; ++dc) { - UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); + UNIT_ASSERT(followersPerDC[dc] == FOLLOWERS); } } } - Y_UNIT_TEST(TestFollowersCrossDC_KillingHiveAndFollower) { + Y_UNIT_TEST(TestFollowersCrossDC_KillingHiveAndFollower) { static constexpr ui32 NODES = 3; static constexpr ui32 DCS = 3; - static constexpr ui32 FOLLOWERS = 1; + static constexpr ui32 FOLLOWERS = 1; TTestBasicRuntime runtime(NODES, DCS); Setup(runtime, true); TVector<ui64> tabletIds; const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive, 0); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive, 0); { TDispatchOptions options; options.FinalEvents.emplace_back(TEvLocal::EvSyncTablets, runtime.GetNodeCount()); @@ -3758,46 +3758,46 @@ Y_UNIT_TEST_SUITE(THiveTest) { TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); ev->Record.SetObjectId(1337); - ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); + ev->Record.SetCrossDataCenterFollowerCount(FOLLOWERS); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, false); - WaitForTabletsBecomeActive(runtime, FOLLOWERS * DCS + 1); + WaitForTabletsBecomeActive(runtime, FOLLOWERS * DCS + 1); - ui32 leaderNode = 0; - ui32 followersNode = 0; + ui32 leaderNode = 0; + ui32 followersNode = 0; { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; ui32 total = 0; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; total++; - leaderNode = node; + leaderNode = node; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { total++; - followers++; - if (node != leaderNode) { - followersNode = node; + followers++; + if (node != leaderNode) { + followersNode = node; } } } } - UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); } runtime.Register(CreateTabletKiller(hiveTablet)); @@ -3806,41 +3806,41 @@ Y_UNIT_TEST_SUITE(THiveTest) { options.FinalEvents.emplace_back(TEvTablet::EvTabletDead); runtime.DispatchEvents(options); } - SendKillLocal(runtime, followersNode); + SendKillLocal(runtime, followersNode); WaitForEvServerDisconnected(runtime); WaitForTabletsBecomeActive(runtime, 1); // hive - CreateLocal(runtime, followersNode); - WaitForTabletsBecomeActive(runtime, 1); // follower + CreateLocal(runtime, followersNode); + WaitForTabletsBecomeActive(runtime, 1); // follower { NTabletPipe::TClientConfig pipeConfig; pipeConfig.ForceLocal = true; ui32 total = 0; - ui32 leaders = 0; - ui32 followers = 0; + ui32 leaders = 0; + ui32 followers = 0; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (leader) { - leaders++; + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (leader) { + leaders++; total++; } } } - pipeConfig.AllowFollower = true; - pipeConfig.ForceFollower = true; + pipeConfig.AllowFollower = true; + pipeConfig.ForceFollower = true; for (ui32 node = 0; node < NODES; ++node) { - bool leader; - if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { - if (!leader) { + bool leader; + if (CheckTabletIsUp(runtime, tabletId, node, &pipeConfig, &leader)) { + if (!leader) { total++; - followers++; + followers++; } } } - UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); - UNIT_ASSERT_VALUES_EQUAL(leaders, 1); - UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(followers, FOLLOWERS * DCS); + UNIT_ASSERT_VALUES_EQUAL(leaders, 1); + UNIT_ASSERT_VALUES_EQUAL(total, 1 + FOLLOWERS * DCS); } } @@ -3849,7 +3849,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -3863,7 +3863,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -3886,7 +3886,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -3906,7 +3906,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); // Block group assignment runtime.SetObserverFunc([](TTestActorRuntimeBase& runtime, TAutoPtr<IEventHandle>& event) { @@ -3984,7 +3984,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -4008,7 +4008,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -4027,7 +4027,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4056,7 +4056,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4070,7 +4070,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsDown(runtime, tabletId, 0); // Reboot the hive tablet - RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); + RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); // Tablet should boot when timeout expires WaitForTabletIsUp(runtime, tabletId, 0); @@ -4086,7 +4086,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { TActorId sender = runtime.AllocateEdgeActor(); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4121,7 +4121,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4146,11 +4146,11 @@ Y_UNIT_TEST_SUITE(THiveTest) { SendDeleteTestTablet(runtime, hiveTablet, MakeHolder<TEvHive::TEvDeleteTablet>(testerTablet, 0, 0)); // Reboot hive while tablet deletion is still delayed. - RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); + RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); // Remove observer and reboot hive one more time, letting delete to finish normally. runtime.SetObserverFunc(prevObserverFunc); - RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); + RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); // Hive should try to notify owner on unlocking VerifyLockTabletExecutionLost(runtime, tabletId, owner); @@ -4159,7 +4159,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { void MakeSureTabletStaysDown(TTestActorRuntime& runtime, ui64 tabletId, const TDuration& timeout) { TActorId edge = runtime.AllocateEdgeActor(); NTabletPipe::TClientConfig clientConfig; - clientConfig.AllowFollower = true; + clientConfig.AllowFollower = true; clientConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); TActorId pipeClient = runtime.Register(NTabletPipe::CreateClient(edge, tabletId, clientConfig)); TAutoPtr<IEventHandle> handle; @@ -4189,7 +4189,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4218,7 +4218,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4232,7 +4232,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { MakeSureTabletIsDown(runtime, tabletId, 0); // Reboot the hive tablet - RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); + RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0)); // Reconnect the lock SendLockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::OK, owner, 40000, true); @@ -4244,7 +4244,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + const TActorId hiveActor = CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); runtime.EnableScheduleForActor(hiveActor); TTabletTypes::EType tabletType = TTabletTypes::Dummy; @@ -4293,7 +4293,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -4314,7 +4314,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -4339,7 +4339,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TTabletTypes::EType tabletType = TTabletTypes::Dummy; THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, BINDED_CHANNELS)); @@ -4364,7 +4364,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { CreateLocal(runtime, 0); // only the 1st node has local running const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); TAutoPtr<TEvHive::TEvCreateTablet> ev = new TEvHive::TEvCreateTablet(testerTablet, 0, TTabletTypes::Dummy, BINDED_CHANNELS); ev->Record.SetTabletBootMode(NKikimrHive::ETabletBootMode::TABLET_BOOT_MODE_EXTERNAL); @@ -4377,7 +4377,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto* result = runtime.GrabEdgeEvent<TEvLocal::TEvBootTablet>(handle); UNIT_ASSERT(result); UNIT_ASSERT_VALUES_EQUAL(result->Record.GetSuggestedGeneration(), 1); - UNIT_ASSERT_EQUAL(result->Record.GetBootMode(), NKikimrLocal::EBootMode::BOOT_MODE_LEADER); + UNIT_ASSERT_EQUAL(result->Record.GetBootMode(), NKikimrLocal::EBootMode::BOOT_MODE_LEADER); const auto& storageInfo = result->Record.GetInfo(); UNIT_ASSERT_EQUAL(storageInfo.GetTabletID(), tabletId); @@ -4390,7 +4390,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { Setup(runtime, true); const ui64 hiveTablet = MakeDefaultHiveID(0); const ui64 testerTablet = MakeDefaultHiveID(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::FLAT_HIVE), &CreateDefaultHive); THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 0, TTabletTypes::Dummy, BINDED_CHANNELS)); ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); @@ -4417,7 +4417,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { auto result = runtime.GrabEdgeEvent<TEvLocal::TEvBootTablet>(bootOwner); const auto* msg = result->Get(); - UNIT_ASSERT_EQUAL(msg->Record.GetBootMode(), NKikimrLocal::EBootMode::BOOT_MODE_LEADER); + UNIT_ASSERT_EQUAL(msg->Record.GetBootMode(), NKikimrLocal::EBootMode::BOOT_MODE_LEADER); const auto& storageInfo = msg->Record.GetInfo(); UNIT_ASSERT_EQUAL(storageInfo.GetTabletID(), tabletId); diff --git a/ydb/core/mind/hive/leader_tablet_info.cpp b/ydb/core/mind/hive/leader_tablet_info.cpp index 7ed0f7d05b9..13e1d5b2ee2 100644 --- a/ydb/core/mind/hive/leader_tablet_info.cpp +++ b/ydb/core/mind/hive/leader_tablet_info.cpp @@ -3,9 +3,9 @@ namespace NKikimr { namespace NHive { -TString TLeaderTabletInfo::DEFAULT_STORAGE_POOL_NAME = "default"; +TString TLeaderTabletInfo::DEFAULT_STORAGE_POOL_NAME = "default"; -TPathId TLeaderTabletInfo::GetTenant() const { +TPathId TLeaderTabletInfo::GetTenant() const { // todo: must be explicit TenantPathId if (!ObjectDomain) return TPathId(); @@ -13,56 +13,56 @@ TPathId TLeaderTabletInfo::GetTenant() const { return TPathId(ObjectDomain.GetSchemeShard(), ObjectDomain.GetPathId()); } -bool TLeaderTabletInfo::IsSomeoneAliveOnNode(TNodeId nodeId) const { +bool TLeaderTabletInfo::IsSomeoneAliveOnNode(TNodeId nodeId) const { if (CanBeAlive() && Node->Id == nodeId) { return true; } - for (const TTabletInfo& follower : Followers) { - if (follower.CanBeAlive() && follower.Node->Id == nodeId) + for (const TTabletInfo& follower : Followers) { + if (follower.CanBeAlive() && follower.Node->Id == nodeId) return true; } return false; } -ui32 TLeaderTabletInfo::GetFollowersAliveOnDataCenter(TDataCenterId dataCenterId) const { - ui32 followers = 0; - for (const TTabletInfo& follower : Followers) { +ui32 TLeaderTabletInfo::GetFollowersAliveOnDataCenter(TDataCenterId dataCenterId) const { + ui32 followers = 0; + for (const TTabletInfo& follower : Followers) { if (follower.CanBeAlive() && follower.Node->Location.GetDataCenterId() == dataCenterId) { - ++followers; + ++followers; } } - return followers; + return followers; } -ui32 TLeaderTabletInfo::GetFollowersAliveOnDataCenterExcludingFollower(TDataCenterId dataCenterId, const TTabletInfo& excludingFollower) const { - ui32 followers = 0; - for (const TTabletInfo& follower : Followers) { - if (follower == excludingFollower) +ui32 TLeaderTabletInfo::GetFollowersAliveOnDataCenterExcludingFollower(TDataCenterId dataCenterId, const TTabletInfo& excludingFollower) const { + ui32 followers = 0; + for (const TTabletInfo& follower : Followers) { + if (follower == excludingFollower) continue; if (follower.CanBeAlive() && follower.Node->Location.GetDataCenterId() == dataCenterId) { - ++followers; + ++followers; } } - return followers; + return followers; } -bool TLeaderTabletInfo::IsFollowerPromotableOnNode(TNodeId nodeId) const { - for (const TFollowerTabletInfo& follower : Followers) { - if (follower.IsRunning() && follower.NodeId == nodeId && follower.FollowerGroup.AllowLeaderPromotion) +bool TLeaderTabletInfo::IsFollowerPromotableOnNode(TNodeId nodeId) const { + for (const TFollowerTabletInfo& follower : Followers) { + if (follower.IsRunning() && follower.NodeId == nodeId && follower.FollowerGroup.AllowLeaderPromotion) return true; } return false; } -TFollowerId TLeaderTabletInfo::GetFollowerPromotableOnNode(TNodeId nodeId) const { - for (const TFollowerTabletInfo& follower : Followers) { - if (follower.IsRunning() && follower.NodeId == nodeId && follower.FollowerGroup.AllowLeaderPromotion) - return follower.Id; +TFollowerId TLeaderTabletInfo::GetFollowerPromotableOnNode(TNodeId nodeId) const { + for (const TFollowerTabletInfo& follower : Followers) { + if (follower.IsRunning() && follower.NodeId == nodeId && follower.FollowerGroup.AllowLeaderPromotion) + return follower.Id; } return 0; } -void TLeaderTabletInfo::AssignDomains(const TSubDomainKey& objectDomain, const TVector<TSubDomainKey>& allowedDomains) { +void TLeaderTabletInfo::AssignDomains(const TSubDomainKey& objectDomain, const TVector<TSubDomainKey>& allowedDomains) { if (!allowedDomains.empty()) { EffectiveAllowedDomains = allowedDomains; if (!objectDomain) { @@ -79,12 +79,12 @@ void TLeaderTabletInfo::AssignDomains(const TSubDomainKey& objectDomain, const T } } -bool TLeaderTabletInfo::InitiateAssignTabletGroups() { +bool TLeaderTabletInfo::InitiateAssignTabletGroups() { Hive.AssignTabletGroups(*this); return true; } -bool TLeaderTabletInfo::InitiateBlockStorage() { +bool TLeaderTabletInfo::InitiateBlockStorage() { // attempt to kill tablet before blocking the storage group Kill(); // blocks PREVIOUS entry of tablet history @@ -93,7 +93,7 @@ bool TLeaderTabletInfo::InitiateBlockStorage() { return true; } -bool TLeaderTabletInfo::InitiateBlockStorage(ui32 generation) { +bool TLeaderTabletInfo::InitiateBlockStorage(ui32 generation) { // attempt to kill tablet before blocking the storage group Kill(); // blocks LATEST entry of tablet history @@ -107,40 +107,40 @@ bool TLeaderTabletInfo::InitiateBlockStorage(ui32 generation) { return true; } -bool TLeaderTabletInfo::InitiateDeleteStorage() { +bool TLeaderTabletInfo::InitiateDeleteStorage() { IActor* x = CreateTabletReqDelete(Hive.SelfId(), TabletStorageInfo); Hive.Register(x); return true; } -TFollowerTabletInfo& TLeaderTabletInfo::AddFollower(TFollowerGroup& followerGroup, TFollowerId followerId) { - Followers.emplace_back(*this, followerId, followerGroup); - TFollowerTabletInfo& follower = Followers.back(); - if (followerId == 0) { - follower.Id = GenerateFollowerId(); +TFollowerTabletInfo& TLeaderTabletInfo::AddFollower(TFollowerGroup& followerGroup, TFollowerId followerId) { + Followers.emplace_back(*this, followerId, followerGroup); + TFollowerTabletInfo& follower = Followers.back(); + if (followerId == 0) { + follower.Id = GenerateFollowerId(); } else { - follower.Id = followerId; + follower.Id = followerId; } Hive.UpdateCounterTabletsTotal(+1); - return follower; + return follower; } -TFollowerGroupId TLeaderTabletInfo::GenerateFollowerGroupId() const { - return GenerateId(FollowerGroups); +TFollowerGroupId TLeaderTabletInfo::GenerateFollowerGroupId() const { + return GenerateId(FollowerGroups); } -TFollowerGroup& TLeaderTabletInfo::AddFollowerGroup(TFollowerGroupId followerGroupId) { - FollowerGroups.emplace_back(); - TFollowerGroup& followerGroup = FollowerGroups.back(); - if (followerGroupId == 0) { - followerGroup.Id = GenerateFollowerGroupId(); +TFollowerGroup& TLeaderTabletInfo::AddFollowerGroup(TFollowerGroupId followerGroupId) { + FollowerGroups.emplace_back(); + TFollowerGroup& followerGroup = FollowerGroups.back(); + if (followerGroupId == 0) { + followerGroup.Id = GenerateFollowerGroupId(); } else { - followerGroup.Id = followerGroupId; + followerGroup.Id = followerGroupId; } - return followerGroup; + return followerGroup; } -TActorId TLeaderTabletInfo::SetLockedToActor(const TActorId& actor, const TDuration& timeout) { +TActorId TLeaderTabletInfo::SetLockedToActor(const TActorId& actor, const TDuration& timeout) { TActorId previousOwner = LockedToActor; if (LockedToActor != actor) { if (LockedToActor.NodeId() != actor.NodeId()) { @@ -162,19 +162,19 @@ TActorId TLeaderTabletInfo::SetLockedToActor(const TActorId& actor, const TDurat return previousOwner; } -void TLeaderTabletInfo::AcquireAllocationUnits() { +void TLeaderTabletInfo::AcquireAllocationUnits() { for (ui32 channel = 0; channel < TabletStorageInfo->Channels.size(); ++channel) { AcquireAllocationUnit(channel); } } -void TLeaderTabletInfo::ReleaseAllocationUnits() { +void TLeaderTabletInfo::ReleaseAllocationUnits() { for (ui32 channel = 0; channel < TabletStorageInfo->Channels.size(); ++channel) { ReleaseAllocationUnit(channel); } } -bool TLeaderTabletInfo::AcquireAllocationUnit(ui32 channelId) { +bool TLeaderTabletInfo::AcquireAllocationUnit(ui32 channelId) { if (channelId < TabletStorageInfo->Channels.size()) { const TTabletChannelInfo& channel = TabletStorageInfo->Channels[channelId]; if (!channel.History.empty()) { @@ -185,7 +185,7 @@ bool TLeaderTabletInfo::AcquireAllocationUnit(ui32 channelId) { return false; } -bool TLeaderTabletInfo::ReleaseAllocationUnit(ui32 channelId) { +bool TLeaderTabletInfo::ReleaseAllocationUnit(ui32 channelId) { if (channelId < TabletStorageInfo->Channels.size()) { const TTabletChannelInfo& channel = TabletStorageInfo->Channels[channelId]; if (!channel.History.empty()) { @@ -196,7 +196,7 @@ bool TLeaderTabletInfo::ReleaseAllocationUnit(ui32 channelId) { return false; } -const NKikimrBlobStorage::TEvControllerSelectGroupsResult::TGroupParameters* TLeaderTabletInfo::FindFreeAllocationUnit(ui32 channelId) { +const NKikimrBlobStorage::TEvControllerSelectGroupsResult::TGroupParameters* TLeaderTabletInfo::FindFreeAllocationUnit(ui32 channelId) { TStoragePoolInfo* storagePool = Hive.FindStoragePool(GetChannelStoragePoolName(channelId)); if (storagePool != nullptr) { THolder<NKikimrBlobStorage::TEvControllerSelectGroups::TGroupParameters> params = Hive.BuildGroupParametersForChannel(*this, channelId); @@ -247,15 +247,15 @@ const NKikimrBlobStorage::TEvControllerSelectGroupsResult::TGroupParameters* TLe return nullptr; } -TString TLeaderTabletInfo::GetChannelStoragePoolName(const TTabletChannelInfo& channel) { +TString TLeaderTabletInfo::GetChannelStoragePoolName(const TTabletChannelInfo& channel) { return channel.StoragePool.empty() ? DEFAULT_STORAGE_POOL_NAME : channel.StoragePool; } -TString TLeaderTabletInfo::GetChannelStoragePoolName(const TChannelProfiles::TProfile::TChannel& channel) { +TString TLeaderTabletInfo::GetChannelStoragePoolName(const TChannelProfiles::TProfile::TChannel& channel) { return channel.PoolKind.empty() ? DEFAULT_STORAGE_POOL_NAME : channel.PoolKind; } -TString TLeaderTabletInfo::GetChannelStoragePoolName(ui32 channelId) { +TString TLeaderTabletInfo::GetChannelStoragePoolName(ui32 channelId) { if (BoundChannels.size() > channelId) { return BoundChannels[channelId].GetStoragePoolName(); } @@ -265,12 +265,12 @@ TString TLeaderTabletInfo::GetChannelStoragePoolName(ui32 channelId) { return DEFAULT_STORAGE_POOL_NAME; } -TStoragePoolInfo& TLeaderTabletInfo::GetStoragePool(ui32 channelId) { +TStoragePoolInfo& TLeaderTabletInfo::GetStoragePool(ui32 channelId) { TStoragePoolInfo& storagePool = Hive.GetStoragePool(GetChannelStoragePoolName(channelId)); return storagePool; } -void TLeaderTabletInfo::ActualizeTabletStatistics(TInstant now) { +void TLeaderTabletInfo::ActualizeTabletStatistics(TInstant now) { TTabletInfo::ActualizeTabletStatistics(now); for (TTabletInfo& follower : Followers) { follower.ActualizeTabletStatistics(now); diff --git a/ydb/core/mind/hive/leader_tablet_info.h b/ydb/core/mind/hive/leader_tablet_info.h index bd62d9f38ef..88425b3caed 100644 --- a/ydb/core/mind/hive/leader_tablet_info.h +++ b/ydb/core/mind/hive/leader_tablet_info.h @@ -2,14 +2,14 @@ #include "hive.h" #include "tablet_info.h" -#include "follower_tablet_info.h" +#include "follower_tablet_info.h" namespace NKikimr { namespace NHive { struct TTabletCategoryInfo { TTabletCategoryId Id; - std::unordered_set<TLeaderTabletInfo*> Tablets; + std::unordered_set<TLeaderTabletInfo*> Tablets; ui64 MaxDisconnectTimeout = 0; bool StickTogetherInDC = false; @@ -20,7 +20,7 @@ struct TTabletCategoryInfo { struct TStoragePoolInfo; -struct TLeaderTabletInfo : TTabletInfo { +struct TLeaderTabletInfo : TTabletInfo { protected: static TString DEFAULT_STORAGE_POOL_NAME; @@ -39,8 +39,8 @@ public: NKikimrHive::TEvReassignTablet::EHiveReassignReason ChannelProfileReassignReason; ui32 KnownGeneration; TTabletCategoryInfo* Category; - TList<TFollowerGroup> FollowerGroups; - TList<TFollowerTabletInfo> Followers; + TList<TFollowerGroup> FollowerGroups; + TList<TFollowerTabletInfo> Followers; TOwnerIdxType::TValueType Owner; TVector<TSubDomainKey> EffectiveAllowedDomains; // AllowedDomains | ObjectDomain NKikimrHive::ETabletBootMode BootMode; @@ -52,8 +52,8 @@ public: bool SeizedByChild = false; // transient state for migration - need to delete it later bool NeedToReleaseFromParent = false; // transient state for migration - need to delete it later - TLeaderTabletInfo(TTabletId id, THive& hive) - : TTabletInfo(ETabletRole::Leader, hive) + TLeaderTabletInfo(TTabletId id, THive& hive) + : TTabletInfo(ETabletRole::Leader, hive) , Id(id) , State(ETabletState::Unknown) , Type(TTabletTypes::TYPE_INVALID) @@ -127,16 +127,16 @@ public: return !SeizedByChild && State == ETabletState::ReadyToWork; } - ui32 GetFollowersAliveOnDataCenter(TDataCenterId dataCenterId) const; - ui32 GetFollowersAliveOnDataCenterExcludingFollower(TDataCenterId dataCenterId, const TTabletInfo& excludingFollower) const; + ui32 GetFollowersAliveOnDataCenter(TDataCenterId dataCenterId) const; + ui32 GetFollowersAliveOnDataCenterExcludingFollower(TDataCenterId dataCenterId, const TTabletInfo& excludingFollower) const; TPathId GetTenant() const; bool IsAllAlive() const { if (!IsAlive()) return false; - for (const TTabletInfo& follower : Followers) { - if (!follower.IsAlive()) + for (const TTabletInfo& follower : Followers) { + if (!follower.IsAlive()) return false; } return true; @@ -145,27 +145,27 @@ public: bool IsSomeoneAlive() const { if (IsAlive()) return true; - for (const TTabletInfo& follower : Followers) { - if (follower.IsAlive()) + for (const TTabletInfo& follower : Followers) { + if (follower.IsAlive()) return true; } return false; } - bool IsSomeFollowerAlive() const { - for (const TTabletInfo& follower : Followers) { - if (follower.IsAlive()) + bool IsSomeFollowerAlive() const { + for (const TTabletInfo& follower : Followers) { + if (follower.IsAlive()) return true; } return false; } - bool HaveFollowers() const { - return !Followers.empty(); + bool HaveFollowers() const { + return !Followers.empty(); } - bool IsFollowerPromotableOnNode(TNodeId nodeId) const; - TFollowerId GetFollowerPromotableOnNode(TNodeId nodeId) const; + bool IsFollowerPromotableOnNode(TNodeId nodeId) const; + TFollowerId GetFollowerPromotableOnNode(TNodeId nodeId) const; void AssignDomains(const TSubDomainKey& objectDomain, const TVector<TSubDomainKey>& allowedDomains); @@ -174,20 +174,20 @@ public: if (IsReadyToBoot()) { boot |= InitiateBoot(); } - if (HaveFollowers()) { - boot |= InitiateFollowersBoot(); + if (HaveFollowers()) { + boot |= InitiateFollowersBoot(); } return boot; } bool InitiateAssignTabletGroups(); - bool InitiateFollowersBoot() { + bool InitiateFollowersBoot() { bool result = false; if (IsReadyToWork()) { - for (TFollowerTabletInfo& follower : Followers) { - if (follower.IsReadyToBoot()) { - result |= follower.InitiateBoot(); + for (TFollowerTabletInfo& follower : Followers) { + if (follower.IsReadyToBoot()) { + result |= follower.InitiateBoot(); } } } @@ -195,8 +195,8 @@ public: } void Kill() { - for (TFollowerTabletInfo& follower : Followers) { - follower.Kill(); + for (TFollowerTabletInfo& follower : Followers) { + follower.Kill(); } TTabletInfo::Kill(); } @@ -210,39 +210,39 @@ public: ++KnownGeneration; } - const TTabletInfo* FindTablet(TFollowerId followerId) const { // get leader or follower tablet depending on followerId - if (followerId == 0) { - return this; // leader + const TTabletInfo* FindTablet(TFollowerId followerId) const { // get leader or follower tablet depending on followerId + if (followerId == 0) { + return this; // leader } - auto it = std::find_if(Followers.begin(), Followers.end(), [followerId](const TFollowerTabletInfo& info) -> bool { - return info.Id == followerId; + auto it = std::find_if(Followers.begin(), Followers.end(), [followerId](const TFollowerTabletInfo& info) -> bool { + return info.Id == followerId; }); - if (it != Followers.end()) { + if (it != Followers.end()) { return &(*it); } return nullptr; } - const TTabletInfo& GetTablet(TFollowerId followerId) const { // get leader or follower tablet depending on followerId - const TTabletInfo* tablet = FindTablet(followerId); + const TTabletInfo& GetTablet(TFollowerId followerId) const { // get leader or follower tablet depending on followerId + const TTabletInfo* tablet = FindTablet(followerId); if (tablet != nullptr) { return *tablet; } - return *this; // leader by default + return *this; // leader by default } - TTabletInfo* FindTablet(TFollowerId followerId) { // get leader or follower tablet depending on followerId - return const_cast<TTabletInfo*>(static_cast<const TLeaderTabletInfo*>(this)->FindTablet(followerId)); + TTabletInfo* FindTablet(TFollowerId followerId) { // get leader or follower tablet depending on followerId + return const_cast<TTabletInfo*>(static_cast<const TLeaderTabletInfo*>(this)->FindTablet(followerId)); } - TTabletInfo& GetTablet(TFollowerId followerId) { // get leader or follower tablet depending on followerId - return const_cast<TTabletInfo&>(static_cast<const TLeaderTabletInfo&>(*this).GetTablet(followerId)); + TTabletInfo& GetTablet(TFollowerId followerId) { // get leader or follower tablet depending on followerId + return const_cast<TTabletInfo&>(static_cast<const TLeaderTabletInfo&>(*this).GetTablet(followerId)); } - TFollowerTabletInfo& SpawnFollower(TFollowerGroup& followerGroup) { - TFollowerTabletInfo& follower = AddFollower(followerGroup); - follower.BecomeStopped(); - return follower; + TFollowerTabletInfo& SpawnFollower(TFollowerGroup& followerGroup) { + TFollowerTabletInfo& follower = AddFollower(followerGroup); + follower.BecomeStopped(); + return follower; } template <template <typename, typename...> class Cont, typename Type, typename... Types> @@ -261,21 +261,21 @@ public: return id; } - TFollowerId GenerateFollowerId() const { - return GenerateId(Followers); + TFollowerId GenerateFollowerId() const { + return GenerateId(Followers); } - TFollowerTabletInfo& AddFollower(TFollowerGroup& followerGroup, TFollowerId followerId = 0); - TFollowerGroupId GenerateFollowerGroupId() const; - TFollowerGroup& AddFollowerGroup(TFollowerGroupId followerGroupId = 0); + TFollowerTabletInfo& AddFollower(TFollowerGroup& followerGroup, TFollowerId followerId = 0); + TFollowerGroupId GenerateFollowerGroupId() const; + TFollowerGroup& AddFollowerGroup(TFollowerGroupId followerGroupId = 0); - TFollowerGroup& GetFollowerGroup(TFollowerGroupId followerGroupId) { - auto it = std::find(FollowerGroups.begin(), FollowerGroups.end(), followerGroupId); - Y_VERIFY(it != FollowerGroups.end(), "%s", (TStringBuilder() + TFollowerGroup& GetFollowerGroup(TFollowerGroupId followerGroupId) { + auto it = std::find(FollowerGroups.begin(), FollowerGroups.end(), followerGroupId); + Y_VERIFY(it != FollowerGroups.end(), "%s", (TStringBuilder() << "TabletId=" << Id - << " FollowerGroupId=" << followerGroupId - << " FollowerGroupSize=" << FollowerGroups.size() - << " FollowersSize=" << Followers.size()).data()); + << " FollowerGroupId=" << followerGroupId + << " FollowerGroupSize=" << FollowerGroups.size() + << " FollowersSize=" << Followers.size()).data()); return *it; } diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp index 13d0416f2f3..7e9a83b354e 100644 --- a/ydb/core/mind/hive/monitoring.cpp +++ b/ydb/core/mind/hive/monitoring.cpp @@ -17,7 +17,7 @@ public: struct TTabletInfo { ui32 KnownGeneration; ui32 TabletType; - ui32 LeaderNode; + ui32 LeaderNode; ETabletState TabletState; }; @@ -55,11 +55,11 @@ public: const ui64 tabletId = rowset.GetValue<Schema::Tablet::ID>(); const ui32 knownGen = rowset.GetValue<Schema::Tablet::KnownGeneration>(); const ui32 type = rowset.GetValue<Schema::Tablet::TabletType>(); - const ui32 leaderNode = rowset.GetValue<Schema::Tablet::LeaderNode>(); + const ui32 leaderNode = rowset.GetValue<Schema::Tablet::LeaderNode>(); const ETabletState tabletState = rowset.GetValue<Schema::Tablet::State>(); - TabletInfo[tabletId] = {knownGen, type, leaderNode, tabletState}; - ++NodeInfo[leaderNode].TabletsOn; // leaderNode could be zero, then - counter of tablets w/o leader node + TabletInfo[tabletId] = {knownGen, type, leaderNode, tabletState}; + ++NodeInfo[leaderNode].TabletsOn; // leaderNode could be zero, then - counter of tablets w/o leader node if (!rowset.Next()) return false; } @@ -109,7 +109,7 @@ public: TABLEH() {out << "Tablet";} TABLEH() {out << "ID";} TABLEH() {out << "KnownGeneration";} - TABLEH() {out << "LeaderNode";} + TABLEH() {out << "LeaderNode";} TABLEH() {out << "State";} TABLEH_CLASS("sorter-false") {} } @@ -126,8 +126,8 @@ public: << "</a></td>"; TABLED() {out << tabletId;} TABLED() {out << x.KnownGeneration;} - TABLED_CLASS(x.LeaderNode ? "" : "warning") - {out << x.LeaderNode;} + TABLED_CLASS(x.LeaderNode ? "" : "warning") + {out << x.LeaderNode;} TABLED() {out << ETabletStateName(x.TabletState);} TABLED() {out << " <a href=\"../tablets?SsId=" << tabletId << "\">" @@ -155,7 +155,7 @@ public: if (nodeId != 0 || x.Local) { TABLER() { if (nodeId == 0) { - TABLED_CLASS("danger") {out << "w/o leader node"; } + TABLED_CLASS("danger") {out << "w/o leader node"; } } else { TABLED() {out << nodeId; } } @@ -255,7 +255,7 @@ public: for (const auto& tabletIdx : tabletIdIndex) { TTabletInfo& x = *tabletIdx.second; if (BadOnly) { - if (x.IsAlive() || x.GetLeader().IsExternalBoot()) { + if (x.IsAlive() || x.GetLeader().IsExternalBoot()) { continue; } if (x.IsLeader() && x.AsLeader().Type == TTabletTypes::BlockStoreVolume && x.IsStopped()) { @@ -269,21 +269,21 @@ public: TFullTabletId tabletId = x.GetFullTabletId(); x.UpdateWeight(); out << "<tr>"; - out << "<td data-text='" << TTabletTypes::TypeToStr(x.GetLeader().Type) << "'><a href=\"../tablets?TabletID=" + out << "<td data-text='" << TTabletTypes::TypeToStr(x.GetLeader().Type) << "'><a href=\"../tablets?TabletID=" << tabletId.first << "\">" - << TTabletTypes::TypeToStr(x.GetLeader().Type) + << TTabletTypes::TypeToStr(x.GetLeader().Type) << "</a></td>"; out << "<td data-text='" << count << "'>" << tabletId.first << '.' << tabletId.second << "</td>"; - out << "<td style='text-align:right'>" << x.GetLeader().KnownGeneration << "</td>"; + out << "<td style='text-align:right'>" << x.GetLeader().KnownGeneration << "</td>"; out << "<td"; if (x.NodeId == 0) { out << " class='warning'"; } out << " style='text-align:right'>" << x.NodeId << "</td>"; - out << "<td>" << ETabletStateName(x.GetLeader().State) << "</td>"; + out << "<td>" << ETabletStateName(x.GetLeader().State) << "</td>"; out << "<td>" << TTabletInfo::EVolatileStateName(x.GetVolatileState()) << "</td>"; - if (x.IsLeader()) { - TLeaderTabletInfo& m(x.GetLeader()); + if (x.IsLeader()) { + TLeaderTabletInfo& m(x.GetLeader()); out << "<td>" << TInstant::MilliSeconds(m.Statistics.GetLastAliveTimestamp()).ToStringUpToSeconds() << "</td>"; out << "<td style='text-align:right'>" << m.Statistics.RestartTimestampSize() << "</td>"; } else { @@ -408,7 +408,7 @@ public: if (domainInfo.HiveId == Self->TabletID()) { out << "<td>itself</td>"; } else { - TLeaderTabletInfo* tablet = Self->FindTablet(domainInfo.HiveId); + TLeaderTabletInfo* tablet = Self->FindTablet(domainInfo.HiveId); if (tablet) { out << "<td>" << tablet->StateString() << "</td>"; } else { @@ -1112,7 +1112,7 @@ public: ++runningTablets; ++tabletsByNodeByType[pr.second.NodeId][GetTabletType(pr.second.Type)]; } - for (const auto& sl : pr.second.Followers) { + for (const auto& sl : pr.second.Followers) { if (sl.IsRunning()){ ++runningTablets; ++tabletsByNodeByType[sl.NodeId][GetTabletType(pr.second.Type) + "s"]; @@ -1755,7 +1755,7 @@ public: ++runningTablets; ++tabletsByNodeByType[pr.second.NodeId][TTxMonEvent_Landing::GetTabletType(pr.second.Type)]; } - for (const auto& sl : pr.second.Followers) { + for (const auto& sl : pr.second.Followers) { if (sl.IsRunning()) { ++runningTablets; ++tabletsByNodeByType[sl.NodeId][TTxMonEvent_Landing::GetTabletType(pr.second.Type) + "s"]; @@ -2139,7 +2139,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_REASSIGN_TABLET; } - TInstant GetMaxTimestamp(const TLeaderTabletInfo* tablet) const { + TInstant GetMaxTimestamp(const TLeaderTabletInfo* tablet) const { TInstant max; for (const auto& channel : tablet->TabletStorageInfo->Channels) { if (TabletChannels.empty() @@ -2161,9 +2161,9 @@ public: Error = "forcedGroup size should be equal to channel size"; return true; } - TVector<TLeaderTabletInfo*> tablets; + TVector<TLeaderTabletInfo*> tablets; if (TabletId != 0) { - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { tablets.push_back(tablet); } @@ -2180,7 +2180,7 @@ public: } } if (TabletPercent != 100) { - std::sort(tablets.begin(), tablets.end(), [this](TLeaderTabletInfo* a, TLeaderTabletInfo* b) -> bool { + std::sort(tablets.begin(), tablets.end(), [this](TLeaderTabletInfo* a, TLeaderTabletInfo* b) -> bool { return GetMaxTimestamp(a) < GetMaxTimestamp(b); }); tablets.resize(tablets.size() * TabletPercent / 100); @@ -2193,7 +2193,7 @@ public: waitActorId = ctx.RegisterWithSameMailbox(waitActor); Self->SubActors.emplace_back(waitActor); } - for (TLeaderTabletInfo* tablet : tablets) { + for (TLeaderTabletInfo* tablet : tablets) { TVector<ui32> channels; TVector<ui32> forcedGroupIds; bool skip = false; @@ -2447,7 +2447,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_STOP_TABLET; } bool Execute(TTransactionContext&, const TActorContext& ctx) override { - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { TActorId waitActorId; TStopTabletWaitActor* waitActor = nullptr; @@ -2526,7 +2526,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_STOP_TABLET; } bool Execute(TTransactionContext&, const TActorContext& ctx) override { - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { TActorId waitActorId; TResumeTabletWaitActor* waitActor = nullptr; @@ -2579,7 +2579,7 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_MON_FIND_TABLET; } - TInstant GetMaxTimestamp(const TLeaderTabletInfo* tablet) const { + TInstant GetMaxTimestamp(const TLeaderTabletInfo* tablet) const { TInstant max; for (const auto& channel : tablet->TabletStorageInfo->Channels) { if (channel.Channel >= ChannelFrom && channel.Channel <= ChannelTo) { @@ -2593,9 +2593,9 @@ public: } bool Execute(TTransactionContext&, const TActorContext&) override { - TDeque<TLeaderTabletInfo*> tablets; + TDeque<TLeaderTabletInfo*> tablets; if (TabletId != 0) { - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { tablets.push_back(tablet); } @@ -2610,11 +2610,11 @@ public: tablets.push_back(&pr.second); } } - Sort(tablets, [this](TLeaderTabletInfo* a, TLeaderTabletInfo* b) -> bool { + Sort(tablets, [this](TLeaderTabletInfo* a, TLeaderTabletInfo* b) -> bool { return GetMaxTimestamp(a) < GetMaxTimestamp(b); }); Result.SetType(NJson::EJsonValueType::JSON_ARRAY); - for (TLeaderTabletInfo* tablet : tablets) { + for (TLeaderTabletInfo* tablet : tablets) { TVector<ui32> channels; for (const auto& channel : tablet->TabletStorageInfo->Channels) { if (channel.Channel < ChannelFrom) { @@ -2799,7 +2799,7 @@ public: static NJson::TJsonValue MakeFrom(const TFollowerGroup& group) { NJson::TJsonValue result; result["Id"] = TStringBuilder() << group.Id; - result["AllowLeaderPromotion"] = group.AllowLeaderPromotion; + result["AllowLeaderPromotion"] = group.AllowLeaderPromotion; result["AllowClientRead"] = group.AllowClientRead; result["RequireAllDataCenters"] = group.RequireAllDataCenters; result["AllowedNodes"] = MakeFrom(group.AllowedNodes); @@ -2917,7 +2917,7 @@ public: bool Execute(TTransactionContext&, const TActorContext& /*ctx*/) override { if (TabletId) { - if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { + if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { Info = tablet->TabletStorageInfo; KnownGeneration = tablet->KnownGeneration; } else { @@ -2993,7 +2993,7 @@ public: return NKikimrServices::TActivity::HIVE_MON_REQUEST; } - TCreateTabletActor(const TActorId& source, ui64 owner, ui64 ownerIdx, TTabletTypes::EType type, ui32 channelsProfile, ui32 followers, THive* hive) + TCreateTabletActor(const TActorId& source, ui64 owner, ui64 ownerIdx, TTabletTypes::EType type, ui32 channelsProfile, ui32 followers, THive* hive) : Source(source) , Event(new TEvHive::TEvCreateTablet()) , Hive(hive) @@ -3002,7 +3002,7 @@ public: Event->Record.SetOwnerIdx(ownerIdx); Event->Record.SetTabletType(type); Event->Record.SetChannelsProfile(channelsProfile); - Event->Record.SetFollowerCount(followers); + Event->Record.SetFollowerCount(followers); } void HandleTimeout(const TActorContext& ctx) { @@ -3166,9 +3166,9 @@ public: TString unitSize; TTabletInfo* tablet = Self->FindTablet(id); if (tablet) { - TLeaderTabletInfo& leader = tablet->GetLeader(); - if (channel < leader.GetChannelCount()) { - unitSize = leader.BoundChannels[channel].ShortDebugString(); + TLeaderTabletInfo& leader = tablet->GetLeader(); + if (channel < leader.GetChannelCount()) { + unitSize = leader.BoundChannels[channel].ShortDebugString(); } } out << "<td>" << unitSize << "</td>"; @@ -3392,8 +3392,8 @@ void THive::CreateEvMonitoring(NMon::TEvRemoteHttpInfo::TPtr& ev, const TActorCo ui64 ownerIdx = FromStringWithDefault<ui64>(cgi.Get("owner_idx"), 0); TTabletTypes::EType type = (TTabletTypes::EType)FromStringWithDefault<ui32>(cgi.Get("type"), 0); ui32 channelsProfile = FromStringWithDefault<ui32>(cgi.Get("profile"), 0); - ui32 followers = FromStringWithDefault<ui32>(cgi.Get("followers"), 0); - ctx.RegisterWithSameMailbox(new TCreateTabletActor(ev->Sender, owner, ownerIdx, type, channelsProfile, followers, this)); + ui32 followers = FromStringWithDefault<ui32>(cgi.Get("followers"), 0); + ctx.RegisterWithSameMailbox(new TCreateTabletActor(ev->Sender, owner, ownerIdx, type, channelsProfile, followers, this)); return; } if (page == "DeleteTablet") { diff --git a/ydb/core/mind/hive/node_info.cpp b/ydb/core/mind/hive/node_info.cpp index f5d3f6bd496..8b6913c9819 100644 --- a/ydb/core/mind/hive/node_info.cpp +++ b/ydb/core/mind/hive/node_info.cpp @@ -113,7 +113,7 @@ bool TNodeInfo::IsAllowedToRunTablet(const TTabletInfo& tablet, TTabletDebugStat return false; } - const TVector<TSubDomainKey>& allowedDomains = tablet.GetLeader().EffectiveAllowedDomains; + const TVector<TSubDomainKey>& allowedDomains = tablet.GetLeader().EffectiveAllowedDomains; bool result = false; for (const auto& candidate : allowedDomains) { @@ -143,17 +143,17 @@ bool TNodeInfo::IsAllowedToRunTablet(const TTabletInfo& tablet, TTabletDebugStat return false; } - if (tablet.IsFollower() && tablet.AsFollower().FollowerGroup.LocalNodeOnly) { - const TLeaderTabletInfo& leader = tablet.GetLeader(); - if (!leader.IsRunning()) { + if (tablet.IsFollower() && tablet.AsFollower().FollowerGroup.LocalNodeOnly) { + const TLeaderTabletInfo& leader = tablet.GetLeader(); + if (!leader.IsRunning()) { if (debugState) { - debugState->LeaderNotRunning = true; + debugState->LeaderNotRunning = true; } return false; } - if (leader.NodeId != Id) { + if (leader.NodeId != Id) { if (debugState) { - debugState->NodesWithLeaderNotLocal++; + debugState->NodesWithLeaderNotLocal++; } return false; } @@ -179,40 +179,40 @@ bool TNodeInfo::IsAbleToRunTablet(const TTabletInfo& tablet, TTabletDebugState* if (tablet.IsAliveOnLocal(Local)) { return !IsOverloaded(); } - if (tablet.IsLeader()) { - const TLeaderTabletInfo& leader = tablet.AsLeader(); - if (leader.IsFollowerPromotableOnNode(Id)) { + if (tablet.IsLeader()) { + const TLeaderTabletInfo& leader = tablet.AsLeader(); + if (leader.IsFollowerPromotableOnNode(Id)) { return true; } } -// const TLeaderTabletInfo& leader = tablet.GetLeader(); -// if (!leader.Followers.empty()) { -// if (leader.IsSomeoneAliveOnNode(Id)) { +// const TLeaderTabletInfo& leader = tablet.GetLeader(); +// if (!leader.Followers.empty()) { +// if (leader.IsSomeoneAliveOnNode(Id)) { // return false; // } // } - if (tablet.IsFollower()) { - const TFollowerTabletInfo& follower = tablet.AsFollower(); - const TFollowerGroup& followerGroup = follower.FollowerGroup; - const TLeaderTabletInfo& leader = follower.LeaderTablet; - if (followerGroup.RequireAllDataCenters) { + if (tablet.IsFollower()) { + const TFollowerTabletInfo& follower = tablet.AsFollower(); + const TFollowerGroup& followerGroup = follower.FollowerGroup; + const TLeaderTabletInfo& leader = follower.LeaderTablet; + if (followerGroup.RequireAllDataCenters) { auto dataCenters = Hive.GetRegisteredDataCenters(); ui32 maxFollowersPerDataCenter = (followerGroup.GetComputedFollowerCount(Hive.GetDataCenters()) + dataCenters - 1) / dataCenters; // ceil - ui32 existingFollowers; + ui32 existingFollowers; if (tablet.IsAlive()) { existingFollowers = leader.GetFollowersAliveOnDataCenterExcludingFollower(Location.GetDataCenterId(), tablet); } else { existingFollowers = leader.GetFollowersAliveOnDataCenter(Location.GetDataCenterId()); } - if (maxFollowersPerDataCenter <= existingFollowers) { + if (maxFollowersPerDataCenter <= existingFollowers) { if (debugState) { - debugState->NodesFilledWithDatacenterFollowers++; + debugState->NodesFilledWithDatacenterFollowers++; } return false; } } - if (followerGroup.RequireDifferentNodes) { - if (leader.IsSomeoneAliveOnNode(Id)) { + if (followerGroup.RequireDifferentNodes) { + if (leader.IsSomeoneAliveOnNode(Id)) { if (debugState) { debugState->NodesWithSomeoneFromOurFamily++; } diff --git a/ydb/core/mind/hive/node_info.h b/ydb/core/mind/hive/node_info.h index 90a68a4c633..fa7400fd25b 100644 --- a/ydb/core/mind/hive/node_info.h +++ b/ydb/core/mind/hive/node_info.h @@ -56,7 +56,7 @@ public: TVector<TSubDomainKey> ServicedDomains; TVector<TSubDomainKey> LastSeenServicedDomains; TVector<TActorId> PipeServers; - THashSet<TLeaderTabletInfo*> LockedTablets; + THashSet<TLeaderTabletInfo*> LockedTablets; mutable TInstant LastResourceChangeReaction; NKikimrHive::TNodeStatistics Statistics; diff --git a/ydb/core/mind/hive/storage_group_info.cpp b/ydb/core/mind/hive/storage_group_info.cpp index 8abb37ae5ce..fbcb7fc7ba4 100644 --- a/ydb/core/mind/hive/storage_group_info.cpp +++ b/ydb/core/mind/hive/storage_group_info.cpp @@ -9,7 +9,7 @@ TStorageGroupInfo::TStorageGroupInfo(const TStoragePoolInfo& storagePool, TStora , Id(id) {} -bool TStorageGroupInfo::AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel) { +bool TStorageGroupInfo::AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel) { Y_VERIFY(tablet->BoundChannels.size() > channel); bool acquired = Units.insert({tablet, channel}).second; if (acquired) { @@ -20,7 +20,7 @@ bool TStorageGroupInfo::AcquireAllocationUnit(const TLeaderTabletInfo* tablet, u return acquired; } -bool TStorageGroupInfo::ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel) { +bool TStorageGroupInfo::ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel) { Y_VERIFY(tablet->BoundChannels.size() > channel); bool released = Units.erase({tablet, channel}) != 0; if (released) { diff --git a/ydb/core/mind/hive/storage_group_info.h b/ydb/core/mind/hive/storage_group_info.h index 2495e37ede4..cbd7d976e2f 100644 --- a/ydb/core/mind/hive/storage_group_info.h +++ b/ydb/core/mind/hive/storage_group_info.h @@ -1,7 +1,7 @@ #pragma once #include "hive.h" -#include "leader_tablet_info.h" +#include "leader_tablet_info.h" namespace NKikimr { namespace NHive { @@ -13,7 +13,7 @@ struct TStoragePoolInfo; struct TStorageGroupInfo { const TStoragePoolInfo& StoragePool; TStorageGroupId Id; - std::unordered_set<std::pair<const TLeaderTabletInfo*, ui32>> Units; // Tablet + Channel + std::unordered_set<std::pair<const TLeaderTabletInfo*, ui32>> Units; // Tablet + Channel double AcquiredIOPS = 0; ui64 AcquiredThroughput = 0; ui64 AcquiredSize = 0; @@ -27,8 +27,8 @@ struct TStorageGroupInfo { TStorageGroupInfo(TStorageGroupInfo&&) = delete; TStorageGroupInfo& operator =(const TStorageGroupInfo&) = delete; TStorageGroupInfo& operator =(TStorageGroupInfo&&) = delete; - bool AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel); - bool ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel); + bool AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel); + bool ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel); void UpdateStorageGroup(const TEvControllerSelectGroupsResult::TGroupParameters& groupParameters); bool IsMatchesParameters(const TEvControllerSelectGroups::TGroupParameters& groupParameters) const; double GetUsage() const; diff --git a/ydb/core/mind/hive/storage_pool_info.cpp b/ydb/core/mind/hive/storage_pool_info.cpp index e9c6cfa762e..fafd6644dee 100644 --- a/ydb/core/mind/hive/storage_pool_info.cpp +++ b/ydb/core/mind/hive/storage_pool_info.cpp @@ -20,11 +20,11 @@ TStorageGroupInfo& TStoragePoolInfo::GetStorageGroup(TStorageGroupId groupId) { return it->second; } -bool TStoragePoolInfo::AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId) { +bool TStoragePoolInfo::AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId) { return GetStorageGroup(groupId).AcquireAllocationUnit(tablet, channel); } -bool TStoragePoolInfo::ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId) { +bool TStoragePoolInfo::ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId) { return GetStorageGroup(groupId).ReleaseAllocationUnit(tablet, channel); } diff --git a/ydb/core/mind/hive/storage_pool_info.h b/ydb/core/mind/hive/storage_pool_info.h index 638bdf4a626..b606fc40b7e 100644 --- a/ydb/core/mind/hive/storage_pool_info.h +++ b/ydb/core/mind/hive/storage_pool_info.h @@ -54,8 +54,8 @@ struct TStoragePoolInfo { TStoragePoolInfo(TStoragePoolInfo&&) = delete; TStoragePoolInfo& operator =(const TStoragePoolInfo&) = delete; TStoragePoolInfo& operator =(TStoragePoolInfo&&) = delete; - bool AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId); - bool ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId); + bool AcquireAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId); + bool ReleaseAllocationUnit(const TLeaderTabletInfo* tablet, ui32 channel, TStorageGroupId groupId); TStorageGroupInfo& GetStorageGroup(TStorageGroupId groupId); void UpdateStorageGroup(TStorageGroupId groupId, const TEvControllerSelectGroupsResult::TGroupParameters& groupParameters); void DeleteStorageGroup(TStorageGroupId groupId); diff --git a/ydb/core/mind/hive/tablet_info.cpp b/ydb/core/mind/hive/tablet_info.cpp index a0917b5d149..9fddd10801e 100644 --- a/ydb/core/mind/hive/tablet_info.cpp +++ b/ydb/core/mind/hive/tablet_info.cpp @@ -2,8 +2,8 @@ #include "hive_log.h" #include "tablet_info.h" #include "node_info.h" -#include "leader_tablet_info.h" -#include "follower_tablet_info.h" +#include "leader_tablet_info.h" +#include "follower_tablet_info.h" namespace NKikimr { namespace NHive { @@ -23,67 +23,67 @@ TTabletInfo::TTabletInfo(ETabletRole role, THive& hive) , Weight(0) {} -const TLeaderTabletInfo& TTabletInfo::GetLeader() const { - if (IsLeader()) { - return AsLeader(); +const TLeaderTabletInfo& TTabletInfo::GetLeader() const { + if (IsLeader()) { + return AsLeader(); } else { - return AsFollower().LeaderTablet; + return AsFollower().LeaderTablet; } } -TLeaderTabletInfo& TTabletInfo::GetLeader() { - if (IsLeader()) { - return AsLeader(); +TLeaderTabletInfo& TTabletInfo::GetLeader() { + if (IsLeader()) { + return AsLeader(); } else { - return AsFollower().LeaderTablet; + return AsFollower().LeaderTablet; } } -TLeaderTabletInfo& TTabletInfo::AsLeader() { - Y_VERIFY(TabletRole == ETabletRole::Leader); - return static_cast<TLeaderTabletInfo&>(*this); +TLeaderTabletInfo& TTabletInfo::AsLeader() { + Y_VERIFY(TabletRole == ETabletRole::Leader); + return static_cast<TLeaderTabletInfo&>(*this); } -const TLeaderTabletInfo& TTabletInfo::AsLeader() const { - Y_VERIFY(TabletRole == ETabletRole::Leader); - return static_cast<const TLeaderTabletInfo&>(*this); +const TLeaderTabletInfo& TTabletInfo::AsLeader() const { + Y_VERIFY(TabletRole == ETabletRole::Leader); + return static_cast<const TLeaderTabletInfo&>(*this); } -TFollowerTabletInfo& TTabletInfo::AsFollower() { - Y_VERIFY(TabletRole == ETabletRole::Follower); - return static_cast<TFollowerTabletInfo&>(*this); +TFollowerTabletInfo& TTabletInfo::AsFollower() { + Y_VERIFY(TabletRole == ETabletRole::Follower); + return static_cast<TFollowerTabletInfo&>(*this); } -const TFollowerTabletInfo& TTabletInfo::AsFollower() const { - Y_VERIFY(TabletRole == ETabletRole::Follower); - return static_cast<const TFollowerTabletInfo&>(*this); +const TFollowerTabletInfo& TTabletInfo::AsFollower() const { + Y_VERIFY(TabletRole == ETabletRole::Follower); + return static_cast<const TFollowerTabletInfo&>(*this); } -std::pair<TTabletId, TFollowerId> TTabletInfo::GetFullTabletId() const { - if (IsLeader()) { - return { GetLeader().Id, 0 }; +std::pair<TTabletId, TFollowerId> TTabletInfo::GetFullTabletId() const { + if (IsLeader()) { + return { GetLeader().Id, 0 }; } else { - return { GetLeader().Id, AsFollower().Id }; + return { GetLeader().Id, AsFollower().Id }; } } TObjectId TTabletInfo::GetObjectId() const { - return GetLeader().ObjectId; + return GetLeader().ObjectId; } TTabletTypes::EType TTabletInfo::GetTabletType() const { - return GetLeader().Type; + return GetLeader().Type; } TString TTabletInfo::ToString() const { - const TLeaderTabletInfo& leader = GetLeader(); + const TLeaderTabletInfo& leader = GetLeader(); TStringBuilder str; - str << TTabletTypes::TypeToStr(leader.Type) << '.' << leader.Id << '.' << ETabletRoleName(TabletRole); - if (IsFollower()) { - const TFollowerTabletInfo& follower(AsFollower()); - str << '.' << follower.Id; + str << TTabletTypes::TypeToStr(leader.Type) << '.' << leader.Id << '.' << ETabletRoleName(TabletRole); + if (IsFollower()) { + const TFollowerTabletInfo& follower(AsFollower()); + str << '.' << follower.Id; } else { - str << '.' << leader.KnownGeneration; + str << '.' << leader.KnownGeneration; } return str; } @@ -99,11 +99,11 @@ TString TTabletInfo::StateString() const { TString TTabletInfo::FamilyString() const { TStringBuilder family; - const TLeaderTabletInfo& leader = GetLeader(); + const TLeaderTabletInfo& leader = GetLeader(); family << '{'; - family << leader.ToString() << ' ' << leader.StateString(); - for (const TFollowerTabletInfo& follower : leader.Followers) { - family << ", " << follower.ToString() << ' ' << follower.StateString(); + family << leader.ToString() << ' ' << leader.StateString(); + for (const TFollowerTabletInfo& follower : leader.Followers) { + family << ", " << follower.ToString() << ' ' << follower.StateString(); } family << '}'; return family; @@ -131,8 +131,8 @@ void TTabletInfo::ChangeVolatileState(EVolatileState state) { } bool TTabletInfo::IsReadyToStart(TInstant now) const { - if (IsFollower()) { - if (!GetLeader().IsRunning()) { + if (IsFollower()) { + if (!GetLeader().IsRunning()) { return false; } } @@ -212,10 +212,10 @@ bool TTabletInfo::InitiateStop() { SendStopTablet(local, GetFullTabletId()); LastNodeId = 0; } - if (IsLeader()) { - for (TFollowerTabletInfo& follower : AsLeader().Followers) { - if (follower.FollowerGroup.LocalNodeOnly) { - follower.InitiateStop(); + if (IsLeader()) { + for (TFollowerTabletInfo& follower : AsLeader().Followers) { + if (follower.FollowerGroup.LocalNodeOnly) { + follower.InitiateStop(); } } } @@ -307,7 +307,7 @@ void TTabletInfo::Kill() { } const TVector<i64>& TTabletInfo::GetTabletAllowedMetricIds() const { - return Hive.GetTabletTypeAllowedMetricIds(GetLeader().Type); + return Hive.GetTabletTypeAllowedMetricIds(GetLeader().Type); } void TTabletInfo::UpdateResourceUsage(const NKikimrTabletBase::TMetrics& metrics) { @@ -433,18 +433,18 @@ void TTabletInfo::FilterRawValues(TResourceNormalizedValues& values) const { } const TVector<TNodeId>& TTabletInfo::GetAllowedNodes() const { - if (IsLeader()) { - return AsLeader().AllowedNodes; + if (IsLeader()) { + return AsLeader().AllowedNodes; } else { - return AsFollower().FollowerGroup.AllowedNodes; + return AsFollower().FollowerGroup.AllowedNodes; } } const TVector<TDataCenterId>& TTabletInfo::GetAllowedDataCenters() const { - if (IsLeader()) { - return AsLeader().AllowedDataCenters; + if (IsLeader()) { + return AsLeader().AllowedDataCenters; } else { - return AsFollower().FollowerGroup.AllowedDataCenters; + return AsFollower().FollowerGroup.AllowedDataCenters; } } diff --git a/ydb/core/mind/hive/tablet_info.h b/ydb/core/mind/hive/tablet_info.h index 6b9c3138f6f..dc360a30e48 100644 --- a/ydb/core/mind/hive/tablet_info.h +++ b/ydb/core/mind/hive/tablet_info.h @@ -7,8 +7,8 @@ namespace NKikimr { namespace NHive { struct TNodeInfo; -struct TLeaderTabletInfo; -struct TFollowerTabletInfo; +struct TLeaderTabletInfo; +struct TFollowerTabletInfo; struct TCounters { TVector<ui64> Simple; @@ -82,10 +82,10 @@ struct TTabletDebugState { ui32 NodesDown = 0; ui32 NodesNotAllowed = 0; ui32 NodesInDatacentersNotAllowed = 0; - bool LeaderNotRunning = false; - ui32 NodesWithLeaderNotLocal = 0; + bool LeaderNotRunning = false; + ui32 NodesWithLeaderNotLocal = 0; ui32 NodesWithoutDomain = 0; - ui32 NodesFilledWithDatacenterFollowers = 0; + ui32 NodesFilledWithDatacenterFollowers = 0; ui32 NodesWithoutResources = 0; ui32 NodesWithSomeoneFromOurFamily = 0; ui32 NodesWithoutLocation = 0; @@ -97,8 +97,8 @@ public: using EVolatileState = NKikimrHive::ETabletVolatileState; enum class ETabletRole { - Leader, - Follower + Leader, + Follower }; protected: @@ -122,8 +122,8 @@ public: static TString ETabletRoleName(ETabletRole value) { switch(value) { - case ETabletRole::Leader: return "Leader"; - case ETabletRole::Follower: return "Follower"; + case ETabletRole::Leader: return "Leader"; + case ETabletRole::Follower: return "Follower"; default: return Sprintf("%d", static_cast<int>(value)); } } @@ -173,21 +173,21 @@ public: return VolatileState; } - bool IsLeader() const { - return TabletRole == ETabletRole::Leader; + bool IsLeader() const { + return TabletRole == ETabletRole::Leader; } - bool IsFollower() const { - return TabletRole == ETabletRole::Follower; + bool IsFollower() const { + return TabletRole == ETabletRole::Follower; } - const TLeaderTabletInfo& GetLeader() const; - TLeaderTabletInfo& GetLeader(); - TLeaderTabletInfo& AsLeader(); - const TLeaderTabletInfo& AsLeader() const; - TFollowerTabletInfo& AsFollower(); - const TFollowerTabletInfo& AsFollower() const; - std::pair<TTabletId, TFollowerId> GetFullTabletId() const; + const TLeaderTabletInfo& GetLeader() const; + TLeaderTabletInfo& GetLeader(); + TLeaderTabletInfo& AsLeader(); + const TLeaderTabletInfo& AsLeader() const; + TFollowerTabletInfo& AsFollower(); + const TFollowerTabletInfo& AsFollower() const; + std::pair<TTabletId, TFollowerId> GetFullTabletId() const; TObjectId GetObjectId() const; TTabletTypes::EType GetTabletType() const; TString ToString() const; diff --git a/ydb/core/mind/hive/tx__adopt_tablet.cpp b/ydb/core/mind/hive/tx__adopt_tablet.cpp index 3fafc1c9e17..45203af0d1f 100644 --- a/ydb/core/mind/hive/tx__adopt_tablet.cpp +++ b/ydb/core/mind/hive/tx__adopt_tablet.cpp @@ -54,7 +54,7 @@ public: return true; } - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr && tablet->Type != TabletType) { Explain = "there is the tablet with different type assotiated with the (owner; ownerIdx)"; Status = NKikimrProto::EReplyStatus::RACE; @@ -83,7 +83,7 @@ public: return true; } - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr && tablet->Type != TabletType) { // tablet is the same Explain = "there is the tablet with different type assotiated with the (preOwner; prevOwnerIdx)"; Status = NKikimrProto::EReplyStatus::ERROR; diff --git a/ydb/core/mind/hive/tx__block_storage_result.cpp b/ydb/core/mind/hive/tx__block_storage_result.cpp index e9cd7eecaed..28315ec93bd 100644 --- a/ydb/core/mind/hive/tx__block_storage_result.cpp +++ b/ydb/core/mind/hive/tx__block_storage_result.cpp @@ -19,15 +19,15 @@ public: bool Execute(TTransactionContext& txc, const TActorContext&) override { TEvTabletBase::TEvBlockBlobStorageResult* msg = Result->Get(); BLOG_D("THive::TTxBlockStorageResult::Execute(" << TabletId << " " << NKikimrProto::EReplyStatus_Name(msg->Status) << ")"); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); if (tablet != nullptr) { NIceDb::TNiceDb db(txc.DB); if (msg->Status == NKikimrProto::OK) { if (tablet->State == ETabletState::BlockStorage) { db.Table<Schema::Tablet>().Key(tablet->Id).Update(NIceDb::TUpdate<Schema::Tablet::State>(ETabletState::ReadyToWork)); } else if (tablet->State == ETabletState::Deleting) { - for (TFollowerTabletInfo& follower : tablet->Followers) { - follower.InitiateStop(); + for (TFollowerTabletInfo& follower : tablet->Followers) { + follower.InitiateStop(); } } } @@ -38,7 +38,7 @@ public: void Complete(const TActorContext& ctx) override { TEvTabletBase::TEvBlockBlobStorageResult* msg = Result->Get(); BLOG_D("THive::TTxBlockStorageResult::Complete(" << TabletId << " " << NKikimrProto::EReplyStatus_Name(msg->Status) << ")"); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); if (tablet != nullptr) { if (msg->Status == NKikimrProto::OK || msg->Status == NKikimrProto::RACE diff --git a/ydb/core/mind/hive/tx__create_tablet.cpp b/ydb/core/mind/hive/tx__create_tablet.cpp index ef66629d2dd..f3b27bfd9ac 100644 --- a/ydb/core/mind/hive/tx__create_tablet.cpp +++ b/ydb/core/mind/hive/tx__create_tablet.cpp @@ -27,7 +27,7 @@ class TTxCreateTablet : public TTransactionBase<THive> { TVector<TSubDomainKey> AllowedDomains; ETabletState State; NKikimrHive::TTabletCategory TabletCategory; - TVector<NKikimrHive::TFollowerGroup> FollowerGroups; + TVector<NKikimrHive::TFollowerGroup> FollowerGroups; NKikimrHive::ETabletBootMode BootMode; NKikimrHive::TForwardRequest ForwardRequest; @@ -71,35 +71,35 @@ public: if (RequestData.HasTabletCategory()) { TabletCategory.CopyFrom(RequestData.GetTabletCategory()); } - auto& followerGroups = RequestData.GetFollowerGroups(); - std::copy(followerGroups.begin(), followerGroups.end(), std::back_inserter(FollowerGroups)); - if (FollowerGroups.empty() && - (RequestData.HasFollowerCount() - || RequestData.HasAllowFollowerPromotion() - || RequestData.HasCrossDataCenterFollowers() - || RequestData.HasCrossDataCenterFollowerCount())) { - FollowerGroups.emplace_back(); - NKikimrHive::TFollowerGroup& compatibilityGroup(FollowerGroups.back()); - if (RequestData.HasAllowFollowerPromotion()) { - compatibilityGroup.SetAllowLeaderPromotion(RequestData.GetAllowFollowerPromotion()); + auto& followerGroups = RequestData.GetFollowerGroups(); + std::copy(followerGroups.begin(), followerGroups.end(), std::back_inserter(FollowerGroups)); + if (FollowerGroups.empty() && + (RequestData.HasFollowerCount() + || RequestData.HasAllowFollowerPromotion() + || RequestData.HasCrossDataCenterFollowers() + || RequestData.HasCrossDataCenterFollowerCount())) { + FollowerGroups.emplace_back(); + NKikimrHive::TFollowerGroup& compatibilityGroup(FollowerGroups.back()); + if (RequestData.HasAllowFollowerPromotion()) { + compatibilityGroup.SetAllowLeaderPromotion(RequestData.GetAllowFollowerPromotion()); } - if (RequestData.HasCrossDataCenterFollowers()) { + if (RequestData.HasCrossDataCenterFollowers()) { compatibilityGroup.SetFollowerCount(Self->GetDataCenters()); compatibilityGroup.SetRequireAllDataCenters(true); } - if (RequestData.HasCrossDataCenterFollowerCount()) { + if (RequestData.HasCrossDataCenterFollowerCount()) { compatibilityGroup.SetFollowerCount(RequestData.GetCrossDataCenterFollowerCount() * Self->GetDataCenters()); compatibilityGroup.SetRequireAllDataCenters(true); } - if (RequestData.HasFollowerCount()) { - compatibilityGroup.SetFollowerCount(RequestData.GetFollowerCount()); + if (RequestData.HasFollowerCount()) { + compatibilityGroup.SetFollowerCount(RequestData.GetFollowerCount()); } compatibilityGroup.SetAllowClientRead(true); } ObjectId = RequestData.GetObjectId(); } - void UpdateChannelsBinding(TLeaderTabletInfo& tablet, NIceDb::TNiceDb& db) { + void UpdateChannelsBinding(TLeaderTabletInfo& tablet, NIceDb::TNiceDb& db) { Y_VERIFY(tablet.BoundChannels.size() <= BoundChannels.size(), "only expansion channels number is allowed in Binded Channels"); std::bitset<MAX_TABLET_CHANNELS> newChannels; @@ -143,7 +143,7 @@ public: } } - bool ValidateChannelsBinding(TLeaderTabletInfo& tablet) { + bool ValidateChannelsBinding(TLeaderTabletInfo& tablet) { if (BoundChannels.size() < tablet.BoundChannels.size()) { ErrorReason = NKikimrHive::ERROR_REASON_CHANNELS_CANNOT_SHRINK; return false; @@ -179,7 +179,7 @@ public: auto itOwner = Self->OwnerToTablet.find(ownerIdx); if (itOwner != Self->OwnerToTablet.end()) { // tablet is already created const ui64 tabletId = itOwner->second; - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr) { // make sure tablet type matches the requested one TTabletTypes::EType existingTabletType = tablet->Type; @@ -197,8 +197,8 @@ public: if (Status == NKikimrProto::ALREADY) { if (BootMode == NKikimrHive::TABLET_BOOT_MODE_EXTERNAL) { // Make sure any running tablets are stopped - for (TFollowerTabletInfo& follower : tablet->Followers) { - follower.InitiateStop(); + for (TFollowerTabletInfo& follower : tablet->Followers) { + follower.InitiateStop(); } tablet->InitiateStop(); } @@ -254,43 +254,43 @@ public: UpdateChannelsBinding(*tablet, db); - auto itFollowerGroup = tablet->FollowerGroups.begin(); - for (const auto& srcFollowerGroup : FollowerGroups) { - TFollowerGroup& followerGroup = itFollowerGroup != tablet->FollowerGroups.end() ? *itFollowerGroup : tablet->AddFollowerGroup(); + auto itFollowerGroup = tablet->FollowerGroups.begin(); + for (const auto& srcFollowerGroup : FollowerGroups) { + TFollowerGroup& followerGroup = itFollowerGroup != tablet->FollowerGroups.end() ? *itFollowerGroup : tablet->AddFollowerGroup(); ui32 oldFollowerCount = followerGroup.GetComputedFollowerCount(Self->GetDataCenters()); - followerGroup = srcFollowerGroup; + followerGroup = srcFollowerGroup; TVector<ui32> allowedDataCenters; for (const TDataCenterId& dc : followerGroup.AllowedDataCenters) { allowedDataCenters.push_back(DataCenterFromString(dc)); } - db.Table<Schema::TabletFollowerGroup>().Key(TabletId, followerGroup.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), + db.Table<Schema::TabletFollowerGroup>().Key(TabletId, followerGroup.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenters>(allowedDataCenters), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenterIds>(followerGroup.AllowedDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter), - NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireDifferentNodes>(followerGroup.RequireDifferentNodes)); + NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter), + NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireDifferentNodes>(followerGroup.RequireDifferentNodes)); for (ui32 i = oldFollowerCount; i < followerGroup.GetComputedFollowerCount(Self->GetDataCenters()); ++i) { - TFollowerTabletInfo& follower = tablet->AddFollower(followerGroup); - db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), - NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0)); - follower.InitTabletMetrics(); - follower.BecomeStopped(); + TFollowerTabletInfo& follower = tablet->AddFollower(followerGroup); + db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), + NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0)); + follower.InitTabletMetrics(); + follower.BecomeStopped(); } for (ui32 i = followerGroup.GetComputedFollowerCount(Self->GetDataCenters()); i < oldFollowerCount; ++i) { - TFollowerTabletInfo& follower = tablet->Followers.back(); - db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Delete(); - follower.InitiateStop(); - tablet->Followers.pop_back(); + TFollowerTabletInfo& follower = tablet->Followers.back(); + db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Delete(); + follower.InitiateStop(); + tablet->Followers.pop_back(); } - ++itFollowerGroup; + ++itFollowerGroup; } return true; @@ -340,7 +340,7 @@ public: // insert entry for new tablet State = ETabletState::GroupAssignment; - TLeaderTabletInfo& tablet = Self->GetTablet(TabletId); + TLeaderTabletInfo& tablet = Self->GetTablet(TabletId); tablet.NodeId = 0; tablet.Type = (TTabletTypes::EType)TabletType; tablet.KnownGeneration = 0; // because we will increase it on start @@ -360,7 +360,7 @@ public: allowedDataCenters.push_back(DataCenterFromString(dc)); } db.Table<Schema::Tablet>().Key(TabletId).Update(NIceDb::TUpdate<Schema::Tablet::Owner>(tablet.Owner), - NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet.NodeId), + NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet.NodeId), NIceDb::TUpdate<Schema::Tablet::TabletType>(tablet.Type), NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(tablet.KnownGeneration), NIceDb::TUpdate<Schema::Tablet::State>(tablet.State), @@ -423,33 +423,33 @@ public: UpdateChannelsBinding(tablet, db); - for (const auto& srcFollowerGroup : FollowerGroups) { - TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); - followerGroup = srcFollowerGroup; + for (const auto& srcFollowerGroup : FollowerGroups) { + TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); + followerGroup = srcFollowerGroup; TVector<ui32> allowedDataCenters; for (const TDataCenterId& dc : followerGroup.AllowedDataCenters) { allowedDataCenters.push_back(DataCenterFromString(dc)); } - db.Table<Schema::TabletFollowerGroup>().Key(TabletId, followerGroup.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), + db.Table<Schema::TabletFollowerGroup>().Key(TabletId, followerGroup.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenters>(allowedDataCenters), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenterIds>(followerGroup.AllowedDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter)); + NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter)); for (ui32 i = 0; i < followerGroup.GetComputedFollowerCount(Self->GetDataCenters()); ++i) { - TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); + TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); follower.Statistics.SetLastAliveTimestamp(now.MilliSeconds()); - db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), + db.Table<Schema::TabletFollowerTablet>().Key(TabletId, follower.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0), NIceDb::TUpdate<Schema::TabletFollowerTablet::Statistics>(follower.Statistics)); - follower.InitTabletMetrics(); - follower.BecomeStopped(); + follower.InitTabletMetrics(); + follower.BecomeStopped(); } } @@ -470,7 +470,7 @@ public: reply->Record.MutableForwardRequest()->CopyFrom(ForwardRequest); } ctx.Send(Sender, reply.Release(), 0, Cookie); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { if (Status == NKikimrProto::OK && tablet->Type == TTabletTypes::Hive) { auto itSubDomain = Self->Domains.find(tablet->ObjectDomain); diff --git a/ydb/core/mind/hive/tx__cut_tablet_history.cpp b/ydb/core/mind/hive/tx__cut_tablet_history.cpp index b511b9b405f..9bf4c94b98c 100644 --- a/ydb/core/mind/hive/tx__cut_tablet_history.cpp +++ b/ydb/core/mind/hive/tx__cut_tablet_history.cpp @@ -18,7 +18,7 @@ public: TEvHive::TEvCutTabletHistory* msg = Event->Get(); auto tabletId = msg->Record.GetTabletID(); BLOG_D("THive::TTxCutTabletHistory::Execute(" << tabletId << ")"); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(tabletId); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(tabletId); if (tablet != nullptr && tablet->IsReadyToReassignTablet()) { auto channel = msg->Record.GetChannel(); Y_VERIFY(channel < tablet->TabletStorageInfo->Channels.size()); diff --git a/ydb/core/mind/hive/tx__delete_tablet.cpp b/ydb/core/mind/hive/tx__delete_tablet.cpp index e02f50cc089..6d481e695fd 100644 --- a/ydb/core/mind/hive/tx__delete_tablet.cpp +++ b/ydb/core/mind/hive/tx__delete_tablet.cpp @@ -29,7 +29,7 @@ public: if (it != Self->OwnerToTablet.end()) { deletedTablet = it->second; BLOG_D("THive::TTxDeleteTablet::Execute Tablet " << it->second); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(it->second); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(it->second); Y_VERIFY(tablet != nullptr, "%s", (TStringBuilder() << "Tablet " << it->second << " OwnerIdx " << ownerIdx).data()); if (tablet->SeizedByChild) { BLOG_W("THive::TTxDeleteTablet tablet " << it->second << " seized by child"); @@ -38,10 +38,10 @@ public: if (tablet->State != ETabletState::Deleting) { tablet->State = ETabletState::Deleting; tablet->InitiateStop(); - db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::State, Schema::Tablet::LeaderNode>(ETabletState::Deleting, 0); - for (TTabletInfo& follower : tablet->Followers) { - follower.InitiateStop(); - db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::State, Schema::Tablet::LeaderNode>(ETabletState::Deleting, 0); + for (TTabletInfo& follower : tablet->Followers) { + follower.InitiateStop(); + db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } if (!tablet->InitiateBlockStorage(std::numeric_limits<ui32>::max())) { Self->DeleteTabletWithoutStorage(tablet); @@ -85,13 +85,13 @@ public: } } for (ui64 tabletId : TabletIds) { - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr) { for (const TActorId& actor : tablet->ActorsToNotifyOnRestart) { Notifications.Send(actor, new TEvPrivate::TEvRestartComplete(tablet->GetFullTabletId(), "delete")); } tablet->ActorsToNotifyOnRestart.clear(); - for (TTabletInfo& follower : tablet->Followers) { + for (TTabletInfo& follower : tablet->Followers) { for (const TActorId& actor : follower.ActorsToNotifyOnRestart) { Notifications.Send(actor, new TEvPrivate::TEvRestartComplete(follower.GetFullTabletId(), "delete")); } @@ -137,7 +137,7 @@ public: if (it != Self->OwnerToTablet.end()) { deletedTablet = it->second; BLOG_D("THive::TTxDeleteTablet::Execute Tablet " << it->second); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(it->second); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(it->second); Y_VERIFY(tablet != nullptr, "%s", (TStringBuilder() << "Tablet " << it->second << " OwnerIdx " << ownerIdx).data()); if (tablet->SeizedByChild) { BLOG_W("THive::TTxDeleteTablet tablet " << it->second << " seized by child"); @@ -146,10 +146,10 @@ public: if (tablet->State != ETabletState::Deleting) { tablet->State = ETabletState::Deleting; tablet->InitiateStop(); - db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::State, Schema::Tablet::LeaderNode>(ETabletState::Deleting, 0); - for (TTabletInfo& follower : tablet->Followers) { - follower.InitiateStop(); - db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::State, Schema::Tablet::LeaderNode>(ETabletState::Deleting, 0); + for (TTabletInfo& follower : tablet->Followers) { + follower.InitiateStop(); + db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } if (!tablet->InitiateBlockStorage(std::numeric_limits<ui32>::max())) { Self->DeleteTabletWithoutStorage(tablet); @@ -172,7 +172,7 @@ public: if (item.first.first != rec.GetOwner()) { continue; } - const TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(item.second); + const TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(item.second); if (tablet) { if (!tablet->IsDeleting()) { ToDelete.push_back(item.first.second); diff --git a/ydb/core/mind/hive/tx__delete_tablet_result.cpp b/ydb/core/mind/hive/tx__delete_tablet_result.cpp index afcd52c113e..bbe89acae48 100644 --- a/ydb/core/mind/hive/tx__delete_tablet_result.cpp +++ b/ydb/core/mind/hive/tx__delete_tablet_result.cpp @@ -7,7 +7,7 @@ namespace NHive { class TTxDeleteTabletResult : public TTransactionBase<THive> { TEvTabletBase::TEvDeleteTabletResult::TPtr Result; TTabletId TabletId; - TLeaderTabletInfo* Tablet = nullptr; + TLeaderTabletInfo* Tablet = nullptr; TVector<TActorId> StorageInfoSubscribers; TActorId UnlockedFromActor; @@ -34,13 +34,13 @@ public: } db.Table<Schema::TabletChannel>().Key(Tablet->Id, channelInfo.Channel).Delete(); } - for (TFollowerTabletInfo& follower : Tablet->Followers) { - auto fullTabletId = follower.GetFullTabletId(); - db.Table<Schema::TabletFollowerTablet>().Key(fullTabletId).Delete(); + for (TFollowerTabletInfo& follower : Tablet->Followers) { + auto fullTabletId = follower.GetFullTabletId(); + db.Table<Schema::TabletFollowerTablet>().Key(fullTabletId).Delete(); db.Table<Schema::Metrics>().Key(fullTabletId).Delete(); } - for (TFollowerGroup& group : Tablet->FollowerGroups) { - db.Table<Schema::TabletFollowerGroup>().Key(Tablet->Id, group.Id).Delete(); + for (TFollowerGroup& group : Tablet->FollowerGroups) { + db.Table<Schema::TabletFollowerGroup>().Key(Tablet->Id, group.Id).Delete(); } db.Table<Schema::Tablet>().Key(Tablet->Id).Delete(); StorageInfoSubscribers.swap(Tablet->StorageInfoSubscribers); diff --git a/ydb/core/mind/hive/tx__disconnect_node.cpp b/ydb/core/mind/hive/tx__disconnect_node.cpp index a301ce7acc6..0969a6e3b92 100644 --- a/ydb/core/mind/hive/tx__disconnect_node.cpp +++ b/ydb/core/mind/hive/tx__disconnect_node.cpp @@ -28,8 +28,8 @@ public: event->StartTime = TActivationContext::Now(); for (const auto& t : node->Tablets) { for (TTabletInfo* tablet : t.second) { - TLeaderTabletInfo& leader = tablet->GetLeader(); - TTabletCategoryId tabletCategoryId = leader.Category ? leader.Category->Id : 0; + TLeaderTabletInfo& leader = tablet->GetLeader(); + TTabletCategoryId tabletCategoryId = leader.Category ? leader.Category->Id : 0; event->Tablets[tabletCategoryId].emplace_back(tablet->GetFullTabletId()); } } diff --git a/ydb/core/mind/hive/tx__init_scheme.cpp b/ydb/core/mind/hive/tx__init_scheme.cpp index 99b5b7f8f7a..b65451f94a7 100644 --- a/ydb/core/mind/hive/tx__init_scheme.cpp +++ b/ydb/core/mind/hive/tx__init_scheme.cpp @@ -36,24 +36,24 @@ public: NIceDb::TNiceDb db(txc.DB); auto tabletRowset = db.Table<Schema::OldTablet>().Range().Select< Schema::OldTablet::ID, - Schema::OldTablet::CrossDataCenterFollowers, - Schema::OldTablet::FollowerCount, - Schema::OldTablet::AllowFollowerPromotion>(); + Schema::OldTablet::CrossDataCenterFollowers, + Schema::OldTablet::FollowerCount, + Schema::OldTablet::AllowFollowerPromotion>(); if (!tabletRowset.IsReady()) return false; while (!tabletRowset.EndOfSet()) { TTabletId tabletId = tabletRowset.GetValue<Schema::OldTablet::ID>(); - ui32 followerCount = tabletRowset.GetValueOrDefault<Schema::OldTablet::FollowerCount>(0); - bool crossDataCenterFollowers = tabletRowset.GetValueOrDefault<Schema::OldTablet::CrossDataCenterFollowers>(false); - if (followerCount == 0 && crossDataCenterFollowers) { + ui32 followerCount = tabletRowset.GetValueOrDefault<Schema::OldTablet::FollowerCount>(0); + bool crossDataCenterFollowers = tabletRowset.GetValueOrDefault<Schema::OldTablet::CrossDataCenterFollowers>(false); + if (followerCount == 0 && crossDataCenterFollowers) { followerCount = Self->GetDataCenters(); } - bool allowFollowerPromotion = tabletRowset.GetValueOrDefault<Schema::OldTablet::AllowFollowerPromotion>(); - if (followerCount > 0) { - db.Table<Schema::TabletFollowerGroup>().Key(tabletId, 1).Update( - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerCount), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(allowFollowerPromotion), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(true)); + bool allowFollowerPromotion = tabletRowset.GetValueOrDefault<Schema::OldTablet::AllowFollowerPromotion>(); + if (followerCount > 0) { + db.Table<Schema::TabletFollowerGroup>().Key(tabletId, 1).Update( + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerCount), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(allowFollowerPromotion), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(true)); } if (!tabletRowset.Next()) return false; @@ -65,21 +65,21 @@ public: NIceDb::TNiceDb db(txc.DB); auto tabletRowset = db.Table<Schema::OldTablet>().Range().Select< Schema::OldTablet::ID, - Schema::OldTablet::CrossDataCenterFollowerCount, - Schema::OldTablet::FollowerCount, - Schema::OldTablet::AllowFollowerPromotion>(); + Schema::OldTablet::CrossDataCenterFollowerCount, + Schema::OldTablet::FollowerCount, + Schema::OldTablet::AllowFollowerPromotion>(); if (!tabletRowset.IsReady()) return false; while (!tabletRowset.EndOfSet()) { TTabletId tabletId = tabletRowset.GetValue<Schema::OldTablet::ID>(); - ui32 crossDataCenterFollowerCount = tabletRowset.GetValueOrDefault<Schema::OldTablet::CrossDataCenterFollowerCount>(0); + ui32 crossDataCenterFollowerCount = tabletRowset.GetValueOrDefault<Schema::OldTablet::CrossDataCenterFollowerCount>(0); ui32 followerCount = tabletRowset.GetValueOrDefault<Schema::OldTablet::FollowerCount>(Self->GetDataCenters() * crossDataCenterFollowerCount); - bool allowFollowerPromotion = tabletRowset.GetValueOrDefault<Schema::OldTablet::AllowFollowerPromotion>(); - if (followerCount > 0) { - db.Table<Schema::TabletFollowerGroup>().Key(tabletId, 1).Update( - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerCount), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(allowFollowerPromotion), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(true)); + bool allowFollowerPromotion = tabletRowset.GetValueOrDefault<Schema::OldTablet::AllowFollowerPromotion>(); + if (followerCount > 0) { + db.Table<Schema::TabletFollowerGroup>().Key(tabletId, 1).Update( + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerCount), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(allowFollowerPromotion), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(true)); } if (!tabletRowset.Next()) return false; diff --git a/ydb/core/mind/hive/tx__kill_node.cpp b/ydb/core/mind/hive/tx__kill_node.cpp index ec0c73470b0..268327a0ddd 100644 --- a/ydb/core/mind/hive/tx__kill_node.cpp +++ b/ydb/core/mind/hive/tx__kill_node.cpp @@ -27,11 +27,11 @@ public: for (const auto& t : node->Tablets) { for (TTabletInfo* tablet : t.second) { if (tablet->NodeId != 0) { - TTabletId tabletId = tablet->GetLeader().Id; - if (tablet->IsLeader()) { - db.Table<Schema::Tablet>().Key(tabletId).Update<Schema::Tablet::LeaderNode>(0); + TTabletId tabletId = tablet->GetLeader().Id; + if (tablet->IsLeader()) { + db.Table<Schema::Tablet>().Key(tabletId).Update<Schema::Tablet::LeaderNode>(0); } else { - db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } } } diff --git a/ydb/core/mind/hive/tx__load_everything.cpp b/ydb/core/mind/hive/tx__load_everything.cpp index 8cf94966dea..e4c1cf1f51e 100644 --- a/ydb/core/mind/hive/tx__load_everything.cpp +++ b/ydb/core/mind/hive/tx__load_everything.cpp @@ -46,8 +46,8 @@ public: auto tabletChannelRowset = db.Table<Schema::TabletChannel>().Range().Select(); auto tabletChannelGenRowset = db.Table<Schema::TabletChannelGen>().Range().Select(); auto metrics = db.Table<Schema::Metrics>().Range().Select(); - auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range().Select(); - auto tabletFollowerRowset = db.Table<Schema::TabletFollowerTablet>().Range().Select(); + auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range().Select(); + auto tabletFollowerRowset = db.Table<Schema::TabletFollowerTablet>().Range().Select(); auto tabletTypeAllowedMetrics = db.Table<Schema::TabletTypeMetrics>().Range().Select(); auto stateRowset = db.Table<Schema::State>().Select(); auto sequencesRowset = db.Table<Schema::Sequences>().Select(); @@ -58,8 +58,8 @@ public: || !tabletChannelRowset.IsReady() || !tabletChannelGenRowset.IsReady() || !metrics.IsReady() - || !tabletFollowerGroupRowset.IsReady() - || !tabletFollowerRowset.IsReady() + || !tabletFollowerGroupRowset.IsReady() + || !tabletFollowerRowset.IsReady() || !tabletTypeAllowedMetrics.IsReady() || !stateRowset.IsReady() || !sequencesRowset.IsReady() @@ -336,7 +336,7 @@ public: while (!tabletRowset.EndOfSet()) { TTabletId tabletId = tabletRowset.GetValue<Schema::Tablet::ID>(); maxTabletId = std::max(maxTabletId, UniqPartFromTabletID(tabletId)); - TLeaderTabletInfo& tablet = Self->Tablets.emplace( + TLeaderTabletInfo& tablet = Self->Tablets.emplace( std::piecewise_construct, std::tuple<TTabletId>(tabletId), std::tuple<TTabletId, THive&>(tabletId, *Self)).first->second; @@ -360,7 +360,7 @@ public: TSubDomainKey objectDomain = TSubDomainKey(tabletRowset.GetValueOrDefault<Schema::Tablet::ObjectDomain>()); tablet.AssignDomains(objectDomain, allowedDomains); //tablet.Weight = tabletRowset.GetValueOrDefault<Schema::Tablet::Weight>(1000); - tablet.NodeId = tabletRowset.GetValue<Schema::Tablet::LeaderNode>(); + tablet.NodeId = tabletRowset.GetValue<Schema::Tablet::LeaderNode>(); tablet.KnownGeneration = tabletRowset.GetValue<Schema::Tablet::KnownGeneration>(); tablet.ActorsToNotify = tabletRowset.GetValueOrDefault<Schema::Tablet::ActorsToNotify>(); if (tabletRowset.HaveValue<Schema::Tablet::ActorToNotify>()) { @@ -412,18 +412,18 @@ public: } } - std::unordered_map<TFollowerGroup*, ui32> followersPerGroup; + std::unordered_map<TFollowerGroup*, ui32> followersPerGroup; - auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range(tabletId).Select(); - if (!tabletFollowerGroupRowset.IsReady()) + auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range(tabletId).Select(); + if (!tabletFollowerGroupRowset.IsReady()) return false; - while (!tabletFollowerGroupRowset.EndOfSet()) { - TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); - followerGroup.Id = tabletFollowerGroupRowset.GetValue<Schema::TabletFollowerGroup::GroupID>(); - followerGroup.SetFollowerCount(tabletFollowerGroupRowset.GetValue<Schema::TabletFollowerGroup::FollowerCount>()); - followerGroup.AllowLeaderPromotion = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowLeaderPromotion>(); - followerGroup.AllowClientRead = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowClientRead>(); - followerGroup.AllowedNodes = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowedNodes>(); + while (!tabletFollowerGroupRowset.EndOfSet()) { + TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); + followerGroup.Id = tabletFollowerGroupRowset.GetValue<Schema::TabletFollowerGroup::GroupID>(); + followerGroup.SetFollowerCount(tabletFollowerGroupRowset.GetValue<Schema::TabletFollowerGroup::FollowerCount>()); + followerGroup.AllowLeaderPromotion = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowLeaderPromotion>(); + followerGroup.AllowClientRead = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowClientRead>(); + followerGroup.AllowedNodes = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowedNodes>(); if (tabletFollowerGroupRowset.HaveValue<Schema::TabletFollowerGroup::AllowedDataCenters>()) { // this is priority format due to migration issues; when migration is complete, this code will @@ -435,38 +435,38 @@ public: followerGroup.AllowedDataCenters = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowedDataCenterIds>(); } - followerGroup.RequireAllDataCenters = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>(); - followerGroup.LocalNodeOnly = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::LocalNodeOnly>(); - followerGroup.FollowerCountPerDataCenter = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(); - followerGroup.RequireDifferentNodes = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireDifferentNodes>(); - followersPerGroup.emplace(&followerGroup, 0); - if (!tabletFollowerGroupRowset.Next()) + followerGroup.RequireAllDataCenters = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>(); + followerGroup.LocalNodeOnly = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::LocalNodeOnly>(); + followerGroup.FollowerCountPerDataCenter = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(); + followerGroup.RequireDifferentNodes = tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireDifferentNodes>(); + followersPerGroup.emplace(&followerGroup, 0); + if (!tabletFollowerGroupRowset.Next()) return false; } - auto tabletFollowerRowset = db.Table<Schema::TabletFollowerTablet>().Range(tabletId).Select(); - if (!tabletFollowerRowset.IsReady()) + auto tabletFollowerRowset = db.Table<Schema::TabletFollowerTablet>().Range(tabletId).Select(); + if (!tabletFollowerRowset.IsReady()) return false; - while (!tabletFollowerRowset.EndOfSet()) { - TFollowerGroupId followerGroupId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::GroupID>(); - TFollowerId followerId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::FollowerID>(); - TNodeId nodeId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::FollowerNode>(); - TFollowerGroup& followerGroup = tablet.GetFollowerGroup(followerGroupId); - TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup, followerId); + while (!tabletFollowerRowset.EndOfSet()) { + TFollowerGroupId followerGroupId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::GroupID>(); + TFollowerId followerId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::FollowerID>(); + TNodeId nodeId = tabletFollowerRowset.GetValue<Schema::TabletFollowerTablet::FollowerNode>(); + TFollowerGroup& followerGroup = tablet.GetFollowerGroup(followerGroupId); + TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup, followerId); follower.Statistics = tabletFollowerRowset.GetValueOrDefault<Schema::TabletFollowerTablet::Statistics>(); - follower.InitTabletMetrics(); + follower.InitTabletMetrics(); if (nodeId == 0) { - follower.BecomeStopped(); + follower.BecomeStopped(); } else { auto it = Self->Nodes.find(nodeId); if (it != Self->Nodes.end() && it->second.IsUnknown()) { - follower.BecomeUnknown(&it->second); + follower.BecomeUnknown(&it->second); } else { - follower.BecomeStopped(); + follower.BecomeStopped(); } } - followersPerGroup[&followerGroup]++; - if (!tabletFollowerRowset.Next()) + followersPerGroup[&followerGroup]++; + if (!tabletFollowerRowset.Next()) return false; } @@ -474,27 +474,27 @@ public: if (!metricsRowset.IsReady()) return false; while (!metricsRowset.EndOfSet()) { - TFollowerId followerId = metricsRowset.GetValue<Schema::Metrics::FollowerID>(); - auto* leaderOrFollower = tablet.FindTablet(followerId); - if (leaderOrFollower) { - leaderOrFollower->MutableResourceMetricsAggregates().MaximumCPU.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumCPU>()); - leaderOrFollower->MutableResourceMetricsAggregates().MaximumMemory.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumMemory>()); - leaderOrFollower->MutableResourceMetricsAggregates().MaximumNetwork.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumNetwork>()); + TFollowerId followerId = metricsRowset.GetValue<Schema::Metrics::FollowerID>(); + auto* leaderOrFollower = tablet.FindTablet(followerId); + if (leaderOrFollower) { + leaderOrFollower->MutableResourceMetricsAggregates().MaximumCPU.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumCPU>()); + leaderOrFollower->MutableResourceMetricsAggregates().MaximumMemory.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumMemory>()); + leaderOrFollower->MutableResourceMetricsAggregates().MaximumNetwork.InitiaizeFrom(metricsRowset.GetValueOrDefault<Schema::Metrics::MaximumNetwork>()); // do not reorder - leaderOrFollower->UpdateResourceUsage(metricsRowset.GetValueOrDefault<Schema::Metrics::ProtoMetrics>()); + leaderOrFollower->UpdateResourceUsage(metricsRowset.GetValueOrDefault<Schema::Metrics::ProtoMetrics>()); } if (!metricsRowset.Next()) return false; } - for (auto& pr : followersPerGroup) { - TFollowerGroup& followerGroup(*pr.first); + for (auto& pr : followersPerGroup) { + TFollowerGroup& followerGroup(*pr.first); while (followerGroup.GetComputedFollowerCount(Self->GetDataCenters()) > pr.second) { - TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); - follower.InitTabletMetrics(); - follower.BecomeStopped(); - db.Table<Schema::TabletFollowerTablet>().Key(tabletId, follower.Id).Update(NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0), - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(followerGroup.Id)); + TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); + follower.InitTabletMetrics(); + follower.BecomeStopped(); + db.Table<Schema::TabletFollowerTablet>().Key(tabletId, follower.Id).Update(NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0), + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(followerGroup.Id)); ++pr.second; } } @@ -622,12 +622,12 @@ public: i64 tabletsTotal = 0; for (auto it = Self->Tablets.begin(); it != Self->Tablets.end(); ++it) { ++tabletsTotal; - for (const TTabletInfo& follower : it->second.Followers) { + for (const TTabletInfo& follower : it->second.Followers) { ++tabletsTotal; - if (follower.IsLeader()) { - follower.AsLeader(); + if (follower.IsLeader()) { + follower.AsLeader(); } else { - follower.AsFollower(); + follower.AsFollower(); } } } diff --git a/ydb/core/mind/hive/tx__lock_tablet.cpp b/ydb/core/mind/hive/tx__lock_tablet.cpp index d4d6e5a24f0..6365dd09886 100644 --- a/ydb/core/mind/hive/tx__lock_tablet.cpp +++ b/ydb/core/mind/hive/tx__lock_tablet.cpp @@ -43,7 +43,7 @@ public: return true; } - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet == nullptr) { Status = NKikimrProto::ERROR; StatusMessage = TStringBuilder() << "Trying to lock tablet " << TabletId @@ -89,12 +89,12 @@ public: ctx.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId)); } - if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { + if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { // Tablet still exists by the time transaction finished if (tablet->IsLockedToActor()) { // Make sure running tablets will be stopped - for (auto& follower : tablet->Followers) { - follower.InitiateStop(); + for (auto& follower : tablet->Followers) { + follower.InitiateStop(); } tablet->InitiateStop(); } diff --git a/ydb/core/mind/hive/tx__reassign_groups.cpp b/ydb/core/mind/hive/tx__reassign_groups.cpp index 58931a33fda..ec9f4bfdd23 100644 --- a/ydb/core/mind/hive/tx__reassign_groups.cpp +++ b/ydb/core/mind/hive/tx__reassign_groups.cpp @@ -26,7 +26,7 @@ public: bool Execute(TTransactionContext &txc, const TActorContext&) override { //SetTxType(NHive::TXTYPE_KILL_TABLET); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { BLOG_D("THive::TTxReassignGroups(" << tablet->Id << "," << ChannelProfileNewGroup << ")::Execute"); if (tablet->IsReadyToReassignTablet()) { diff --git a/ydb/core/mind/hive/tx__register_node.cpp b/ydb/core/mind/hive/tx__register_node.cpp index 74f3d622eb7..941c0dce658 100644 --- a/ydb/core/mind/hive/tx__register_node.cpp +++ b/ydb/core/mind/hive/tx__register_node.cpp @@ -28,10 +28,10 @@ public: node.ActualizeNodeStatistics(now); for (const auto& t : node.Tablets) { for (TTabletInfo* tablet : t.second) { - if (tablet->IsLeader()) { - db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update<Schema::Tablet::LeaderNode>(0); + if (tablet->IsLeader()) { + db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update<Schema::Tablet::LeaderNode>(0); } else { - db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } } } diff --git a/ydb/core/mind/hive/tx__release_tablets.cpp b/ydb/core/mind/hive/tx__release_tablets.cpp index 675591cffda..cdfd82ce063 100644 --- a/ydb/core/mind/hive/tx__release_tablets.cpp +++ b/ydb/core/mind/hive/tx__release_tablets.cpp @@ -24,15 +24,15 @@ public: BLOG_D("THive::TTxReleaseTablets::Execute " << request); NIceDb::TNiceDb db(txc.DB); for (TTabletId tabletId : request.GetTabletIDs()) { - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr) { Y_VERIFY(tablet->SeizedByChild); if (tablet->IsAlive() && tablet->Node != nullptr) { tablet->SendStopTablet(tablet->Node->Local, tablet->GetFullTabletId()); - for (TFollowerTabletInfo& follower : tablet->Followers) { - if (follower.IsAlive() && follower.Node != nullptr) { - follower.SendStopTablet(follower.Node->Local, follower.GetFullTabletId()); + for (TFollowerTabletInfo& follower : tablet->Followers) { + if (follower.IsAlive() && follower.Node != nullptr) { + follower.SendStopTablet(follower.Node->Local, follower.GetFullTabletId()); } } } @@ -44,13 +44,13 @@ public: } db.Table<Schema::TabletChannel>().Key(tablet->Id, channelInfo.Channel).Delete(); } - for (TFollowerTabletInfo& follower : tablet->Followers) { - auto fullTabletId = follower.GetFullTabletId(); - db.Table<Schema::TabletFollowerTablet>().Key(fullTabletId).Delete(); + for (TFollowerTabletInfo& follower : tablet->Followers) { + auto fullTabletId = follower.GetFullTabletId(); + db.Table<Schema::TabletFollowerTablet>().Key(fullTabletId).Delete(); db.Table<Schema::Metrics>().Key(fullTabletId).Delete(); } - for (TFollowerGroup& group : tablet->FollowerGroups) { - db.Table<Schema::TabletFollowerGroup>().Key(tablet->Id, group.Id).Delete(); + for (TFollowerGroup& group : tablet->FollowerGroups) { + db.Table<Schema::TabletFollowerGroup>().Key(tablet->Id, group.Id).Delete(); } db.Table<Schema::Tablet>().Key(tablet->Id).Delete(); TActorId unlockedFromActor = tablet->ClearLockedToActor(); diff --git a/ydb/core/mind/hive/tx__release_tablets_reply.cpp b/ydb/core/mind/hive/tx__release_tablets_reply.cpp index 7a4b1682609..8589258f32e 100644 --- a/ydb/core/mind/hive/tx__release_tablets_reply.cpp +++ b/ydb/core/mind/hive/tx__release_tablets_reply.cpp @@ -84,7 +84,7 @@ public: } for (TTabletId tabletId : request.GetTabletIDs()) { - TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet != nullptr) { tablet->NeedToReleaseFromParent = false; if (tablet->IsReadyToAssignGroups()) { diff --git a/ydb/core/mind/hive/tx__restart_tablet.cpp b/ydb/core/mind/hive/tx__restart_tablet.cpp index a171eb6f7cc..3c070ed706c 100644 --- a/ydb/core/mind/hive/tx__restart_tablet.cpp +++ b/ydb/core/mind/hive/tx__restart_tablet.cpp @@ -34,10 +34,10 @@ public: if (!tablet->IsStopped()) { NIceDb::TNiceDb db(txc.DB); if (tablet->Node != nullptr) { - if (tablet->IsLeader()) { - db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update<Schema::Tablet::LeaderNode>(0); + if (tablet->IsLeader()) { + db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update<Schema::Tablet::LeaderNode>(0); } else { - db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } } tablet->InitiateStop(); diff --git a/ydb/core/mind/hive/tx__resume_tablet.cpp b/ydb/core/mind/hive/tx__resume_tablet.cpp index 5f8537edef2..a7252bff725 100644 --- a/ydb/core/mind/hive/tx__resume_tablet.cpp +++ b/ydb/core/mind/hive/tx__resume_tablet.cpp @@ -21,7 +21,7 @@ public: bool Execute(TTransactionContext &txc, const TActorContext&) override { BLOG_D("THive::TTxResumeTablet::Execute Tablet: " << TabletId); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { ETabletState State = tablet->State; ETabletState NewState = State; @@ -67,7 +67,7 @@ public: if (Status != NKikimrProto::UNKNOWN) { ctx.Send(ActorToNotify, new TEvHive::TEvResumeTabletResult(Status, TabletId), 0, 0); if (Status == NKikimrProto::OK) { - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { if (tablet->IsReadyToBoot()) { tablet->InitiateBoot(); diff --git a/ydb/core/mind/hive/tx__seize_tablets.cpp b/ydb/core/mind/hive/tx__seize_tablets.cpp index f17754df41d..09a93c9656d 100644 --- a/ydb/core/mind/hive/tx__seize_tablets.cpp +++ b/ydb/core/mind/hive/tx__seize_tablets.cpp @@ -16,12 +16,12 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_SEIZE_TABLETS; } - static bool IsMatch(const TLeaderTabletInfo& tablet, const NKikimrHive::TEvSeizeTablets& record) { + static bool IsMatch(const TLeaderTabletInfo& tablet, const NKikimrHive::TEvSeizeTablets& record) { return tablet.ObjectDomain == TSubDomainKey(record.GetFilterDomain()) && record.GetNewOwnerID() != tablet.Id; } - static bool IsAbleToMigrate(const TLeaderTabletInfo& tablet) { + static bool IsAbleToMigrate(const TLeaderTabletInfo& tablet) { // we can only migrate 'big' tablet ids, which have non-zero bits in 44+ // that's because it stored in the same id space, where ownerIdx is stored // return !tablet.IsDeleting() && StateStorageGroupFromTabletID(tablet.Id) > 0 || HiveUidFromTabletID(tablet.Id) > 0; @@ -52,7 +52,7 @@ public: // Schema::Tablet::AllowedNodes - because nobody is using it now // Schema::Tablet::AllowedDataCenters - because nobody is using it now - // we also skip current metrics state for followers + // we also skip current metrics state for followers TTabletId id = tabletId; BLOG_D("THive::TTxSeizeTablets is migrating tablet " << id << " to " << newOwnerId); @@ -120,21 +120,21 @@ public: return false; } - auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range(tabletId).Select(); - if (!tabletFollowerGroupRowset.IsReady()) + auto tabletFollowerGroupRowset = db.Table<Schema::TabletFollowerGroup>().Range(tabletId).Select(); + if (!tabletFollowerGroupRowset.IsReady()) return false; - while (!tabletFollowerGroupRowset.EndOfSet()) { - NKikimrHive::TFollowerGroup& followerGroup = *tabletInfo.AddFollowerGroups(); - followerGroup.SetFollowerCount(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCount>()); - followerGroup.SetAllowLeaderPromotion(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowLeaderPromotion>()); - followerGroup.SetAllowClientRead(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowClientRead>()); - followerGroup.SetRequireAllDataCenters(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>()); - followerGroup.SetLocalNodeOnly(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::LocalNodeOnly>()); - followerGroup.SetRequireAllDataCenters(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>()); - followerGroup.SetRequireDifferentNodes(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireDifferentNodes>()); - followerGroup.SetFollowerCountPerDataCenter(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>()); - if (!tabletFollowerGroupRowset.Next()) { + while (!tabletFollowerGroupRowset.EndOfSet()) { + NKikimrHive::TFollowerGroup& followerGroup = *tabletInfo.AddFollowerGroups(); + followerGroup.SetFollowerCount(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCount>()); + followerGroup.SetAllowLeaderPromotion(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowLeaderPromotion>()); + followerGroup.SetAllowClientRead(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::AllowClientRead>()); + followerGroup.SetRequireAllDataCenters(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>()); + followerGroup.SetLocalNodeOnly(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::LocalNodeOnly>()); + followerGroup.SetRequireAllDataCenters(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireAllDataCenters>()); + followerGroup.SetRequireDifferentNodes(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::RequireDifferentNodes>()); + followerGroup.SetFollowerCountPerDataCenter(tabletFollowerGroupRowset.GetValueOrDefault<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>()); + if (!tabletFollowerGroupRowset.Next()) { return false; } } diff --git a/ydb/core/mind/hive/tx__seize_tablets_reply.cpp b/ydb/core/mind/hive/tx__seize_tablets_reply.cpp index 624026b75e2..6e6db7131be 100644 --- a/ydb/core/mind/hive/tx__seize_tablets_reply.cpp +++ b/ydb/core/mind/hive/tx__seize_tablets_reply.cpp @@ -23,7 +23,7 @@ public: for (const NKikimrHive::TTabletInfo& protoTabletInfo : request.GetTablets()) { TTabletId tabletId = protoTabletInfo.GetTabletID(); std::pair<ui64, ui64> owner(protoTabletInfo.GetTabletOwner().GetOwner(), protoTabletInfo.GetTabletOwner().GetOwnerIdx()); - TLeaderTabletInfo& tablet = Self->GetTablet(tabletId); + TLeaderTabletInfo& tablet = Self->GetTablet(tabletId); tablet.Type = protoTabletInfo.GetTabletType(); tablet.NodeId = 0; tablet.Node = nullptr; @@ -57,7 +57,7 @@ public: NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(protoTabletInfo.GetGeneration()), NIceDb::TUpdate<Schema::Tablet::TabletType>(protoTabletInfo.GetTabletType()), NIceDb::TUpdate<Schema::Tablet::State>(static_cast<ETabletState>(protoTabletInfo.GetState())), - NIceDb::TUpdate<Schema::Tablet::LeaderNode>(protoTabletInfo.GetNodeID()), + NIceDb::TUpdate<Schema::Tablet::LeaderNode>(protoTabletInfo.GetNodeID()), //NIceDb::TUpdate<Schema::Tablet::Category>(), //NIceDb::TUpdate<Schema::Tablet::AllowedNodes>(), //NIceDb::TUpdate<Schema::Tablet::AllowedDataCenters>(), @@ -111,32 +111,32 @@ public: tablet.AcquireAllocationUnits(); - for (const auto& protoFollowerGroup : protoTabletInfo.GetFollowerGroups()) { - TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); - followerGroup = protoFollowerGroup; + for (const auto& protoFollowerGroup : protoTabletInfo.GetFollowerGroups()) { + TFollowerGroup& followerGroup = tablet.AddFollowerGroup(); + followerGroup = protoFollowerGroup; TVector<ui32> allowedDataCenters; for (const TDataCenterId& dc : followerGroup.AllowedDataCenters) { allowedDataCenters.push_back(DataCenterFromString(dc)); } - db.Table<Schema::TabletFollowerGroup>().Key(tabletId, followerGroup.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), - NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), + db.Table<Schema::TabletFollowerGroup>().Key(tabletId, followerGroup.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCount>(followerGroup.GetRawFollowerCount()), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowLeaderPromotion>(followerGroup.AllowLeaderPromotion), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowClientRead>(followerGroup.AllowClientRead), + NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedNodes>(followerGroup.AllowedNodes), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenters>(allowedDataCenters), NIceDb::TUpdate<Schema::TabletFollowerGroup::AllowedDataCenterIds>(followerGroup.AllowedDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), - NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireDifferentNodes>(followerGroup.RequireDifferentNodes), - NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter)); + NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireAllDataCenters>(followerGroup.RequireAllDataCenters), + NIceDb::TUpdate<Schema::TabletFollowerGroup::RequireDifferentNodes>(followerGroup.RequireDifferentNodes), + NIceDb::TUpdate<Schema::TabletFollowerGroup::FollowerCountPerDataCenter>(followerGroup.FollowerCountPerDataCenter)); for (ui32 i = 0; i < followerGroup.GetComputedFollowerCount(Self->GetDataCenters()); ++i) { - TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); - db.Table<Schema::TabletFollowerTablet>().Key(tabletId, follower.Id).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), - NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0)); - follower.InitTabletMetrics(); - follower.BecomeStopped(); + TFollowerTabletInfo& follower = tablet.AddFollower(followerGroup); + db.Table<Schema::TabletFollowerTablet>().Key(tabletId, follower.Id).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(follower.FollowerGroup.Id), + NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0)); + follower.InitTabletMetrics(); + follower.BecomeStopped(); } } diff --git a/ydb/core/mind/hive/tx__start_tablet.cpp b/ydb/core/mind/hive/tx__start_tablet.cpp index ab7ed3ae989..4cef3a0e069 100644 --- a/ydb/core/mind/hive/tx__start_tablet.cpp +++ b/ydb/core/mind/hive/tx__start_tablet.cpp @@ -26,13 +26,13 @@ public: BLOG_D("THive::TTxStartTablet::Execute Tablet " << TabletId); TTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { - if (tablet->IsLeader()) { - TLeaderTabletInfo& leader = tablet->AsLeader(); - if (leader.IsStarting() || leader.IsBootingSuppressed() && External) { + if (tablet->IsLeader()) { + TLeaderTabletInfo& leader = tablet->AsLeader(); + if (leader.IsStarting() || leader.IsBootingSuppressed() && External) { NIceDb::TNiceDb db(txc.DB); - leader.IncreaseGeneration(); - KnownGeneration = leader.KnownGeneration; - db.Table<Schema::Tablet>().Key(leader.Id).Update<Schema::Tablet::KnownGeneration>(leader.KnownGeneration); + leader.IncreaseGeneration(); + KnownGeneration = leader.KnownGeneration; + db.Table<Schema::Tablet>().Key(leader.Id).Update<Schema::Tablet::KnownGeneration>(leader.KnownGeneration); } else { BLOG_W("THive::TTxStartTablet::Execute Tablet " << TabletId << " skipped generation increment"); } @@ -53,38 +53,38 @@ public: } tablet->LastNodeId = 0; } - if (tablet->IsLeader()) { - TLeaderTabletInfo& leader = tablet->AsLeader(); - if (leader.IsStartingOnNode(Local.NodeId()) || leader.IsBootingSuppressed() && External) { - if (KnownGeneration == leader.KnownGeneration) { - BLOG_D("THive::TTxStartTablet::Complete, Sending TEvBootTablet(" << leader.ToString() << ")" + if (tablet->IsLeader()) { + TLeaderTabletInfo& leader = tablet->AsLeader(); + if (leader.IsStartingOnNode(Local.NodeId()) || leader.IsBootingSuppressed() && External) { + if (KnownGeneration == leader.KnownGeneration) { + BLOG_D("THive::TTxStartTablet::Complete, Sending TEvBootTablet(" << leader.ToString() << ")" << " to node " << Local.NodeId() - << " storage " << leader.TabletStorageInfo->ToString()); - TFollowerId promotableFollowerId = leader.GetFollowerPromotableOnNode(Local.NodeId()); + << " storage " << leader.TabletStorageInfo->ToString()); + TFollowerId promotableFollowerId = leader.GetFollowerPromotableOnNode(Local.NodeId()); ctx.Send(Local, - new TEvLocal::TEvBootTablet(*leader.TabletStorageInfo, promotableFollowerId, KnownGeneration), + new TEvLocal::TEvBootTablet(*leader.TabletStorageInfo, promotableFollowerId, KnownGeneration), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession, Cookie); return; } else { - BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << leader.ToString() << ") - wrong generation"); + BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << leader.ToString() << ") - wrong generation"); } } else { - BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << leader.ToString() << ") - wrong state or node"); + BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << leader.ToString() << ") - wrong state or node"); } } else { - TFollowerTabletInfo& follower = tablet->AsFollower(); - if (follower.IsStartingOnNode(Local.NodeId())) { - BLOG_D("THive::TTxStartTablet::Complete, Sending TEvBootTablet(" << follower.ToString() << ")" + TFollowerTabletInfo& follower = tablet->AsFollower(); + if (follower.IsStartingOnNode(Local.NodeId())) { + BLOG_D("THive::TTxStartTablet::Complete, Sending TEvBootTablet(" << follower.ToString() << ")" << " to node " << Local.NodeId() - << " storage " << follower.LeaderTablet.TabletStorageInfo->ToString()); + << " storage " << follower.LeaderTablet.TabletStorageInfo->ToString()); ctx.Send(Local, - new TEvLocal::TEvBootTablet(*follower.LeaderTablet.TabletStorageInfo, follower.Id), + new TEvLocal::TEvBootTablet(*follower.LeaderTablet.TabletStorageInfo, follower.Id), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession, Cookie); return; } else { - BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << follower.ToString() << ") - wrong state or node"); + BLOG_W("THive::TTxStartTablet::Complete, ignoring outstanding TEvBootTablet(" << follower.ToString() << ") - wrong state or node"); } } // if anything wrong - attempt to restart the tablet diff --git a/ydb/core/mind/hive/tx__stop_tablet.cpp b/ydb/core/mind/hive/tx__stop_tablet.cpp index 3adbbf2be1b..c05103b258d 100644 --- a/ydb/core/mind/hive/tx__stop_tablet.cpp +++ b/ydb/core/mind/hive/tx__stop_tablet.cpp @@ -21,7 +21,7 @@ public: bool Execute(TTransactionContext &txc, const TActorContext&) override { BLOG_D("THive::TTxStopTablet::Execute Tablet: " << TabletId); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { ETabletState State = tablet->State; ETabletState NewState = State; @@ -41,15 +41,15 @@ public: case ETabletState::ReadyToWork: // Switch to Stopping NewState = ETabletState::Stopped; - for (TTabletInfo& follower : tablet->Followers) { - if (follower.IsAlive()) { - follower.InitiateStop(); - db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); + for (TTabletInfo& follower : tablet->Followers) { + if (follower.IsAlive()) { + follower.InitiateStop(); + db.Table<Schema::TabletFollowerTablet>().Key(follower.GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } } if (tablet->IsAlive()) { tablet->InitiateStop(); - db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::LeaderNode>(0); + db.Table<Schema::Tablet>().Key(tablet->Id).Update<Schema::Tablet::LeaderNode>(0); } Status = NKikimrProto::OK; break; @@ -77,7 +77,7 @@ public: BLOG_D("THive::TTxStopTablet::Complete TabletId: " << TabletId); if (Status != NKikimrProto::UNKNOWN) { ctx.Send(ActorToNotify, new TEvHive::TEvStopTabletResult(Status, TabletId), 0, 0); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { Self->ReportStoppedToWhiteboard(*tablet); BLOG_D("Report tablet " << tablet->ToString() << " as stopped to Whiteboard"); diff --git a/ydb/core/mind/hive/tx__sync_tablets.cpp b/ydb/core/mind/hive/tx__sync_tablets.cpp index 3506bd12ce7..29eb4cfba1c 100644 --- a/ydb/core/mind/hive/tx__sync_tablets.cpp +++ b/ydb/core/mind/hive/tx__sync_tablets.cpp @@ -7,8 +7,8 @@ namespace NHive { class TTxSyncTablets : public TTransactionBase<THive> { TActorId Local; NKikimrLocal::TEvSyncTablets SyncTablets; - THashSet<std::pair<TTabletId, TFollowerId>> TabletsToStop; - THashSet<std::pair<TTabletId, TFollowerId>> TabletsToBoot; + THashSet<std::pair<TTabletId, TFollowerId>> TabletsToStop; + THashSet<std::pair<TTabletId, TFollowerId>> TabletsToBoot; public: TTxSyncTablets(const TActorId &local, NKikimrLocal::TEvSyncTablets& rec, THive* hive) : TBase(hive) @@ -20,16 +20,16 @@ public: TTxType GetTxType() const override { return NHive::TXTYPE_SYNC_TABLETS; } bool IsSameTablet(const TTabletInfo* local, const NKikimrLocal::TEvSyncTablets_TTabletInfo& remote) const { - if (local->IsFollower()) { - if (remote.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER) { - if (local->AsFollower().Id == remote.GetFollowerId() + if (local->IsFollower()) { + if (remote.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER) { + if (local->AsFollower().Id == remote.GetFollowerId() && (local->IsStopped() || local->IsAliveOnLocal(Local))) { return true; } } } else { - if (remote.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_LEADER) { - if (remote.GetGeneration() >= local->GetLeader().KnownGeneration) { + if (remote.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_LEADER) { + if (remote.GetGeneration() >= local->GetLeader().KnownGeneration) { return true; } } @@ -49,17 +49,17 @@ public: } } for (const NKikimrLocal::TEvSyncTablets_TTabletInfo& ti : SyncTablets.GetInbootTablets()) { - auto tabletId = std::pair<TTabletId, TFollowerId>(ti.GetTabletId(), ti.GetFollowerId()); + auto tabletId = std::pair<TTabletId, TFollowerId>(ti.GetTabletId(), ti.GetFollowerId()); TTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet) { if (IsSameTablet(tablet, ti)) { - if (tablet->IsLeader()) { - tablet->GetLeader().KnownGeneration = ti.GetGeneration(); + if (tablet->IsLeader()) { + tablet->GetLeader().KnownGeneration = ti.GetGeneration(); } tablet->BecomeStarting(node.Id); BLOG_TRACE("THive::TTxSyncTablets(" << Local << ") confirmed starting tablet " << tabletId); TabletsToStop.erase(tabletId); - if (tablet->GetLeader().IsBootingSuppressed()) { + if (tablet->GetLeader().IsBootingSuppressed()) { tablet->InitiateStop(); } continue; @@ -71,31 +71,31 @@ public: } } for (const NKikimrLocal::TEvSyncTablets_TTabletInfo& ti : SyncTablets.GetOnlineTablets()) { - auto tabletId = std::pair<TTabletId, TFollowerId>(ti.GetTabletId(), ti.GetFollowerId()); + auto tabletId = std::pair<TTabletId, TFollowerId>(ti.GetTabletId(), ti.GetFollowerId()); TTabletInfo* tablet = Self->FindTablet(tabletId); if (tablet) { if (IsSameTablet(tablet, ti)) { - if (tablet->IsLeader()) { - tablet->GetLeader().KnownGeneration = ti.GetGeneration(); + if (tablet->IsLeader()) { + tablet->GetLeader().KnownGeneration = ti.GetGeneration(); } if (tablet->BecomeRunning(node.Id)) { - if (tablet->IsLeader()) { - db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet->NodeId), - NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(tablet->GetLeader().KnownGeneration)); + if (tablet->IsLeader()) { + db.Table<Schema::Tablet>().Key(tablet->GetLeader().Id).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet->NodeId), + NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(tablet->GetLeader().KnownGeneration)); TabletsToBoot.insert(tabletId); } else { - db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), - NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(tablet->NodeId)); + db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), + NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(tablet->NodeId)); } } BLOG_TRACE("THive::TTxSyncTablets(" << Local << ") confirmed running tablet " << tabletId); TabletsToStop.erase(tabletId); - if (tablet->GetLeader().IsBootingSuppressed()) { + if (tablet->GetLeader().IsBootingSuppressed()) { tablet->InitiateStop(); } continue; - } else if (ti.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER) { + } else if (ti.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER) { Self->StopTablet(Local, tabletId); // the tablet is running somewhere else BLOG_TRACE("THive::TTxSyncTablets(" << Local << ") confirmed and stopped running tablet " << tabletId); TabletsToBoot.insert(tabletId); @@ -113,13 +113,13 @@ public: void Complete(const TActorContext& ctx) override { BLOG_D("THive::TTxSyncTablets(" << Local << ")::Complete"); - for (std::pair<TTabletId, TFollowerId> tabletId : TabletsToStop) { + for (std::pair<TTabletId, TFollowerId> tabletId : TabletsToStop) { Self->Execute(Self->CreateRestartTablet(tabletId), ctx); } - for (std::pair<TTabletId, TFollowerId> tabletId : TabletsToBoot) { + for (std::pair<TTabletId, TFollowerId> tabletId : TabletsToBoot) { TTabletInfo* tablet = Self->FindTablet(tabletId.first, tabletId.second); if (tablet != nullptr) { - tablet->GetLeader().TryToBoot(); // for followers + tablet->GetLeader().TryToBoot(); // for followers } } Self->ProcessBootQueue(); diff --git a/ydb/core/mind/hive/tx__unlock_tablet.cpp b/ydb/core/mind/hive/tx__unlock_tablet.cpp index 5c4bd70afa4..66786b43b2a 100644 --- a/ydb/core/mind/hive/tx__unlock_tablet.cpp +++ b/ydb/core/mind/hive/tx__unlock_tablet.cpp @@ -40,7 +40,7 @@ public: bool Execute(TTransactionContext& txc, const TActorContext&) override { BLOG_D("THive::TTxUnlockTabletExecution::Execute"); - TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); + TLeaderTabletInfo* tablet = Self->FindTabletEvenInDeleting(TabletId); if (tablet == nullptr) { Status = NKikimrProto::ERROR; StatusMessage = TStringBuilder() << "Trying to unlock tablet " << TabletId @@ -85,7 +85,7 @@ public: ctx.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId)); } - if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { + if (TLeaderTabletInfo* tablet = Self->FindTablet(TabletId)) { // Tablet still exists by the time transaction finished if (!tablet->IsLockedToActor()) { // Try to boot it if possible @@ -119,7 +119,7 @@ ITransaction* THive::CreateUnlockTabletExecution(ui64 tabletId, ui64 seqNo) { void THive::ScheduleUnlockTabletExecution(TNodeInfo& node) { // Unlock tablets that have been locked by this node - for (TLeaderTabletInfo* tablet : node.LockedTablets) { + for (TLeaderTabletInfo* tablet : node.LockedTablets) { Y_VERIFY(FindTabletEvenInDeleting(tablet->Id) == tablet); Y_VERIFY(tablet->LockedToActor.NodeId() == node.Id); if (tablet->PendingUnlockSeqNo == 0) { @@ -139,7 +139,7 @@ void THive::Handle(TEvPrivate::TEvUnlockTabletReconnectTimeout::TPtr& ev) { TTabletId tabletId = ev->Get()->TabletId; ui64 seqNo = ev->Get()->SeqNo; BLOG_D("THive::Handle::TEvUnlockTabletReconnectTimeout TabletId=" << tabletId); - TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); + TLeaderTabletInfo* tablet = FindTabletEvenInDeleting(tabletId); if (tablet != nullptr && tablet->IsLockedToActor() && tablet->PendingUnlockSeqNo == seqNo) { // We use sequence numbers to make sure unlock happens only if some // other pending lock/unlock transaction has not modified the lock. diff --git a/ydb/core/mind/hive/tx__update_tablet_groups.cpp b/ydb/core/mind/hive/tx__update_tablet_groups.cpp index b5cf3708cfd..2d9a11bc3b8 100644 --- a/ydb/core/mind/hive/tx__update_tablet_groups.cpp +++ b/ydb/core/mind/hive/tx__update_tablet_groups.cpp @@ -30,7 +30,7 @@ public: bool Execute(TTransactionContext &txc, const TActorContext& ctx) override { TStringBuilder tabletBootState; - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (!tablet) { BLOG_W("THive::TTxUpdateTabletGroups:: tablet " << TabletId << " wasn't found"); Ignored = true; @@ -255,7 +255,7 @@ public: " - Ignored transaction"); } else { BLOG_D("THive::TTxUpdateTabletGroups{" << (ui64)this << "}(" << TabletId << ")::Complete"); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { tablet->State = NewTabletState; if (Changed) { diff --git a/ydb/core/mind/hive/tx__update_tablet_metrics.cpp b/ydb/core/mind/hive/tx__update_tablet_metrics.cpp index 7ed85612e0c..7e6150ec9a8 100644 --- a/ydb/core/mind/hive/tx__update_tablet_metrics.cpp +++ b/ydb/core/mind/hive/tx__update_tablet_metrics.cpp @@ -23,23 +23,23 @@ public: NIceDb::TNiceDb db(txc.DB); for (const auto& metrics : record.GetTabletMetrics()) { TTabletId tabletId = metrics.GetTabletID(); - TFollowerId followerId = metrics.GetFollowerID(); + TFollowerId followerId = metrics.GetFollowerID(); //BLOG_D("THive::TTxUpdateTabletMetrics::Execute Tablet: " << tabletId); - TTabletInfo* tablet = Self->FindTablet(tabletId, followerId); + TTabletInfo* tablet = Self->FindTablet(tabletId, followerId); if (tablet != nullptr && metrics.HasResourceUsage()) { tablet->UpdateResourceUsage(metrics.GetResourceUsage()); const NKikimrTabletBase::TMetrics& metrics(tablet->GetResourceValues()); - db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::ProtoMetrics>(metrics); + db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::ProtoMetrics>(metrics); - db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumCPU>(tablet->GetResourceMetricsAggregates().MaximumCPU); - db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumMemory>(tablet->GetResourceMetricsAggregates().MaximumMemory); - db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumNetwork>(tablet->GetResourceMetricsAggregates().MaximumNetwork); + db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumCPU>(tablet->GetResourceMetricsAggregates().MaximumCPU); + db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumMemory>(tablet->GetResourceMetricsAggregates().MaximumMemory); + db.Table<Schema::Metrics>().Key(tabletId, followerId).Update<Schema::Metrics::MaximumNetwork>(tablet->GetResourceMetricsAggregates().MaximumNetwork); tablet->Statistics.SetLastAliveTimestamp(now.MilliSeconds()); tablet->ActualizeTabletStatistics(now); - if (tablet->IsLeader()) { + if (tablet->IsLeader()) { db.Table<Schema::Tablet>() .Key(tabletId) .Update<Schema::Tablet::Statistics>(tablet->Statistics); @@ -50,7 +50,7 @@ public: } } Reply->Record.AddTabletId(tabletId); - Reply->Record.AddFollowerId(followerId); + Reply->Record.AddFollowerId(followerId); } TNodeInfo* node = Self->FindNode(nodeId); if (node != nullptr) { diff --git a/ydb/core/mind/hive/tx__update_tablet_status.cpp b/ydb/core/mind/hive/tx__update_tablet_status.cpp index f044a89905e..7e682e857d0 100644 --- a/ydb/core/mind/hive/tx__update_tablet_status.cpp +++ b/ydb/core/mind/hive/tx__update_tablet_status.cpp @@ -10,7 +10,7 @@ class TTxUpdateTabletStatus : public TTransactionBase<THive> { const TEvLocal::TEvTabletStatus::EStatus Status; const TEvTablet::TEvTabletDead::EReason Reason; ui32 Generation; - TFollowerId FollowerId; + TFollowerId FollowerId; TCompleteNotifications Notifications; public: @@ -18,7 +18,7 @@ public: TTabletId tabletId, const TActorId &local, ui32 generation, - TFollowerId followerId, + TFollowerId followerId, TEvLocal::TEvTabletStatus::EStatus status, TEvTablet::TEvTabletDead::EReason reason, THive *hive) @@ -28,7 +28,7 @@ public: , Status(status) , Reason(reason) , Generation(generation) - , FollowerId(followerId) + , FollowerId(followerId) {} TTxType GetTxType() const override { return NHive::TXTYPE_UPDATE_TABLET_STATUS; } @@ -62,7 +62,7 @@ public: } bool Execute(TTransactionContext &txc, const TActorContext&) override { - TTabletInfo* tablet = Self->FindTablet(TabletId, FollowerId); + TTabletInfo* tablet = Self->FindTablet(TabletId, FollowerId); if (tablet != nullptr) { BLOG_D("THive::TTxUpdateTabletStatus::Execute for tablet " << tablet->ToString() @@ -70,8 +70,8 @@ public: << GetStatus() << " generation " << Generation - << " follower " - << FollowerId + << " follower " + << FollowerId << " from local " << Local); NIceDb::TNiceDb db(txc.DB); @@ -86,34 +86,34 @@ public: // KIKIMR-9614 return true; } - if (tablet->IsLeader() && Generation < tablet->GetLeader().KnownGeneration) { + if (tablet->IsLeader() && Generation < tablet->GetLeader().KnownGeneration) { return true; } for (const TActorId& actor : tablet->ActorsToNotifyOnRestart) { Notifications.Send(actor, new TEvPrivate::TEvRestartComplete({TabletId, FollowerId}, "OK")); } tablet->ActorsToNotifyOnRestart.clear(); - if (tablet->GetLeader().IsDeleting()) { - tablet->SendStopTablet(Local, {TabletId, FollowerId}); + if (tablet->GetLeader().IsDeleting()) { + tablet->SendStopTablet(Local, {TabletId, FollowerId}); return true; } tablet->BecomeRunning(Local.NodeId()); - if (tablet->GetLeader().IsLockedToActor()) { + if (tablet->GetLeader().IsLockedToActor()) { // Tablet is locked and shouldn't be running, but we just found out it's running on this node // Ask it to stop using InitiateStop (which uses data saved by BecomeRunning call above) tablet->InitiateStop(); } tablet->BootState = Self->BootStateRunning; tablet->Statistics.SetLastAliveTimestamp(now.MilliSeconds()); - if (tablet->IsLeader()) { - TLeaderTabletInfo& leader(tablet->AsLeader()); - leader.KnownGeneration = Generation; - db.Table<Schema::Tablet>().Key(TabletId).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet->NodeId), + if (tablet->IsLeader()) { + TLeaderTabletInfo& leader(tablet->AsLeader()); + leader.KnownGeneration = Generation; + db.Table<Schema::Tablet>().Key(TabletId).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(tablet->NodeId), NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(Generation), NIceDb::TUpdate<Schema::Tablet::Statistics>(tablet->Statistics)); } else { - db.Table<Schema::TabletFollowerTablet>().Key(TabletId, FollowerId).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), + db.Table<Schema::TabletFollowerTablet>().Key(TabletId, FollowerId).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(Local.NodeId()), NIceDb::TUpdate<Schema::TabletFollowerTablet::Statistics>(tablet->Statistics)); } @@ -124,7 +124,7 @@ public: db.Table<Schema::Tablet>().Key(TabletId).UpdateToNull<Schema::Tablet::ActorsToNotify>(); } else { if (Local) { - Notifications.Send(Local, new TEvLocal::TEvDeadTabletAck(std::make_pair(TabletId, FollowerId), Generation)); + Notifications.Send(Local, new TEvLocal::TEvDeadTabletAck(std::make_pair(TabletId, FollowerId), Generation)); } if (tablet->IsLeader()) { TLeaderTabletInfo& leader(tablet->AsLeader()); @@ -141,37 +141,37 @@ public: } if (Local) { if (tablet->IsAliveOnLocal(Local)) { - if (tablet->IsLeader()) { - TLeaderTabletInfo& leader(tablet->AsLeader()); - db.Table<Schema::Tablet>().Key(TabletId).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(0), - NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(leader.KnownGeneration), + if (tablet->IsLeader()) { + TLeaderTabletInfo& leader(tablet->AsLeader()); + db.Table<Schema::Tablet>().Key(TabletId).Update(NIceDb::TUpdate<Schema::Tablet::LeaderNode>(0), + NIceDb::TUpdate<Schema::Tablet::KnownGeneration>(leader.KnownGeneration), NIceDb::TUpdate<Schema::Tablet::Statistics>(tablet->Statistics)); } else { - db.Table<Schema::TabletFollowerTablet>().Key(TabletId, FollowerId).Update( - NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), + db.Table<Schema::TabletFollowerTablet>().Key(TabletId, FollowerId).Update( + NIceDb::TUpdate<Schema::TabletFollowerTablet::GroupID>(tablet->AsFollower().FollowerGroup.Id), NIceDb::TUpdate<Schema::TabletFollowerTablet::FollowerNode>(0), NIceDb::TUpdate<Schema::TabletFollowerTablet::Statistics>(tablet->Statistics)); } tablet->InitiateStop(); } } - switch (tablet->GetLeader().State) { + switch (tablet->GetLeader().State) { case ETabletState::GroupAssignment: //Y_FAIL("Unexpected tablet boot failure during group assignment"); // Just ignore it. This is fail from previous generation. return true; case ETabletState::StoppingInGroupAssignment: case ETabletState::Stopping: - if (tablet->IsLeader()) { - for (const TActorId& actor : tablet->GetLeader().ActorsToNotify) { + if (tablet->IsLeader()) { + for (const TActorId& actor : tablet->GetLeader().ActorsToNotify) { Notifications.Send(actor, new TEvHive::TEvStopTabletResult(NKikimrProto::OK, TabletId)); } - tablet->GetLeader().ActorsToNotify.clear(); + tablet->GetLeader().ActorsToNotify.clear(); } [[fallthrough]]; // AUTOGENERATED_FALLTHROUGH_FIXME case ETabletState::Stopped: - Self->ReportStoppedToWhiteboard(tablet->GetLeader()); + Self->ReportStoppedToWhiteboard(tablet->GetLeader()); BLOG_D("Report tablet " << tablet->ToString() << " as stopped to Whiteboard"); break; case ETabletState::BlockStorage: @@ -188,7 +188,7 @@ public: void Complete(const TActorContext& ctx) override { BLOG_D("THive::TTxUpdateTabletStatus::Complete TabletId: " << TabletId << " Notifications: " << Notifications); Notifications.Send(ctx); - TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); + TLeaderTabletInfo* tablet = Self->FindTablet(TabletId); if (tablet != nullptr) { tablet->TryToBoot(); } @@ -200,7 +200,7 @@ ITransaction* THive::CreateUpdateTabletStatus( TTabletId tabletId, const TActorId &local, ui32 generation, - TFollowerId followerId, + TFollowerId followerId, TEvLocal::TEvTabletStatus::EStatus status, TEvTablet::TEvTabletDead::EReason reason) { return new TTxUpdateTabletStatus(tabletId, local, generation, followerId, status, reason, this); diff --git a/ydb/core/mind/hive/ya.make b/ydb/core/mind/hive/ya.make index d51a5d815d7..171f26f1b5f 100644 --- a/ydb/core/mind/hive/ya.make +++ b/ydb/core/mind/hive/ya.make @@ -25,17 +25,17 @@ SRCS( hive_schema.h hive_statics.cpp hive_transactions.h - leader_tablet_info.cpp - leader_tablet_info.h + leader_tablet_info.cpp + leader_tablet_info.h metrics.h monitoring.cpp node_info.cpp node_info.h sequencer.cpp sequencer.h - follower_group.h - follower_tablet_info.cpp - follower_tablet_info.h + follower_group.h + follower_tablet_info.cpp + follower_tablet_info.h storage_group_info.cpp storage_group_info.h storage_pool_info.cpp diff --git a/ydb/core/mind/local.cpp b/ydb/core/mind/local.cpp index 63e8c7945ed..09fc15f76dd 100644 --- a/ydb/core/mind/local.cpp +++ b/ydb/core/mind/local.cpp @@ -48,14 +48,14 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { ui32 Generation; TTabletTypes::EType TabletType; NKikimrLocal::EBootMode BootMode; - ui32 FollowerId; + ui32 FollowerId; TTablet() : Tablet() , Generation(0) , TabletType() - , BootMode(NKikimrLocal::EBootMode::BOOT_MODE_LEADER) - , FollowerId(0) + , BootMode(NKikimrLocal::EBootMode::BOOT_MODE_LEADER) + , FollowerId(0) {} }; @@ -88,9 +88,9 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { TActorId BootQueue; ui32 HiveGeneration; - TActorId KnownHiveLeader; + TActorId KnownHiveLeader; - using TTabletId = std::pair<ui64, ui32>; // <TTabletId, TFollowerId> + using TTabletId = std::pair<ui64, ui32>; // <TTabletId, TFollowerId> TInstant StartTime; std::unordered_map<TTabletId, TTabletEntry> InbootTablets; std::unordered_map<TTabletId, TOnlineTabletEntry> OnlineTablets; @@ -113,12 +113,12 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { TIntrusivePtr<TDrainProgress> LastDrainRequest; NKikimrTabletBase::TMetrics ResourceLimit; - TResourceProfilesPtr ResourceProfiles; - TSharedQuotaPtr TxCacheQuota; + TResourceProfilesPtr ResourceProfiles; + TSharedQuotaPtr TxCacheQuota; NMonitoring::TDynamicCounterPtr Counters; NMonitoring::TDynamicCounters::TCounterPtr CounterStartAttempts; - NMonitoring::TDynamicCounters::TCounterPtr CounterFollowerAttempts; + NMonitoring::TDynamicCounters::TCounterPtr CounterFollowerAttempts; NMonitoring::TDynamicCounters::TCounterPtr CounterRestored; NMonitoring::TDynamicCounters::TCounterPtr CounterCancelLocked; NMonitoring::TDynamicCounters::TCounterPtr CounterCancelSSTimeout; @@ -230,7 +230,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { if (!isFilteringNeeded || tablet.second.TabletType == tabletType) { auto *info = result->Record.AddTabletInfo(); info->SetTabletId(tablet.first.first); - info->SetFollowerId(tablet.first.second); + info->SetFollowerId(tablet.first.second); info->SetTabletType(tablet.second.TabletType); info->SetBootMode(tablet.second.BootMode); ++tabletIdx; @@ -346,7 +346,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { for (const auto& pr : InbootTablets) { auto* tablet = eventSyncTablets->Record.AddInbootTablets(); tablet->SetTabletId(pr.first.first); - tablet->SetFollowerId(pr.first.second); + tablet->SetFollowerId(pr.first.second); tablet->SetGeneration(pr.second.Generation); tablet->SetBootMode(pr.second.BootMode); @@ -355,7 +355,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { for (const auto& pr : OnlineTablets) { auto* tablet = eventSyncTablets->Record.AddOnlineTablets(); tablet->SetTabletId(pr.first.first); - tablet->SetFollowerId(pr.first.second); + tablet->SetFollowerId(pr.first.second); tablet->SetGeneration(pr.second.Generation); tablet->SetBootMode(pr.second.BootMode); @@ -380,10 +380,10 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { NKikimrLocal::TEvBootTablet &record = ev->Get()->Record; TIntrusivePtr<TTabletStorageInfo> info(TabletStorageInfoFromProto(record.GetInfo())); info->HiveId = HiveId; - TTabletId tabletId(info->TabletID, record.GetFollowerId()); + TTabletId tabletId(info->TabletID, record.GetFollowerId()); LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar::Handle TEvLocal::TEvBootTablet tabletId:" << tabletId - << (record.HasBootMode() && record.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER ? ".Follower" : ".Leader") + << (record.HasBootMode() && record.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER ? ".Follower" : ".Leader") << " storage:" << info->ToString()); Y_VERIFY(!info->Channels.empty() && !info->Channels[0].History.empty()); @@ -416,22 +416,22 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { { auto it = OnlineTablets.find(tabletId); if (it != OnlineTablets.end()) { - if (it->second.BootMode == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER - && record.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_LEADER) { - // promote to leader - it->second.BootMode = NKikimrLocal::EBootMode::BOOT_MODE_LEADER; + if (it->second.BootMode == NKikimrLocal::EBootMode::BOOT_MODE_FOLLOWER + && record.GetBootMode() == NKikimrLocal::EBootMode::BOOT_MODE_LEADER) { + // promote to leader + it->second.BootMode = NKikimrLocal::EBootMode::BOOT_MODE_LEADER; it->second.Generation = suggestedGen; - tabletId.second = 0; // FollowerId = 0 + tabletId.second = 0; // FollowerId = 0 TTabletEntry &entry = InbootTablets[tabletId]; entry = it->second; entry.From = ctx.Now(); - entry.BootMode = NKikimrLocal::EBootMode::BOOT_MODE_LEADER; + entry.BootMode = NKikimrLocal::EBootMode::BOOT_MODE_LEADER; entry.Generation = suggestedGen; - ctx.Send(entry.Tablet, new TEvTablet::TEvPromoteToLeader(suggestedGen, info)); - MarkDeadTablet(it->first, 0, TEvLocal::TEvTabletStatus::StatusSupersededByLeader, TEvTablet::TEvTabletDead::ReasonError, ctx); + ctx.Send(entry.Tablet, new TEvTablet::TEvPromoteToLeader(suggestedGen, info)); + MarkDeadTablet(it->first, 0, TEvLocal::TEvTabletStatus::StatusSupersededByLeader, TEvTablet::TEvTabletDead::ReasonError, ctx); OnlineTablets.erase(it); LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, - "TLocalNodeRegistrar::Handle TEvLocal::TEvBootTablet follower tablet " << tabletId << " promoted to leader"); + "TLocalNodeRegistrar::Handle TEvLocal::TEvBootTablet follower tablet " << tabletId << " promoted to leader"); return; } ctx.Send(it->second.Tablet, new TEvTablet::TEvTabletStop(tabletId.first, TEvTablet::TEvTabletStop::ReasonStop)); @@ -446,13 +446,13 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { TTabletSetupInfo *setupInfo = it->second.SetupInfo.Get(); switch (record.GetBootMode()) { - case NKikimrLocal::BOOT_MODE_LEADER: + case NKikimrLocal::BOOT_MODE_LEADER: entry.Tablet = setupInfo->Tablet(info.Get(), ctx.SelfID, ctx, suggestedGen, ResourceProfiles, TxCacheQuota); CounterStartAttempts->Inc(); break; - case NKikimrLocal::BOOT_MODE_FOLLOWER: - entry.Tablet = setupInfo->Follower(info.Get(), ctx.SelfID, ctx, tabletId.second, ResourceProfiles, TxCacheQuota); - CounterFollowerAttempts->Inc(); + case NKikimrLocal::BOOT_MODE_FOLLOWER: + entry.Tablet = setupInfo->Follower(info.Get(), ctx.SelfID, ctx, tabletId.second, ResourceProfiles, TxCacheQuota); + CounterFollowerAttempts->Inc(); break; } @@ -463,7 +463,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar::Handle TEvLocal::TEvBootTablet tabletId:" << tabletId << " tablet entry created"); - if (record.GetBootMode() == NKikimrLocal::BOOT_MODE_FOLLOWER) { + if (record.GetBootMode() == NKikimrLocal::BOOT_MODE_FOLLOWER) { MarkRunningTablet(tabletId, suggestedGen, ctx); } } @@ -471,7 +471,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void Handle(TEvLocal::TEvStopTablet::TPtr &ev, const TActorContext &ctx) { const NKikimrLocal::TEvStopTablet &record = ev->Get()->Record; Y_VERIFY(record.HasTabletId()); - TTabletId tabletId(record.GetTabletId(), record.GetFollowerId()); + TTabletId tabletId(record.GetTabletId(), record.GetFollowerId()); LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar: Handle TEvStopTablet TabletId:" << tabletId); auto onlineTabletIt = OnlineTablets.find(tabletId); @@ -490,13 +490,13 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void Handle(TEvLocal::TEvDeadTabletAck::TPtr &ev, const TActorContext &ctx) { const NKikimrLocal::TEvDeadTabletAck &record = ev->Get()->Record; Y_VERIFY(record.HasTabletId()); - TTabletId tabletId(record.GetTabletId(), record.GetFollowerId()); + TTabletId tabletId(record.GetTabletId(), record.GetFollowerId()); LOG_DEBUG_S(ctx, NKikimrServices::LOCAL, "TLocalNodeRegistrar: Handle TEvDeadTabletAck TabletId:" << tabletId); } void Handle(TEvLocal::TEvTabletMetrics::TPtr& ev, const TActorContext& ctx) { TEvLocal::TEvTabletMetrics* msg = ev->Get(); - const TTabletId tabletId(msg->TabletId, msg->FollowerId); + const TTabletId tabletId(msg->TabletId, msg->FollowerId); auto it = OnlineTablets.find(tabletId); if (it != OnlineTablets.end()) { const auto& metrics(msg->ResourceValues); @@ -590,7 +590,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { TOnlineTabletEntry& tablet = it->second; auto& metrics = *record.AddTabletMetrics(); metrics.SetTabletID(tabletId.first); - metrics.SetFollowerID(tabletId.second); + metrics.SetFollowerID(tabletId.second); metrics.MutableResourceUsage()->MergeFrom(tablet.ResourceValues); } } @@ -598,9 +598,9 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void Handle(TEvLocal::TEvTabletMetricsAck::TPtr& ev, const TActorContext& ctx) { TEvLocal::TEvTabletMetricsAck* msg = ev->Get(); auto size = msg->Record.TabletIdSize(); - Y_VERIFY(msg->Record.FollowerIdSize() == size); + Y_VERIFY(msg->Record.FollowerIdSize() == size); for (decltype(size) i = 0; i < size; ++i) { - TTabletId tabletId(msg->Record.GetTabletId(i), msg->Record.GetFollowerId(i)); + TTabletId tabletId(msg->Record.GetTabletId(i), msg->Record.GetFollowerId(i)); auto uit = UpdatedTabletMetrics.find(tabletId); if (uit != UpdatedTabletMetrics.end() && --uit->second == 0) { UpdatedTabletMetrics.erase(uit); @@ -688,7 +688,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> { void Handle(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx) { TEvTablet::TEvRestored *msg = ev->Get(); - if (msg->Follower) // ignore follower notifications + if (msg->Follower) // ignore follower notifications return; CounterRestored->Inc(); // always update counter for every tablet, even non-actual one. it's about tracking not resource allocation @@ -879,7 +879,7 @@ public: Counters->GetCounter("TxDataCacheSize")); CounterStartAttempts = Counters->GetCounter("Local_StartAttempts", true); - CounterFollowerAttempts = Counters->GetCounter("Local_FollowerAttempts", true); + CounterFollowerAttempts = Counters->GetCounter("Local_FollowerAttempts", true); CounterRestored = Counters->GetCounter("Local_Restored", true); CounterCancelLocked = Counters->GetCounter("Local_CancelLocked", true); CounterCancelSSTimeout = Counters->GetCounter("Local_CancelSSTimeout", true); diff --git a/ydb/core/mind/local.h b/ydb/core/mind/local.h index 743e51d1fc7..05c9bdc48eb 100644 --- a/ydb/core/mind/local.h +++ b/ydb/core/mind/local.h @@ -155,17 +155,17 @@ struct TEvLocal { TEvBootTablet() {} - TEvBootTablet(const TTabletStorageInfo &info, ui32 followerId, ui32 suggestedGeneration) { + TEvBootTablet(const TTabletStorageInfo &info, ui32 followerId, ui32 suggestedGeneration) { TabletStorageInfoToProto(info, Record.MutableInfo()); Record.SetSuggestedGeneration(suggestedGeneration); - Record.SetBootMode(NKikimrLocal::BOOT_MODE_LEADER); - Record.SetFollowerId(followerId); + Record.SetBootMode(NKikimrLocal::BOOT_MODE_LEADER); + Record.SetFollowerId(followerId); } - TEvBootTablet(const TTabletStorageInfo &info, ui32 followerId) { + TEvBootTablet(const TTabletStorageInfo &info, ui32 followerId) { TabletStorageInfoToProto(info, Record.MutableInfo()); - Record.SetBootMode(NKikimrLocal::BOOT_MODE_FOLLOWER); - Record.SetFollowerId(followerId); + Record.SetBootMode(NKikimrLocal::BOOT_MODE_FOLLOWER); + Record.SetFollowerId(followerId); } }; @@ -176,7 +176,7 @@ struct TEvLocal { TEvStopTablet(std::pair<ui64, ui32> tabletId) { Record.SetTabletId(tabletId.first); - Record.SetFollowerId(tabletId.second); + Record.SetFollowerId(tabletId.second); } }; @@ -187,7 +187,7 @@ struct TEvLocal { TEvDeadTabletAck(std::pair<ui64, ui32> tabletId, ui32 generation) { Record.SetTabletId(tabletId.first); - Record.SetFollowerId(tabletId.second); + Record.SetFollowerId(tabletId.second); Record.SetGeneration(generation); } }; @@ -201,7 +201,7 @@ struct TEvLocal { StatusBSWriteError, StatusFailed, StatusBootQueueUnknown, - StatusSupersededByLeader, + StatusSupersededByLeader, }; TEvTabletStatus() @@ -218,7 +218,7 @@ struct TEvLocal { TEvTabletStatus(EStatus status, std::pair<ui64, ui32> tabletId, ui32 generation) { Record.SetStatus(status); Record.SetTabletID(tabletId.first); - Record.SetFollowerId(tabletId.second); + Record.SetFollowerId(tabletId.second); Record.SetGeneration(generation); } }; @@ -249,12 +249,12 @@ struct TEvLocal { struct TEvTabletMetrics : public TEventLocal<TEvTabletMetrics, EvTabletMetrics> { ui64 TabletId; - ui32 FollowerId; + ui32 FollowerId; NKikimrTabletBase::TMetrics ResourceValues; - TEvTabletMetrics(ui64 tabletId, ui32 followerId, const NKikimrTabletBase::TMetrics& resourceValues) + TEvTabletMetrics(ui64 tabletId, ui32 followerId, const NKikimrTabletBase::TMetrics& resourceValues) : TabletId(tabletId) - , FollowerId(followerId) + , FollowerId(followerId) , ResourceValues(resourceValues) {} }; diff --git a/ydb/core/mind/node_broker_ut.cpp b/ydb/core/mind/node_broker_ut.cpp index 5b50a1c0b4a..0d9498ddcdd 100644 --- a/ydb/core/mind/node_broker_ut.cpp +++ b/ydb/core/mind/node_broker_ut.cpp @@ -156,7 +156,7 @@ void SetupServices(TTestActorRuntime &runtime, runtime.DispatchEvents(options); } - auto aid = CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeNodeBrokerID(0), TTabletTypes::NODE_BROKER), &CreateNodeBroker); + auto aid = CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeNodeBrokerID(0), TTabletTypes::NODE_BROKER), &CreateNodeBroker); runtime.EnableScheduleForActor(aid, true); } diff --git a/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp b/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp index b754e59909b..011f03d93cd 100644 --- a/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp +++ b/ydb/core/mind/ut_fat/blobstorage_node_warden_ut_fat.cpp @@ -229,7 +229,7 @@ void SetupServices(TTestActorRuntime &runtime) { } ui64 defaultStateStorageGroup = runtime.GetAppData(0).DomainsInfo->GetDefaultStateStorageGroup(DOMAIN_ID); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(defaultStateStorageGroup), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(defaultStateStorageGroup), TTabletTypes::FLAT_BS_CONTROLLER, TBlobStorageGroupType::ErasureMirror3, groupId), &CreateFlatBsController); } diff --git a/ydb/core/node_whiteboard/node_whiteboard.h b/ydb/core/node_whiteboard/node_whiteboard.h index ebfccdb973e..cdf7601807c 100644 --- a/ydb/core/node_whiteboard/node_whiteboard.h +++ b/ydb/core/node_whiteboard/node_whiteboard.h @@ -14,7 +14,7 @@ namespace NKikimr { using TTabletId = ui64; -using TFollowerId = ui32; +using TFollowerId = ui32; using TNodeId = ui32; namespace NNodeWhiteboard { @@ -65,13 +65,13 @@ struct TEvWhiteboard{ struct TEvTabletStateUpdate : TEventPB<TEvTabletStateUpdate, NKikimrWhiteboard::TTabletStateInfo, EvTabletStateUpdate> { TEvTabletStateUpdate() = default; - TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, const TIntrusivePtr<TTabletStorageInfo>& storageInfo, ui32 generation, bool leader) { + TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, const TIntrusivePtr<TTabletStorageInfo>& storageInfo, ui32 generation, bool leader) { Record.SetTabletId(tabletId); - Record.SetFollowerId(followerId); + Record.SetFollowerId(followerId); Record.SetType(storageInfo->TabletType); Record.SetState(state); Record.SetGeneration(generation); - Record.SetLeader(leader); + Record.SetLeader(leader); Record.MutableChannelGroupIDs()->Resize(storageInfo->Channels.size(), 0); for (const auto& channel : storageInfo->Channels) { const auto* latestEntry = channel.LatestEntry(); @@ -86,19 +86,19 @@ struct TEvWhiteboard{ } } - TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, ui32 generation) { + TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, ui32 generation) { Record.SetTabletId(tabletId); - Record.SetFollowerId(followerId); + Record.SetFollowerId(followerId); Record.SetState(state); Record.SetGeneration(generation); } - TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, ui32 generation, bool leader) { + TEvTabletStateUpdate(TTabletId tabletId, TFollowerId followerId, NKikimrWhiteboard::TTabletStateInfo::ETabletState state, ui32 generation, bool leader) { Record.SetTabletId(tabletId); - Record.SetFollowerId(followerId); + Record.SetFollowerId(followerId); Record.SetState(state); Record.SetGeneration(generation); - Record.SetLeader(leader); + Record.SetLeader(leader); } TEvTabletStateUpdate(TTabletId tabletId, ui32 userState) { diff --git a/ydb/core/persqueue/pq_ut.h b/ydb/core/persqueue/pq_ut.h index 6a6d7e158ff..3db93bc1047 100644 --- a/ydb/core/persqueue/pq_ut.h +++ b/ydb/core/persqueue/pq_ut.h @@ -140,16 +140,16 @@ struct TTestContext { SetupLogging(*Runtime); SetupTabletServices(*Runtime); setup(*Runtime); - CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreatePersQueue); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); Runtime->DispatchEvents(options); - CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(BalancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), + CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(BalancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), &CreatePersQueueReadBalancer); options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -167,16 +167,16 @@ struct TTestContext { Runtime->SetScheduledLimit(200); SetupLogging(*Runtime); SetupTabletServices(*Runtime); - CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreatePersQueue); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); Runtime->DispatchEvents(options); - CreateTestBootstrapper(*Runtime, - CreateTestTabletInfo(BalancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), + CreateTestBootstrapper(*Runtime, + CreateTestTabletInfo(BalancerTabletId, TTabletTypes::PERSQUEUE_READ_BALANCER, TErasureType::ErasureNone), &CreatePersQueueReadBalancer); options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -333,7 +333,7 @@ void BalancerPrepare(const TString topic, const TVector<std::pair<ui32, std::pai //TODO: check state TTestActorRuntime& runtime = *tc.Runtime; - ForwardToTablet(runtime, tc.BalancerTabletId, tc.Edge, new TEvents::TEvPoisonPill()); + ForwardToTablet(runtime, tc.BalancerTabletId, tc.Edge, new TEvents::TEvPoisonPill()); TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvRestored, 2)); runtime.DispatchEvents(rebootOptions); @@ -375,7 +375,7 @@ void PQGetPartInfo(ui64 startOffset, ui64 endOffset, TTestContext& tc) { void RestartTablet(TTestContext& tc) { TTestActorRuntime& runtime = *tc.Runtime; - ForwardToTablet(runtime, tc.TabletId, tc.Edge, new TEvents::TEvPoisonPill()); + ForwardToTablet(runtime, tc.TabletId, tc.Edge, new TEvents::TEvPoisonPill()); TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvRestored, 2)); runtime.DispatchEvents(rebootOptions); diff --git a/ydb/core/persqueue/read_balancer.h b/ydb/core/persqueue/read_balancer.h index 674a61765b3..6a07edcb784 100644 --- a/ydb/core/persqueue/read_balancer.h +++ b/ydb/core/persqueue/read_balancer.h @@ -195,8 +195,8 @@ class TPersQueueReadBalancer : public TActor<TPersQueueReadBalancer>, public TTa void OnActivateExecutor(const TActorContext &ctx) override { ResourceMetrics = Executor()->GetResourceMetrics(); Become(&TThis::StateWork); - if (Executor()->GetStats().IsFollower) - Y_FAIL("is follower works well with Balancer?"); + if (Executor()->GetStats().IsFollower) + Y_FAIL("is follower works well with Balancer?"); else Execute(new TTxPreInit(this), ctx); } diff --git a/ydb/core/protos/base.proto b/ydb/core/protos/base.proto index 3b143a2ed47..1f7e855e091 100644 --- a/ydb/core/protos/base.proto +++ b/ydb/core/protos/base.proto @@ -32,11 +32,11 @@ message TLogoBlobID { optional fixed64 RawX2 = 2; optional fixed64 RawX3 = 3; }; - -message TRowVersion { - optional uint64 Step = 1; - optional uint64 TxId = 2; -} + +message TRowVersion { + optional uint64 Step = 1; + optional uint64 TxId = 2; +} message TPathID { optional fixed64 OwnerId = 1; diff --git a/ydb/core/protos/blobstorage.proto b/ydb/core/protos/blobstorage.proto index 02186eadda5..a08ccbf865c 100644 --- a/ydb/core/protos/blobstorage.proto +++ b/ydb/core/protos/blobstorage.proto @@ -179,10 +179,10 @@ message TGroupInfo { optional EEntityStatus EntityStatus = 5; optional uint32 EncryptionMode = 6 [default = 0]; optional uint32 LifeCyclePhase = 7 [default = 0]; - optional bytes MainKeyId = 8 [default = ""]; + optional bytes MainKeyId = 8 [default = ""]; optional bytes EncryptedGroupKey = 9 [default = ""]; optional uint64 GroupKeyNonce = 10 [default = 0]; - optional uint64 MainKeyVersion = 11 [default = 0]; + optional uint64 MainKeyVersion = 11 [default = 0]; optional NActorsInterconnect.TScopeId AcceptedScope = 12; // some kind of ACL for scopes; empty = no restrictions optional string StoragePoolName = 13; optional EPDiskType DeviceType = 14; @@ -1072,9 +1072,9 @@ message TEvControllerProposeGroupKey { optional uint32 NodeId = 1 [default = 0]; optional uint32 GroupId = 2 [default = 0]; optional uint32 LifeCyclePhase = 3 [default = 0]; - optional bytes MainKeyId = 4 [default = ""]; + optional bytes MainKeyId = 4 [default = ""]; optional bytes EncryptedGroupKey = 5 [default = ""]; - optional uint64 MainKeyVersion = 6 [default = 0]; + optional uint64 MainKeyVersion = 6 [default = 0]; optional uint64 GroupKeyNonce = 7 [default = 0]; } diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto index 625b57bc34a..d64169d4fc0 100644 --- a/ydb/core/protos/config.proto +++ b/ydb/core/protos/config.proto @@ -334,7 +334,7 @@ message TBootstrap { optional NKikimrTabletBase.TTabletStorageInfo Info = 3; optional bool StandBy = 4; optional uint64 WatchThreshold = 5; - optional bool StartFollowers = 6; + optional bool StartFollowers = 6; optional bool AllowDynamicConfiguration = 7 [default = false]; } @@ -634,7 +634,7 @@ message TFeatureFlags { optional bool CompileMinikqlWithVersion = 19 [default = true]; // deprecated: always true optional bool ReadTableWithSnapshot = 20 [default = true]; optional bool ImportantTabletsUseSystemPool = 21 [default = true]; - optional bool EnableOfflineSlaves = 22 [default = true]; // deprecated: always true + optional bool EnableOfflineSlaves = 22 [default = true]; // deprecated: always true optional bool CheckDatabaseAccessPermission = 23 [default = false]; optional bool AllowOnlineIndexBuild = 24 [default = true]; // deprecated: always true optional bool EnablePersistentQueryStats = 25 [default = false]; @@ -659,13 +659,13 @@ message TFeatureFlags { optional bool EnableOlapSchemaOperations = 44 [default = false]; optional bool EnableVPatch = 45 [default = false]; optional bool EnableMvccSnapshotReads = 46 [default = false]; - optional Tribool EnableMvcc = 47 [default = VALUE_TRUE]; + optional Tribool EnableMvcc = 47 [default = VALUE_TRUE]; optional bool EnableSchemeTransactionsAtSchemeShard = 48 [default = false]; optional bool EnableArrowFormatAtDatashard = 49 [default = false]; optional bool Enable3x3RequestsForMirror3DCMinLatencyPut = 50 [default = false]; - optional bool EnableBackgroundCompaction = 51 [default = true]; + optional bool EnableBackgroundCompaction = 51 [default = true]; optional bool EnableArrowFormatInChannels = 52 [default = false]; - optional bool EnableBackgroundCompactionServerless = 53 [default = false]; + optional bool EnableBackgroundCompactionServerless = 53 [default = false]; optional bool EnableNotNullColumns = 54 [default = false]; optional bool EnableTtlOnAsyncIndexedTables = 55 [default = false]; optional bool EnableBulkUpsertToAsyncIndexedTables = 56 [default = false]; @@ -692,8 +692,8 @@ message TSqsConfig { optional THttpServerConfig HttpServerConfig = 4; // Turn on queue leaders option - optional bool EnableQueueMaster = 6 [default = true]; // TODO: remove - optional bool EnableQueueLeader = 68 [default = true]; + optional bool EnableQueueMaster = 6 [default = true]; // TODO: remove + optional bool EnableQueueLeader = 68 [default = true]; // Time to live for queue attributes cache optional uint64 QueueAttributesCacheTimeMs = 8 [default = 60000]; @@ -722,13 +722,13 @@ message TSqsConfig { repeated string MeteringCloudNetCidr = 53; repeated string MeteringYandexNetCidr = 54; - // TODO: remove both + // TODO: remove both optional uint32 MastersDescriberUpdateTimeMs = 17 [default = 10000]; optional uint32 MasterConnectTimeoutMs = 18 [default = 10000]; - optional uint32 LeadersDescriberUpdateTimeMs = 69 [default = 10000]; - optional uint32 LeaderConnectTimeoutMs = 70 [default = 10000]; - + optional uint32 LeadersDescriberUpdateTimeMs = 69 [default = 10000]; + optional uint32 LeaderConnectTimeoutMs = 70 [default = 10000]; + optional uint64 MinMessageRetentionPeriodMs = 19 [default = 60000]; // DB requests retries @@ -913,8 +913,8 @@ message TStoragePolicy { message TReplicationPolicy { optional string Name = 1; - optional uint64 FollowerCount = 2; - optional bool AllowFollowerPromotion = 3 [default = true]; + optional uint64 FollowerCount = 2; + optional bool AllowFollowerPromotion = 3 [default = true]; optional bool CrossDataCenter = 4; } @@ -1297,19 +1297,19 @@ message TDataShardConfig { optional uint64 CleanupSnapshotPeriod = 10 [default = 15000]; // milliseconds } -message TCompactionConfig { - message TBackgroundCompactionConfig { - optional double Rate = 1 [default = 1]; // 1 compaction / s - optional uint64 InflightLimit = 2 [default = 1]; - optional uint64 TimeoutSeconds = 3 [default = 600]; - optional uint64 WakeupIntervalSeconds = 4 [default = 60]; - optional uint64 MinCompactionRepeatDelay = 5 [default = 600]; - optional uint32 SearchHeightThreshold = 6 [default = 10]; - } - - optional TBackgroundCompactionConfig BackgroundCompactionConfig = 1; -} - +message TCompactionConfig { + message TBackgroundCompactionConfig { + optional double Rate = 1 [default = 1]; // 1 compaction / s + optional uint64 InflightLimit = 2 [default = 1]; + optional uint64 TimeoutSeconds = 3 [default = 600]; + optional uint64 WakeupIntervalSeconds = 4 [default = 60]; + optional uint64 MinCompactionRepeatDelay = 5 [default = 600]; + optional uint32 SearchHeightThreshold = 6 [default = 10]; + } + + optional TBackgroundCompactionConfig BackgroundCompactionConfig = 1; +} + // This message is used to upload custom service configs // to CMS. Config name is used to identify owner and // data format. @@ -1378,7 +1378,7 @@ message TAppConfig { optional THiveConfig HiveConfig = 46; optional TDataShardConfig DataShardConfig = 49; optional NYq.NConfig.TConfig YandexQueryConfig = 50; - optional TCompactionConfig CompactionConfig = 52; + optional TCompactionConfig CompactionConfig = 52; repeated TNamedConfig NamedConfigs = 100; optional string ClusterYamlConfig = 101; diff --git a/ydb/core/protos/console_config.proto b/ydb/core/protos/console_config.proto index e2e28eb81d0..d5a32d05c66 100644 --- a/ydb/core/protos/console_config.proto +++ b/ydb/core/protos/console_config.proto @@ -109,9 +109,9 @@ message TConfigItem { MeteringConfigItem = 45; HiveConfigItem = 46; DataShardConfigItem = 49; - YandexQueryConfigItem = 50; - PDiskKeyConfigItem = 51; - CompactionConfigItem = 52; + YandexQueryConfigItem = 50; + PDiskKeyConfigItem = 51; + CompactionConfigItem = 52; NamedConfigsItem = 100; ClusterYamlConfigItem = 101; diff --git a/ydb/core/protos/counters_datashard.proto b/ydb/core/protos/counters_datashard.proto index a223444069f..956a1369378 100644 --- a/ydb/core/protos/counters_datashard.proto +++ b/ydb/core/protos/counters_datashard.proto @@ -103,11 +103,11 @@ enum ECumulativeCounters { COUNTER_TX_NOT_ENOUGH_MEMORY_2 = 77 [(CounterOpts) = {Name: "TxNotEnoughMemory2"}]; COUNTER_TX_NOT_ENOUGH_MEMORY_3 = 78 [(CounterOpts) = {Name: "TxNotEnoughMemory3"}]; COUNTER_TX_NOT_ENOUGH_MEMORY_4 = 79 [(CounterOpts) = {Name: "TxNotEnoughMemory4"}]; - COUNTER_TX_TABLET_NOT_READY = 80 [(CounterOpts) = {Name: "TxTabletNotReady"}]; - COUNTER_TX_BACKGROUND_COMPACTION = 81 [(CounterOpts) = {Name: "TxCompactTable"}]; - COUNTER_TX_BACKGROUND_COMPACTION_NOT_NEEDED = 82 [(CounterOpts) = {Name: "TxCompactTableNotNeeded"}]; - COUNTER_TX_BACKGROUND_COMPACTION_FAILED_BORROWED = 83 [(CounterOpts) = {Name: "TxCompactTableFailedBorrowed"}]; - COUNTER_TX_BACKGROUND_COMPACTION_FAILED_START = 84 [(CounterOpts) = {Name: "TxCompactTableFailedStart"}]; + COUNTER_TX_TABLET_NOT_READY = 80 [(CounterOpts) = {Name: "TxTabletNotReady"}]; + COUNTER_TX_BACKGROUND_COMPACTION = 81 [(CounterOpts) = {Name: "TxCompactTable"}]; + COUNTER_TX_BACKGROUND_COMPACTION_NOT_NEEDED = 82 [(CounterOpts) = {Name: "TxCompactTableNotNeeded"}]; + COUNTER_TX_BACKGROUND_COMPACTION_FAILED_BORROWED = 83 [(CounterOpts) = {Name: "TxCompactTableFailedBorrowed"}]; + COUNTER_TX_BACKGROUND_COMPACTION_FAILED_START = 84 [(CounterOpts) = {Name: "TxCompactTableFailedStart"}]; } enum EPercentileCounters { @@ -308,41 +308,41 @@ enum EPercentileCounters { Ranges: { Value: 15000 Name: "15000"}, Ranges: { Value: 30000 Name: "30000"} }]; - - COUNTER_SHARDS_WITH_SEARCH_HEIGHT = 18 [(CounterOpts) = {Name: "ShardsWithSearchHeight", - Integral: true, - Ranges: { Value: 0 Name: "0"}, - Ranges: { Value: 1 Name: "1"}, - Ranges: { Value: 2 Name: "2"}, - Ranges: { Value: 3 Name: "3"}, - Ranges: { Value: 4 Name: "4"}, - Ranges: { Value: 5 Name: "5"}, - Ranges: { Value: 6 Name: "6"}, - Ranges: { Value: 7 Name: "7"}, - Ranges: { Value: 8 Name: "8"}, - Ranges: { Value: 9 Name: "9"}, - Ranges: { Value: 10 Name: "10"}, - Ranges: { Value: 11 Name: "11"}, - Ranges: { Value: 12 Name: "12"}, - Ranges: { Value: 13 Name: "13"}, - Ranges: { Value: 14 Name: "14"}, - Ranges: { Value: 15 Name: "15"}, - Ranges: { Value: 20 Name: "20"}, - }]; - - // buckets are hours since last full compaction ts, i.e. number of shards - // compacted within 1 hour or within 24 hours - COUNTER_SHARDS_WITH_FULL_COMPACTION = 19 [(CounterOpts) = {Name: "ShardsFullCompactionAgeHours", - Integral: true, - Ranges: { Value: 0 Name: "0"}, - Ranges: { Value: 1 Name: "1"}, - Ranges: { Value: 6 Name: "6"}, - Ranges: { Value: 12 Name: "12"}, - Ranges: { Value: 24 Name: "24"}, - Ranges: { Value: 48 Name: "48"}, - Ranges: { Value: 72 Name: "72"}, - Ranges: { Value: 168 Name: "inf"}, - }]; + + COUNTER_SHARDS_WITH_SEARCH_HEIGHT = 18 [(CounterOpts) = {Name: "ShardsWithSearchHeight", + Integral: true, + Ranges: { Value: 0 Name: "0"}, + Ranges: { Value: 1 Name: "1"}, + Ranges: { Value: 2 Name: "2"}, + Ranges: { Value: 3 Name: "3"}, + Ranges: { Value: 4 Name: "4"}, + Ranges: { Value: 5 Name: "5"}, + Ranges: { Value: 6 Name: "6"}, + Ranges: { Value: 7 Name: "7"}, + Ranges: { Value: 8 Name: "8"}, + Ranges: { Value: 9 Name: "9"}, + Ranges: { Value: 10 Name: "10"}, + Ranges: { Value: 11 Name: "11"}, + Ranges: { Value: 12 Name: "12"}, + Ranges: { Value: 13 Name: "13"}, + Ranges: { Value: 14 Name: "14"}, + Ranges: { Value: 15 Name: "15"}, + Ranges: { Value: 20 Name: "20"}, + }]; + + // buckets are hours since last full compaction ts, i.e. number of shards + // compacted within 1 hour or within 24 hours + COUNTER_SHARDS_WITH_FULL_COMPACTION = 19 [(CounterOpts) = {Name: "ShardsFullCompactionAgeHours", + Integral: true, + Ranges: { Value: 0 Name: "0"}, + Ranges: { Value: 1 Name: "1"}, + Ranges: { Value: 6 Name: "6"}, + Ranges: { Value: 12 Name: "12"}, + Ranges: { Value: 24 Name: "24"}, + Ranges: { Value: 48 Name: "48"}, + Ranges: { Value: 72 Name: "72"}, + Ranges: { Value: 168 Name: "inf"}, + }]; } enum ETxTypes { diff --git a/ydb/core/protos/counters_schemeshard.proto b/ydb/core/protos/counters_schemeshard.proto index bc7ada3cffa..a839915c98f 100644 --- a/ydb/core/protos/counters_schemeshard.proto +++ b/ydb/core/protos/counters_schemeshard.proto @@ -136,8 +136,8 @@ enum ESimpleCounters { COUNTER_STREAM_SHARDS_COUNT = 112 [(CounterOpts) = {Name: "StreamShardsCount"}]; COUNTER_STREAM_SHARDS_QUOTA = 113 [(CounterOpts) = {Name: "StreamShardsQuota"}]; - - COUNTER_BACKGROUND_COMPACTION_QUEUE_SIZE = 114 [(CounterOpts) = {Name: "BackgroundCompactionQueueSize"}]; + + COUNTER_BACKGROUND_COMPACTION_QUEUE_SIZE = 114 [(CounterOpts) = {Name: "BackgroundCompactionQueueSize"}]; COUNTER_STREAM_RESERVED_THROUGHPUT = 115 [(CounterOpts) = {Name: "StreamReservedThroughput"}]; COUNTER_STREAM_RESERVED_STORAGE = 116 [(CounterOpts) = {Name: "StreamReservedStorage"}]; @@ -227,10 +227,10 @@ enum ECumulativeCounters { COUNTER_FINISHED_OPS_TxCreateSequence = 64 [(CounterOpts) = {Name: "FinishedOps/CreateSequence"}]; COUNTER_FINISHED_OPS_TxAlterSequence = 65 [(CounterOpts) = {Name: "FinishedOps/AlterSequence"}]; COUNTER_FINISHED_OPS_TxDropSequence = 66 [(CounterOpts) = {Name: "FinishedOps/DropSequence"}]; - - COUNTER_BACKGROUND_COMPACTION_FAILED = 67 [(CounterOpts) = {Name: "BackgroundCompactionFailed"}]; - COUNTER_BACKGROUND_COMPACTION_OK = 68 [(CounterOpts) = {Name: "BackgroundCompactionOK"}]; - COUNTER_BACKGROUND_COMPACTION_TIMEOUT = 69 [(CounterOpts) = {Name: "BackgroundCompactionTimeout"}]; + + COUNTER_BACKGROUND_COMPACTION_FAILED = 67 [(CounterOpts) = {Name: "BackgroundCompactionFailed"}]; + COUNTER_BACKGROUND_COMPACTION_OK = 68 [(CounterOpts) = {Name: "BackgroundCompactionOK"}]; + COUNTER_BACKGROUND_COMPACTION_TIMEOUT = 69 [(CounterOpts) = {Name: "BackgroundCompactionTimeout"}]; COUNTER_FINISHED_OPS_TxCreateReplication = 70 [(CounterOpts) = {Name: "FinishedOps/CreateReplication"}]; COUNTER_FINISHED_OPS_TxAlterReplication = 71 [(CounterOpts) = {Name: "FinishedOps/AlterReplication"}]; @@ -239,27 +239,27 @@ enum ECumulativeCounters { enum EPercentileCounters { option (GlobalCounterOpts) = { - Ranges { Value: 0 Name: "(1) < 500 us" } - Ranges { Value: 500 Name: "(2) 0.5-1 ms" } - Ranges { Value: 1000 Name: "(3) 1-2 ms" } - Ranges { Value: 2000 Name: "(4) 2-4 ms" } - Ranges { Value: 4000 Name: "(5) 4-8 ms" } - Ranges { Value: 8000 Name: "(6) 8-16 ms" } - Ranges { Value: 16000 Name: "(7) 16-32 ms" } - Ranges { Value: 32000 Name: "(8) 32-64 ms" } - Ranges { Value: 64000 Name: "(9) 64-128 ms" } - Ranges { Value: 128000 Name: "(10) 128-256 ms" } - Ranges { Value: 256000 Name: "(11) 256-512 ms" } - Ranges { Value: 512000 Name: "(12) 512-1024 ms" } - Ranges { Value: 1024000 Name: "(13) 1024-2000 ms" } - Ranges { Value: 2000000 Name: "(14) 2-4 s" } - Ranges { Value: 4000000 Name: "(15) 4-8 s" } - Ranges { Value: 8000000 Name: "(16) 8-16 s" } - Ranges { Value: 16000000 Name: "(17) 16-32 s" } - Ranges { Value: 32000000 Name: "(18) 32 < s" } + Ranges { Value: 0 Name: "(1) < 500 us" } + Ranges { Value: 500 Name: "(2) 0.5-1 ms" } + Ranges { Value: 1000 Name: "(3) 1-2 ms" } + Ranges { Value: 2000 Name: "(4) 2-4 ms" } + Ranges { Value: 4000 Name: "(5) 4-8 ms" } + Ranges { Value: 8000 Name: "(6) 8-16 ms" } + Ranges { Value: 16000 Name: "(7) 16-32 ms" } + Ranges { Value: 32000 Name: "(8) 32-64 ms" } + Ranges { Value: 64000 Name: "(9) 64-128 ms" } + Ranges { Value: 128000 Name: "(10) 128-256 ms" } + Ranges { Value: 256000 Name: "(11) 256-512 ms" } + Ranges { Value: 512000 Name: "(12) 512-1024 ms" } + Ranges { Value: 1024000 Name: "(13) 1024-2000 ms" } + Ranges { Value: 2000000 Name: "(14) 2-4 s" } + Ranges { Value: 4000000 Name: "(15) 4-8 s" } + Ranges { Value: 8000000 Name: "(16) 8-16 s" } + Ranges { Value: 16000000 Name: "(17) 16-32 s" } + Ranges { Value: 32000000 Name: "(18) 32 < s" } }; - COUNTER_BACKGROUND_COMPACTION_OK_LATENCY = 0 [(CounterOpts) = {Name: "BackgroundCompactionOkLatency"}]; + COUNTER_BACKGROUND_COMPACTION_OK_LATENCY = 0 [(CounterOpts) = {Name: "BackgroundCompactionOkLatency"}]; COUNTER_NUM_SHARDS_BY_TTL_LAG = 1 [(CounterOpts) = { Name: "NumShardsByTtlLag" diff --git a/ydb/core/protos/flat_scheme_op.proto b/ydb/core/protos/flat_scheme_op.proto index 69ae4a62783..33e598c1c25 100644 --- a/ydb/core/protos/flat_scheme_op.proto +++ b/ydb/core/protos/flat_scheme_op.proto @@ -250,12 +250,12 @@ message TPipelineConfig { message TPartitionConfig { optional string NamedCompactionPolicy = 1; // One of the predefined policies optional TCompactionPolicy CompactionPolicy = 2; // Customized policy - optional uint64 FollowerCount = 3; + optional uint64 FollowerCount = 3; optional uint64 ExecutorCacheSize = 4; // Cache size for the whole tablet including all user and system tables - optional bool AllowFollowerPromotion = 5 [default = true]; // if true followers can upgrade to leader, if false followers only handle reads + optional bool AllowFollowerPromotion = 5 [default = true]; // if true followers can upgrade to leader, if false followers only handle reads optional uint64 TxReadSizeLimit = 6; // Maximum size in bytes that is allowed to be read by a single Tx - //optional bool CrossDataCenterFollowers = 7; // deprecated -> CrossDataCenterFollowerCount - optional uint32 CrossDataCenterFollowerCount = 8; // deprecated -> FollowerGroups + //optional bool CrossDataCenterFollowers = 7; // deprecated -> CrossDataCenterFollowerCount + optional uint32 CrossDataCenterFollowerCount = 8; // deprecated -> FollowerGroups optional uint32 ChannelProfileId = 9; // for configuring erasure and disk categories optional TPartitioningPolicy PartitioningPolicy = 10; optional TPipelineConfig PipelineConfig = 11; @@ -270,7 +270,7 @@ message TPartitionConfig { optional uint32 EraseCacheMaxBytes = 20; // Maximum number of bytes to use for cached rows (default 1MB) optional EFreezeState FreezeState = 21; optional bool ShadowData = 22; // Table has separate shadow data for later merging - repeated NKikimrHive.TFollowerGroup FollowerGroups = 23; + repeated NKikimrHive.TFollowerGroup FollowerGroups = 23; reserved 24; // EMvccState MvccState = 24; no longer used optional uint64 KeepSnapshotTimeout = 25; // milliseconds } @@ -349,7 +349,7 @@ message TTableDescription { optional TTTLSettings TTLSettings = 35; - optional bool OmitFollowers = 36 [default = false]; // used with CopyFromTable + optional bool OmitFollowers = 36 [default = false]; // used with CopyFromTable optional bool IsBackup = 37 [default = false]; repeated TCdcStreamDescription CdcStreams = 38; @@ -806,7 +806,7 @@ message TCopyTableConfig { //TTableDescription implemets copying a table in orig optional string DstPath = 2; optional bool OmitIndexes = 3 [default = false]; - optional bool OmitFollowers = 4 [default = false]; + optional bool OmitFollowers = 4 [default = false]; optional bool IsBackup = 5 [default = false]; } diff --git a/ydb/core/protos/follower_group.proto b/ydb/core/protos/follower_group.proto index 057f761c6c8..d374752bcde 100644 --- a/ydb/core/protos/follower_group.proto +++ b/ydb/core/protos/follower_group.proto @@ -1,15 +1,15 @@ package NKikimrHive; option java_package = "ru.yandex.kikimr.proto"; -message TFollowerGroup { - optional uint32 FollowerCount = 1; - optional bool AllowLeaderPromotion = 2; +message TFollowerGroup { + optional uint32 FollowerCount = 1; + optional bool AllowLeaderPromotion = 2; optional bool AllowClientRead = 3; repeated uint32 AllowedNodeIDs = 4; repeated uint32 AllowedDataCenterNumIDs = 5 [deprecated=true]; // use AllowedDataCenters optional bool RequireAllDataCenters = 6; optional bool LocalNodeOnly = 7; optional bool RequireDifferentNodes = 8; - optional bool FollowerCountPerDataCenter = 9; // multiplies FollowerCount by number of DataCenters + optional bool FollowerCountPerDataCenter = 9; // multiplies FollowerCount by number of DataCenters repeated string AllowedDataCenters = 10; } diff --git a/ydb/core/protos/hive.proto b/ydb/core/protos/hive.proto index 9b53eeeeeb1..0059db81de8 100644 --- a/ydb/core/protos/hive.proto +++ b/ydb/core/protos/hive.proto @@ -9,7 +9,7 @@ package NKikimrHive; option java_package = "ru.yandex.kikimr.proto"; enum ETabletBootMode { - // Default boot mode, hive tries to keep leader tablet running + // Default boot mode, hive tries to keep leader tablet running TABLET_BOOT_MODE_DEFAULT = 0; // External boot mode, hive will assume it starts outside of any local service @@ -86,7 +86,7 @@ message TEvCreateTablet { repeated uint32 AllowedNodeIDs = 7; repeated uint64 AllowedDataCenterNumIDs = 14 [deprecated=true]; // array of DC IDs allowed to run the tablet; obsolete; use AllowedDataCenters instead optional TTabletCategory TabletCategory = 16; - repeated TFollowerGroup FollowerGroups = 17; + repeated TFollowerGroup FollowerGroups = 17; optional NKikimrSubDomains.TDomainKey ObjectDomain = 18; optional ETabletBootMode TabletBootMode = 19; optional uint64 ObjectId = 20; @@ -101,10 +101,10 @@ message TEvCreateTablet { optional uint32 BootTimeoutMilliSeconds = 8 [deprecated = true]; // DEPRECATED optional uint32 BootAttemptLimit = 9 [deprecated = true]; // DEPRECATED optional uint64 Weight = 10 [default = 1000, deprecated = true]; // DEPRECATED - optional uint32 FollowerCount = 11 [default = 0]; // DEPRECATED - optional bool AllowFollowerPromotion = 12 [default = false]; // DEPRECATED - optional bool CrossDataCenterFollowers = 13 [default = false]; // enable to make followers automatically in every DC (one follower per one datacenter) - DEPRECATED - optional uint32 CrossDataCenterFollowerCount = 15; // follower count per one datacenter - DEPRECATED + optional uint32 FollowerCount = 11 [default = 0]; // DEPRECATED + optional bool AllowFollowerPromotion = 12 [default = false]; // DEPRECATED + optional bool CrossDataCenterFollowers = 13 [default = false]; // enable to make followers automatically in every DC (one follower per one datacenter) - DEPRECATED + optional uint32 CrossDataCenterFollowerCount = 15; // follower count per one datacenter - DEPRECATED } message TEvLookupTablet { @@ -227,7 +227,7 @@ message TEvChannelInfo { message TTabletMetrics { optional fixed64 TabletID = 1; optional NKikimrTabletBase.TMetrics ResourceUsage = 4; - optional uint32 FollowerID = 3; + optional uint32 FollowerID = 3; } message TEvTabletMetrics { @@ -255,8 +255,8 @@ message TForwardRequest { message TEvRequestHiveInfo { optional fixed64 TabletID = 1; optional NKikimrTabletBase.TTabletTypes.EType TabletType = 2; - optional bool ReturnFollowers = 3; - optional uint32 FollowerID = 4; + optional bool ReturnFollowers = 3; + optional uint32 FollowerID = 4; optional bool ReturnMetrics = 5; } @@ -266,7 +266,7 @@ message TEvResponseHiveInfo { } message TEvRequestHiveDomainStats { - optional bool ReturnFollowers = 3; + optional bool ReturnFollowers = 3; optional bool ReturnMetrics = 5; } @@ -441,7 +441,7 @@ message TTabletInfo { repeated uint64 ExecutorCounters = 5; repeated uint64 ApplicationCounters = 6; optional TTabletOwner TabletOwner = 7; - optional uint32 FollowerID = 8; + optional uint32 FollowerID = 8; optional uint32 State = 9; // THive::ETabletState optional NKikimrTabletBase.TMetrics Metrics = 10; optional uint32 Generation = 11; @@ -449,7 +449,7 @@ message TTabletInfo { optional NKikimrSubDomains.TDomainKey ObjectDomain = 13; optional uint64 ObjectId = 14; repeated NKikimrSubDomains.TDomainKey AllowedDomains = 15; - repeated TFollowerGroup FollowerGroups = 16; + repeated TFollowerGroup FollowerGroups = 16; repeated TTabletChannelInfo TabletChannels = 17; optional NActorsProto.TActorId LockedToActor = 18; optional uint64 LockedReconnectTimeout = 19; diff --git a/ydb/core/protos/local.proto b/ydb/core/protos/local.proto index 9210acc69e8..a385a3cf3e1 100644 --- a/ydb/core/protos/local.proto +++ b/ydb/core/protos/local.proto @@ -40,7 +40,7 @@ message TEvPing { message TEvDeadTabletAck { optional fixed64 TabletId = 1; optional uint32 Generation = 2; - optional uint32 FollowerId = 3; + optional uint32 FollowerId = 3; } message TEvStatus { @@ -54,28 +54,28 @@ message TEvStatus { } enum EBootMode { - BOOT_MODE_LEADER = 0; - BOOT_MODE_FOLLOWER = 1; + BOOT_MODE_LEADER = 0; + BOOT_MODE_FOLLOWER = 1; } message TEvBootTablet { optional NKikimrTabletBase.TTabletStorageInfo Info = 1; optional uint32 SuggestedGeneration = 2; - optional EBootMode BootMode = 3 [default = BOOT_MODE_LEADER]; - optional NKikimrHive.TFollowerGroup FollowerGroup = 4; - optional uint32 FollowerId = 5; + optional EBootMode BootMode = 3 [default = BOOT_MODE_LEADER]; + optional NKikimrHive.TFollowerGroup FollowerGroup = 4; + optional uint32 FollowerId = 5; } message TEvStopTablet { optional fixed64 TabletId = 1; - optional uint32 FollowerId = 2; + optional uint32 FollowerId = 2; } message TEvTabletStatus { optional uint32 Status = 1; optional fixed64 TabletID = 2; optional uint32 Generation = 3; - optional uint32 FollowerId = 4; + optional uint32 FollowerId = 4; optional uint32 Reason = 5 [default = 34]; // ReasonError } @@ -89,8 +89,8 @@ message TEvEnumerateTabletsResult { message TTabletInfo { optional uint64 TabletId = 1; optional NKikimrTabletBase.TTabletTypes.EType TabletType = 2; - optional EBootMode BootMode = 3 [default = BOOT_MODE_LEADER]; - optional uint32 FollowerId = 4; + optional EBootMode BootMode = 3 [default = BOOT_MODE_LEADER]; + optional uint32 FollowerId = 4; } repeated TTabletInfo TabletInfo = 2; @@ -101,7 +101,7 @@ message TEvSyncTablets { optional uint64 TabletId = 1; optional uint32 Generation = 2; optional EBootMode BootMode = 3; - optional uint32 FollowerId = 4; + optional uint32 FollowerId = 4; } repeated TTabletInfo InbootTablets = 1; @@ -110,7 +110,7 @@ message TEvSyncTablets { message TEvTabletMetricsAck { repeated fixed64 TabletId = 1; - repeated uint32 FollowerId = 2; + repeated uint32 FollowerId = 2; } message TEvReconnect { diff --git a/ydb/core/protos/msgbus.proto b/ydb/core/protos/msgbus.proto index 533b4a6fc72..df7cda59800 100644 --- a/ydb/core/protos/msgbus.proto +++ b/ydb/core/protos/msgbus.proto @@ -166,7 +166,7 @@ message TResponse { optional NKikimrQueryStats.TTxStats TxStats = 111; optional NKikimrTxUserProxy.TMiniKQLCompileResults MiniKQLCompileResults = 108; - optional bool HadFollowerReads = 109; + optional bool HadFollowerReads = 109; optional bytes SerializedReadTableResponse = 110; // Serialized Ydb.Db.TResultSet optional uint32 BSAssignedID = 40; @@ -254,7 +254,7 @@ message TFakeConfigDummy { message TTabletCountersRequest { optional uint64 TabletID = 1; - optional bool ConnectToFollower = 2; + optional bool ConnectToFollower = 2; optional bool WithRetry = 10; optional uint64 Timeout = 11; @@ -273,7 +273,7 @@ message TLocalMKQL { optional uint64 TabletID = 1; optional NKikimrTxUserProxy.TMiniKQLTransaction Program = 2; - optional bool ConnectToFollower = 3; + optional bool ConnectToFollower = 3; optional string SecurityToken = 5; @@ -283,7 +283,7 @@ message TLocalMKQL { message TLocalSchemeTx { optional uint64 TabletID = 1; - optional bool ConnectToFollower = 2; + optional bool ConnectToFollower = 2; optional NTabletFlatScheme.TSchemeChanges SchemeChanges = 3; optional bool DryRun = 4; optional string SecurityToken = 5; diff --git a/ydb/core/protos/node_whiteboard.proto b/ydb/core/protos/node_whiteboard.proto index df29b8712bb..b96713ca298 100644 --- a/ydb/core/protos/node_whiteboard.proto +++ b/ydb/core/protos/node_whiteboard.proto @@ -39,7 +39,7 @@ message TTabletStateInfo { Lock = 8; Dead = 9; Active = 10; - ResolveLeader = 11; + ResolveLeader = 11; Deleted = 12; Stopped = 13; Reserved14 = 14; @@ -58,9 +58,9 @@ message TTabletStateInfo { repeated uint32 ChannelGroupIDs = 9; // BS Group per channel repeated TCustomTabletAttribute Attributes = 10; optional uint32 NodeId = 11; // filled during merge - optional bool Leader = 12; // leader or follower + optional bool Leader = 12; // leader or follower optional uint32 Count = 13; // filled during group count - optional uint32 FollowerId = 14; + optional uint32 FollowerId = 14; optional EFlag Overall = 15; // filled during merge optional NKikimrSubDomains.TDomainKey TenantId = 16; optional fixed64 HiveId = 17; diff --git a/ydb/core/protos/out/out.cpp b/ydb/core/protos/out/out.cpp index 167e24b9cbe..28c49a5c363 100644 --- a/ydb/core/protos/out/out.cpp +++ b/ydb/core/protos/out/out.cpp @@ -152,10 +152,10 @@ Y_DECLARE_OUT_SPEC(, NKikimrBlobStorage::TPDiskSpaceColor::E, stream, value) { Y_DECLARE_OUT_SPEC(, NKikimrWhiteboard::EFlag, stream, value) { stream << NKikimrWhiteboard::EFlag_Name(value); } - -Y_DECLARE_OUT_SPEC(, NKikimrTxDataShard::TEvCompactTableResult::EStatus, stream, value) { - stream << NKikimrTxDataShard::TEvCompactTableResult::EStatus_Name(value); -} + +Y_DECLARE_OUT_SPEC(, NKikimrTxDataShard::TEvCompactTableResult::EStatus, stream, value) { + stream << NKikimrTxDataShard::TEvCompactTableResult::EStatus_Name(value); +} Y_DECLARE_OUT_SPEC(, NKikimrKqp::EQueryAction, stream, value) { stream << NKikimrKqp::EQueryAction_Name(value); diff --git a/ydb/core/protos/services.proto b/ydb/core/protos/services.proto index 1d97d937941..c17c8a7dc37 100644 --- a/ydb/core/protos/services.proto +++ b/ydb/core/protos/services.proto @@ -287,9 +287,9 @@ enum EServiceKikimr { STREAMS_RESOURCE_SERVICE = 1015; STREAMS_CHECKPOINT_COORDINATOR = 1016; STREAMS_CONTROL_PLANE_SERVICE = 1017; - STREAMS_GRAND_LEADER_SERVICE = 1018; + STREAMS_GRAND_LEADER_SERVICE = 1018; STREAMS_META_STORAGE_SERVICE = 1019; - STREAMS_GRAPH_LEADER = 1020; + STREAMS_GRAPH_LEADER = 1020; // YandexQuery YQ_CONTROL_PLANE_STORAGE = 1021; @@ -453,8 +453,8 @@ message TActivity { RTMR_TABLET_EXECUTOR_READBLOCKS = 138; RTMR_TABLET_EXECUTOR_READSTATS = 139; RTMR_TABLET_EXECUTOR_RECOVERY = 140; - RTMR_TABLET_EXECUTOR_FOLLOWERREAD = 141; - RTMR_TABLET_EXECUTOR_FOLLOWERUPDATE = 142; + RTMR_TABLET_EXECUTOR_FOLLOWERREAD = 141; + RTMR_TABLET_EXECUTOR_FOLLOWERUPDATE = 142; RTMR_TABLET_EXECUTOR_SNAPSHOT = 143; RTMR_TABLET_EXECUTOR_UPDATE = 144; RTMR_TABLET_EXECUTOR_UPDATESTATS = 145; @@ -626,7 +626,7 @@ message TActivity { FOLDER_SERVICE_LIST_FOLDER = 311; ACTOR_SYSTEM_SCHEDULER_ACTOR = 312; SQS_PROXY_SERVICE_ACTOR = 313; - SQS_QUEUE_LEADER_ACTOR = 314; + SQS_QUEUE_LEADER_ACTOR = 314; TABLET_LOOKUP_ACTOR = 315; TRACE_LOOKUP_ACTOR = 316; TRACE_REQUEST_ACTOR = 317; @@ -734,7 +734,7 @@ message TActivity { YF_QUEUED_FECTER_ACTOR = 419; YF_GRPC_JOB_SERVICE_ACTOR = 420; YF_HTTP_FETCHER_ACTOR = 421; - YF_JOB_SERVICE_LEADER_ACTOR = 422; + YF_JOB_SERVICE_LEADER_ACTOR = 422; YF_JOB_SERVICE_PROXY_ACTOR = 423; YF_JOB_SERVICE_SESSION_MONITOR_ACTOR = 424; YF_JOB_SERVICE_WORKER_ACTOR = 425; diff --git a/ydb/core/protos/statestorage.proto b/ydb/core/protos/statestorage.proto index d95ffd86c71..4165af89ba0 100644 --- a/ydb/core/protos/statestorage.proto +++ b/ydb/core/protos/statestorage.proto @@ -4,7 +4,7 @@ import "ydb/core/protos/base.proto"; package NKikimrStateStorage; option java_package = "ru.yandex.kikimr.proto"; -// todo: add followers info +// todo: add followers info message TEvLookup { optional fixed64 TabletID = 1; @@ -15,16 +15,16 @@ message TEvInfo { optional NKikimrProto.EReplyStatus Status = 1; optional fixed64 TabletID = 2; optional uint64 Cookie = 3; - optional NActorsProto.TActorId CurrentLeader = 4; - optional NActorsProto.TActorId CurrentLeaderTablet = 5; + optional NActorsProto.TActorId CurrentLeader = 4; + optional NActorsProto.TActorId CurrentLeaderTablet = 5; optional uint32 CurrentGeneration = 6; optional uint32 CurrentStep = 7; optional bool Locked = 8; optional uint64 LockedFor = 9; optional uint64 Signature = 10; - repeated NActorsProto.TActorId Follower = 11; - repeated NActorsProto.TActorId FollowerTablet = 12; - repeated NActorsProto.TActorId FollowerCandidates = 13; + repeated NActorsProto.TActorId Follower = 11; + repeated NActorsProto.TActorId FollowerTablet = 12; + repeated NActorsProto.TActorId FollowerCandidates = 13; optional fixed32 ConfigContentHash = 14; }; @@ -41,8 +41,8 @@ message TEvDump { message TEvUpdate { optional fixed64 TabletID = 1; optional uint64 Cookie = 2; - optional NActorsProto.TActorId ProposedLeader = 3; - optional NActorsProto.TActorId ProposedLeaderTablet = 4; + optional NActorsProto.TActorId ProposedLeader = 3; + optional NActorsProto.TActorId ProposedLeaderTablet = 4; optional uint32 ProposedGeneration = 5; optional uint32 ProposedStep = 6; optional uint64 Signature = 7; @@ -55,30 +55,30 @@ message TEvDelete { message TEvCleanup { optional fixed64 TabletID = 1; - optional NActorsProto.TActorId ProposedLeader = 2; + optional NActorsProto.TActorId ProposedLeader = 2; } -message TEvRegisterFollower { +message TEvRegisterFollower { optional fixed64 TabletID = 1; - optional NActorsProto.TActorId Follower = 2; - optional NActorsProto.TActorId FollowerTablet = 3; + optional NActorsProto.TActorId Follower = 2; + optional NActorsProto.TActorId FollowerTablet = 3; optional bool Candidate = 4; } -message TEvUnregisterFollower { +message TEvUnregisterFollower { optional fixed64 TabletID = 1; - optional NActorsProto.TActorId Follower = 2; + optional NActorsProto.TActorId Follower = 2; } message TEvLock { optional fixed64 TabletID = 1; optional uint64 Cookie = 2; - optional NActorsProto.TActorId ProposedLeader = 3; + optional NActorsProto.TActorId ProposedLeader = 3; optional uint32 ProposedGeneration = 4; optional uint64 Signature = 5; }; -message TEvReplicaLeaderDemoted { +message TEvReplicaLeaderDemoted { optional fixed64 TabletID = 1; optional uint64 Signature = 2; }; diff --git a/ydb/core/protos/sys_view.proto b/ydb/core/protos/sys_view.proto index 5dcfc664958..cfc03662725 100644 --- a/ydb/core/protos/sys_view.proto +++ b/ydb/core/protos/sys_view.proto @@ -332,7 +332,7 @@ message TEvGetStorageStatsResponse { message TTabletEntry { optional fixed64 TabletId = 1; - optional uint32 FollowerId = 2; + optional uint32 FollowerId = 2; optional string Type = 3; optional string State = 4; optional string VolatileState = 5; diff --git a/ydb/core/protos/table_stats.proto b/ydb/core/protos/table_stats.proto index 58326cfc567..a555e0b659d 100644 --- a/ydb/core/protos/table_stats.proto +++ b/ydb/core/protos/table_stats.proto @@ -38,9 +38,9 @@ message TTableStats { optional uint64 PartCount = 24; optional THistogram KeyAccessSample = 26; - - optional uint64 SearchHeight = 27; - - // seconds since epoch - optional uint64 LastFullCompactionTs = 28; + + optional uint64 SearchHeight = 27; + + // seconds since epoch + optional uint64 LastFullCompactionTs = 28; } diff --git a/ydb/core/protos/tablet.proto b/ydb/core/protos/tablet.proto index c3d611b3189..f0bec238e78 100644 --- a/ydb/core/protos/tablet.proto +++ b/ydb/core/protos/tablet.proto @@ -126,14 +126,14 @@ message TEvReadLocalBaseResult { optional bytes Scheme = 5; } -message TEvFollowerAttach { +message TEvFollowerAttach { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; } -message TEvFollowerUpdate { +message TEvFollowerUpdate { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; optional uint64 StreamCounter = 3; optional uint32 Generation = 10; @@ -151,33 +151,33 @@ message TEvFollowerUpdate { optional bool NeedGCApplyAck = 22; } -message TEvFollowerGcAck { +message TEvFollowerGcAck { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; optional uint32 Generation = 3; optional uint32 Step = 4; } -message TEvFollowerAuxUpdate { +message TEvFollowerAuxUpdate { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; optional uint64 StreamCounter = 3; optional bytes AuxPayload = 10; } -message TEvFollowerDetach { +message TEvFollowerDetach { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; } -message TEvFollowerDisconnect { +message TEvFollowerDisconnect { optional fixed64 TabletId = 1; - optional uint32 FollowerAttempt = 2; + optional uint32 FollowerAttempt = 2; optional uint32 Reason = 3; // todo: enum } -message TEvFollowerRefresh { +message TEvFollowerRefresh { optional fixed64 TabletId = 1; optional uint32 Generation = 2; optional bool OfflineProtocol = 3; diff --git a/ydb/core/protos/tablet_pipe.proto b/ydb/core/protos/tablet_pipe.proto index 26114c41de1..e1fd3769f84 100644 --- a/ydb/core/protos/tablet_pipe.proto +++ b/ydb/core/protos/tablet_pipe.proto @@ -19,7 +19,7 @@ message TEvConnectResult { optional uint64 TabletId = 2; optional NActorsProto.TActorId ClientId = 3; optional NActorsProto.TActorId ServerId = 4; - optional bool Leader = 5 [default = true]; + optional bool Leader = 5 [default = true]; }; message TEvPush { diff --git a/ydb/core/protos/tablet_tracing_signals.proto b/ydb/core/protos/tablet_tracing_signals.proto index fcfbc199a4c..51c1c7dd4b4 100644 --- a/ydb/core/protos/tablet_tracing_signals.proto +++ b/ydb/core/protos/tablet_tracing_signals.proto @@ -17,7 +17,7 @@ message TOnCancelTablet { message TOnTabletBootstrap { optional fixed64 TimeStamp = 1; - optional bool Leader = 2; + optional bool Leader = 2; optional uint32 SuggestedGeneration = 3; optional NActorsProto.TActorId StateStorageProxyID = 4; } @@ -67,11 +67,11 @@ message TOnWriteZeroEntry { optional uint32 LastInGeneration = 4; } -message TOnFollowerPromoteToLeader { +message TOnFollowerPromoteToLeader { optional fixed64 TimeStamp = 1; optional uint32 SuggestedGeneration = 2; - optional NActorsProto.TActorId KnownLeaderID = 3; - optional NActorsProto.TActorId FollowerStStGuardian = 4; + optional NActorsProto.TActorId KnownLeaderID = 3; + optional NActorsProto.TActorId FollowerStStGuardian = 4; } message TRebuildGraphBootstrap { diff --git a/ydb/core/protos/tx_datashard.proto b/ydb/core/protos/tx_datashard.proto index a71128ed02a..89863b25400 100644 --- a/ydb/core/protos/tx_datashard.proto +++ b/ydb/core/protos/tx_datashard.proto @@ -94,7 +94,7 @@ message TROTransaction { message TTableId { optional uint64 OwnerId = 1; optional uint64 TableId = 2; - optional uint64 SchemaVersion = 3; + optional uint64 SchemaVersion = 3; } message TReadTableTransaction { @@ -529,7 +529,7 @@ message TTabletInfo { optional uint32 Generation = 2; optional uint64 Step = 3; optional NActorsProto.TActorId ActorId = 4; - optional bool IsFollower = 5; + optional bool IsFollower = 5; } message TEvProposeTransactionResult { @@ -865,7 +865,7 @@ message TEvGetInfoResponse { optional uint64 SchemeShard = 1; optional uint64 Mediator = 2; optional uint32 Generation = 3; - optional bool IsFollower = 4; + optional bool IsFollower = 4; optional string State = 5; optional bool IsActive = 6; optional bool HasSharedBlobs = 7; @@ -1397,181 +1397,181 @@ message TEvKqpScan { optional bytes OlapProgram = 19; optional NKikimrSchemeOp.EOlapProgramType OlapProgramType = 20; } - -message TEvCompactTable { + +message TEvCompactTable { optional NKikimrProto.TPathID PathId = 1; optional bool CompactBorrowed = 2; -} - -message TEvCompactTableResult { - enum EStatus { - OK = 0; - NOT_NEEDED = 1; - FAILED = 2; - }; - - optional uint64 TabletId = 1; +} + +message TEvCompactTableResult { + enum EStatus { + OK = 0; + NOT_NEEDED = 1; + FAILED = 2; + }; + + optional uint64 TabletId = 1; optional NKikimrProto.TPathID PathId = 2; - optional EStatus Status = 3; -} + optional EStatus Status = 3; +} message TEvCompactBorrowed { optional NKikimrProto.TPathID PathId = 1; } - -message TEvGetCompactTableStats { + +message TEvGetCompactTableStats { optional NKikimrProto.TPathID PathId = 1; -} - -message TEvGetCompactTableStatsResult { - optional uint64 BackgroundCompactionRequests = 1; -} - -// TEvRead is used to request multiple queries from a shard and -// to read results possibly splitted into multiple replies. -// -// The TEvRead message starts a new read request with given queries -// and starts streaming a single resultset in the requested format. -// The TEvRead contains number of bytes/rows (quota) the client can handle, -// the server is allowed to reply with multiple TEvReadResult messages -// within the quota. To update quota user uses TEvReadAck message. -// -// The protocol works as follows: -// 1. Optionally user obtains LockTxId from TxProxy. -// 2. Optionally user obtains snapshot version. -// 3. User starts reading by sending TEvRead to the shard. -// 4. Shard replies with TEvReadResult, which contains: -// - ReadId which is the same as in TEvRead -// - Snapshot version, which is useful when it wasn't specified in TEvRead. -// Shard gives no guarantee that the ReadId will be valid any time. -// - SeqNo that should be used by user in TEvReadAck -// - ContinuationToken, which user can use to restart the read. -// 5. User reads until the end using TEvReadAck to update the quota. -// 6. User stops reading by TEvReadCancel. -message TEvRead { - // User must always provide unique ReadId - // Note that shard distinguishes equal ReadId's - // from different users. - optional uint64 ReadId = 1; - - // To read regular user tables client must specify proper - // owner of the table (schemeshard). - // Only for internal usage we support reading shard system tables: - // in this case owner is shard itself, TableId is LocalTid, SchemaVersion - // must not be set - optional TTableId TableId = 2; - - // A list of column ids that are returned in the result set - repeated uint32 Columns = 3; - - // An optional snapshot for point in time queries - // When snapshot is unspecified datashard will read the most recent data - // and try to allocate an appropriate point in time for repeatable reads - // appropriate for this shard. - optional NKikimrProto.TRowVersion Snapshot = 4; - - // An optional LockTxId for acquiring locks - // When specified shard adds read locks with the specified TxId on processed ranges - optional uint64 LockTxId = 5; - - // Specifies the format for result data in TEvReadResult - optional EScanDataFormat ResultFormat = 6; - - // Limits the total number of rows or bytes client currently can handle - optional uint32 MaxRows = 7; - optional uint32 MaxBytes = 8; - - // mainly for testing purposes, limits number of rows in single result message - optional uint32 MaxRowsInResult = 9; - - // When specified requests are handled in reverse order as well as range reads - optional bool Reverse = 10; - - // Request must contain either keys, queries or program - // mixed requests are not supported - - // TSerializedCellVec containing a PK prefix - repeated bytes Keys = 900; - - // A range of PK values where From is always the left border - // and To is always the right border. Both From and To can - // be PK prefixes. - repeated NKikimrTx.TKeyRange Ranges = 901; - - optional bytes Program = 902; - optional NKikimrSchemeOp.EOlapProgramType ProgramType = 903; -} - -message TReadContinuationToken { - // An index of the last query that datashard attempted to process - // When starting a new TEvRead call for the same query, this would be - // the first query that needs to be resent. - optional uint32 FirstUnprocessedQuery = 1; - - // TSerializedCellVec of the last observed key before returning the result - // When starting a new TEvRead call for the same query, this would be - // the first non-inclusive from key for the first range. - optional bytes LastProcessedKey = 2; -} - -// Every TEvRead and TEvReadNext produces a result -// The result may be partial, in which case client may continue streaming more -// results using TEvReadNext. -// -// Note the condition that everything has been read: FirstUnprocessedQuery equals to -// the size of Queries from TEvRead and LastProcessedKey is not set. -message TEvReadResult { - message TArrowBatch { - optional bytes Schema = 1; - optional bytes Batch = 2; - } - - message TCellVecBatch { - // TODO: add schema? - repeated bytes Rows = 1; - } - - // same as ReadId from the TEvRead - optional uint64 ReadId = 1; - - // Specifies SeqNo for the next TEvReadNext call - optional uint64 SeqNo = 2; - - optional TStatus Status = 3; - optional EScanDataFormat ResultFormat = 4; - optional NKikimrProto.TRowVersion Snapshot = 5; - - optional bytes ContinuationToken = 6; - - // True when shard may have possibly returned more data, but - // stopped because it reached MaxRows or MaxBytes limits. - optional bool LimitReached = 7; - - optional NKikimrQueryStats.TReadOpStats Stats = 8; - - optional bool Finished = 9; - - repeated TLock TxLocks = 10; - repeated TLock BrokenTxLocks = 11; - - // Data for the possibly partial result - oneof ReadResult { - TArrowBatch ArrowBatch = 900; - TCellVecBatch CellVec = 901; - } -} - -message TEvReadAck { - optional uint64 ReadId = 1; - optional uint64 SeqNo = 2; - optional uint32 MaxRows = 3; - optional uint32 MaxBytes = 4; -}; - -// Cancels a possibly active previously started read -message TEvReadCancel { - optional uint64 ReadId = 1; -}; +} + +message TEvGetCompactTableStatsResult { + optional uint64 BackgroundCompactionRequests = 1; +} + +// TEvRead is used to request multiple queries from a shard and +// to read results possibly splitted into multiple replies. +// +// The TEvRead message starts a new read request with given queries +// and starts streaming a single resultset in the requested format. +// The TEvRead contains number of bytes/rows (quota) the client can handle, +// the server is allowed to reply with multiple TEvReadResult messages +// within the quota. To update quota user uses TEvReadAck message. +// +// The protocol works as follows: +// 1. Optionally user obtains LockTxId from TxProxy. +// 2. Optionally user obtains snapshot version. +// 3. User starts reading by sending TEvRead to the shard. +// 4. Shard replies with TEvReadResult, which contains: +// - ReadId which is the same as in TEvRead +// - Snapshot version, which is useful when it wasn't specified in TEvRead. +// Shard gives no guarantee that the ReadId will be valid any time. +// - SeqNo that should be used by user in TEvReadAck +// - ContinuationToken, which user can use to restart the read. +// 5. User reads until the end using TEvReadAck to update the quota. +// 6. User stops reading by TEvReadCancel. +message TEvRead { + // User must always provide unique ReadId + // Note that shard distinguishes equal ReadId's + // from different users. + optional uint64 ReadId = 1; + + // To read regular user tables client must specify proper + // owner of the table (schemeshard). + // Only for internal usage we support reading shard system tables: + // in this case owner is shard itself, TableId is LocalTid, SchemaVersion + // must not be set + optional TTableId TableId = 2; + + // A list of column ids that are returned in the result set + repeated uint32 Columns = 3; + + // An optional snapshot for point in time queries + // When snapshot is unspecified datashard will read the most recent data + // and try to allocate an appropriate point in time for repeatable reads + // appropriate for this shard. + optional NKikimrProto.TRowVersion Snapshot = 4; + + // An optional LockTxId for acquiring locks + // When specified shard adds read locks with the specified TxId on processed ranges + optional uint64 LockTxId = 5; + + // Specifies the format for result data in TEvReadResult + optional EScanDataFormat ResultFormat = 6; + + // Limits the total number of rows or bytes client currently can handle + optional uint32 MaxRows = 7; + optional uint32 MaxBytes = 8; + + // mainly for testing purposes, limits number of rows in single result message + optional uint32 MaxRowsInResult = 9; + + // When specified requests are handled in reverse order as well as range reads + optional bool Reverse = 10; + + // Request must contain either keys, queries or program + // mixed requests are not supported + + // TSerializedCellVec containing a PK prefix + repeated bytes Keys = 900; + + // A range of PK values where From is always the left border + // and To is always the right border. Both From and To can + // be PK prefixes. + repeated NKikimrTx.TKeyRange Ranges = 901; + + optional bytes Program = 902; + optional NKikimrSchemeOp.EOlapProgramType ProgramType = 903; +} + +message TReadContinuationToken { + // An index of the last query that datashard attempted to process + // When starting a new TEvRead call for the same query, this would be + // the first query that needs to be resent. + optional uint32 FirstUnprocessedQuery = 1; + + // TSerializedCellVec of the last observed key before returning the result + // When starting a new TEvRead call for the same query, this would be + // the first non-inclusive from key for the first range. + optional bytes LastProcessedKey = 2; +} + +// Every TEvRead and TEvReadNext produces a result +// The result may be partial, in which case client may continue streaming more +// results using TEvReadNext. +// +// Note the condition that everything has been read: FirstUnprocessedQuery equals to +// the size of Queries from TEvRead and LastProcessedKey is not set. +message TEvReadResult { + message TArrowBatch { + optional bytes Schema = 1; + optional bytes Batch = 2; + } + + message TCellVecBatch { + // TODO: add schema? + repeated bytes Rows = 1; + } + + // same as ReadId from the TEvRead + optional uint64 ReadId = 1; + + // Specifies SeqNo for the next TEvReadNext call + optional uint64 SeqNo = 2; + + optional TStatus Status = 3; + optional EScanDataFormat ResultFormat = 4; + optional NKikimrProto.TRowVersion Snapshot = 5; + + optional bytes ContinuationToken = 6; + + // True when shard may have possibly returned more data, but + // stopped because it reached MaxRows or MaxBytes limits. + optional bool LimitReached = 7; + + optional NKikimrQueryStats.TReadOpStats Stats = 8; + + optional bool Finished = 9; + + repeated TLock TxLocks = 10; + repeated TLock BrokenTxLocks = 11; + + // Data for the possibly partial result + oneof ReadResult { + TArrowBatch ArrowBatch = 900; + TCellVecBatch CellVec = 901; + } +} + +message TEvReadAck { + optional uint64 ReadId = 1; + optional uint64 SeqNo = 2; + optional uint32 MaxRows = 3; + optional uint32 MaxBytes = 4; +}; + +// Cancels a possibly active previously started read +message TEvReadCancel { + optional uint64 ReadId = 1; +}; // Applies a batch of replication changes message TEvApplyReplicationChanges { diff --git a/ydb/core/protos/tx_proxy.proto b/ydb/core/protos/tx_proxy.proto index 5a863116db1..dedd2f9cbb5 100644 --- a/ydb/core/protos/tx_proxy.proto +++ b/ydb/core/protos/tx_proxy.proto @@ -229,7 +229,7 @@ message TEvProposeTransactionStatus { optional NKikimrQueryStats.TTxStats TxStats = 19; optional TTxProxyTimings Timings = 20; - optional bool HadFollowerReads = 21; + optional bool HadFollowerReads = 21; optional uint32 SchemeShardStatus = 30; optional uint32 SchemeShardReportedId = 31; diff --git a/ydb/core/protos/ya.make b/ydb/core/protos/ya.make index c4d29fdd6d3..70bb65514cd 100644 --- a/ydb/core/protos/ya.make +++ b/ydb/core/protos/ya.make @@ -92,7 +92,7 @@ SRCS( services.proto shared_cache.proto sqs.proto - follower_group.proto + follower_group.proto ssa.proto statestorage.proto stream.proto diff --git a/ydb/core/quoter/quoter_service_bandwidth_test/server.cpp b/ydb/core/quoter/quoter_service_bandwidth_test/server.cpp index 7997f04f0e8..4b301ea3edf 100644 --- a/ydb/core/quoter/quoter_service_bandwidth_test/server.cpp +++ b/ydb/core/quoter/quoter_service_bandwidth_test/server.cpp @@ -117,7 +117,7 @@ void TTestServer::CreateKesusResource(ui64 kesusTabletId, const TString& resourc } TActorId sender = GetEdgeActor(); - ForwardToTablet(*runtime, kesusTabletId, sender, request.Release(), 0); + ForwardToTablet(*runtime, kesusTabletId, sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvAddQuoterResourceResult>(handle); diff --git a/ydb/core/quoter/quoter_service_ut.cpp b/ydb/core/quoter/quoter_service_ut.cpp index 29b9e8478e6..88c74ca3fb1 100644 --- a/ydb/core/quoter/quoter_service_ut.cpp +++ b/ydb/core/quoter/quoter_service_ut.cpp @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TQuoterServiceTest) { const ui64 tabletId = pathDesc.GetKesus().GetKesusTabletId(); TActorId sender = runtime->AllocateEdgeActor(); - ForwardToTablet(*runtime, tabletId, sender, request.Release(), 0); + ForwardToTablet(*runtime, tabletId, sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvAddQuoterResourceResult>(handle); diff --git a/ydb/core/quoter/ut_helpers.cpp b/ydb/core/quoter/ut_helpers.cpp index e23380a735b..e57a073d74a 100644 --- a/ydb/core/quoter/ut_helpers.cpp +++ b/ydb/core/quoter/ut_helpers.cpp @@ -79,7 +79,7 @@ void TKesusQuoterTestSetup::CreateKesusResource(const TString& kesusPath, const TActorId sender = GetEdgeActor(); Cerr << "AddQuoterResource: " << request->Record << Endl; - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvAddQuoterResourceResult>(handle); @@ -100,7 +100,7 @@ void TKesusQuoterTestSetup::DeleteKesusResource(const TString& kesusPath, const TActorId sender = GetEdgeActor(); Cerr << "DeleteQuoterResource: " << request->Record << Endl; - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvDeleteQuoterResourceResult>(handle); @@ -155,13 +155,13 @@ void TKesusQuoterTestSetup::KillKesusTablet(const TString& kesusPath) { TActorId sender = GetEdgeActor(); Cerr << "Kill kesus tablet: " << kesusPath << Endl; - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, new TEvents::TEvPoisonPill(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, new TEvents::TEvPoisonPill(), 0); } NKikimrKesus::TEvGetQuoterResourceCountersResult TKesusQuoterTestSetup::GetQuoterCounters(const TString& kesusPath) { TTestActorRuntime* const runtime = Server->GetRuntime(); - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), GetEdgeActor(), new NKesus::TEvKesus::TEvGetQuoterResourceCounters(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), GetEdgeActor(), new NKesus::TEvKesus::TEvGetQuoterResourceCounters(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvGetQuoterResourceCountersResult>(handle); diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index 5bd6ea91275..bccfdca97db 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -477,11 +477,11 @@ public: const TString &GetBuffer() const { return Buf; } - TString ReleaseBuffer() { - Cells.clear(); - return std::move(Buf); - } - + TString ReleaseBuffer() { + Cells.clear(); + return std::move(Buf); + } + private: #pragma pack(push,4) diff --git a/ydb/core/scheme/scheme_tabledefs.h b/ydb/core/scheme/scheme_tabledefs.h index 7943b76cf59..190233fdeee 100644 --- a/ydb/core/scheme/scheme_tabledefs.h +++ b/ydb/core/scheme/scheme_tabledefs.h @@ -502,8 +502,8 @@ struct TReadTarget { Snapshot, Head, HeadAfterSnapshot, - Follower, - FollowerAfterSnapshot + Follower, + FollowerAfterSnapshot }; TReadTarget() @@ -515,7 +515,7 @@ struct TReadTarget { } bool HasSnapshotTime() const { - return Mode == EMode::Snapshot || Mode == EMode::HeadAfterSnapshot || Mode == EMode::FollowerAfterSnapshot; + return Mode == EMode::Snapshot || Mode == EMode::HeadAfterSnapshot || Mode == EMode::FollowerAfterSnapshot; } std::pair<ui64, ui64> GetSnapshotTime() const { @@ -542,12 +542,12 @@ struct TReadTarget { return TReadTarget(EMode::HeadAfterSnapshot, snapshotTime); } - static TReadTarget Follower() { - return TReadTarget(EMode::Follower); + static TReadTarget Follower() { + return TReadTarget(EMode::Follower); } - static TReadTarget FollowerAfterSnapshot(const std::pair<ui64, ui64>& snapshotTime) { - return TReadTarget(EMode::FollowerAfterSnapshot, snapshotTime); + static TReadTarget FollowerAfterSnapshot(const std::pair<ui64, ui64>& snapshotTime) { + return TReadTarget(EMode::FollowerAfterSnapshot, snapshotTime); } private: diff --git a/ydb/core/sys_view/common/schema.h b/ydb/core/sys_view/common/schema.h index 4512de93d34..f7a4f191e13 100644 --- a/ydb/core/sys_view/common/schema.h +++ b/ydb/core/sys_view/common/schema.h @@ -308,7 +308,7 @@ struct Schema : NIceDb::Schema { struct Tablets : Table<8> { struct TabletId : Column<1, NScheme::NTypeIds::Uint64> {}; - struct FollowerId : Column<2, NScheme::NTypeIds::Uint32> {}; + struct FollowerId : Column<2, NScheme::NTypeIds::Uint32> {}; struct TypeCol : Column<3, NScheme::NTypeIds::String> { static TString GetColumnName(const TString&) { return "Type"; } }; struct State : Column<4, NScheme::NTypeIds::String> {}; struct VolatileState : Column<5, NScheme::NTypeIds::String> {}; @@ -319,10 +319,10 @@ struct Schema : NIceDb::Schema { struct Memory : Column<10, NScheme::NTypeIds::Uint64> {}; struct Network : Column<11, NScheme::NTypeIds::Uint64> {}; - using TKey = TableKey<TabletId, FollowerId>; + using TKey = TableKey<TabletId, FollowerId>; using TColumns = TableColumns< TabletId, - FollowerId, + FollowerId, TypeCol, State, VolatileState, diff --git a/ydb/core/sys_view/tablets/tablets.cpp b/ydb/core/sys_view/tablets/tablets.cpp index 9afb719ce91..88627748d8c 100644 --- a/ydb/core/sys_view/tablets/tablets.cpp +++ b/ydb/core/sys_view/tablets/tablets.cpp @@ -62,7 +62,7 @@ private: bool CalculateRangeFrom() { /* - * Please note that TabletId and FollowerId do not have NULLs in columns + * Please note that TabletId and FollowerId do not have NULLs in columns */ const auto& cellsFrom = TableRange.From.GetCells(); @@ -84,7 +84,7 @@ private: if (cellsFrom.size() == 2) { if (!cellsFrom[1].IsNull()) { - FromFollowerId = cellsFrom[1].AsValue<ui32>(); + FromFollowerId = cellsFrom[1].AsValue<ui32>(); } if (TableRange.FromInclusive) { @@ -92,17 +92,17 @@ private: } // The range start from NULL exclusive. So, the next value after NULL will be used. - if (!FromFollowerId.has_value()) { - FromFollowerId = Min<ui32>(); + if (!FromFollowerId.has_value()) { + FromFollowerId = Min<ui32>(); return true; } - if (FromFollowerId.value() < Max<ui32>()) { - FromFollowerId = FromFollowerId.value() + 1; + if (FromFollowerId.value() < Max<ui32>()) { + FromFollowerId = FromFollowerId.value() + 1; return true; } - FromFollowerId.reset(); + FromFollowerId.reset(); } if (FromTabletId < Max<ui64>()) { @@ -139,7 +139,7 @@ private: if (cellsTo.size() == 2) { if (!cellsTo[1].IsNull()) { - ToFollowerId = cellsTo[1].AsValue<ui32>(); + ToFollowerId = cellsTo[1].AsValue<ui32>(); } if (TableRange.ToInclusive) { @@ -147,17 +147,17 @@ private: } // The range ends at NULL exclusive. So, the value before NULL will be used. - if (!ToFollowerId.has_value()) { - ToFollowerId = Max<ui32>(); + if (!ToFollowerId.has_value()) { + ToFollowerId = Max<ui32>(); return decreaseTabletId(); } - if (ToFollowerId > Min<ui32>()) { - ToFollowerId = ToFollowerId.value() - 1; + if (ToFollowerId > Min<ui32>()) { + ToFollowerId = ToFollowerId.value() - 1; return true; } - ToFollowerId.reset(); + ToFollowerId.reset(); } return decreaseTabletId(); @@ -240,8 +240,8 @@ private: insert({TSchema::TabletId::ColumnId, [] (const TEntry& entry) { return TCell::Make<ui64>(entry.GetTabletId()); }}); - insert({TSchema::FollowerId::ColumnId, [] (const TEntry& entry) { - return TCell::Make<ui32>(entry.GetFollowerId()); + insert({TSchema::FollowerId::ColumnId, [] (const TEntry& entry) { + return TCell::Make<ui32>(entry.GetFollowerId()); }}); insert({TSchema::TypeCol::ColumnId, [] (const TEntry& entry) { const auto& type = entry.GetType(); @@ -285,7 +285,7 @@ private: static TExtractorsMap extractors; size_t index = 0; - ui32 fromFollowerId = FromFollowerId.value_or(Min<ui32>()); + ui32 fromFollowerId = FromFollowerId.value_or(Min<ui32>()); if (record.EntriesSize() > 0 && record.GetEntries(0).GetTabletId() == FromTabletId) @@ -293,7 +293,7 @@ private: for (; index < record.EntriesSize(); ++index) { const auto& entry = record.GetEntries(index); - if (entry.GetTabletId() != FromTabletId || entry.GetFollowerId() >= fromFollowerId) { + if (entry.GetTabletId() != FromTabletId || entry.GetFollowerId() >= fromFollowerId) { break; } } @@ -301,12 +301,12 @@ private: auto batch = MakeHolder<NKqp::TEvKqpCompute::TEvScanData>(ScanId); TVector<TCell> cells; - ui32 toFollowerId = ToFollowerId.value_or(Max<ui32>()); + ui32 toFollowerId = ToFollowerId.value_or(Max<ui32>()); for (; index < record.EntriesSize(); ++index) { const auto& entry = record.GetEntries(index); - if (entry.GetTabletId() == ToTabletId && entry.GetFollowerId() > toFollowerId) { + if (entry.GetTabletId() == ToTabletId && entry.GetFollowerId() > toFollowerId) { break; } @@ -346,10 +346,10 @@ private: static constexpr size_t BatchSize = 10000; ui64 FromTabletId = 0; - std::optional<ui32> FromFollowerId; + std::optional<ui32> FromFollowerId; ui64 ToTabletId = Max<ui64>(); - std::optional<ui32> ToFollowerId; + std::optional<ui32> ToFollowerId; TVector<ui64> TabletIds; TVector<ui64>::const_iterator FromIterator; diff --git a/ydb/core/sys_view/ut_kqp.cpp b/ydb/core/sys_view/ut_kqp.cpp index fae22e8c891..5e90eb59927 100644 --- a/ydb/core/sys_view/ut_kqp.cpp +++ b/ydb/core/sys_view/ut_kqp.cpp @@ -1430,7 +1430,7 @@ Y_UNIT_TEST_SUITE(SystemView) { Memory, Network, NodeId, - FollowerId, + FollowerId, State, TabletId, Type, @@ -1449,7 +1449,7 @@ Y_UNIT_TEST_SUITE(SystemView) { check.Uint64GreaterOrEquals(0u); // Memory check.Uint64(0u); // Network check.Uint64(env.GetServer().GetRuntime()->GetNodeId(0)); // NodeId - check.Uint64(0u); // FollowerId + check.Uint64(0u); // FollowerId check.String("ReadyToWork"); // State check.Uint64(72075186224037888ul); // TabletId check.String("DataShard"); // Type @@ -1462,7 +1462,7 @@ Y_UNIT_TEST_SUITE(SystemView) { TTableClient client(env.GetDriver()); auto it = client.StreamExecuteScanQuery(R"( - SELECT FollowerId, TabletId, Type + SELECT FollowerId, TabletId, Type FROM `/Root/.sys/hive_tablets`; )").GetValueSync(); UNIT_ASSERT_C(it.IsSuccess(), it.GetIssues().ToString()); @@ -1474,7 +1474,7 @@ Y_UNIT_TEST_SUITE(SystemView) { ])", NKqp::StreamResultToYson(it)); } - Y_UNIT_TEST(TabletsFollowers) { + Y_UNIT_TEST(TabletsFollowers) { TTestEnv env(1, 0); TTableClient client(env.GetDriver()); @@ -1493,7 +1493,7 @@ Y_UNIT_TEST_SUITE(SystemView) { UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); auto it = client.StreamExecuteScanQuery(R"( - SELECT FollowerId, TabletId, Type + SELECT FollowerId, TabletId, Type FROM `/Root/.sys/hive_tablets`; )").GetValueSync(); UNIT_ASSERT_C(it.IsSuccess(), it.GetIssues().ToString()); @@ -1527,14 +1527,14 @@ Y_UNIT_TEST_SUITE(SystemView) { std::vector<std::pair<TString, TString>> testData = { { - "TabletId = 72075186224037888ul AND FollowerId > 1u", + "TabletId = 72075186224037888ul AND FollowerId > 1u", R"([ [[2u];[72075186224037888u]]; [[3u];[72075186224037888u]]; ])" }, { - "TabletId = 72075186224037888ul AND FollowerId >= 1u", + "TabletId = 72075186224037888ul AND FollowerId >= 1u", R"([ [[1u];[72075186224037888u]]; [[2u];[72075186224037888u]]; @@ -1542,14 +1542,14 @@ Y_UNIT_TEST_SUITE(SystemView) { ])" }, { - "TabletId = 72075186224037888ul AND FollowerId < 2u", + "TabletId = 72075186224037888ul AND FollowerId < 2u", R"([ [[0u];[72075186224037888u]]; [[1u];[72075186224037888u]]; ])" }, { - "TabletId = 72075186224037888ul AND FollowerId <= 2u", + "TabletId = 72075186224037888ul AND FollowerId <= 2u", R"([ [[0u];[72075186224037888u]]; [[1u];[72075186224037888u]]; @@ -1573,7 +1573,7 @@ Y_UNIT_TEST_SUITE(SystemView) { for (auto& data: testData) { TString query = R"( - SELECT FollowerId, TabletId + SELECT FollowerId, TabletId FROM `/Root/.sys/hive_tablets` WHERE <PREDICATE>; )"; @@ -1615,7 +1615,7 @@ Y_UNIT_TEST_SUITE(SystemView) { UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); TString query = R"( - SELECT FollowerId, TabletId + SELECT FollowerId, TabletId FROM `/Root/.sys/hive_tablets` WHERE TabletId <= 72075186224037888ul OR TabletId >= 72075186224037890ul; )"; diff --git a/ydb/core/tablet/bootstrapper.cpp b/ydb/core/tablet/bootstrapper.cpp index a83fd0c5fcb..d2e5dd8b7f3 100644 --- a/ydb/core/tablet/bootstrapper.cpp +++ b/ydb/core/tablet/bootstrapper.cpp @@ -54,7 +54,7 @@ class TBootstrapper : public TActor<TBootstrapper> { TIntrusivePtr<TBootstrapperInfo> BootstrapperInfo; TActorId LookOnActorID; - TActorId FollowerActorID; + TActorId FollowerActorID; ui64 RoundCounter; ui64 SelfSeed; @@ -215,10 +215,10 @@ class TBootstrapper : public TActor<TBootstrapper> { LOG_NOTICE(ctx, NKikimrServices::BOOTSTRAPPER, "tablet: %" PRIu64 ", type: %s, boot", TabletInfo->TabletID, GetTabletTypeName()); - if (FollowerActorID) { - LookOnActorID = FollowerActorID; - FollowerActorID = TActorId(); - ctx.Send(LookOnActorID, new TEvTablet::TEvPromoteToLeader(0, TabletInfo)); + if (FollowerActorID) { + LookOnActorID = FollowerActorID; + FollowerActorID = TActorId(); + ctx.Send(LookOnActorID, new TEvTablet::TEvPromoteToLeader(0, TabletInfo)); } else { TTabletSetupInfo *x = BootstrapperInfo->SetupInfo.Get(); LookOnActorID = x->Tablet(TabletInfo.Get(), ctx.SelfID, ctx, 0, AppData(ctx)->ResourceProfiles); @@ -247,9 +247,9 @@ class TBootstrapper : public TActor<TBootstrapper> { LookOnActorID = TActorId(); } - if (FollowerActorID) { - Send(FollowerActorID, new TEvents::TEvPoisonPill()); - FollowerActorID = TActorId(); + if (FollowerActorID) { + Send(FollowerActorID, new TEvents::TEvPoisonPill()); + FollowerActorID = TActorId(); } NotifyWatchers(); @@ -284,11 +284,11 @@ class TBootstrapper : public TActor<TBootstrapper> { TabletInfo->TabletID, GetTabletTypeName(), watchOn.NodeId()); Watches->Watched.push_back(TWatch::TWatched(watchOn, owner)); - if (BootstrapperInfo->StartFollowers && !FollowerActorID) { + if (BootstrapperInfo->StartFollowers && !FollowerActorID) { LOG_NOTICE(ctx, NKikimrServices::BOOTSTRAPPER, "tablet: %" PRIu64 ", type: %s, boot follower", TabletInfo->TabletID, GetTabletTypeName()); TTabletSetupInfo *x = BootstrapperInfo->SetupInfo.Get(); - FollowerActorID = x->Follower(TabletInfo.Get(), ctx.SelfID, ctx, 0, AppData(ctx)->ResourceProfiles); + FollowerActorID = x->Follower(TabletInfo.Get(), ctx.SelfID, ctx, 0, AppData(ctx)->ResourceProfiles); } Become(&TThis::StateWatch); diff --git a/ydb/core/tablet/bootstrapper.h b/ydb/core/tablet/bootstrapper.h index 891b413b17f..2e246ea2b07 100644 --- a/ydb/core/tablet/bootstrapper.h +++ b/ydb/core/tablet/bootstrapper.h @@ -37,13 +37,13 @@ struct TBootstrapperInfo : public TThrRefBase { TVector<ui32> OtherNodes; TDuration WatchThreshold; TDuration OfflineDelay; - bool StartFollowers; + bool StartFollowers; TBootstrapperInfo(TTabletSetupInfo *setupInfo) : SetupInfo(setupInfo) , WatchThreshold(TDuration::MilliSeconds(200)) , OfflineDelay(TDuration::Seconds(3)) - , StartFollowers(false) + , StartFollowers(false) {} }; diff --git a/ydb/core/tablet/node_tablet_monitor.cpp b/ydb/core/tablet/node_tablet_monitor.cpp index 4a24a49837d..8bb34e7ea0b 100644 --- a/ydb/core/tablet/node_tablet_monitor.cpp +++ b/ydb/core/tablet/node_tablet_monitor.cpp @@ -372,12 +372,12 @@ public: TABLED() {str << ei.GetCurrentGeneration();} TABLED() {if (ei.HasLockedFor()) str << TDuration::MicroSeconds(ei.GetLockedFor()).Seconds();} TABLED() { - ui32 nodeId = ActorIdFromProto(ei.GetCurrentLeader()).NodeId(); + ui32 nodeId = ActorIdFromProto(ei.GetCurrentLeader()).NodeId(); str << nodeId; auto eq_it = EqualRange(NodesInfo->Nodes.begin(), NodesInfo->Nodes.end(), nodeId); if (eq_it.first != NodesInfo->Nodes.end() && eq_it.first->Host) str << " / " << eq_it.first->Host; } - TABLED() {if (ActorIdFromProto(ei.GetCurrentLeaderTablet())) str << "<span class='glyphicon glyphicon-ok' title='User Actor present'/>";} + TABLED() {if (ActorIdFromProto(ei.GetCurrentLeaderTablet())) str << "<span class='glyphicon glyphicon-ok' title='User Actor present'/>";} } } } diff --git a/ydb/core/tablet/node_whiteboard.cpp b/ydb/core/tablet/node_whiteboard.cpp index d9813405db5..783758e99d1 100644 --- a/ydb/core/tablet/node_whiteboard.cpp +++ b/ydb/core/tablet/node_whiteboard.cpp @@ -70,7 +70,7 @@ public: } protected: - std::unordered_map<std::pair<TTabletId, TFollowerId>, NKikimrWhiteboard::TTabletStateInfo> TabletStateInfo; + std::unordered_map<std::pair<TTabletId, TFollowerId>, NKikimrWhiteboard::TTabletStateInfo> TabletStateInfo; std::unordered_map<TString, NKikimrWhiteboard::TNodeStateInfo> NodeStateInfo; std::unordered_map<ui32, NKikimrWhiteboard::TPDiskStateInfo> PDiskStateInfo; std::unordered_map<TVDiskID, NKikimrWhiteboard::TVDiskStateInfo, THash<TVDiskID>> VDiskStateInfo; @@ -374,7 +374,7 @@ protected: } void Handle(TEvWhiteboard::TEvTabletStateUpdate::TPtr &ev, const TActorContext &ctx) { - auto tabletId(std::make_pair(ev->Get()->Record.GetTabletId(), ev->Get()->Record.GetFollowerId())); + auto tabletId(std::make_pair(ev->Get()->Record.GetTabletId(), ev->Get()->Record.GetFollowerId())); auto& tabletStateInfo = TabletStateInfo[tabletId]; if (ev->Get()->Record.HasGeneration() && tabletStateInfo.GetGeneration() > ev->Get()->Record.GetGeneration()) { return; // skip updates from previous generations diff --git a/ydb/core/tablet/tablet_counters_aggregator.cpp b/ydb/core/tablet/tablet_counters_aggregator.cpp index 226081ffebe..1885b26e09c 100644 --- a/ydb/core/tablet/tablet_counters_aggregator.cpp +++ b/ydb/core/tablet/tablet_counters_aggregator.cpp @@ -30,8 +30,8 @@ //////////////////////////////////////////// namespace NKikimr { -TActorId MakeTabletCountersAggregatorID(ui32 node, bool follower) { - if (!follower) { +TActorId MakeTabletCountersAggregatorID(ui32 node, bool follower) { + if (!follower) { char x[12] = {'t','a','b','l','c','o','u','n','t','a','g','g'}; return TActorId(node, TStringBuf(x, 12)); } else { @@ -470,13 +470,13 @@ private: class TTabletMon { public: // - TTabletMon(NMonitoring::TDynamicCounterPtr counters, bool isFollower, TActorId dbWatcherActorId) - : Counters(GetServiceCounters(counters, isFollower ? "followers" : "tablets")) + TTabletMon(NMonitoring::TDynamicCounterPtr counters, bool isFollower, TActorId dbWatcherActorId) + : Counters(GetServiceCounters(counters, isFollower ? "followers" : "tablets")) , AllTypes(Counters.Get(), "type", "all", true) - , IsFollower(isFollower) + , IsFollower(isFollower) , DbWatcherActorId(dbWatcherActorId) { - if (!IsFollower) { + if (!IsFollower) { YdbCounters = MakeIntrusive<TYdbTabletCounters>(GetServiceCounters(counters, "ydb")); } } @@ -492,7 +492,7 @@ public: typeCounters->Apply(tabletID, executorCounters, appCounters, tabletType); } // - if (!IsFollower && AppData(ctx)->FeatureFlags.GetEnableDbCounters() && tenantPathId) { + if (!IsFollower && AppData(ctx)->FeatureFlags.GetEnableDbCounters() && tenantPathId) { auto dbCounters = GetDbCounters(tenantPathId, ctx); if (dbCounters) { auto* limitedAppCounters = GetOrAddLimitedAppCounters(tabletType); @@ -1525,7 +1525,7 @@ private: // NMonitoring::TDynamicCounterPtr Counters; TTabletCountersForTabletType AllTypes; - bool IsFollower = false; + bool IsFollower = false; typedef THashMap<TPathId, TIntrusivePtr<TTabletCountersForDb>> TCountersByPathId; typedef TMap<TTabletTypes::EType, THolder<TTabletCountersBase>> TAppCountersByTabletType; @@ -1563,7 +1563,7 @@ public: } // - TTabletCountersAggregatorActor(bool follower); + TTabletCountersAggregatorActor(bool follower); virtual ~TTabletCountersAggregatorActor(); // @@ -1589,14 +1589,14 @@ private: TActorId DbWatcherActorId; THashMap<TActorId, std::pair<TActorId, TAutoPtr<NMon::TEvHttpInfo>>> HttpRequestHandlers; THashSet<ui32> TabletTypeOfReceivedLabeledCounters; - bool Follower; + bool Follower; }; //////////////////////////////////////////// /// The TTabletCountersAggregatorActor class //////////////////////////////////////////// -TTabletCountersAggregatorActor::TTabletCountersAggregatorActor(bool follower) - : Follower(follower) +TTabletCountersAggregatorActor::TTabletCountersAggregatorActor(bool follower) + : Follower(follower) {} //////////////////////////////////////////// @@ -1611,18 +1611,18 @@ TTabletCountersAggregatorActor::Bootstrap(const TActorContext &ctx) { TAppData* appData = AppData(ctx); Y_VERIFY(!TabletMon); - if (AppData(ctx)->FeatureFlags.GetEnableDbCounters() && !Follower) { + if (AppData(ctx)->FeatureFlags.GetEnableDbCounters() && !Follower) { auto callback = MakeIntrusive<TTabletMon::TTabletsDbWatcherCallback>(ctx.ActorSystem()); DbWatcherActorId = ctx.Register(NSysView::CreateDbWatcherActor(callback)); } - TabletMon = new TTabletMon(appData->Counters, Follower, DbWatcherActorId); + TabletMon = new TTabletMon(appData->Counters, Follower, DbWatcherActorId); auto mon = appData->Mon; if (mon) { - if (!Follower) + if (!Follower) mon->RegisterActorPage(nullptr, "labeledcounters", "Labeled Counters", false, TlsActivationContext->ExecutorThread.ActorSystem, SelfId(), false); else - mon->RegisterActorPage(nullptr, "followercounters", "Follower Counters", false, TlsActivationContext->ExecutorThread.ActorSystem, SelfId(), false); + mon->RegisterActorPage(nullptr, "followercounters", "Follower Counters", false, TlsActivationContext->ExecutorThread.ActorSystem, SelfId(), false); } ctx.Schedule(TDuration::Seconds(WAKEUP_TIMEOUT_SECONDS), new TEvents::TEvWakeup()); @@ -1852,12 +1852,12 @@ STFUNC(TTabletCountersAggregatorActor::StateWork) { static ui32 AGGREGATOR_TIMEOUT_SECONDS = 60; IActor* -CreateTabletCountersAggregator(bool follower) { - return new TTabletCountersAggregatorActor(follower); +CreateTabletCountersAggregator(bool follower) { + return new TTabletCountersAggregatorActor(follower); } -void TabletCountersForgetTablet(ui64 tabletId, TTabletTypes::EType tabletType, TPathId tenantPathId, bool follower, TActorIdentity identity) { - const TActorId countersAggregator = MakeTabletCountersAggregatorID(identity.NodeId(), follower); +void TabletCountersForgetTablet(ui64 tabletId, TTabletTypes::EType tabletType, TPathId tenantPathId, bool follower, TActorIdentity identity) { + const TActorId countersAggregator = MakeTabletCountersAggregatorID(identity.NodeId(), follower); identity.Send(countersAggregator, new TEvTabletCounters::TEvTabletCountersForgetTablet(tabletId, tabletType, tenantPathId)); } diff --git a/ydb/core/tablet/tablet_counters_aggregator.h b/ydb/core/tablet/tablet_counters_aggregator.h index 211848ea51f..db350d41cbf 100644 --- a/ydb/core/tablet/tablet_counters_aggregator.h +++ b/ydb/core/tablet/tablet_counters_aggregator.h @@ -16,7 +16,7 @@ namespace NKikimr { //////////////////////////////////////////// -TActorId MakeTabletCountersAggregatorID(ui32 node, bool follower = false); +TActorId MakeTabletCountersAggregatorID(ui32 node, bool follower = false); static const ui32 WORKERS_COUNT = 0; @@ -115,7 +115,7 @@ struct TEvTabletCounters { }; //////////////////////////////////////////// -void TabletCountersForgetTablet(ui64 tabletId, TTabletTypes::EType tabletType, TPathId tenantPathId, bool follower, TActorIdentity identity); +void TabletCountersForgetTablet(ui64 tabletId, TTabletTypes::EType tabletType, TPathId tenantPathId, bool follower, TActorIdentity identity); TStringBuf GetHistogramAggregateSimpleName(TStringBuf name); bool IsHistogramAggregateSimpleName(TStringBuf name); @@ -127,7 +127,7 @@ TIntrusivePtr<NSysView::IDbCounters> CreateTabletDbCounters( THolder<TTabletCountersBase> executorCounters); //////////////////////////////////////////// -IActor* CreateTabletCountersAggregator(bool follower); +IActor* CreateTabletCountersAggregator(bool follower); //////////////////////////////////////////// diff --git a/ydb/core/tablet/tablet_impl.h b/ydb/core/tablet/tablet_impl.h index e7946059ec6..b47b1f10971 100644 --- a/ydb/core/tablet/tablet_impl.h +++ b/ydb/core/tablet/tablet_impl.h @@ -13,7 +13,7 @@ namespace NKikimr { -IActor* CreateTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie); +IActor* CreateTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie); IActor* CreateTabletFindLastEntry(const TActorId &owner, bool readBody, TTabletStorageInfo *info, ui32 blockedGen); IActor* CreateTabletReqWriteLog(const TActorId &owner, const TLogoBlobID &entryId, NKikimrTabletBase::TTabletLogEntry *entry, TVector<TEvTablet::TLogEntryReference> &refs, TEvBlobStorage::TEvPut::ETactic commitTactic, TTabletStorageInfo *info); IActor* CreateTabletReqBlockBlobStorage(const TActorId &owner, TTabletStorageInfo *info, ui32 generation, bool blockPrevEntry); @@ -27,9 +27,9 @@ struct TEvTabletBase { EvWriteLogResult, EvDeleteTabletResult, - EvFollowerRetry = EvBlockBlobStorageResult + 512, - EvTrySyncFollower, - EvTryBuildFollowerGraph, + EvFollowerRetry = EvBlockBlobStorageResult + 512, + EvTrySyncFollower, + EvTryBuildFollowerGraph, EvEnd }; @@ -135,25 +135,25 @@ struct TEvTabletBase { {} }; - struct TEvFollowerRetry : public TEventLocal<TEvFollowerRetry, EvFollowerRetry> { + struct TEvFollowerRetry : public TEventLocal<TEvFollowerRetry, EvFollowerRetry> { const ui32 Round; - TEvFollowerRetry(ui32 round) + TEvFollowerRetry(ui32 round) : Round(round) {} }; - struct TEvTrySyncFollower : public TEventLocal<TEvTrySyncFollower, EvTrySyncFollower> { - const TActorId FollowerId; + struct TEvTrySyncFollower : public TEventLocal<TEvTrySyncFollower, EvTrySyncFollower> { + const TActorId FollowerId; TSchedulerCookieHolder CookieHolder; - TEvTrySyncFollower(TActorId followerId, ISchedulerCookie *cookie) - : FollowerId(followerId) + TEvTrySyncFollower(TActorId followerId, ISchedulerCookie *cookie) + : FollowerId(followerId) , CookieHolder(cookie) {} }; - struct TEvTryBuildFollowerGraph : public TEventLocal<TEvTryBuildFollowerGraph, EvTryBuildFollowerGraph> {}; + struct TEvTryBuildFollowerGraph : public TEventLocal<TEvTryBuildFollowerGraph, EvTryBuildFollowerGraph> {}; struct TEvDeleteTabletResult : public TEventLocal<TEvDeleteTabletResult, EvDeleteTabletResult> { const NKikimrProto::EReplyStatus Status; diff --git a/ydb/core/tablet/tablet_metrics.cpp b/ydb/core/tablet/tablet_metrics.cpp index 08eccc6ac91..182c7c566e4 100644 --- a/ydb/core/tablet/tablet_metrics.cpp +++ b/ydb/core/tablet/tablet_metrics.cpp @@ -84,9 +84,9 @@ void TResourceMetricsValues::Fill(NKikimrTabletBase::TMetrics& metrics) const { } } -TResourceMetricsSendState::TResourceMetricsSendState(ui64 tabletId, ui32 followerId, const TActorId& launcher) +TResourceMetricsSendState::TResourceMetricsSendState(ui64 tabletId, ui32 followerId, const TActorId& launcher) : TabletId(tabletId) - , FollowerId(followerId) + , FollowerId(followerId) , Launcher(launcher) {} @@ -270,7 +270,7 @@ bool TResourceMetricsSendState::TryUpdate(TResourceMetricsValues& src, const TAc NKikimrTabletBase::TMetrics values; bool updated = FillChanged(src, values, now, past > TDuration::Seconds(60)); if (updated) { - ctx.Send(Launcher, new TEvLocal::TEvTabletMetrics(TabletId, FollowerId, values)); + ctx.Send(Launcher, new TEvLocal::TEvTabletMetrics(TabletId, FollowerId, values)); LastUpdate = now; } return updated; diff --git a/ydb/core/tablet/tablet_metrics.h b/ydb/core/tablet/tablet_metrics.h index 78017685a97..b426284d33f 100644 --- a/ydb/core/tablet/tablet_metrics.h +++ b/ydb/core/tablet/tablet_metrics.h @@ -54,7 +54,7 @@ public: class TResourceMetricsSendState { public: - TResourceMetricsSendState(ui64 tabletId, ui32 followerId, const TActorId& launcher); + TResourceMetricsSendState(ui64 tabletId, ui32 followerId, const TActorId& launcher); bool FillChanged(TResourceMetricsValues& src, NKikimrTabletBase::TMetrics& metrics, TInstant now = TInstant::Now(), bool forceAll = false); bool TryUpdate(TResourceMetricsValues& src, const TActorContext& ctx); @@ -67,7 +67,7 @@ protected: static constexpr ui64 SignificantChangeIops = 10 /* 10 iops? */; const ui64 TabletId; - const ui32 FollowerId; + const ui32 FollowerId; const TActorId Launcher; ui32 LevelCPU = 0; ui32 LevelMemory = 0; @@ -83,8 +83,8 @@ protected: class TResourceMetrics : public TResourceMetricsValues, public TResourceMetricsSendState { public: - TResourceMetrics(ui64 tabletId, ui32 followerId, const TActorId& launcher) - : TResourceMetricsSendState(tabletId, followerId, launcher) {} + TResourceMetrics(ui64 tabletId, ui32 followerId, const TActorId& launcher) + : TResourceMetricsSendState(tabletId, followerId, launcher) {} bool FillChanged(NKikimrTabletBase::TMetrics& metrics, TInstant now = TInstant::Now(), bool forceAll = false) { return TResourceMetricsSendState::FillChanged(*this, metrics, now, forceAll); diff --git a/ydb/core/tablet/tablet_monitoring_proxy.cpp b/ydb/core/tablet/tablet_monitoring_proxy.cpp index b5a8786b627..a61a43b7e5c 100644 --- a/ydb/core/tablet/tablet_monitoring_proxy.cpp +++ b/ydb/core/tablet/tablet_monitoring_proxy.cpp @@ -27,7 +27,7 @@ public: TForwardingActor(const TTabletMonitoringProxyConfig& config, ui64 targetTablet, bool forceFollower, const TActorId& sender, const TString& query, HTTP_METHOD method) : Config(config) , TargetTablet(targetTablet) - , ForceFollower(forceFollower) + , ForceFollower(forceFollower) , Sender(sender) , Query(query) , Method(method) @@ -39,8 +39,8 @@ public: void Bootstrap(const TActorContext& ctx) { NTabletPipe::TClientConfig config; - config.AllowFollower = ForceFollower; - config.ForceFollower = ForceFollower; + config.AllowFollower = ForceFollower; + config.ForceFollower = ForceFollower; config.PreferLocal = Config.PreferLocal; config.RetryPolicy = Config.RetryPolicy; @@ -112,7 +112,7 @@ public: private: const TTabletMonitoringProxyConfig Config; const ui64 TargetTablet; - const bool ForceFollower; + const bool ForceFollower; const TActorId Sender; const TString Query; TActorId PipeClient; @@ -201,9 +201,9 @@ TTabletMonitoringProxyActor::Handle(NMon::TEvHttpInfo::TPtr &ev, const TActorCon } } - bool hasFollowerParam = cgi->Has("FollowerID"); - if (hasFollowerParam) { - const TString &tabletIdParam = cgi->Get("FollowerID"); + bool hasFollowerParam = cgi->Has("FollowerID"); + if (hasFollowerParam) { + const TString &tabletIdParam = cgi->Get("FollowerID"); const ui64 tabletId = TryParseTabletId(tabletIdParam); if (tabletId) { TString url = TStringBuilder() << msg->Request.GetPathInfo() << "?" << cgi->Print(); diff --git a/ydb/core/tablet/tablet_pipe_client.cpp b/ydb/core/tablet/tablet_pipe_client.cpp index 3d860596510..2fa35af9a0e 100644 --- a/ydb/core/tablet/tablet_pipe_client.cpp +++ b/ydb/core/tablet/tablet_pipe_client.cpp @@ -38,7 +38,7 @@ namespace NTabletPipe { , Config(config) , IsShutdown(false) , PayloadQueue(new TPayloadQueue()) - , Leader(true) + , Leader(true) { Y_VERIFY(tabletId != 0); } @@ -127,12 +127,12 @@ namespace NTabletPipe { } bool IsLocalNode(const TActorContext& ctx) const { - auto leader = GetTabletLeader(); - return leader.NodeId() == 0 || ctx.ExecutorThread.ActorSystem->NodeId == leader.NodeId(); + auto leader = GetTabletLeader(); + return leader.NodeId() == 0 || ctx.ExecutorThread.ActorSystem->NodeId == leader.NodeId(); } - TActorId GetTabletLeader() const { - return Config.ConnectToUserTablet ? LastKnownLeaderTablet : LastKnownLeader; + TActorId GetTabletLeader() const { + return Config.ConnectToUserTablet ? LastKnownLeaderTablet : LastKnownLeader; } void HandleSendQueued(TAutoPtr<IEventHandle>& ev, const TActorContext& ctx) { @@ -163,8 +163,8 @@ namespace NTabletPipe { return TryToReconnect(ctx); } - LastKnownLeaderTablet = ev->Get()->TabletActor; - LastKnownLeader = ev->Get()->Tablet; + LastKnownLeaderTablet = ev->Get()->TabletActor; + LastKnownLeader = ev->Get()->Tablet; LastCacheEpoch = ev->Get()->CacheEpoch; if (IsLocalNode(ctx)) { @@ -172,7 +172,7 @@ namespace NTabletPipe { UnsubscribeNetworkSession(ctx); Connect(ctx); } else { - const ui32 nodeId = GetTabletLeader().NodeId(); + const ui32 nodeId = GetTabletLeader().NodeId(); BLOG_D("forward result remote node " << nodeId); if (InterconnectNodeId == nodeId) { // Already connected to correct remote node @@ -254,7 +254,7 @@ namespace NTabletPipe { } void Connect(const TActorContext &ctx) { - SendEvent(new IEventHandle(GetTabletLeader(), ctx.SelfID, new TEvTabletPipe::TEvConnect(TabletId, ctx.SelfID, GenerateConnectFeatures()), + SendEvent(new IEventHandle(GetTabletLeader(), ctx.SelfID, new TEvTabletPipe::TEvConnect(TabletId, ctx.SelfID, GenerateConnectFeatures()), IEventHandle::FlagTrackDelivery, ++ConnectCookie), ctx); Become(&TThis::StateConnect); } @@ -282,10 +282,10 @@ namespace NTabletPipe { Y_VERIFY(record.GetTabletId() == TabletId); ServerId = ActorIdFromProto(record.GetServerId()); - Leader = record.GetLeader(); + Leader = record.GetLeader(); Y_VERIFY(!ServerId || record.GetStatus() == NKikimrProto::OK); - BLOG_D("connected with status " << record.GetStatus() << " role: " << (Leader ? "Leader" : "Follower")); + BLOG_D("connected with status " << record.GetStatus() << " role: " << (Leader ? "Leader" : "Follower")); if (!ServerId) { return TryToReconnect(ctx); @@ -299,7 +299,7 @@ namespace NTabletPipe { PayloadQueue.Destroy(); - ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::OK, ctx.SelfID, ServerId, Leader, false)); + ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::OK, ctx.SelfID, ServerId, Leader, false)); if (IsShutdown) { BLOG_D("shutdown pipe due to pending shutdown request"); @@ -383,8 +383,8 @@ namespace NTabletPipe { Y_UNUSED(ev); BLOG_D("client retry"); - LastKnownLeaderTablet = TActorId(); - LastKnownLeader = TActorId(); + LastKnownLeaderTablet = TActorId(); + LastKnownLeader = TActorId(); Lookup(ctx); } @@ -415,7 +415,7 @@ namespace NTabletPipe { } } - ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, definitelyDead)); + ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, definitelyDead)); return Die(ctx); } @@ -437,7 +437,7 @@ namespace NTabletPipe { return; auto *msg = ev->Get(); if (msg->Status != NKikimrProto::OK) { - ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); + ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); return Die(ctx); } } @@ -445,7 +445,7 @@ namespace NTabletPipe { void Handle(TEvTabletPipe::TEvClientDestroyed::TPtr &ev, const TActorContext &ctx) { if (HiveClient != ev->Sender) return; - ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); + ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); return Die(ctx); } @@ -460,7 +460,7 @@ namespace NTabletPipe { Become(&TThis::StateCheckDead, RetryState.MakeCheckDelay(), new TEvTabletPipe::TEvClientCheckDelay()); } else { BLOG_D("connect failed"); - ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); + ctx.Send(Owner, new TEvTabletPipe::TEvClientConnected(TabletId, NKikimrProto::ERROR, SelfId(), TActorId(), Leader, false)); return Die(ctx); } } @@ -492,8 +492,8 @@ namespace NTabletPipe { void Lookup(const TActorContext& ctx) { BLOG_D("lookup"); TEvTabletResolver::TEvForward::TResolveFlags resolveFlags; - resolveFlags.SetAllowFollower(Config.AllowFollower); - resolveFlags.SetForceFollower(Config.ForceFollower); + resolveFlags.SetAllowFollower(Config.AllowFollower); + resolveFlags.SetForceFollower(Config.ForceFollower); resolveFlags.SetPreferLocal(Config.PreferLocal); resolveFlags.SetForceLocal(Config.ForceLocal); @@ -502,11 +502,11 @@ namespace NTabletPipe { } void TryToReconnect(const TActorContext& ctx) { - if (LastKnownLeaderTablet) - ctx.Send(MakeTabletResolverID(), new TEvTabletResolver::TEvTabletProblem(TabletId, LastKnownLeaderTablet)); + if (LastKnownLeaderTablet) + ctx.Send(MakeTabletResolverID(), new TEvTabletResolver::TEvTabletProblem(TabletId, LastKnownLeaderTablet)); - LastKnownLeaderTablet = TActorId(); - LastKnownLeader = TActorId(); + LastKnownLeaderTablet = TActorId(); + LastKnownLeader = TActorId(); TDuration waitDuration; if (Config.RetryPolicy && RetryState.IsAllowedToRetry(waitDuration, Config.RetryPolicy)) { @@ -666,8 +666,8 @@ namespace NTabletPipe { const ui64 TabletId; const TClientConfig Config; bool IsShutdown; - TActorId LastKnownLeader; - TActorId LastKnownLeaderTablet; + TActorId LastKnownLeader; + TActorId LastKnownLeaderTablet; ui64 LastCacheEpoch = 0; ui32 InterconnectNodeId = 0; ui64 InterconnectCookie = 0; @@ -678,7 +678,7 @@ namespace NTabletPipe { typedef TOneOneQueueInplace<IEventHandle*, 32> TPayloadQueue; TAutoPtr<TPayloadQueue, TPayloadQueue::TPtrCleanDestructor> PayloadQueue; TClientRetryState RetryState; - bool Leader; + bool Leader; TActorId HiveClient; ui32 CurrentHiveForwards = 0; static constexpr ui32 MAX_HIVE_FORWARDS = 10; diff --git a/ydb/core/tablet/tablet_pipe_server.cpp b/ydb/core/tablet/tablet_pipe_server.cpp index 9e23873c431..b7c669e72cc 100644 --- a/ydb/core/tablet/tablet_pipe_server.cpp +++ b/ydb/core/tablet/tablet_pipe_server.cpp @@ -23,7 +23,7 @@ namespace NTabletPipe { , ConnectCookie(connectCookie) , Features(features) , NeedUnsubscribe(false) - , Leader(true) + , Leader(true) , Connected(false) { Y_VERIFY(tabletId != 0); @@ -184,7 +184,7 @@ namespace NTabletPipe { void Handle(TEvTabletPipe::TEvActivate::TPtr& ev, const TActorContext& ctx) { OwnerId = ev->Get()->OwnerId; RecipientId = ev->Get()->RecipientId; - Leader = ev->Get()->Leader; + Leader = ev->Get()->Leader; Y_VERIFY(OwnerId); Y_VERIFY(RecipientId); if (InterconnectSession) { @@ -249,7 +249,7 @@ namespace NTabletPipe { const ui64 ConnectCookie; const ui32 Features; bool NeedUnsubscribe; - bool Leader; + bool Leader; bool Connected; bool HadShutdown = false; }; @@ -263,7 +263,7 @@ namespace NTabletPipe { { } - TActorId Accept(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, TActorId recipientId, bool leader) override { + TActorId Accept(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, TActorId recipientId, bool leader) override { Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const TActorId clientId = ActorIdFromProto(ev->Get()->Record.GetClientId()); IActor* server = CreateServer(TabletId, clientId, ev->InterconnectSession, ev->Get()->Record.GetFeatures(), ev->Cookie); @@ -271,16 +271,16 @@ namespace NTabletPipe { LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" << " Accept Connect Originator# " << ev->Sender); ServerIds.insert(serverId); - ActivateServer(TabletId, serverId, owner, recipientId, leader); + ActivateServer(TabletId, serverId, owner, recipientId, leader); return serverId; } - void Reject(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, NKikimrProto::EReplyStatus status, bool leader) override { + void Reject(TEvTabletPipe::TEvConnect::TPtr &ev, TActorIdentity owner, NKikimrProto::EReplyStatus status, bool leader) override { Y_VERIFY(ev->Get()->Record.GetTabletId() == TabletId); const TActorId clientId = ActorIdFromProto(ev->Get()->Record.GetClientId()); LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" << " Reject Connect Originator# " << ev->Sender); - owner.Send(clientId, new TEvTabletPipe::TEvConnectResult(status, TabletId, clientId, TActorId(), leader)); + owner.Send(clientId, new TEvTabletPipe::TEvConnectResult(status, TabletId, clientId, TActorId(), leader)); } void Stop(TActorIdentity owner) override { @@ -315,10 +315,10 @@ namespace NTabletPipe { return serverId; } - void Activate(TActorIdentity owner, TActorId recipientId, bool leader) override { + void Activate(TActorIdentity owner, TActorId recipientId, bool leader) override { LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::PIPE_SERVER, "[" << TabletId << "]" << " Activate"); for (const auto& serverId : ActivatePending) { - ActivateServer(TabletId, serverId, owner, recipientId, leader); + ActivateServer(TabletId, serverId, owner, recipientId, leader); } ActivatePending.clear(); @@ -356,8 +356,8 @@ namespace NTabletPipe { return new TConnectAcceptor(tabletId); } - void ActivateServer(ui64 tabletId, TActorId serverId, TActorIdentity owner, TActorId recipientId, bool leader) { - owner.Send(serverId, new TEvTabletPipe::TEvActivate(tabletId, owner, recipientId, leader)); + void ActivateServer(ui64 tabletId, TActorId serverId, TActorIdentity owner, TActorId recipientId, bool leader) { + owner.Send(serverId, new TEvTabletPipe::TEvActivate(tabletId, owner, recipientId, leader)); } void CloseServer(TActorIdentity owner, TActorId serverId) { diff --git a/ydb/core/tablet/tablet_pipe_ut.cpp b/ydb/core/tablet/tablet_pipe_ut.cpp index f0fe4d1c87c..2a528070fb6 100644 --- a/ydb/core/tablet/tablet_pipe_ut.cpp +++ b/ydb/core/tablet/tablet_pipe_ut.cpp @@ -101,7 +101,7 @@ namespace NKikimr { } auto client = NTabletPipe::CreateClient(ctx.SelfID, ev->Get()->UseBadTabletId ? - TTestTxConfig::TxTablet2 : TTestTxConfig::TxTablet1, Config); + TTestTxConfig::TxTablet2 : TTestTxConfig::TxTablet1, Config); ClientId = ctx.ExecutorThread.RegisterActor(client, TMailboxType::Simple, Max<ui32>(), ctx.SelfID); } @@ -136,7 +136,7 @@ namespace NKikimr { Cout << "Pipe reset on client\n"; if (IsOpened && ClientId == ev->Get()->ClientId && !IsShutdown) { Cout << "Recreate client\n"; - auto client = NTabletPipe::CreateClient(ctx.SelfID, TTestTxConfig::TxTablet1, Config); + auto client = NTabletPipe::CreateClient(ctx.SelfID, TTestTxConfig::TxTablet1, Config); ClientId = ctx.ExecutorThread.RegisterActor(client); } } @@ -405,10 +405,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -418,21 +418,21 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(true)); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -445,10 +445,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -458,8 +458,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.SetLogPriority(NKikimrServices::PIPE_CLIENT, NActors::NLog::PRI_DEBUG); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -489,7 +489,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { i32 i = 3; while (i --> 0) { - auto client = NTabletPipe::CreateClient(sender, TTestTxConfig::TxTablet1, config); + auto client = NTabletPipe::CreateClient(sender, TTestTxConfig::TxTablet1, config); TActorId clientId = runtime.Register(client); // We want to close the client right after it has sent EvConnect to the target tablet but before @@ -504,7 +504,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } { - ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvPrivate::TEvGetServerPipeInfo()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvPrivate::TEvGetServerPipeInfo()); TAutoPtr<IEventHandle> handle; const TEvPrivate::TEvServerPipeInfo* ev = runtime.GrabEdgeEvent<TEvPrivate::TEvServerPipeInfo>(handle); UNIT_ASSERT_VALUES_EQUAL(ev->ServerPipesOpened, ev->ServerPipesClosed); @@ -516,10 +516,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -529,8 +529,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(true)); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -543,10 +543,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -556,14 +556,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -577,14 +577,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { TActorId sender = runtime.AllocateEdgeActor(); TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); auto guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -594,7 +594,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -602,8 +602,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } Cout << "Reboot consumer\n"; - RebootTablet(runtime, TTestTxConfig::TxTablet1, sender); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + RebootTablet(runtime, TTestTxConfig::TxTablet1, sender); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -611,9 +611,9 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } Cout << "Reboot producer\n"; - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -626,10 +626,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -639,7 +639,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -647,7 +647,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } - ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvConsumerTablet::TEvReject()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvConsumerTablet::TEvReject()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientDestroyed, 1)); @@ -660,10 +660,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -673,8 +673,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvConsumerTablet::TEvReject()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet1, sender, new TEvConsumerTablet::TEvReject()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -687,10 +687,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTabletWithoutAcceptor(tablet, info); }); @@ -700,14 +700,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false)); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -722,14 +722,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { TActorId sender = runtime.AllocateEdgeActor(); TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); auto guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTabletWithoutAcceptor(tablet, info); }); @@ -739,7 +739,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false, true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false, true)); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -747,8 +747,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } Cout << "Reboot consumer\n"; - RebootTablet(runtime, TTestTxConfig::TxTablet1, sender); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + RebootTablet(runtime, TTestTxConfig::TxTablet1, sender); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -756,9 +756,9 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { } Cout << "Reboot producer\n"; - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false, true)); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, false, true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -771,10 +771,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -784,8 +784,8 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false)); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend(true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend(true)); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -798,10 +798,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender1 = runtime.AllocateEdgeActor(0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }, 0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }, 1); @@ -811,14 +811,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -831,10 +831,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender1 = runtime.AllocateEdgeActor(0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }, 0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }, 1); @@ -844,7 +844,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); @@ -866,7 +866,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -879,11 +879,11 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender = runtime.AllocateEdgeActor(); TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); auto scheduledEventsGuard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }); @@ -893,7 +893,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvConnect(false, true, true)); { TDispatchOptions options; @@ -912,7 +912,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }); @@ -923,7 +923,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvProducerTablet::TEvSend()); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -936,10 +936,10 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { SetupTabletServices(runtime); TActorId sender1 = runtime.AllocateEdgeActor(0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }, 0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }, 1); @@ -949,30 +949,30 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); runtime.DispatchEvents(options); } - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender1); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender1); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -989,14 +989,14 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { TActorId sender2 = runtime.AllocateEdgeActor(1); TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); auto guard = CreateTabletScheduledEventsGuard(tabletIds, runtime, sender1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TProducerTablet(tablet, info); }, 0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet1, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TConsumerTablet(tablet, info); }, 1); @@ -1006,30 +1006,30 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(false, true, true), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(false, true, true), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); runtime.DispatchEvents(options); } - RebootTablet(runtime, TTestTxConfig::TxTablet1, sender2, 1); + RebootTablet(runtime, TTestTxConfig::TxTablet1, sender2, 1); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(false, true, true), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvConnect(false, true, true), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTabletPipe::EvClientConnected, 1)); runtime.DispatchEvents(options); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvProducerTablet::TEvSend(), 0); { TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvents::THelloWorld::Pong)); @@ -1135,7 +1135,7 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { TActorId sender1 = runtime.AllocateEdgeActor(0); TActorId sender2 = runtime.AllocateEdgeActor(1); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId & tablet, TTabletStorageInfo* info) { return new TEchoTablet(tablet, info); }); @@ -1147,12 +1147,12 @@ Y_UNIT_TEST_SUITE(TTabletPipeTest) { TAutoPtr<IEventHandle> handle; - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvents::TEvPing(), /* node index */ 0); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender1, new TEvents::TEvPing(), /* node index */ 0); runtime.GrabEdgeEvent<TEvents::TEvPong>(handle); UNIT_ASSERT(handle); UNIT_ASSERT_C(handle->Recipient == sender1, "Event recipient " << handle->Recipient << " != " << sender1); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender2, new TEvents::TEvPing(), /* node index */ 1); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender2, new TEvents::TEvPing(), /* node index */ 1); runtime.GrabEdgeEvent<TEvents::TEvPong>(handle); UNIT_ASSERT(handle); UNIT_ASSERT_C(handle->Recipient == sender2, "Event recipient " << handle->Recipient << " != " << sender2); diff --git a/ydb/core/tablet/tablet_pipecache.cpp b/ydb/core/tablet/tablet_pipecache.cpp index 52e470f28ef..292571f661c 100644 --- a/ydb/core/tablet/tablet_pipecache.cpp +++ b/ydb/core/tablet/tablet_pipecache.cpp @@ -461,9 +461,9 @@ IActor* CreatePipePeNodeCache(const TIntrusivePtr<TPipePeNodeCacheConfig> &confi return new TPipePeNodeCache(config); } -TActorId MakePipePeNodeCacheID(bool allowFollower) { +TActorId MakePipePeNodeCacheID(bool allowFollower) { char x[12] = "PipeCache"; - x[9] = allowFollower ? 'F' : 'A'; + x[9] = allowFollower ? 'F' : 'A'; return TActorId(0, TStringBuf(x, 12)); } diff --git a/ydb/core/tablet/tablet_pipecache_ut.cpp b/ydb/core/tablet/tablet_pipecache_ut.cpp index f3859ea4244..e59fbd4a18d 100644 --- a/ydb/core/tablet/tablet_pipecache_ut.cpp +++ b/ydb/core/tablet/tablet_pipecache_ut.cpp @@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(TPipeCacheTest) { TTestBasicRuntime runtime; SetupTabletServices(runtime); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId& tablet, TTabletStorageInfo* info) { return new TCustomTablet(tablet, info); }); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TPipeCacheTest) { runtime.AdvanceCurrentTime(TDuration::Seconds(2)); runtime.Send(new IEventHandle(cacheActor, sender, new TEvPipeCache::TEvForward( new TEvCustomTablet::TEvHelloRequest, - TTestTxConfig::TxTablet0, + TTestTxConfig::TxTablet0, false)), 0, true); runtime.GrabEdgeEventRethrow<TEvCustomTablet::TEvHelloResponse>(sender); } @@ -112,12 +112,12 @@ Y_UNIT_TEST_SUITE(TPipeCacheTest) { TActorId sender = runtime.AllocateEdgeActor(); - runtime.Send(new IEventHandle(cacheActor, sender, new TEvPipeCache::TEvGetTabletNode(TTestTxConfig::TxTablet0))); + runtime.Send(new IEventHandle(cacheActor, sender, new TEvPipeCache::TEvGetTabletNode(TTestTxConfig::TxTablet0))); auto ev1 = runtime.GrabEdgeEventRethrow<TEvPipeCache::TEvGetTabletNodeResult>(sender); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->TabletId, TTestTxConfig::TxTablet0); + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->TabletId, TTestTxConfig::TxTablet0); UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->NodeId, 0); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY), [](const TActorId& tablet, TTabletStorageInfo* info) { return new TCustomTablet(tablet, info); }); @@ -128,9 +128,9 @@ Y_UNIT_TEST_SUITE(TPipeCacheTest) { runtime.DispatchEvents(options); } - runtime.Send(new IEventHandle(cacheActor, sender, new TEvPipeCache::TEvGetTabletNode(TTestTxConfig::TxTablet0))); + runtime.Send(new IEventHandle(cacheActor, sender, new TEvPipeCache::TEvGetTabletNode(TTestTxConfig::TxTablet0))); auto ev2 = runtime.GrabEdgeEventRethrow<TEvPipeCache::TEvGetTabletNodeResult>(sender); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->TabletId, TTestTxConfig::TxTablet0); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->TabletId, TTestTxConfig::TxTablet0); UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->NodeId, runtime.GetNodeId(0)); } } diff --git a/ydb/core/tablet/tablet_req_blockbs_ut.cpp b/ydb/core/tablet/tablet_req_blockbs_ut.cpp index 56f9d03b371..186a3e84d6b 100644 --- a/ydb/core/tablet/tablet_req_blockbs_ut.cpp +++ b/ydb/core/tablet/tablet_req_blockbs_ut.cpp @@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TBlockBlobStorageTest) { SetupTabletServices(runtime); THashSet<ui32> groups; - TIntrusivePtr<TTabletStorageInfo> info = CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY); + TIntrusivePtr<TTabletStorageInfo> info = CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::TX_DUMMY); for (size_t channel = 0; channel < info->Channels.size(); ++channel) { // use non-existant groups for all channels >= 2 if (channel >= 2) { diff --git a/ydb/core/tablet/tablet_req_rebuildhistory.cpp b/ydb/core/tablet/tablet_req_rebuildhistory.cpp index 1ef6b4263d5..c0b4c0c2bc1 100644 --- a/ydb/core/tablet/tablet_req_rebuildhistory.cpp +++ b/ydb/core/tablet/tablet_req_rebuildhistory.cpp @@ -16,11 +16,11 @@ #error log macro definition clash #endif -#define BLOG_D(stream) LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) -#define BLOG_W(stream) LOG_WARN_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) -#define BLOG_ERROR(stream) LOG_ERROR_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) -#define BLOG_TRACE(stream) LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) -#define BLOG_CRIT(stream) LOG_CRIT_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) +#define BLOG_D(stream) LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) +#define BLOG_W(stream) LOG_WARN_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) +#define BLOG_ERROR(stream) LOG_ERROR_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) +#define BLOG_TRACE(stream) LOG_TRACE_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) +#define BLOG_CRIT(stream) LOG_CRIT_S(*TlsActivationContext, NKikimrServices::TABLET_MAIN, "TabletId# " << Info->TabletID << (FollowerCookie ? "f " : " ") << stream) namespace NKikimr { @@ -203,7 +203,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil NMetrics::TTabletIopsRawValue GroupReadOps; THolder<NTracing::ITrace> IntrospectionTrace; - const ui64 FollowerCookie; + const ui64 FollowerCookie; TGenerationEntry& GenerationInfo(ui32 gen) { TGenerationEntry& x = LogInfo[gen]; @@ -213,7 +213,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil } void ReplyAndDie(NKikimrProto::EReplyStatus status, const TString &reason) { - Send(Owner, new TEvTabletBase::TEvRebuildGraphResult(status, IntrospectionTrace.Release(), reason), 0, FollowerCookie); + Send(Owner, new TEvTabletBase::TEvRebuildGraphResult(status, IntrospectionTrace.Release(), reason), 0, FollowerCookie); PassAway(); } @@ -348,7 +348,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil gx.Ensure(step); - // ignore synth log entries, they are for follower sync only + // ignore synth log entries, they are for follower sync only if (id.Cookie() == 0) { gx.Entry(step).UpdateReferences(logEntry); } @@ -437,7 +437,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil if (Confirmed.first) DiscoverRange(Snapshot, Confirmed, false); - if (FollowerCookie == 0) { + if (FollowerCookie == 0) { if (lastGen != Confirmed.first || lastStep != Confirmed.second) DiscoverRange({ Confirmed.first, Confirmed.second + 1 }, { lastGen, lastStep }, true); } @@ -621,8 +621,8 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil std::pair<ui32, ui32> id(generation, step); if (isTail) { - // Ignore unconfirmed commits on followers - if (FollowerCookie != 0) { + // Ignore unconfirmed commits on followers + if (FollowerCookie != 0) { break; } @@ -776,7 +776,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil std::move(GroupReadBytes), std::move(GroupReadOps), IntrospectionTrace.Release()), - 0, FollowerCookie); + 0, FollowerCookie); PassAway(); } @@ -790,7 +790,7 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrapped<TTabletReqRebuil switch (msg->Status) { case NKikimrProto::OK: - if (FollowerCookie == 0 && msg->Latest.Generation() > BlockedGen) { + if (FollowerCookie == 0 && msg->Latest.Generation() > BlockedGen) { BLOG_ERROR("TTabletReqRebuildHistoryGraph - Found entry beyond blocked generation" << " LastBlobID: " << msg->Latest.ToString() << ". Blocked: " << BlockedGen); if (IntrospectionTrace) { @@ -866,13 +866,13 @@ public: return NKikimrServices::TActivity::TABLET_REQ_REBUILD_GRAPH; } - TTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie) + TTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie) : Owner(owner) , Info(info) , BlockedGen(blockedGen) , RequestsLeft(0) , IntrospectionTrace(trace) - , FollowerCookie(followerCookie) + , FollowerCookie(followerCookie) {} void Bootstrap() { @@ -880,7 +880,7 @@ public: IntrospectionTrace->Attach(MakeHolder<NTracing::TRebuildGraphBootstrap>(BlockedGen)); } - if (FollowerCookie == 0) + if (FollowerCookie == 0) Register(CreateTabletFindLastEntry(SelfId(), true, Info.Get(), BlockedGen)); else Register(CreateTabletFindLastEntry(SelfId(), true, Info.Get(), 0)); @@ -912,8 +912,8 @@ public: } }; -IActor* CreateTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie) { - return new TTabletReqRebuildHistoryGraph(owner, info, blockedGen, trace, followerCookie); +IActor* CreateTabletReqRebuildHistoryGraph(const TActorId &owner, TTabletStorageInfo *info, ui32 blockedGen, NTracing::ITrace *trace, ui64 followerCookie) { + return new TTabletReqRebuildHistoryGraph(owner, info, blockedGen, trace, followerCookie); } diff --git a/ydb/core/tablet/tablet_req_reset.cpp b/ydb/core/tablet/tablet_req_reset.cpp index 699664e8ff8..b73c68c120f 100644 --- a/ydb/core/tablet/tablet_req_reset.cpp +++ b/ydb/core/tablet/tablet_req_reset.cpp @@ -10,7 +10,7 @@ class TTabletReqReset : public TActorBootstrapped<TTabletReqReset> { const TActorId Owner; const TIntrusivePtr<TTabletStorageInfo> TabletStorageInfo; ui32 Generation = 0; - TActorId CurrentLeader; + TActorId CurrentLeader; void ReplyAndDie(NKikimrProto::EReplyStatus status, const TActorContext& ctx) { ctx.Send(Owner, new TEvTablet::TEvResetTabletResult(status, TabletStorageInfo->TabletID)); @@ -18,7 +18,7 @@ class TTabletReqReset : public TActorBootstrapped<TTabletReqReset> { } void Handle(TEvStateStorage::TEvInfo::TPtr& ev, const TActorContext&) { - CurrentLeader = ev->Get()->CurrentLeader; + CurrentLeader = ev->Get()->CurrentLeader; Generation = std::max(Generation, ev->Get()->CurrentGeneration); } @@ -69,8 +69,8 @@ class TTabletReqReset : public TActorBootstrapped<TTabletReqReset> { } void Handle(TEvTabletBase::TEvDeleteTabletResult::TPtr& ev, const TActorContext& ctx) { - if (CurrentLeader) { - ctx.Send(CurrentLeader, new TEvents::TEvPoisonPill()); + if (CurrentLeader) { + ctx.Send(CurrentLeader, new TEvents::TEvPoisonPill()); } ReplyAndDie(ev->Get()->Status, ctx); } diff --git a/ydb/core/tablet/tablet_resolver.cpp b/ydb/core/tablet/tablet_resolver.cpp index 8f1dbe6066a..c0a39a2216b 100644 --- a/ydb/core/tablet/tablet_resolver.cpp +++ b/ydb/core/tablet/tablet_resolver.cpp @@ -73,7 +73,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { StNormal, StProblemResolve, StProblemPing, - StFollowerUpdate, + StFollowerUpdate, }; static const char* StateToString(EState state) { @@ -83,7 +83,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case StNormal: return "StNormal"; case StProblemResolve: return "StProblemResolve"; case StProblemPing: return "StProblemPing"; - case StFollowerUpdate: return "StFollowerUpdate"; + case StFollowerUpdate: return "StFollowerUpdate"; default: return "Unknown"; } } @@ -103,15 +103,15 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { EState State = StInit; TAutoPtr<TQueueType, TQueueType::TPtrCleanDestructor> Queue; - TActorId KnownLeader; - TActorId KnownLeaderTablet; + TActorId KnownLeader; + TActorId KnownLeaderTablet; TInstant LastResolved; TInstant LastPing; TSchedulerCookieHolder Cookie; - TVector<std::pair<TActorId, TActorId>> KnownFollowers; + TVector<std::pair<TActorId, TActorId>> KnownFollowers; ui64 CacheEpoch = 0; ui64 LastCheckEpoch = 0; @@ -126,25 +126,25 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { ui32 NumLocal; ui32 NumLocalDc; ui32 NumOtherDc; - bool * NeedFollowerUpdate; + bool * NeedFollowerUpdate; - TResolveInfo(const TEvTabletResolver::TEvForward& msg, const TDuration& sinceResolve, bool * needFollowerUpdate) + TResolveInfo(const TEvTabletResolver::TEvForward& msg, const TDuration& sinceResolve, bool * needFollowerUpdate) : ResFlags(msg.ResolveFlags) , SinceLastResolve(sinceResolve) , NumLocal(0) , NumLocalDc(0) , NumOtherDc(0) - , NeedFollowerUpdate(needFollowerUpdate) + , NeedFollowerUpdate(needFollowerUpdate) {} ~TResolveInfo() { - if (!NeedFollowerUpdate) + if (!NeedFollowerUpdate) return; - else if (!ResFlags.AllowFollower()) { - *NeedFollowerUpdate = false; + else if (!ResFlags.AllowFollower()) { + *NeedFollowerUpdate = false; return; } - *NeedFollowerUpdate = (!NumLocalDc && SinceLastResolve > TDuration::Seconds(2)) || + *NeedFollowerUpdate = (!NumLocalDc && SinceLastResolve > TDuration::Seconds(2)) || (SinceLastResolve > TDuration::Minutes(5)); } @@ -173,13 +173,13 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { ui64 LastCacheEpoch = 0; - NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderLocal; - NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderLocalDc; - NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderOtherDc; + NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderLocal; + NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderLocalDc; + NMonitoring::TDynamicCounters::TCounterPtr SelectedLeaderOtherDc; - NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerLocal; - NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerLocalDc; - NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerOtherDc; + NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerLocal; + NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerLocalDc; + NMonitoring::TDynamicCounters::TCounterPtr SelectedFollowerOtherDc; NMonitoring::TDynamicCounters::TCounterPtr SelectedNone; @@ -211,11 +211,11 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { const std::optional<TString> leaderDc = FindNodeDc(entry.KnownLeader.NodeId()); struct TCandidate { - TActorId KnownLeader; - TActorId KnownLeaderTablet; + TActorId KnownLeader; + TActorId KnownLeaderTablet; bool IsLocal; bool IsLocalDc; - bool IsLeader; + bool IsLeader; }; ui32 disallowed = 0; // do not save (prio == 0), just count @@ -233,21 +233,21 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } }; - bool countLeader = (entry.State == TEntry::StNormal || entry.State == TEntry::StFollowerUpdate); - if (countLeader) { - bool isLocal = (entry.KnownLeader.NodeId() == selfNode); + bool countLeader = (entry.State == TEntry::StNormal || entry.State == TEntry::StFollowerUpdate); + if (countLeader) { + bool isLocal = (entry.KnownLeader.NodeId() == selfNode); bool isLocalDc = selfDc && leaderDc == selfDc; info.Count(isLocal, isLocalDc); ui32 prio = info.ResFlags.GetTabletPriority(isLocal, isLocalDc, false); if (prio) - addCandidate(prio, TCandidate{ entry.KnownLeader, entry.KnownLeaderTablet, isLocal, isLocalDc, true }); + addCandidate(prio, TCandidate{ entry.KnownLeader, entry.KnownLeaderTablet, isLocal, isLocalDc, true }); else ++disallowed; } - if (info.ResFlags.AllowFollower()) { - for (const auto &x : entry.KnownFollowers) { + if (info.ResFlags.AllowFollower()) { + for (const auto &x : entry.KnownFollowers) { bool isLocal = (x.first.NodeId() == selfNode); bool isLocalDc = selfDc && FindNodeDc(x.first.NodeId()) == selfDc; info.Count(isLocal, isLocalDc); @@ -269,30 +269,30 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { LOG_DEBUG(ctx, NKikimrServices::TABLET_RESOLVER, "SelectForward node %" PRIu32 " selfDC %s leaderDC %s %s" " local %" PRIu32 " localDc %" PRIu32 " other %" PRIu32 " disallowed %" PRIu32 - " tabletId: %" PRIu64 " followers: %" PRIu64 " countLeader %" PRIu32 - " allowFollowers %" PRIu32 " winner: %s", + " tabletId: %" PRIu64 " followers: %" PRIu64 " countLeader %" PRIu32 + " allowFollowers %" PRIu32 " winner: %s", selfNode, dcName(selfDc), dcName(leaderDc), info.ResFlags.ToString().data(), info.NumLocal, info.NumLocalDc, info.NumOtherDc, disallowed, - tabletId, entry.KnownFollowers.size(), countLeader, info.ResFlags.AllowFollower(), - winner.KnownLeader.ToString().c_str()); + tabletId, entry.KnownFollowers.size(), countLeader, info.ResFlags.AllowFollower(), + winner.KnownLeader.ToString().c_str()); - if (winner.IsLeader) { + if (winner.IsLeader) { if (winner.IsLocal) - SelectedLeaderLocal->Inc(); + SelectedLeaderLocal->Inc(); if (winner.IsLocal || winner.IsLocalDc) - SelectedLeaderLocalDc->Inc(); + SelectedLeaderLocalDc->Inc(); else - SelectedLeaderOtherDc->Inc(); + SelectedLeaderOtherDc->Inc(); } else { if (winner.IsLocal) - SelectedFollowerLocal->Inc(); + SelectedFollowerLocal->Inc(); if (winner.IsLocal || winner.IsLocalDc) - SelectedFollowerLocalDc->Inc(); + SelectedFollowerLocalDc->Inc(); else - SelectedFollowerOtherDc->Inc(); + SelectedFollowerOtherDc->Inc(); } - return std::make_pair(winner.KnownLeader, winner.KnownLeaderTablet); + return std::make_pair(winner.KnownLeader, winner.KnownLeaderTablet); } LOG_INFO(ctx, NKikimrServices::TABLET_RESOLVER, @@ -307,8 +307,8 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } bool SendForward(const TActorId &sender, const TEntry &entry, TEvTabletResolver::TEvForward *msg, - const TActorContext &ctx, bool * needFollowerUpdate = nullptr) { - TResolveInfo info(*msg, ctx.Now() - entry.LastResolved, needFollowerUpdate); // fills needFollowerUpdate in dtor + const TActorContext &ctx, bool * needFollowerUpdate = nullptr) { + TResolveInfo info(*msg, ctx.Now() - entry.LastResolved, needFollowerUpdate); // fills needFollowerUpdate in dtor const std::pair<TActorId, TActorId> endpoint = SelectForward(ctx, entry, info, msg->TabletID); if (endpoint.first) { ctx.Send(sender, new TEvTabletResolver::TEvForwardResult(msg->TabletID, endpoint.second, endpoint.first, LastCacheEpoch)); @@ -332,7 +332,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } void SendPing(ui64 tabletId, TEntry &entry, const TActorContext &ctx) { - ctx.Send(entry.KnownLeader, new TEvTablet::TEvPing(tabletId, 0), IEventHandle::FlagTrackDelivery, tabletId); // no subscribe for reason + ctx.Send(entry.KnownLeader, new TEvTablet::TEvPing(tabletId, 0), IEventHandle::FlagTrackDelivery, tabletId); // no subscribe for reason entry.Cookie.Reset(ISchedulerCookie::Make3Way()); const TDuration timeout = TDuration::MilliSeconds(500); @@ -340,22 +340,22 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } void ApplyEntryInfo(TEvStateStorage::TEvInfo& msg, TEntry &entry, const TActorContext &ctx) { - entry.KnownLeader = msg.CurrentLeader; - entry.KnownLeaderTablet = msg.CurrentLeaderTablet; + entry.KnownLeader = msg.CurrentLeader; + entry.KnownLeaderTablet = msg.CurrentLeaderTablet; entry.LastResolved = ctx.Now(); - entry.KnownFollowers = std::move(msg.Followers); + entry.KnownFollowers = std::move(msg.Followers); entry.CacheEpoch = ++LastCacheEpoch; LOG_DEBUG(ctx, NKikimrServices::TABLET_RESOLVER, - "ApplyEntry leader tabletId: %" PRIu64 " followers: %" PRIu64, - msg.TabletID, entry.KnownFollowers.size()); + "ApplyEntry leader tabletId: %" PRIu64 " followers: %" PRIu64, + msg.TabletID, entry.KnownFollowers.size()); SendQueued(msg.TabletID, entry, ctx); } void DropEntry(ui64 tabletId, TEntry& entry, const TActorContext &ctx) { LOG_DEBUG(ctx, NKikimrServices::TABLET_RESOLVER, - "DropEntry tabletId: %" PRIu64 " followers: %" PRIu64, - tabletId, entry.KnownFollowers.size()); + "DropEntry tabletId: %" PRIu64 " followers: %" PRIu64, + tabletId, entry.KnownFollowers.size()); if (TEntry::TQueueType *queue = entry.Queue.Get()) { for (TAutoPtr<TEntry::TQueueEntry> x = queue->Pop(); !!x; x.Reset(queue->Pop())) { ctx.Send(x->Ev->Sender, new TEvTabletResolver::TEvForwardResult(NKikimrProto::ERROR, tabletId)); @@ -415,29 +415,29 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { switch (entry.State) { case TEntry::StNormal: - case TEntry::StFollowerUpdate: + case TEntry::StFollowerUpdate: if (entry.CacheEpoch < LastNodeProblemsUpdateEpoch && entry.LastCheckEpoch < LastNodeProblemsUpdateEpoch) { entry.LastCheckEpoch = LastCacheEpoch; - auto *pMaxProblemEpoch = NodeProblems.FindPtr(entry.KnownLeader.NodeId()); + auto *pMaxProblemEpoch = NodeProblems.FindPtr(entry.KnownLeader.NodeId()); if (pMaxProblemEpoch && entry.CacheEpoch <= *pMaxProblemEpoch) { LOG_DEBUG(ctx, NKikimrServices::TABLET_RESOLVER, "Delayed invalidation of tabletId: %" PRIu64 - " leader: %s by NodeId", tabletId, entry.KnownLeader.ToString().c_str()); + " leader: %s by NodeId", tabletId, entry.KnownLeader.ToString().c_str()); ResolveRequest(tabletId, ctx); entry.State = TEntry::StProblemResolve; MoveEntryToUnresolved(tabletId, *entryHolder); return; } - auto itDst = entry.KnownFollowers.begin(); - auto itSrc = entry.KnownFollowers.begin(); - while (itSrc != entry.KnownFollowers.end()) { + auto itDst = entry.KnownFollowers.begin(); + auto itSrc = entry.KnownFollowers.begin(); + while (itSrc != entry.KnownFollowers.end()) { pMaxProblemEpoch = NodeProblems.FindPtr(itSrc->first.NodeId()); if (pMaxProblemEpoch && entry.CacheEpoch <= *pMaxProblemEpoch) { LOG_DEBUG(ctx, NKikimrServices::TABLET_RESOLVER, "Delayed invalidation of tabletId: %" PRIu64 - " follower: %s by nodeId", tabletId, itSrc->first.ToString().c_str()); + " follower: %s by nodeId", tabletId, itSrc->first.ToString().c_str()); ++itSrc; continue; } @@ -449,9 +449,9 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { } if (itDst != itSrc) { - entry.KnownFollowers.erase(itDst, itSrc); + entry.KnownFollowers.erase(itDst, itSrc); ResolveRequest(tabletId, ctx); - entry.State = TEntry::StFollowerUpdate; + entry.State = TEntry::StFollowerUpdate; } } break; @@ -492,15 +492,15 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { PushQueue(ev, entry, ctx); break; case TEntry::StNormal: { - bool needFollowerUpdate = false; - if (!SendForward(ev->Sender, entry, msg, ctx, &needFollowerUpdate)) { + bool needFollowerUpdate = false; + if (!SendForward(ev->Sender, entry, msg, ctx, &needFollowerUpdate)) { PushQueue(ev, entry, ctx); ResolveRequest(tabletId, ctx); - entry.State = TEntry::StFollowerUpdate; + entry.State = TEntry::StFollowerUpdate; } - if (needFollowerUpdate) { + if (needFollowerUpdate) { ResolveRequest(tabletId, ctx); - entry.State = TEntry::StFollowerUpdate; + entry.State = TEntry::StFollowerUpdate; } break; } @@ -508,7 +508,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StProblemPing: PushQueue(ev, entry, ctx); break; - case TEntry::StFollowerUpdate: + case TEntry::StFollowerUpdate: if (!SendForward(ev->Sender, entry, msg, ctx)) PushQueue(ev, entry, ctx); break; @@ -537,17 +537,17 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StInitResolve: break; case TEntry::StNormal: - if (!msg->TabletActor || entry.KnownLeaderTablet == msg->TabletActor) { + if (!msg->TabletActor || entry.KnownLeaderTablet == msg->TabletActor) { ResolveRequest(tabletId, ctx); entry.State = TEntry::StProblemResolve; MoveEntryToUnresolved(tabletId, *entryHolder); } else { - // find in follower list - for (auto it = entry.KnownFollowers.begin(), end = entry.KnownFollowers.end(); it != end; ++it) { + // find in follower list + for (auto it = entry.KnownFollowers.begin(), end = entry.KnownFollowers.end(); it != end; ++it) { if (it->second == msg->TabletActor) { - entry.KnownFollowers.erase(it); + entry.KnownFollowers.erase(it); ResolveRequest(tabletId, ctx); - entry.State = TEntry::StFollowerUpdate; + entry.State = TEntry::StFollowerUpdate; break; } } @@ -556,10 +556,10 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { break; case TEntry::StProblemResolve: case TEntry::StProblemPing: - case TEntry::StFollowerUpdate: - for (auto it = entry.KnownFollowers.begin(), end = entry.KnownFollowers.end(); it != end; ++it) { + case TEntry::StFollowerUpdate: + for (auto it = entry.KnownFollowers.begin(), end = entry.KnownFollowers.end(); it != end; ++it) { if (it->second == msg->TabletActor) { - entry.KnownFollowers.erase(it); + entry.KnownFollowers.erase(it); break; } } @@ -611,12 +611,12 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { Y_FAIL("must not happens"); case TEntry::StInitResolve: if (success) { - if (msg->CurrentLeaderTablet) { + if (msg->CurrentLeaderTablet) { entry.State = TEntry::StNormal; ApplyEntryInfo(*msg, entry, ctx); MoveEntryToResolved(tabletId, *entryHolder); } else { - // HACK: Don't cache invalid CurrentLeaderTablet + // HACK: Don't cache invalid CurrentLeaderTablet // FIXME: Use subscription + cache here to reduce the workload ApplyEntryInfo(*msg, entry, ctx); DropEntry(tabletId, entry, ctx); @@ -625,13 +625,13 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { DropEntry(tabletId, entry, ctx); } break; - case TEntry::StFollowerUpdate: + case TEntry::StFollowerUpdate: if (success) { - if (msg->CurrentLeaderTablet) { + if (msg->CurrentLeaderTablet) { entry.State = TEntry::StNormal; ApplyEntryInfo(*msg, entry, ctx); } else { - // HACK: Don't cache invalid CurrentLeaderTablet + // HACK: Don't cache invalid CurrentLeaderTablet // FIXME: Use subscription + cache here to reduce the workload ApplyEntryInfo(*msg, entry, ctx); DropEntry(tabletId, entry, ctx); @@ -642,16 +642,16 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { break; case TEntry::StProblemResolve: if (success) { - if (entry.KnownLeader == msg->CurrentLeader) { - if (!(entry.KnownLeaderTablet == msg->CurrentLeaderTablet || !entry.KnownLeaderTablet)) { + if (entry.KnownLeader == msg->CurrentLeader) { + if (!(entry.KnownLeaderTablet == msg->CurrentLeaderTablet || !entry.KnownLeaderTablet)) { DropEntry(tabletId, entry, ctx); // got info but not full, occurs on transitional cluster states } else { - entry.KnownLeaderTablet = msg->CurrentLeaderTablet; + entry.KnownLeaderTablet = msg->CurrentLeaderTablet; entry.State = TEntry::StProblemPing; SendPing(tabletId, entry, ctx); } } else { - if (msg->CurrentLeaderTablet) { + if (msg->CurrentLeaderTablet) { entry.State = TEntry::StNormal; ApplyEntryInfo(*msg, entry, ctx); MoveEntryToResolved(tabletId, *entryHolder); @@ -694,7 +694,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StProblemResolve: break; case TEntry::StProblemPing: - if (ev->Sender == entry.KnownLeader) { + if (ev->Sender == entry.KnownLeader) { entry.Cookie.Detach(); entry.State = TEntry::StNormal; SendQueued(tabletId, entry, ctx); @@ -725,10 +725,10 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StInitResolve: case TEntry::StNormal: case TEntry::StProblemResolve: - case TEntry::StFollowerUpdate: + case TEntry::StFollowerUpdate: break; case TEntry::StProblemPing: - if (ev->Sender == entry.KnownLeader) { + if (ev->Sender == entry.KnownLeader) { DropEntry(tabletId, entry, ctx); } break; @@ -757,7 +757,7 @@ class TTabletResolver : public TActorBootstrapped<TTabletResolver> { case TEntry::StInitResolve: case TEntry::StNormal: case TEntry::StProblemResolve: - case TEntry::StFollowerUpdate: + case TEntry::StFollowerUpdate: break; case TEntry::StProblemPing: if (msg->Cookie.DetachEvent()) { @@ -837,12 +837,12 @@ public: auto tablets = GetServiceCounters(AppData()->Counters, "tablets"); - SelectedLeaderLocal = tablets->GetCounter("TabletResolver/SelectedLeaderLocal", true); - SelectedLeaderLocalDc = tablets->GetCounter("TabletResolver/SelectedLeaderLocalDc", true); - SelectedLeaderOtherDc = tablets->GetCounter("TabletResolver/SelectedLeaderOtherDc", true); - SelectedFollowerLocal = tablets->GetCounter("TabletResolver/SelectedFollowerLocal", true); - SelectedFollowerLocalDc = tablets->GetCounter("TabletResolver/SelectedFollowerLocalDc", true); - SelectedFollowerOtherDc = tablets->GetCounter("TabletResolver/SelectedFollowerOtherDc", true); + SelectedLeaderLocal = tablets->GetCounter("TabletResolver/SelectedLeaderLocal", true); + SelectedLeaderLocalDc = tablets->GetCounter("TabletResolver/SelectedLeaderLocalDc", true); + SelectedLeaderOtherDc = tablets->GetCounter("TabletResolver/SelectedLeaderOtherDc", true); + SelectedFollowerLocal = tablets->GetCounter("TabletResolver/SelectedFollowerLocal", true); + SelectedFollowerLocalDc = tablets->GetCounter("TabletResolver/SelectedFollowerLocalDc", true); + SelectedFollowerOtherDc = tablets->GetCounter("TabletResolver/SelectedFollowerOtherDc", true); SelectedNone = tablets->GetCounter("TabletResolver/SelectedNone", true); InFlyResolveCounter = tablets->GetCounter("TabletResolver/InFly"); diff --git a/ydb/core/tablet/tablet_resolver_ut.cpp b/ydb/core/tablet/tablet_resolver_ut.cpp index ab2bd37875c..b341cae1331 100644 --- a/ydb/core/tablet/tablet_resolver_ut.cpp +++ b/ydb/core/tablet/tablet_resolver_ut.cpp @@ -12,42 +12,42 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { Y_UNIT_TEST(TabletResolvePriority) { TEvTabletResolver::TEvForward::TResolveFlags flags; - flags.SetAllowFollower(true); // this actually sets PreferFollower + flags.SetAllowFollower(true); // this actually sets PreferFollower flags.SetPreferLocal(true); - auto localNodeLeader = flags.GetTabletPriority(true, true, false); - auto localNodeFollower = flags.GetTabletPriority(true, true, true); - auto localDcLeader = flags.GetTabletPriority(false, true, false); - auto localDcFollower = flags.GetTabletPriority(false, true, true); - auto remoteDcLeader = flags.GetTabletPriority(false, false, false); - auto remoteDcFollower = flags.GetTabletPriority(false, false, true); - - // Since PreferLocal is set we must prefer local node follower - UNIT_ASSERT_GT(localNodeFollower, localDcFollower); - UNIT_ASSERT_GT(localNodeFollower, remoteDcFollower); - UNIT_ASSERT_GT(localDcFollower, remoteDcFollower); - - // Since PreferFollower is set we must prefer local dc follower over - // any leader, even when that leader is on local node - UNIT_ASSERT_GT(localNodeFollower, remoteDcLeader); - UNIT_ASSERT_GT(localDcFollower, remoteDcLeader); - UNIT_ASSERT_GT(localNodeFollower, localDcLeader); - UNIT_ASSERT_GT(localDcFollower, localDcLeader); - UNIT_ASSERT_GT(localNodeFollower, localNodeLeader); - UNIT_ASSERT_GT(localDcFollower, localNodeLeader); - - // We still expect local dc leader to be preferred to remote dc follower - UNIT_ASSERT_GT(localNodeLeader, remoteDcFollower); - UNIT_ASSERT_GT(localDcLeader, remoteDcFollower); + auto localNodeLeader = flags.GetTabletPriority(true, true, false); + auto localNodeFollower = flags.GetTabletPriority(true, true, true); + auto localDcLeader = flags.GetTabletPriority(false, true, false); + auto localDcFollower = flags.GetTabletPriority(false, true, true); + auto remoteDcLeader = flags.GetTabletPriority(false, false, false); + auto remoteDcFollower = flags.GetTabletPriority(false, false, true); + + // Since PreferLocal is set we must prefer local node follower + UNIT_ASSERT_GT(localNodeFollower, localDcFollower); + UNIT_ASSERT_GT(localNodeFollower, remoteDcFollower); + UNIT_ASSERT_GT(localDcFollower, remoteDcFollower); + + // Since PreferFollower is set we must prefer local dc follower over + // any leader, even when that leader is on local node + UNIT_ASSERT_GT(localNodeFollower, remoteDcLeader); + UNIT_ASSERT_GT(localDcFollower, remoteDcLeader); + UNIT_ASSERT_GT(localNodeFollower, localDcLeader); + UNIT_ASSERT_GT(localDcFollower, localDcLeader); + UNIT_ASSERT_GT(localNodeFollower, localNodeLeader); + UNIT_ASSERT_GT(localDcFollower, localNodeLeader); + + // We still expect local dc leader to be preferred to remote dc follower + UNIT_ASSERT_GT(localNodeLeader, remoteDcFollower); + UNIT_ASSERT_GT(localDcLeader, remoteDcFollower); } class TRegisterTabletInfo : public TActorBootstrapped<TRegisterTabletInfo> { public: - TRegisterTabletInfo(const TActorId& edge, ui64 tabletId, ui32 gen, TActorId leader, TActorId leaderTablet) + TRegisterTabletInfo(const TActorId& edge, ui64 tabletId, ui32 gen, TActorId leader, TActorId leaderTablet) : Edge(edge) , TabletId(tabletId) , Generation(gen) - , Leader(leader) - , LeaderTablet(leaderTablet) + , Leader(leader) + , LeaderTablet(leaderTablet) { } void Bootstrap() { @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { SignatureSz = msg->SignatureSz; Signature.Reset(msg->Signature.Release()); - Send(ProxyId, new TEvStateStorage::TEvUpdate(TabletId, 0, Leader, LeaderTablet, Generation, 0, Signature.Get(), SignatureSz, TEvStateStorage::TProxyOptions::SigSync)); + Send(ProxyId, new TEvStateStorage::TEvUpdate(TabletId, 0, Leader, LeaderTablet, Generation, 0, Signature.Get(), SignatureSz, TEvStateStorage::TProxyOptions::SigSync)); Become(&TThis::StateUpdate); } @@ -89,17 +89,17 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { const TActorId Edge; const ui64 TabletId; const ui32 Generation; - const TActorId Leader; - const TActorId LeaderTablet; + const TActorId Leader; + const TActorId LeaderTablet; TActorId ProxyId; ui32 SignatureSz = 0; TArrayHolder<ui64> Signature; }; - void DoRegisterTabletInfo(TTestBasicRuntime& runtime, ui64 tabletId, ui32 gen, TActorId leader, TActorId leaderTablet) { + void DoRegisterTabletInfo(TTestBasicRuntime& runtime, ui64 tabletId, ui32 gen, TActorId leader, TActorId leaderTablet) { const TActorId edge = runtime.AllocateEdgeActor(); - runtime.Register(new TRegisterTabletInfo(edge, tabletId, gen, leader, leaderTablet)); + runtime.Register(new TRegisterTabletInfo(edge, tabletId, gen, leader, leaderTablet)); auto ev = runtime.GrabEdgeEventRethrow<TEvStateStorage::TEvInfo>(edge); auto* msg = ev->Get(); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); @@ -122,62 +122,62 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { runtime.SetLogPriority(NKikimrServices::TABLET_RESOLVER, NActors::NLog::PRI_DEBUG); - TActorId firstLeader = runtime.AllocateEdgeActor(0); - TActorId firstLeaderTablet = runtime.AllocateEdgeActor(0); - DoRegisterTabletInfo(runtime, 123, 1, firstLeader, firstLeaderTablet); - TActorId secondLeader = runtime.AllocateEdgeActor(0); - TActorId secondLeaderTablet = runtime.AllocateEdgeActor(0); - DoRegisterTabletInfo(runtime, 234, 1, secondLeader, secondLeaderTablet); + TActorId firstLeader = runtime.AllocateEdgeActor(0); + TActorId firstLeaderTablet = runtime.AllocateEdgeActor(0); + DoRegisterTabletInfo(runtime, 123, 1, firstLeader, firstLeaderTablet); + TActorId secondLeader = runtime.AllocateEdgeActor(0); + TActorId secondLeaderTablet = runtime.AllocateEdgeActor(0); + DoRegisterTabletInfo(runtime, 234, 1, secondLeader, secondLeaderTablet); { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeader); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTablet); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeader); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTablet); } { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeader); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTablet); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeader); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTablet); } // Move both tablets to node 2 - TActorId firstLeaderNode2 = runtime.AllocateEdgeActor(1); - TActorId firstLeaderTabletNode2 = runtime.AllocateEdgeActor(1); - DoRegisterTabletInfo(runtime, 123, 2, firstLeaderNode2, firstLeaderTabletNode2); - TActorId secondLeaderNode2 = runtime.AllocateEdgeActor(1); - TActorId secondLeaderTabletNode2 = runtime.AllocateEdgeActor(1); - DoRegisterTabletInfo(runtime, 234, 2, secondLeaderNode2, secondLeaderTabletNode2); + TActorId firstLeaderNode2 = runtime.AllocateEdgeActor(1); + TActorId firstLeaderTabletNode2 = runtime.AllocateEdgeActor(1); + DoRegisterTabletInfo(runtime, 123, 2, firstLeaderNode2, firstLeaderTabletNode2); + TActorId secondLeaderNode2 = runtime.AllocateEdgeActor(1); + TActorId secondLeaderTabletNode2 = runtime.AllocateEdgeActor(1); + DoRegisterTabletInfo(runtime, 234, 2, secondLeaderNode2, secondLeaderTabletNode2); // We expect tablet resolver to return old cached results ui64 problemEpoch; { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeader); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTablet); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeader); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTablet); problemEpoch = msg->CacheEpoch; } { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeader); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTablet); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeader); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTablet); } // Let's send a node problem signal, it should invalidate both tablets - DoSendNodeProblem(runtime, firstLeader.NodeId(), problemEpoch); + DoSendNodeProblem(runtime, firstLeader.NodeId(), problemEpoch); // Check both tablets resolve to a new node ui64 nextProblemEpoch1; { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode2); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode2); UNIT_ASSERT(msg->CacheEpoch > problemEpoch); nextProblemEpoch1 = msg->CacheEpoch; } @@ -186,72 +186,72 @@ Y_UNIT_TEST_SUITE(TTabletResolver) { { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); UNIT_ASSERT(msg->CacheEpoch > problemEpoch); nextProblemEpoch2 = msg->CacheEpoch; } // Move both tablets to node 3 - TActorId firstLeaderNode3 = runtime.AllocateEdgeActor(2); - TActorId firstLeaderTabletNode3 = runtime.AllocateEdgeActor(2); - DoRegisterTabletInfo(runtime, 123, 3, firstLeaderNode3, firstLeaderTabletNode3); - TActorId secondLeaderNode3 = runtime.AllocateEdgeActor(2); - TActorId secondLeaderTabletNode3 = runtime.AllocateEdgeActor(2); - DoRegisterTabletInfo(runtime, 234, 3, secondLeaderNode3, secondLeaderTabletNode3); + TActorId firstLeaderNode3 = runtime.AllocateEdgeActor(2); + TActorId firstLeaderTabletNode3 = runtime.AllocateEdgeActor(2); + DoRegisterTabletInfo(runtime, 123, 3, firstLeaderNode3, firstLeaderTabletNode3); + TActorId secondLeaderNode3 = runtime.AllocateEdgeActor(2); + TActorId secondLeaderTabletNode3 = runtime.AllocateEdgeActor(2); + DoRegisterTabletInfo(runtime, 234, 3, secondLeaderNode3, secondLeaderTabletNode3); // Send an outdated node problem signal, it should not cause an invalidation - DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), problemEpoch); + DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), problemEpoch); // Check both tablets still resolve to node 2 { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode2); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode2); } { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); } // Send a proper node problem signal, it should invalidate the first tablet - DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), nextProblemEpoch1); + DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), nextProblemEpoch1); // Check the first tablet resolves to node 3 { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode3); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode3); } { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode2); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode2); } // Send a proper node problem signal, it should invalidate the second tablet too - DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), nextProblemEpoch2); + DoSendNodeProblem(runtime, firstLeaderNode2.NodeId(), nextProblemEpoch2); // Check the second tablet resolves to node 3 too { auto msg = DoResolveTablet(runtime, 123); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode3); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, firstLeaderNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, firstLeaderTabletNode3); } { auto msg = DoResolveTablet(runtime, 234); UNIT_ASSERT_VALUES_EQUAL(msg->Status, NKikimrProto::OK); - UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode3); - UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->Tablet, secondLeaderNode3); + UNIT_ASSERT_VALUES_EQUAL(msg->TabletActor, secondLeaderTabletNode3); } } diff --git a/ydb/core/tablet/tablet_setup.h b/ydb/core/tablet/tablet_setup.h index bb57419a6c8..57ea7d6edba 100644 --- a/ydb/core/tablet/tablet_setup.h +++ b/ydb/core/tablet/tablet_setup.h @@ -33,19 +33,19 @@ public: TActorId Apply(TTabletStorageInfo *info, TActorIdentity owner); TActorId Apply(TTabletStorageInfo *info, const TActorContext &ctx); TActorId Tablet(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, - ui32 suggestedGeneration, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr); - TActorId Follower(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, - ui32 followerID, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr); + ui32 suggestedGeneration, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr); + TActorId Follower(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, + ui32 followerID, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr); }; IActor* CreateTablet(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, - ui32 suggestedGeneration, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr); -IActor* CreateTabletFollower(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, - ui32 followerID, TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr); + ui32 suggestedGeneration, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr); +IActor* CreateTabletFollower(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, + ui32 followerID, TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr); struct ITabletFactory: public virtual TThrRefBase { diff --git a/ydb/core/tablet/tablet_sys.cpp b/ydb/core/tablet/tablet_sys.cpp index 94b05ebeb44..44bfac7b2d6 100644 --- a/ydb/core/tablet/tablet_sys.cpp +++ b/ydb/core/tablet/tablet_sys.cpp @@ -31,8 +31,8 @@ namespace { static constexpr size_t MaxStepsInFlight = 10000; static constexpr size_t MaxBytesInFlight = 256 * 1024 * 1024; - static constexpr TDuration OfflineFollowerWaitFirst = TDuration::Seconds(4); - static constexpr TDuration OfflineFollowerWaitRetry = TDuration::Seconds(15); + static constexpr TDuration OfflineFollowerWaitFirst = TDuration::Seconds(4); + static constexpr TDuration OfflineFollowerWaitRetry = TDuration::Seconds(15); } @@ -44,21 +44,21 @@ ui64 TTablet::TabletID() const { return Info->TabletID; } -void TTablet::NextFollowerAttempt() { - const ui32 node = FollowerInfo.KnownLeaderID.NodeId(); +void TTablet::NextFollowerAttempt() { + const ui32 node = FollowerInfo.KnownLeaderID.NodeId(); if (node && node != SelfId().NodeId()) { const TActorId proxy = TActivationContext::InterconnectProxy(node); Send(proxy, new TEvents::TEvUnsubscribe); } - FollowerInfo.NextAttempt(); + FollowerInfo.NextAttempt(); } void TTablet::ReportTabletStateChange(ETabletState state) { const TActorId tabletStateServiceId = NNodeWhiteboard::MakeNodeWhiteboardServiceId(SelfId().NodeId()); - if (state == TTabletStateInfo::Created || state == TTabletStateInfo::ResolveLeader) { - Send(tabletStateServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate(TabletID(), FollowerId, state, Info, StateStorageInfo.KnownGeneration, Leader)); + if (state == TTabletStateInfo::Created || state == TTabletStateInfo::ResolveLeader) { + Send(tabletStateServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate(TabletID(), FollowerId, state, Info, StateStorageInfo.KnownGeneration, Leader)); } else { - Send(tabletStateServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate(TabletID(), FollowerId, state, StateStorageInfo.KnownGeneration)); + Send(tabletStateServiceId, new NNodeWhiteboard::TEvWhiteboard::TEvTabletStateUpdate(TabletID(), FollowerId, state, StateStorageInfo.KnownGeneration)); } } @@ -229,7 +229,7 @@ void TTablet::WriteZeroEntry(TEvTablet::TDependencyGraph *graph) { void TTablet::StartActivePhase() { Graph.NextEntry = 1; - Graph.MinFollowerUpdate = 1; + Graph.MinFollowerUpdate = 1; Send(Launcher, new TEvTablet::TEvRestored(TabletID(), StateStorageInfo.KnownGeneration, UserTablet, false)); Send(UserTablet, new TEvTablet::TEvRestored(TabletID(), StateStorageInfo.KnownGeneration, UserTablet, false)); @@ -240,7 +240,7 @@ void TTablet::StartActivePhase() { StateStorageGuardian = Register(CreateStateStorageTabletGuardian(TabletID(), SelfId(), UserTablet, StateStorageInfo.KnownGeneration)); // if nowhere to sync - then declare sync done - TryFinishFollowerSync(); + TryFinishFollowerSync(); } void TTablet::TryPumpWaitingForGc() { @@ -248,11 +248,11 @@ void TTablet::TryPumpWaitingForGc() { return; ui32 minConfirmedGcStep = Max<ui32>(); - for (auto &xpair : LeaderInfo) { - const TLeaderInfo &followerInfo = xpair.second; - if (followerInfo.SyncState == EFollowerSyncState::Ignore) + for (auto &xpair : LeaderInfo) { + const TLeaderInfo &followerInfo = xpair.second; + if (followerInfo.SyncState == EFollowerSyncState::Ignore) continue; - minConfirmedGcStep = Min(followerInfo.ConfirmedGCStep, minConfirmedGcStep); + minConfirmedGcStep = Min(followerInfo.ConfirmedGCStep, minConfirmedGcStep); } while (WaitingForGcAck) { @@ -262,13 +262,13 @@ void TTablet::TryPumpWaitingForGc() { break; const TInstant commitMoment = ackFront.second; const TDuration delay = TActivationContext::Now() - commitMoment ; - Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(TabletID(), StateStorageInfo.KnownGeneration, gcStep, delay)); + Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(TabletID(), StateStorageInfo.KnownGeneration, gcStep, delay)); WaitingForGcAck.pop_front(); } } -void TTablet::TryFinishFollowerSync() { - if (InitialFollowerSyncDone) +void TTablet::TryFinishFollowerSync() { + if (InitialFollowerSyncDone) return; // explicit state check is evil, but parallel flag is even more evil. Conceptually correct way is defining dedicated @@ -277,14 +277,14 @@ void TTablet::TryFinishFollowerSync() { if (CurrentStateFunc() != &TThis::StateActivePhase) return; - for (const auto &xpair : LeaderInfo) { - EFollowerSyncState syncState = xpair.second.SyncState; - if (syncState == EFollowerSyncState::NeedSync || syncState == EFollowerSyncState::Pending) + for (const auto &xpair : LeaderInfo) { + EFollowerSyncState syncState = xpair.second.SyncState; + if (syncState == EFollowerSyncState::NeedSync || syncState == EFollowerSyncState::Pending) return; } - InitialFollowerSyncDone = true; - Send(UserTablet, new TEvTablet::TEvFollowerSyncComplete()); + InitialFollowerSyncDone = true; + Send(UserTablet, new TEvTablet::TEvFollowerSyncComplete()); } void TTablet::UpdateStateStorageSignature(TEvStateStorage::TEvUpdateSignature::TPtr &ev) { @@ -296,16 +296,16 @@ void TTablet::HandlePingBoot(TEvTablet::TEvPing::TPtr &ev) { // todo: handle wait-boot flag NKikimrTabletBase::TEvPing &record = ev->Get()->Record; Y_VERIFY(record.GetTabletID() == TabletID()); - Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagBoot | TEvTablet::TEvPong::FlagLeader)); + Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagBoot | TEvTablet::TEvPong::FlagLeader)); } -void TTablet::HandlePingFollower(TEvTablet::TEvPing::TPtr &ev) { +void TTablet::HandlePingFollower(TEvTablet::TEvPing::TPtr &ev) { NKikimrTabletBase::TEvPing &record = ev->Get()->Record; Y_VERIFY(record.GetTabletID() == TabletID()); - Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagFollower)); + Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagFollower)); } -void TTablet::HandleStateStorageLeaderResolve(TEvStateStorage::TEvInfo::TPtr &ev) { +void TTablet::HandleStateStorageLeaderResolve(TEvStateStorage::TEvInfo::TPtr &ev) { TEvStateStorage::TEvInfo *msg = ev->Get(); if (msg->SignatureSz) { @@ -316,42 +316,42 @@ void TTablet::HandleStateStorageLeaderResolve(TEvStateStorage::TEvInfo::TPtr &ev StateStorageInfo.KnownGeneration = msg->CurrentGeneration; StateStorageInfo.Signature.Reset(msg->Signature.Release()); - if (msg->Status == NKikimrProto::OK && msg->CurrentLeader) { - FollowerInfo.KnownLeaderID = msg->CurrentLeader; - Send(FollowerInfo.KnownLeaderID, - new TEvTablet::TEvFollowerAttach(TabletID(), FollowerInfo.FollowerAttempt), + if (msg->Status == NKikimrProto::OK && msg->CurrentLeader) { + FollowerInfo.KnownLeaderID = msg->CurrentLeader; + Send(FollowerInfo.KnownLeaderID, + new TEvTablet::TEvFollowerAttach(TabletID(), FollowerInfo.FollowerAttempt), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); - Become(&TThis::StateFollowerSubscribe); + Become(&TThis::StateFollowerSubscribe); } else { // something goes weird, try again a bit later - NextFollowerAttempt(); + NextFollowerAttempt(); TActivationContext::Schedule(TDuration::MilliSeconds(100), new IEventHandle(SelfId(), SelfId(), - new TEvTabletBase::TEvFollowerRetry(++FollowerInfo.RetryRound), - 0, FollowerInfo.FollowerAttempt) + new TEvTabletBase::TEvFollowerRetry(++FollowerInfo.RetryRound), + 0, FollowerInfo.FollowerAttempt) ); } } -void TTablet::HandleFollowerRetry(TEvTabletBase::TEvFollowerRetry::TPtr &ev) { - if (ev->Cookie != FollowerInfo.FollowerAttempt) +void TTablet::HandleFollowerRetry(TEvTabletBase::TEvFollowerRetry::TPtr &ev) { + if (ev->Cookie != FollowerInfo.FollowerAttempt) return; - BootstrapFollower(); + BootstrapFollower(); } -void TTablet::HandleByFollower(TEvTabletBase::TEvTryBuildFollowerGraph::TPtr &ev) { +void TTablet::HandleByFollower(TEvTabletBase::TEvTryBuildFollowerGraph::TPtr &ev) { Y_UNUSED(ev); BLOG_TRACE("Follower starting to rebuild history"); Y_VERIFY_DEBUG(!RebuildGraphRequest); - RebuildGraphRequest = Register(CreateTabletReqRebuildHistoryGraph(SelfId(), Info.Get(), 0, nullptr, ++FollowerInfo.RebuildGraphCookie)); + RebuildGraphRequest = Register(CreateTabletReqRebuildHistoryGraph(SelfId(), Info.Get(), 0, nullptr, ++FollowerInfo.RebuildGraphCookie)); // todo: tracing? at least as event } -void TTablet::HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev) { - if (ev->Sender != RebuildGraphRequest || ev->Cookie != FollowerInfo.RebuildGraphCookie || UserTablet) { +void TTablet::HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev) { + if (ev->Sender != RebuildGraphRequest || ev->Cookie != FollowerInfo.RebuildGraphCookie || UserTablet) { BLOG_D("Outdated TEvRebuildGraphResult ignored"); return; } @@ -365,7 +365,7 @@ void TTablet::HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev) { { UserTablet = SetupInfo->Apply(Info.Get(), SelfId()); Send(UserTablet, - new TEvTablet::TEvFBoot(TabletID(), FollowerId, 0, + new TEvTablet::TEvFBoot(TabletID(), FollowerId, 0, Launcher, msg->DependencyGraph.Get(), Info, ResourceProfiles, TxCacheQuota)); @@ -375,29 +375,29 @@ void TTablet::HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev) { break; case NKikimrProto::NODATA: // any not-positive cases ignored and handled by long retry default: - Schedule(OfflineFollowerWaitRetry, new TEvTabletBase::TEvTryBuildFollowerGraph()); + Schedule(OfflineFollowerWaitRetry, new TEvTabletBase::TEvTryBuildFollowerGraph()); break; } } -bool TTablet::CheckFollowerUpdate(const TActorId &sender, ui32 attempt, ui64 counter) { - if (sender != FollowerInfo.KnownLeaderID || attempt != FollowerInfo.FollowerAttempt) +bool TTablet::CheckFollowerUpdate(const TActorId &sender, ui32 attempt, ui64 counter) { + if (sender != FollowerInfo.KnownLeaderID || attempt != FollowerInfo.FollowerAttempt) return false; - if (counter != FollowerInfo.StreamCounter) { - Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); - NextFollowerAttempt(); - RetryFollowerBootstrapOrWait(); + if (counter != FollowerInfo.StreamCounter) { + Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); + NextFollowerAttempt(); + RetryFollowerBootstrapOrWait(); return false; } return true; } -void TTablet::HandleByFollower(TEvents::TEvUndelivered::TPtr &ev) { - if (ev->Sender == FollowerInfo.KnownLeaderID) { - NextFollowerAttempt(); - RetryFollowerBootstrapOrWait(); +void TTablet::HandleByFollower(TEvents::TEvUndelivered::TPtr &ev) { + if (ev->Sender == FollowerInfo.KnownLeaderID) { + NextFollowerAttempt(); + RetryFollowerBootstrapOrWait(); return; } @@ -406,67 +406,67 @@ void TTablet::HandleByFollower(TEvents::TEvUndelivered::TPtr &ev) { } } -void TTablet::HandleByFollower(TEvInterconnect::TEvNodeDisconnected::TPtr &ev) { - if (ev->Get()->NodeId != FollowerInfo.KnownLeaderID.NodeId()) +void TTablet::HandleByFollower(TEvInterconnect::TEvNodeDisconnected::TPtr &ev) { + if (ev->Get()->NodeId != FollowerInfo.KnownLeaderID.NodeId()) return; BLOG_TRACE("Follower got TEvNodeDisconnected NodeId# " << ev->Get()->NodeId); - NextFollowerAttempt(); - RetryFollowerBootstrapOrWait(); + NextFollowerAttempt(); + RetryFollowerBootstrapOrWait(); } -void TTablet::HandleByFollower(TEvTablet::TEvFollowerDisconnect::TPtr &ev) { - // sent from PassAway of leader - if (ev->Sender != FollowerInfo.KnownLeaderID) +void TTablet::HandleByFollower(TEvTablet::TEvFollowerDisconnect::TPtr &ev) { + // sent from PassAway of leader + if (ev->Sender != FollowerInfo.KnownLeaderID) return; BLOG_TRACE("Follower got TEvFollowerDisconnect Sender# " << ev->Sender); - NextFollowerAttempt(); - RetryFollowerBootstrapOrWait(); + NextFollowerAttempt(); + RetryFollowerBootstrapOrWait(); } -void TTablet::HandleByFollower(TEvTablet::TEvFollowerRefresh::TPtr &ev) { +void TTablet::HandleByFollower(TEvTablet::TEvFollowerRefresh::TPtr &ev) { const auto &record = ev->Get()->Record; Y_VERIFY(record.GetTabletId() == TabletID()); - if (record.GetGeneration() < ExpandGenStepPair(FollowerInfo.EpochGenStep).first) { - Send(ev->Sender, new TEvTablet::TEvFollowerDetach(TabletID(), Max<ui32>())); + if (record.GetGeneration() < ExpandGenStepPair(FollowerInfo.EpochGenStep).first) { + Send(ev->Sender, new TEvTablet::TEvFollowerDetach(TabletID(), Max<ui32>())); return; } - NextFollowerAttempt(); + NextFollowerAttempt(); - FollowerInfo.KnownLeaderID = ev->Sender; - Send(FollowerInfo.KnownLeaderID, - new TEvTablet::TEvFollowerAttach(TabletID(), FollowerInfo.FollowerAttempt), + FollowerInfo.KnownLeaderID = ev->Sender; + Send(FollowerInfo.KnownLeaderID, + new TEvTablet::TEvFollowerAttach(TabletID(), FollowerInfo.FollowerAttempt), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); - Become(&TThis::StateFollowerSubscribe); + Become(&TThis::StateFollowerSubscribe); } -void TTablet::HandleByFollower(TEvTablet::TEvFollowerAuxUpdate::TPtr &ev) { +void TTablet::HandleByFollower(TEvTablet::TEvFollowerAuxUpdate::TPtr &ev) { const auto &record = ev->Get()->Record; - if (!CheckFollowerUpdate(ev->Sender, record.GetFollowerAttempt(), record.GetStreamCounter())) + if (!CheckFollowerUpdate(ev->Sender, record.GetFollowerAttempt(), record.GetStreamCounter())) return; - Y_VERIFY(FollowerInfo.StreamCounter != 0); + Y_VERIFY(FollowerInfo.StreamCounter != 0); Y_VERIFY(UserTablet); - Send(UserTablet, new TEvTablet::TEvFAuxUpdate(record.GetAuxPayload())); + Send(UserTablet, new TEvTablet::TEvFAuxUpdate(record.GetAuxPayload())); - ++FollowerInfo.StreamCounter; + ++FollowerInfo.StreamCounter; } -void TTablet::HandleByFollower(TEvTablet::TEvFollowerUpdate::TPtr &ev) { +void TTablet::HandleByFollower(TEvTablet::TEvFollowerUpdate::TPtr &ev) { const auto &record = ev->Get()->Record; - BLOG_TRACE("FollowerUpdate attempt: " << record.GetFollowerAttempt() << ":" << record.GetStreamCounter() + BLOG_TRACE("FollowerUpdate attempt: " << record.GetFollowerAttempt() << ":" << record.GetStreamCounter() << ", " << record.GetGeneration() << ":" << record.GetStep()); - if (!CheckFollowerUpdate(ev->Sender, record.GetFollowerAttempt(), record.GetStreamCounter())) + if (!CheckFollowerUpdate(ev->Sender, record.GetFollowerAttempt(), record.GetStreamCounter())) return; - if (FollowerInfo.StreamCounter == 0) { - FollowerInfo.RetryRound = 0; // reset retry round counter to enable fast sync with leader + if (FollowerInfo.StreamCounter == 0) { + FollowerInfo.RetryRound = 0; // reset retry round counter to enable fast sync with leader // first event, must be snapshot Y_VERIFY(record.GetIsSnapshot()); @@ -487,52 +487,52 @@ void TTablet::HandleByFollower(TEvTablet::TEvFollowerUpdate::TPtr &ev) { Send(Launcher, new TEvTablet::TEvRestored(TabletID(), StateStorageInfo.KnownGeneration, UserTablet, true)); } - if (!FollowerStStGuardian) - FollowerStStGuardian = Register(CreateStateStorageFollowerGuardian(TabletID(), SelfId())); + if (!FollowerStStGuardian) + FollowerStStGuardian = Register(CreateStateStorageFollowerGuardian(TabletID(), SelfId())); - FollowerInfo.EpochGenStep = MakeGenStepPair(record.GetGeneration(), record.GetStep()); + FollowerInfo.EpochGenStep = MakeGenStepPair(record.GetGeneration(), record.GetStep()); Send(UserTablet, - new TEvTablet::TEvFBoot(TabletID(), FollowerId, record.GetGeneration(), + new TEvTablet::TEvFBoot(TabletID(), FollowerId, record.GetGeneration(), Launcher, *ev->Get(), Info, ResourceProfiles, TxCacheQuota)); - BLOG_TRACE("SBoot attempt: " << FollowerInfo.FollowerAttempt + BLOG_TRACE("SBoot attempt: " << FollowerInfo.FollowerAttempt << ", " << record.GetGeneration() << ":" << record.GetStep()); } else { Y_VERIFY(UserTablet); - Send(UserTablet, new TEvTablet::TEvFUpdate(*ev->Get())); + Send(UserTablet, new TEvTablet::TEvFUpdate(*ev->Get())); - BLOG_TRACE("SUpdate attempt: " << FollowerInfo.FollowerAttempt + BLOG_TRACE("SUpdate attempt: " << FollowerInfo.FollowerAttempt << ", " << record.GetGeneration() << ":" << record.GetStep()); } - ++FollowerInfo.StreamCounter; + ++FollowerInfo.StreamCounter; } -void TTablet::HandleByFollower(TEvTablet::TEvPromoteToLeader::TPtr &ev) { - TEvTablet::TEvPromoteToLeader *msg = ev->Get(); - BLOG_TRACE("Follower got TEvPromoteToLeader Sender# " << ev->Sender << " Generation# " << msg->SuggestedGeneration); +void TTablet::HandleByFollower(TEvTablet::TEvPromoteToLeader::TPtr &ev) { + TEvTablet::TEvPromoteToLeader *msg = ev->Get(); + BLOG_TRACE("Follower got TEvPromoteToLeader Sender# " << ev->Sender << " Generation# " << msg->SuggestedGeneration); if (IntrospectionTrace) { - IntrospectionTrace->Attach(MakeHolder<NTracing::TOnFollowerPromoteToLeader>( + IntrospectionTrace->Attach(MakeHolder<NTracing::TOnFollowerPromoteToLeader>( msg->SuggestedGeneration - , FollowerInfo.KnownLeaderID - , FollowerStStGuardian)); + , FollowerInfo.KnownLeaderID + , FollowerStStGuardian)); } Info = msg->TabletStorageInfo; - // detach from leader - if (FollowerInfo.KnownLeaderID) { - Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); - NextFollowerAttempt(); + // detach from leader + if (FollowerInfo.KnownLeaderID) { + Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); + NextFollowerAttempt(); } - if (FollowerStStGuardian) { - Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); - FollowerStStGuardian = TActorId(); + if (FollowerStStGuardian) { + Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); + FollowerStStGuardian = TActorId(); } if (RebuildGraphRequest) { @@ -542,106 +542,106 @@ void TTablet::HandleByFollower(TEvTablet::TEvPromoteToLeader::TPtr &ev) { // setup start info SuggestedGeneration = msg->SuggestedGeneration; - Leader = true; - FollowerId = 0; + Leader = true; + FollowerId = 0; Bootstrap(); } -void TTablet::HandleByFollower(TEvTablet::TEvFGcAck::TPtr &ev) { - const TEvTablet::TEvFGcAck *msg = ev->Get(); +void TTablet::HandleByFollower(TEvTablet::TEvFGcAck::TPtr &ev) { + const TEvTablet::TEvFGcAck *msg = ev->Get(); - if (FollowerInfo.EpochGenStep <= MakeGenStepPair(msg->Generation, msg->Step)) - Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerGcAck(TabletID(), FollowerInfo.FollowerAttempt, msg->Generation, msg->Step)); + if (FollowerInfo.EpochGenStep <= MakeGenStepPair(msg->Generation, msg->Step)) + Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerGcAck(TabletID(), FollowerInfo.FollowerAttempt, msg->Generation, msg->Step)); } -TMap<TActorId, TTablet::TLeaderInfo>::iterator -TTablet::EraseFollowerInfo(TMap<TActorId, TLeaderInfo>::iterator followerIt) { - const ui32 followerNode = followerIt->first.NodeId(); +TMap<TActorId, TTablet::TLeaderInfo>::iterator +TTablet::EraseFollowerInfo(TMap<TActorId, TLeaderInfo>::iterator followerIt) { + const ui32 followerNode = followerIt->first.NodeId(); - auto retIt = LeaderInfo.erase(followerIt); + auto retIt = LeaderInfo.erase(followerIt); TryPumpWaitingForGc(); - TryFinishFollowerSync(); + TryFinishFollowerSync(); - if (followerNode != SelfId().NodeId()) { - bool noMoreFollowersOnNode = true; - for (const auto &xpair : LeaderInfo) { - if (xpair.first.NodeId() == followerNode) { - noMoreFollowersOnNode = false; + if (followerNode != SelfId().NodeId()) { + bool noMoreFollowersOnNode = true; + for (const auto &xpair : LeaderInfo) { + if (xpair.first.NodeId() == followerNode) { + noMoreFollowersOnNode = false; break; } } - if (noMoreFollowersOnNode) - Send(TActivationContext::InterconnectProxy(followerNode), new TEvents::TEvUnsubscribe); + if (noMoreFollowersOnNode) + Send(TActivationContext::InterconnectProxy(followerNode), new TEvents::TEvUnsubscribe); } return retIt; } -TMap<TActorId, TTablet::TLeaderInfo>::iterator TTablet::HandleFollowerConnectionProblem(TMap<TActorId, TLeaderInfo>::iterator followerIt) { - TLeaderInfo &followerInfo = followerIt->second; +TMap<TActorId, TTablet::TLeaderInfo>::iterator TTablet::HandleFollowerConnectionProblem(TMap<TActorId, TLeaderInfo>::iterator followerIt) { + TLeaderInfo &followerInfo = followerIt->second; bool shouldEraseEntry = false; - switch (followerInfo.SyncState) { - case EFollowerSyncState::Pending: - case EFollowerSyncState::Active: - followerInfo.SyncState = EFollowerSyncState::NeedSync; - followerInfo.SyncAttempt = 0; - BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " moved to NeedSync state"); + switch (followerInfo.SyncState) { + case EFollowerSyncState::Pending: + case EFollowerSyncState::Active: + followerInfo.SyncState = EFollowerSyncState::NeedSync; + followerInfo.SyncAttempt = 0; + BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " moved to NeedSync state"); break; - case EFollowerSyncState::NeedSync: - if (!followerInfo.SyncCookieHolder && followerInfo.SyncAttempt > 3) { - shouldEraseEntry = !followerInfo.PresentInList; - followerInfo.SyncState = EFollowerSyncState::Ignore; - BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " moved to Ignore state, shouldEraseEntry# " << shouldEraseEntry); + case EFollowerSyncState::NeedSync: + if (!followerInfo.SyncCookieHolder && followerInfo.SyncAttempt > 3) { + shouldEraseEntry = !followerInfo.PresentInList; + followerInfo.SyncState = EFollowerSyncState::Ignore; + BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " moved to Ignore state, shouldEraseEntry# " << shouldEraseEntry); } else { - BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " kept in NeedSync state"); + BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " kept in NeedSync state"); } break; - case EFollowerSyncState::Ignore: - BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " kept in Ignore state"); + case EFollowerSyncState::Ignore: + BLOG_D("HandleFollowerConnectionProblem " << followerIt->first << " kept in Ignore state"); break; } if (shouldEraseEntry) { - followerIt = EraseFollowerInfo(followerIt); + followerIt = EraseFollowerInfo(followerIt); } else { - TrySyncToFollower(followerIt); - ++followerIt; + TrySyncToFollower(followerIt); + ++followerIt; } TryPumpWaitingForGc(); - TryFinishFollowerSync(); + TryFinishFollowerSync(); - return followerIt; + return followerIt; } -void TTablet::TrySyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt) { - TLeaderInfo &followerInfo = followerIt->second; - if (followerInfo.SyncCookieHolder) // already awaiting +void TTablet::TrySyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt) { + TLeaderInfo &followerInfo = followerIt->second; + if (followerInfo.SyncCookieHolder) // already awaiting return; - TDuration delay = TDuration::MilliSeconds(250 + Min<ui32>(3, followerInfo.SyncAttempt) * 250); - followerInfo.SyncCookieHolder.Reset(new TSchedulerCookieHolder(ISchedulerCookie::Make3Way())); - auto *schedCookie = followerInfo.SyncCookieHolder->Get(); - Schedule(delay, new TEvTabletBase::TEvTrySyncFollower(followerIt->first, schedCookie), schedCookie); + TDuration delay = TDuration::MilliSeconds(250 + Min<ui32>(3, followerInfo.SyncAttempt) * 250); + followerInfo.SyncCookieHolder.Reset(new TSchedulerCookieHolder(ISchedulerCookie::Make3Way())); + auto *schedCookie = followerInfo.SyncCookieHolder->Get(); + Schedule(delay, new TEvTabletBase::TEvTrySyncFollower(followerIt->first, schedCookie), schedCookie); } -void TTablet::DoSyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt) { - TLeaderInfo &followerInfo = followerIt->second; +void TTablet::DoSyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt) { + TLeaderInfo &followerInfo = followerIt->second; - Send(followerIt->first, new TEvTablet::TEvFollowerRefresh(TabletID(), StateStorageInfo.KnownGeneration), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); + Send(followerIt->first, new TEvTablet::TEvFollowerRefresh(TabletID(), StateStorageInfo.KnownGeneration), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); - ++followerInfo.SyncAttempt; - followerInfo.LastSyncAttempt = TActivationContext::Now(); + ++followerInfo.SyncAttempt; + followerInfo.LastSyncAttempt = TActivationContext::Now(); } -void TTablet::HandleByLeader(TEvents::TEvUndelivered::TPtr &ev) { - auto followerIt = LeaderInfo.find(ev->Sender); - if (followerIt != LeaderInfo.end()) { - HandleFollowerConnectionProblem(followerIt); +void TTablet::HandleByLeader(TEvents::TEvUndelivered::TPtr &ev) { + auto followerIt = LeaderInfo.find(ev->Sender); + if (followerIt != LeaderInfo.end()) { + HandleFollowerConnectionProblem(followerIt); return; } @@ -650,39 +650,39 @@ void TTablet::HandleByLeader(TEvents::TEvUndelivered::TPtr &ev) { } } -void TTablet::HandleByLeader(TEvInterconnect::TEvNodeDisconnected::TPtr &ev) { - // typical number if followers on one node is one. so we don't bother with batched check for unsubscribe +void TTablet::HandleByLeader(TEvInterconnect::TEvNodeDisconnected::TPtr &ev) { + // typical number if followers on one node is one. so we don't bother with batched check for unsubscribe // and we still need to unsubscribe 'cuz of possible races const TEvInterconnect::TEvNodeDisconnected *msg = ev->Get(); - for (auto it = LeaderInfo.begin(); it != LeaderInfo.end(); ) { + for (auto it = LeaderInfo.begin(); it != LeaderInfo.end(); ) { if (it->first.NodeId() == msg->NodeId) - it = HandleFollowerConnectionProblem(it); + it = HandleFollowerConnectionProblem(it); else ++it; } } -void TTablet::HandleByLeader(TEvTablet::TEvFollowerListRefresh::TPtr &ev) { +void TTablet::HandleByLeader(TEvTablet::TEvFollowerListRefresh::TPtr &ev) { auto *msg = ev->Get(); - TMap<TActorId, TLeaderInfo>::iterator infoIt = LeaderInfo.begin(); + TMap<TActorId, TLeaderInfo>::iterator infoIt = LeaderInfo.begin(); - for (auto it = msg->FollowerList.begin(), end = msg->FollowerList.end(); it != end; ++it) { - while (infoIt != LeaderInfo.end() && infoIt->first < *it) { - if (infoIt->second.SyncState == EFollowerSyncState::Ignore) { - infoIt = EraseFollowerInfo(infoIt); + for (auto it = msg->FollowerList.begin(), end = msg->FollowerList.end(); it != end; ++it) { + while (infoIt != LeaderInfo.end() && infoIt->first < *it) { + if (infoIt->second.SyncState == EFollowerSyncState::Ignore) { + infoIt = EraseFollowerInfo(infoIt); } else { infoIt->second.PresentInList = false; ++infoIt; } } - if (infoIt != LeaderInfo.end() && infoIt->first == *it) + if (infoIt != LeaderInfo.end() && infoIt->first == *it) infoIt->second.PresentInList = true; } - while (infoIt != LeaderInfo.end()) { - if (infoIt->second.SyncState == EFollowerSyncState::Ignore) { - infoIt = EraseFollowerInfo(infoIt); + while (infoIt != LeaderInfo.end()) { + if (infoIt->second.SyncState == EFollowerSyncState::Ignore) { + infoIt = EraseFollowerInfo(infoIt); } else { infoIt->second.PresentInList = false; ++infoIt; @@ -690,76 +690,76 @@ void TTablet::HandleByLeader(TEvTablet::TEvFollowerListRefresh::TPtr &ev) { } } -void TTablet::HandleByLeader(TEvTabletBase::TEvTrySyncFollower::TPtr &ev) { - TEvTabletBase::TEvTrySyncFollower *msg = ev->Get(); +void TTablet::HandleByLeader(TEvTabletBase::TEvTrySyncFollower::TPtr &ev) { + TEvTabletBase::TEvTrySyncFollower *msg = ev->Get(); if (msg->CookieHolder.DetachEvent()) { - auto it = LeaderInfo.find(msg->FollowerId); - if (it == LeaderInfo.end()) + auto it = LeaderInfo.find(msg->FollowerId); + if (it == LeaderInfo.end()) return; it->second.SyncCookieHolder.Destroy(); - DoSyncToFollower(it); + DoSyncToFollower(it); } } -void TTablet::HandleByLeader(TEvTablet::TEvFollowerRefresh::TPtr &ev) { - // could be received by promoted leader - Send(ev->Sender, new TEvTablet::TEvFollowerDetach(TabletID(), Max<ui32>())); +void TTablet::HandleByLeader(TEvTablet::TEvFollowerRefresh::TPtr &ev) { + // could be received by promoted leader + Send(ev->Sender, new TEvTablet::TEvFollowerDetach(TabletID(), Max<ui32>())); } -void TTablet::HandleByLeader(TEvTablet::TEvFollowerDetach::TPtr &ev) { - // could be received by leader from promoted leader, just cleanup and wait for normal termination +void TTablet::HandleByLeader(TEvTablet::TEvFollowerDetach::TPtr &ev) { + // could be received by leader from promoted leader, just cleanup and wait for normal termination const auto &record = ev->Get()->Record; - auto followerIt = LeaderInfo.find(ev->Sender); - if (followerIt == LeaderInfo.end() || followerIt->second.FollowerAttempt != record.GetFollowerAttempt()) + auto followerIt = LeaderInfo.find(ev->Sender); + if (followerIt == LeaderInfo.end() || followerIt->second.FollowerAttempt != record.GetFollowerAttempt()) return; - EraseFollowerInfo(followerIt); + EraseFollowerInfo(followerIt); } -void TTablet::HandleByLeader(TEvTablet::TEvFollowerAttach::TPtr &ev) { - const TActorId followerId = ev->Sender; +void TTablet::HandleByLeader(TEvTablet::TEvFollowerAttach::TPtr &ev) { + const TActorId followerId = ev->Sender; const auto &record = ev->Get()->Record; - auto followerIt = LeaderInfo.find(followerId); - if (followerIt != LeaderInfo.end()) { - // attaching follower known - Y_VERIFY(followerIt->second.FollowerAttempt < record.GetFollowerAttempt() || followerIt->second.FollowerAttempt == Max<ui32>()); + auto followerIt = LeaderInfo.find(followerId); + if (followerIt != LeaderInfo.end()) { + // attaching follower known + Y_VERIFY(followerIt->second.FollowerAttempt < record.GetFollowerAttempt() || followerIt->second.FollowerAttempt == Max<ui32>()); - followerIt->second.SyncState = EFollowerSyncState::Pending; // keep ConfirmedGCStep and FromList + followerIt->second.SyncState = EFollowerSyncState::Pending; // keep ConfirmedGCStep and FromList } else { - if (LeaderInfo.empty()) { - // Consider sending follower updates starting with the next commit - Graph.MinFollowerUpdate = Graph.NextEntry; + if (LeaderInfo.empty()) { + // Consider sending follower updates starting with the next commit + Graph.MinFollowerUpdate = Graph.NextEntry; } - auto followerItPair = LeaderInfo.insert(decltype(LeaderInfo)::value_type(ev->Sender, TLeaderInfo(EFollowerSyncState::Pending))); - Y_VERIFY(followerItPair.second); + auto followerItPair = LeaderInfo.insert(decltype(LeaderInfo)::value_type(ev->Sender, TLeaderInfo(EFollowerSyncState::Pending))); + Y_VERIFY(followerItPair.second); - followerIt = followerItPair.first; + followerIt = followerItPair.first; } - TLeaderInfo &followerInfo = followerIt->second; + TLeaderInfo &followerInfo = followerIt->second; - followerInfo.FollowerAttempt = record.GetFollowerAttempt(); - followerInfo.StreamCounter = 0; - followerInfo.SyncAttempt = 0; - followerInfo.SyncCookieHolder.Destroy(); + followerInfo.FollowerAttempt = record.GetFollowerAttempt(); + followerInfo.StreamCounter = 0; + followerInfo.SyncAttempt = 0; + followerInfo.SyncCookieHolder.Destroy(); if (UserTablet) - Send(UserTablet, new TEvTablet::TEvNewFollowerAttached(LeaderInfo.size())); + Send(UserTablet, new TEvTablet::TEvNewFollowerAttached(LeaderInfo.size())); } -void TTablet::HandleByLeader(TEvTablet::TEvFollowerGcAck::TPtr &ev) { - const TActorId followerId = ev->Sender; - TLeaderInfo *followerInfo = LeaderInfo.FindPtr(followerId); - if (!followerInfo || followerInfo->SyncState != EFollowerSyncState::Active) +void TTablet::HandleByLeader(TEvTablet::TEvFollowerGcAck::TPtr &ev) { + const TActorId followerId = ev->Sender; + TLeaderInfo *followerInfo = LeaderInfo.FindPtr(followerId); + if (!followerInfo || followerInfo->SyncState != EFollowerSyncState::Active) return; const auto &record = ev->Get()->Record; - if (record.GetGeneration() != StateStorageInfo.KnownGeneration || followerInfo->FollowerAttempt != record.GetFollowerAttempt()) + if (record.GetGeneration() != StateStorageInfo.KnownGeneration || followerInfo->FollowerAttempt != record.GetFollowerAttempt()) return; const ui32 step = record.GetStep(); - Y_VERIFY_DEBUG(followerInfo->ConfirmedGCStep < step); - followerInfo->ConfirmedGCStep = Max(step, followerInfo->ConfirmedGCStep); + Y_VERIFY_DEBUG(followerInfo->ConfirmedGCStep < step); + followerInfo->ConfirmedGCStep = Max(step, followerInfo->ConfirmedGCStep); TryPumpWaitingForGc(); } @@ -805,7 +805,7 @@ void TTablet::HandleStateStorageInfoResolve(TEvStateStorage::TEvInfo::TPtr &ev) return CancelTablet(TEvTablet::TEvTabletDead::ReasonBootRace); } - if (!msg->CurrentLeader || !msg->CurrentGeneration) { + if (!msg->CurrentLeader || !msg->CurrentGeneration) { return LockedInitializationPath(); } @@ -865,17 +865,17 @@ void TTablet::HandleStateStorageInfoUpgrade(TEvStateStorage::TEvInfo::TPtr &ev) { // ok, we marked ourselves as generation owner NeedCleanupOnLockedPath = false; StateStorageInfo.Update(msg); - for (const auto &xpair : msg->Followers) { + for (const auto &xpair : msg->Followers) { if (xpair.first == SelfId()) continue; - if (LeaderInfo.empty()) { - // Consider sending follower updates starting with the next commit - Graph.MinFollowerUpdate = Graph.NextEntry; + if (LeaderInfo.empty()) { + // Consider sending follower updates starting with the next commit + Graph.MinFollowerUpdate = Graph.NextEntry; } - auto itPair = LeaderInfo.insert(decltype(LeaderInfo)::value_type(xpair.first, TLeaderInfo(EFollowerSyncState::NeedSync))); - // some followers could be already present by active TEvFollowerAttach + auto itPair = LeaderInfo.insert(decltype(LeaderInfo)::value_type(xpair.first, TLeaderInfo(EFollowerSyncState::NeedSync))); + // some followers could be already present by active TEvFollowerAttach if (itPair.second) - TrySyncToFollower(itPair.first); + TrySyncToFollower(itPair.first); } return TabletBlockBlobStorage(); @@ -936,7 +936,7 @@ void TTablet::HandleBlockBlobStorageResult(TEvTabletBase::TEvBlockBlobStorageRes } void TTablet::HandleRebuildGraphResult(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev) { - if (ev->Cookie != 0) // remains from follower past + if (ev->Cookie != 0) // remains from follower past return; RebuildGraphRequest = TActorId(); // check consistency?? @@ -992,10 +992,10 @@ void TTablet::HandleWriteZeroEntry(TEvTabletBase::TEvWriteLogResult::TPtr &ev) { void TTablet::Handle(TEvTablet::TEvPing::TPtr &ev) { NKikimrTabletBase::TEvPing &record = ev->Get()->Record; Y_VERIFY(record.GetTabletID() == TabletID()); - Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagLeader)); + Send(ev->Sender, new TEvTablet::TEvPong(TabletID(), TEvTablet::TEvPong::FlagLeader)); } -void TTablet::HandleByLeader(TEvTablet::TEvTabletActive::TPtr &ev) { +void TTablet::HandleByLeader(TEvTablet::TEvTabletActive::TPtr &ev) { Y_UNUSED(ev); ReportTabletStateChange(TTabletStateInfo::Active); ActivateTime = AppData()->TimeProvider->Now(); @@ -1006,20 +1006,20 @@ void TTablet::HandleByLeader(TEvTablet::TEvTabletActive::TPtr &ev) { PipeConnectAcceptor->Activate(SelfId(), UserTablet, true); } -void TTablet::HandleByFollower(TEvTablet::TEvTabletActive::TPtr &ev) { +void TTablet::HandleByFollower(TEvTablet::TEvTabletActive::TPtr &ev) { Y_UNUSED(ev); - BLOG_D("Follower TabletStateActive"); + BLOG_D("Follower TabletStateActive"); PipeConnectAcceptor->Activate(SelfId(), UserTablet, false); - Send(FollowerStStGuardian, new TEvTablet::TEvFollowerUpdateState(false, SelfId(), UserTablet)); + Send(FollowerStStGuardian, new TEvTablet::TEvFollowerUpdateState(false, SelfId(), UserTablet)); ReportTabletStateChange(TTabletStateInfo::Active); } TTablet::TLogEntry* TTablet::MakeLogEntry(TEvTablet::TCommitInfo &commitInfo, NKikimrTabletBase::TTabletLogEntry *commitEv) { - Y_VERIFY(commitInfo.TabletID == TabletID() && commitInfo.Generation == StateStorageInfo.KnownGeneration && commitInfo.Step == Graph.NextEntry, - "commitInfo.TabletID=%ld, tablet=%ld, commitInfo.Generation=%d, KnownGeneration=%d, commitInfo.Step=%d, nextEntry=%d", - commitInfo.TabletID, TabletID(), commitInfo.Generation, StateStorageInfo.KnownGeneration, commitInfo.Step, Graph.NextEntry); + Y_VERIFY(commitInfo.TabletID == TabletID() && commitInfo.Generation == StateStorageInfo.KnownGeneration && commitInfo.Step == Graph.NextEntry, + "commitInfo.TabletID=%ld, tablet=%ld, commitInfo.Generation=%d, KnownGeneration=%d, commitInfo.Step=%d, nextEntry=%d", + commitInfo.TabletID, TabletID(), commitInfo.Generation, StateStorageInfo.KnownGeneration, commitInfo.Step, Graph.NextEntry); const ui32 step = Graph.NextEntry++; @@ -1070,12 +1070,12 @@ void TTablet::Handle(TEvTablet::TEvPreCommit::TPtr &ev) { } void TTablet::Handle(TEvTablet::TEvAux::TPtr &ev) { - TString& auxUpdate = ev->Get()->FollowerAux; + TString& auxUpdate = ev->Get()->FollowerAux; if (!Graph.Queue.empty()) { - Graph.Queue.back()->FollowerAuxUpdates.emplace_back(std::move(auxUpdate)); + Graph.Queue.back()->FollowerAuxUpdates.emplace_back(std::move(auxUpdate)); } else { - SpreadFollowerAuxUpdate(auxUpdate); + SpreadFollowerAuxUpdate(auxUpdate); } } @@ -1104,14 +1104,14 @@ bool TTablet::HandleNext(TEvTablet::TEvCommit::TPtr &ev) { entry->Source = ev->Sender; entry->SourceCookie = ev->Cookie; - entry->WaitFollowerGcAck = msg->WaitFollowerGcAck; + entry->WaitFollowerGcAck = msg->WaitFollowerGcAck; x->SetSnapshot(MakeGenStepPair(Graph.Snapshot.first, Graph.Snapshot.second)); x->SetConfirmed(Graph.Confirmed); - const bool saveFollowerUpdate = !LeaderInfo.empty(); - if (saveFollowerUpdate) - entry->FollowerUpdate.Reset(new TFollowerUpdate()); + const bool saveFollowerUpdate = !LeaderInfo.empty(); + if (saveFollowerUpdate) + entry->FollowerUpdate.Reset(new TFollowerUpdate()); if (entry->IsSnapshot) x->SetIsSnapshot(true); @@ -1120,8 +1120,8 @@ bool TTablet::HandleNext(TEvTablet::TEvCommit::TPtr &ev) { x->MutableReferences()->Reserve((i32)(msg->ExternalReferences.size() + msg->References.size())); - if (saveFollowerUpdate) - entry->FollowerUpdate->References.reserve(msg->References.size()); + if (saveFollowerUpdate) + entry->FollowerUpdate->References.reserve(msg->References.size()); for (TVector<TLogoBlobID>::const_iterator it = msg->ExternalReferences.begin(), end = msg->ExternalReferences.end(); it != end; ++it) LogoBlobIDFromLogoBlobID(*it, x->AddReferences()); @@ -1131,8 +1131,8 @@ bool TTablet::HandleNext(TEvTablet::TEvCommit::TPtr &ev) { Y_VERIFY(id.TabletID() == TabletID() && id.Generation() == StateStorageInfo.KnownGeneration); LogoBlobIDFromLogoBlobID(id, x->AddReferences()); - if (saveFollowerUpdate) - entry->FollowerUpdate->References.push_back(std::make_pair(it->Id, it->Buffer)); + if (saveFollowerUpdate) + entry->FollowerUpdate->References.push_back(std::make_pair(it->Id, it->Buffer)); } if (!msg->GcDiscovered.empty()) { @@ -1140,8 +1140,8 @@ bool TTablet::HandleNext(TEvTablet::TEvCommit::TPtr &ev) { for (auto &gcx : msg->GcDiscovered) LogoBlobIDFromLogoBlobID(gcx, x->AddGcDiscovered()); - if (saveFollowerUpdate) - entry->FollowerUpdate->GcDiscovered.swap(msg->GcDiscovered); + if (saveFollowerUpdate) + entry->FollowerUpdate->GcDiscovered.swap(msg->GcDiscovered); } if (!msg->GcLeft.empty()) { @@ -1149,20 +1149,20 @@ bool TTablet::HandleNext(TEvTablet::TEvCommit::TPtr &ev) { for (auto &gcx : msg->GcLeft) LogoBlobIDFromLogoBlobID(gcx, x->AddGcLeft()); - if (saveFollowerUpdate) - entry->FollowerUpdate->GcLeft.swap(msg->GcLeft); + if (saveFollowerUpdate) + entry->FollowerUpdate->GcLeft.swap(msg->GcLeft); } if (msg->EmbeddedLogBody) { Y_VERIFY(x->ReferencesSize() == 0); x->SetEmbeddedLogBody(msg->EmbeddedLogBody); - if (saveFollowerUpdate) - entry->FollowerUpdate->Body = msg->EmbeddedLogBody; + if (saveFollowerUpdate) + entry->FollowerUpdate->Body = msg->EmbeddedLogBody; } - if (saveFollowerUpdate && msg->FollowerAux) - entry->FollowerUpdate->AuxPayload = msg->FollowerAux; + if (saveFollowerUpdate && msg->FollowerAux) + entry->FollowerUpdate->AuxPayload = msg->FollowerAux; entry->ByteSize = x->ByteSizeLong(); for (const auto& ref : msg->References) { @@ -1322,24 +1322,24 @@ void TTablet::GcLogChannel(ui32 step) { GcNextStep = 0; } -void TTablet::SpreadFollowerAuxUpdate(const TString& auxUpdate) { - for (auto &xpair : LeaderInfo) { - SendFollowerAuxUpdate(xpair.second, xpair.first, auxUpdate); - } -} +void TTablet::SpreadFollowerAuxUpdate(const TString& auxUpdate) { + for (auto &xpair : LeaderInfo) { + SendFollowerAuxUpdate(xpair.second, xpair.first, auxUpdate); + } +} + +void TTablet::SendFollowerAuxUpdate(TLeaderInfo& info, const TActorId& follower, const TString& auxUpdate) { + if (info.FollowerAttempt == Max<ui32>()) + return; + if (info.StreamCounter == 0) + return; -void TTablet::SendFollowerAuxUpdate(TLeaderInfo& info, const TActorId& follower, const TString& auxUpdate) { - if (info.FollowerAttempt == Max<ui32>()) - return; - if (info.StreamCounter == 0) - return; + const ui64 tabletId = TabletID(); + auto notify = MakeHolder<TEvTablet::TEvFollowerAuxUpdate>(tabletId, info.FollowerAttempt, info.StreamCounter); + notify->Record.SetAuxPayload(auxUpdate); - const ui64 tabletId = TabletID(); - auto notify = MakeHolder<TEvTablet::TEvFollowerAuxUpdate>(tabletId, info.FollowerAttempt, info.StreamCounter); - notify->Record.SetAuxPayload(auxUpdate); - - Send(follower, notify.Release(), 0, IEventHandle::FlagTrackDelivery); - ++info.StreamCounter; + Send(follower, notify.Release(), 0, IEventHandle::FlagTrackDelivery); + ++info.StreamCounter; } bool TTablet::ProgressCommitQueue() { @@ -1356,10 +1356,10 @@ bool TTablet::ProgressCommitQueue() { GcLogChannel(entry->ConfirmedOnSend); } - if (entry->FollowerUpdate && LeaderInfo && step >= Graph.MinFollowerUpdate) { + if (entry->FollowerUpdate && LeaderInfo && step >= Graph.MinFollowerUpdate) { Graph.PostponedFollowerUpdates.emplace_back(std::move(Graph.Queue.front())); - } else if (entry->WaitFollowerGcAck) { - Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(tabletId, StateStorageInfo.KnownGeneration, step, TDuration::Max())); + } else if (entry->WaitFollowerGcAck) { + Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(tabletId, StateStorageInfo.KnownGeneration, step, TDuration::Max())); } Graph.Confirmed = step; @@ -1370,51 +1370,51 @@ bool TTablet::ProgressCommitQueue() { return false; } - ProgressFollowerQueue(); - TryFinishFollowerSync(); + ProgressFollowerQueue(); + TryFinishFollowerSync(); return true; } -void TTablet::ProgressFollowerQueue() { - const ui32 goodUntil = LeaderInfo ? Graph.ConfirmedCommited : Max<ui32>(); +void TTablet::ProgressFollowerQueue() { + const ui32 goodUntil = LeaderInfo ? Graph.ConfirmedCommited : Max<ui32>(); - while (!Graph.PostponedFollowerUpdates.empty()) { + while (!Graph.PostponedFollowerUpdates.empty()) { TLogEntry *entry = Graph.PostponedFollowerUpdates.front().get(); const ui32 step = entry->Step; if (step > goodUntil) break; - auto *sup = entry->FollowerUpdate.Get(); + auto *sup = entry->FollowerUpdate.Get(); - bool needWaitForFollowerGcAck = false; - for (auto &xpair : LeaderInfo) { - if (step < Graph.MinFollowerUpdate) { - // We cannot be sure follower updates before LeaderInfo became + bool needWaitForFollowerGcAck = false; + for (auto &xpair : LeaderInfo) { + if (step < Graph.MinFollowerUpdate) { + // We cannot be sure follower updates before LeaderInfo became // non-empty are contiguous and without any holes. We need // to ignore them, as if they didn't exist. break; } - TLeaderInfo &followerInfo = xpair.second; + TLeaderInfo &followerInfo = xpair.second; - if (!needWaitForFollowerGcAck) { - if (followerInfo.SyncState != EFollowerSyncState::Ignore) - needWaitForFollowerGcAck = true; + if (!needWaitForFollowerGcAck) { + if (followerInfo.SyncState != EFollowerSyncState::Ignore) + needWaitForFollowerGcAck = true; } - if (followerInfo.FollowerAttempt == Max<ui32>()) + if (followerInfo.FollowerAttempt == Max<ui32>()) continue; - if (followerInfo.SyncState == EFollowerSyncState::Active - || followerInfo.SyncState == EFollowerSyncState::Pending && entry->IsSnapshot) + if (followerInfo.SyncState == EFollowerSyncState::Active + || followerInfo.SyncState == EFollowerSyncState::Pending && entry->IsSnapshot) { - auto notify = MakeHolder<TEvTablet::TEvFollowerUpdate>(TabletID(), followerInfo.FollowerAttempt, followerInfo.StreamCounter); + auto notify = MakeHolder<TEvTablet::TEvFollowerUpdate>(TabletID(), followerInfo.FollowerAttempt, followerInfo.StreamCounter); auto &record = notify->Record; record.SetGeneration(StateStorageInfo.KnownGeneration); record.SetStep(step); record.SetIsSnapshot(entry->IsSnapshot); - record.SetNeedGCApplyAck(entry->WaitFollowerGcAck); + record.SetNeedGCApplyAck(entry->WaitFollowerGcAck); if (sup->Body) record.SetBody(sup->Body); @@ -1432,33 +1432,33 @@ void TTablet::ProgressFollowerQueue() { } } - if (followerInfo.StreamCounter == 0) { + if (followerInfo.StreamCounter == 0) { TabletStorageInfoToProto(*Info, record.MutableTabletStorageInfo()); - followerInfo.SyncState = EFollowerSyncState::Active; + followerInfo.SyncState = EFollowerSyncState::Active; } - const ui32 subscFlag = (followerInfo.StreamCounter == 0) ? IEventHandle::FlagSubscribeOnSession : 0; + const ui32 subscFlag = (followerInfo.StreamCounter == 0) ? IEventHandle::FlagSubscribeOnSession : 0; Send(xpair.first, notify.Release(), IEventHandle::FlagTrackDelivery | subscFlag); ++xpair.second.StreamCounter; } - for (const TString &x : entry->FollowerAuxUpdates) - SendFollowerAuxUpdate(xpair.second, xpair.first, x); + for (const TString &x : entry->FollowerAuxUpdates) + SendFollowerAuxUpdate(xpair.second, xpair.first, x); } - if (entry->WaitFollowerGcAck) { - if (needWaitForFollowerGcAck) { + if (entry->WaitFollowerGcAck) { + if (needWaitForFollowerGcAck) { WaitingForGcAck.emplace_back(step, entry->CommitedMoment); } else { - Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(TabletID(), StateStorageInfo.KnownGeneration, step, TDuration::Max())); + Send(UserTablet, new TEvTablet::TEvFollowerGcApplied(TabletID(), StateStorageInfo.KnownGeneration, step, TDuration::Max())); } } - Graph.PostponedFollowerUpdates.pop_front(); + Graph.PostponedFollowerUpdates.pop_front(); } - if (Graph.PostponedFollowerUpdates && Graph.Queue.empty() && Graph.SyncCommit.SyncStep == 0) { + if (Graph.PostponedFollowerUpdates && Graph.Queue.empty() && Graph.SyncCommit.SyncStep == 0) { Graph.SyncCommit.SyncStep = Graph.NextEntry - 1; if (GcInFly) { // Since we always confirm the last commit it should be impossible @@ -1487,9 +1487,9 @@ void TTablet::ProgressFollowerQueue() { void TTablet::Handle(TEvTabletPipe::TEvConnect::TPtr& ev) { if (PipeConnectAcceptor->IsStopped()) { - PipeConnectAcceptor->Reject(ev, SelfId(), NKikimrProto::TRYLATER, Leader); + PipeConnectAcceptor->Reject(ev, SelfId(), NKikimrProto::TRYLATER, Leader); } else if (PipeConnectAcceptor->IsActive()) { - PipeConnectAcceptor->Accept(ev, SelfId(), UserTablet, Leader); + PipeConnectAcceptor->Accept(ev, SelfId(), UserTablet, Leader); } else { PipeConnectAcceptor->Enqueue(ev, SelfId()); } @@ -1502,14 +1502,14 @@ void TTablet::Handle(TEvTabletPipe::TEvServerDestroyed::TPtr& ev) { void TTablet::HandleQueued(TEvTabletPipe::TEvConnect::TPtr& ev) { if (PipeConnectAcceptor->IsStopped()) { // FIXME: do we really need it? - PipeConnectAcceptor->Reject(ev, SelfId(), NKikimrProto::TRYLATER, Leader); + PipeConnectAcceptor->Reject(ev, SelfId(), NKikimrProto::TRYLATER, Leader); } else { PipeConnectAcceptor->Enqueue(ev, SelfId()); } } -void TTablet::HandleByFollower(TEvTabletPipe::TEvConnect::TPtr &ev) { - Y_VERIFY_DEBUG(!Leader); +void TTablet::HandleByFollower(TEvTabletPipe::TEvConnect::TPtr &ev) { + Y_VERIFY_DEBUG(!Leader); if (PipeConnectAcceptor->IsActive() && !PipeConnectAcceptor->IsStopped()) { PipeConnectAcceptor->Accept(ev, SelfId(), UserTablet, false); } else { @@ -1678,9 +1678,9 @@ bool TTablet::StopTablet( StateStorageGuardian = { }; } - if (FollowerStStGuardian) { - Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); - FollowerStStGuardian = { }; + if (FollowerStStGuardian) { + Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); + FollowerStStGuardian = { }; } } @@ -1752,32 +1752,32 @@ void TTablet::CancelTablet(TEvTablet::TEvTabletDead::EReason reason, const TStri if (StateStorageGuardian) Send(StateStorageGuardian, new TEvents::TEvPoisonPill()); - if (FollowerStStGuardian) - Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); + if (FollowerStStGuardian) + Send(FollowerStStGuardian, new TEvents::TEvPoisonPill()); if (RebuildGraphRequest) Send(RebuildGraphRequest, new TEvents::TEvPoisonPill()); TSet<ui32> nodesToUnsubsribe; - for (auto &xpair : LeaderInfo) { - Send(xpair.first, new TEvTablet::TEvFollowerDisconnect(TabletID(), xpair.second.FollowerAttempt)); - const ui32 followerNode = xpair.first.NodeId(); - if (followerNode && followerNode != SelfId().NodeId()) - nodesToUnsubsribe.emplace(followerNode); + for (auto &xpair : LeaderInfo) { + Send(xpair.first, new TEvTablet::TEvFollowerDisconnect(TabletID(), xpair.second.FollowerAttempt)); + const ui32 followerNode = xpair.first.NodeId(); + if (followerNode && followerNode != SelfId().NodeId()) + nodesToUnsubsribe.emplace(followerNode); } - LeaderInfo.clear(); + LeaderInfo.clear(); - if (FollowerInfo.KnownLeaderID) - Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); + if (FollowerInfo.KnownLeaderID) + Send(FollowerInfo.KnownLeaderID, new TEvTablet::TEvFollowerDetach(TabletID(), FollowerInfo.FollowerAttempt)); if (NeedCleanupOnLockedPath) Send(StateStorageInfo.ProxyID, new TEvStateStorage::TEvCleanup(TabletID(), SelfId())); ReportTabletStateChange(TTabletStateInfo::Dead); - const ui32 leaderNode = FollowerInfo.KnownLeaderID.NodeId(); - if (leaderNode && leaderNode != SelfId().NodeId()) - nodesToUnsubsribe.emplace(leaderNode); + const ui32 leaderNode = FollowerInfo.KnownLeaderID.NodeId(); + if (leaderNode && leaderNode != SelfId().NodeId()) + nodesToUnsubsribe.emplace(leaderNode); for (ui32 x : nodesToUnsubsribe) { Send(TActivationContext::InterconnectProxy(x), new TEvents::TEvUnsubscribe()); @@ -1816,10 +1816,10 @@ void TTablet::LockedInitializationPath() { ReportTabletStateChange(TTabletStateInfo::Lock); } -TTablet::TTablet(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, bool leader, - ui32 suggestedGeneration, ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) - : TActor(leader ? &TThis::StateBootstrapNormal : &TThis::StateBootstrapFollower) - , InitialFollowerSyncDone(false) +TTablet::TTablet(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, bool leader, + ui32 suggestedGeneration, ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) + : TActor(leader ? &TThis::StateBootstrapNormal : &TThis::StateBootstrapFollower) + , InitialFollowerSyncDone(false) , Launcher(launcher) , Info(info) , SetupInfo(setupInfo) @@ -1827,8 +1827,8 @@ TTablet::TTablet(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetu , NeedCleanupOnLockedPath(false) , GcCounter(0) , PipeConnectAcceptor(NTabletPipe::CreateConnectAcceptor(info->TabletID)) - , Leader(leader) - , FollowerId(followerId) + , Leader(leader) + , FollowerId(followerId) , DiscoveredLastBlocked(Max<ui32>()) , GcInFly(0) , GcInFlyStep(0) @@ -1845,29 +1845,29 @@ TAutoPtr<IEventHandle> TTablet::AfterRegister(const TActorId &self, const TActor return new IEventHandle(self, self, new TEvents::TEvBootstrap()); } -void TTablet::RetryFollowerBootstrapOrWait() { - if (FollowerInfo.RetryRound) { - ReportTabletStateChange(TTabletStateInfo::ResolveLeader); +void TTablet::RetryFollowerBootstrapOrWait() { + if (FollowerInfo.RetryRound) { + ReportTabletStateChange(TTabletStateInfo::ResolveLeader); TActivationContext::Schedule(TDuration::MilliSeconds(2000), new IEventHandle( SelfId(), SelfId(), - new TEvTabletBase::TEvFollowerRetry(++FollowerInfo.RetryRound), - 0, FollowerInfo.FollowerAttempt)); - Become(&TThis::StateResolveLeader); + new TEvTabletBase::TEvFollowerRetry(++FollowerInfo.RetryRound), + 0, FollowerInfo.FollowerAttempt)); + Become(&TThis::StateResolveLeader); } else { - FollowerInfo.RetryRound = 1; - BootstrapFollower(); + FollowerInfo.RetryRound = 1; + BootstrapFollower(); } } -void TTablet::BootstrapFollower() { - // create guardians right now and schedule offline follower boot - if (!FollowerStStGuardian) { - FollowerStStGuardian = Register(CreateStateStorageFollowerGuardian(TabletID(), SelfId())); - Schedule(OfflineFollowerWaitFirst, new TEvTabletBase::TEvTryBuildFollowerGraph()); +void TTablet::BootstrapFollower() { + // create guardians right now and schedule offline follower boot + if (!FollowerStStGuardian) { + FollowerStStGuardian = Register(CreateStateStorageFollowerGuardian(TabletID(), SelfId())); + Schedule(OfflineFollowerWaitFirst, new TEvTabletBase::TEvTryBuildFollowerGraph()); } - Leader = false; + Leader = false; BoostrapTime = AppData()->TimeProvider->Now(); bool enInt = AppData()->EnableIntrospection; if (enInt) { @@ -1880,13 +1880,13 @@ void TTablet::BootstrapFollower() { IntrospectionTrace->Attach(MakeHolder<NTracing::TOnTabletBootstrap>(SuggestedGeneration, false, StateStorageInfo.ProxyID)); } - Become(&TThis::StateResolveLeader); - ReportTabletStateChange(TTabletStateInfo::ResolveLeader); + Become(&TThis::StateResolveLeader); + ReportTabletStateChange(TTabletStateInfo::ResolveLeader); } void TTablet::Bootstrap() { DiscoveredLastBlocked = Max<ui32>(); - Leader = true; + Leader = true; BoostrapTime = AppData()->TimeProvider->Now(); bool enInt = AppData()->EnableIntrospection; if (enInt) { @@ -1923,25 +1923,25 @@ TActorId TTabletSetupInfo::Apply(TTabletStorageInfo *info, const TActorContext & } TActorId TTabletSetupInfo::Tablet(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, - ui32 suggestedGeneration, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { + ui32 suggestedGeneration, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { return ctx.ExecutorThread.RegisterActor(CreateTablet(launcher, info, this, suggestedGeneration, profiles, txCacheQuota), TabletMailboxType, TabletPoolId); } -TActorId TTabletSetupInfo::Follower(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, - ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { - return ctx.ExecutorThread.RegisterActor(CreateTabletFollower(launcher, info, this, followerId, profiles, txCacheQuota), +TActorId TTabletSetupInfo::Follower(TTabletStorageInfo *info, const TActorId &launcher, const TActorContext &ctx, + ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { + return ctx.ExecutorThread.RegisterActor(CreateTabletFollower(launcher, info, this, followerId, profiles, txCacheQuota), TabletMailboxType, TabletPoolId); } IActor* CreateTablet(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, - ui32 suggestedGeneration, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { + ui32 suggestedGeneration, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { return new TTablet(launcher, info, setupInfo, true, suggestedGeneration, 0, profiles, txCacheQuota); } -IActor* CreateTabletFollower(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, - ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { - return new TTablet(launcher, info, setupInfo, false, 0, followerId, profiles, txCacheQuota); +IActor* CreateTabletFollower(const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, + ui32 followerId, TResourceProfilesPtr profiles, TSharedQuotaPtr txCacheQuota) { + return new TTablet(launcher, info, setupInfo, false, 0, followerId, profiles, txCacheQuota); } void TTablet::SendIntrospectionData() { diff --git a/ydb/core/tablet/tablet_sys.h b/ydb/core/tablet/tablet_sys.h index b1cd180b9cc..661d75a4e0a 100644 --- a/ydb/core/tablet/tablet_sys.h +++ b/ydb/core/tablet/tablet_sys.h @@ -20,7 +20,7 @@ class TTablet : public TActor<TTablet> { ui32 KnownGeneration; ui32 KnownStep; - TActorId CurrentLeader; + TActorId CurrentLeader; ui32 SignatureSz; TArrayHolder<ui64> Signature; @@ -34,12 +34,12 @@ class TTablet : public TActor<TTablet> { void Update(const TEvStateStorage::TEvInfo *msg) { const ui32 xg = msg->CurrentGeneration; const ui32 xs = msg->CurrentStep; - const TActorId &xm = msg->CurrentLeader; + const TActorId &xm = msg->CurrentLeader; if (xg > KnownGeneration) { KnownGeneration = xg; KnownStep = xs; - CurrentLeader = xm; + CurrentLeader = xm; } else if (xg == KnownGeneration) { if (KnownStep < xs) KnownStep = xs; @@ -56,7 +56,7 @@ class TTablet : public TActor<TTablet> { } } StateStorageInfo; - struct TFollowerUpdate { + struct TFollowerUpdate { TVector<std::pair<TLogoBlobID, TString>> References; TString Body; TString AuxPayload; @@ -77,7 +77,7 @@ class TTablet : public TActor<TTablet> { bool IsSnapshot; bool IsTotalSnapshot; bool Commited; - bool WaitFollowerGcAck; + bool WaitFollowerGcAck; TInstant CommitedMoment; TActorId Source; @@ -85,8 +85,8 @@ class TTablet : public TActor<TTablet> { ui64 SourceCookie; - THolder<TFollowerUpdate> FollowerUpdate; - TVector<TString> FollowerAuxUpdates; + THolder<TFollowerUpdate> FollowerUpdate; + TVector<TString> FollowerAuxUpdates; NMetrics::TTabletThroughputRawValue GroupWrittenBytes; NMetrics::TTabletIopsRawValue GroupWrittenOps; @@ -104,7 +104,7 @@ class TTablet : public TActor<TTablet> { , IsSnapshot(false) , IsTotalSnapshot(false) , Commited(false) - , WaitFollowerGcAck(false) + , WaitFollowerGcAck(false) , CommitedMoment(TInstant::Zero()) , SourceCookie(sourceCookie) , ByteSize(0) @@ -116,14 +116,14 @@ class TTablet : public TActor<TTablet> { typedef THashMap<ui32, TLogEntry *> TIndex; TQueueType Queue; - TQueueType PostponedFollowerUpdates; + TQueueType PostponedFollowerUpdates; TIndex Index; TDeque<TEvTablet::TEvCommit::TPtr> DelayCommitQueue; ui32 Confirmed; ui32 ConfirmedCommited; ui32 NextEntry; - ui32 MinFollowerUpdate; + ui32 MinFollowerUpdate; ui32 StepsInFlight; ui64 BytesInFlight; @@ -137,51 +137,51 @@ class TTablet : public TActor<TTablet> { : Confirmed(0) , ConfirmedCommited(0) , NextEntry(0) - , MinFollowerUpdate(0) + , MinFollowerUpdate(0) , StepsInFlight(0) , BytesInFlight(0) {} } Graph; - struct TFollowerInfo { - TActorId KnownLeaderID; + struct TFollowerInfo { + TActorId KnownLeaderID; ui32 RetryRound; - ui32 FollowerAttempt; + ui32 FollowerAttempt; ui64 StreamCounter; ui64 EpochGenStep; ui64 RebuildGraphCookie; - TFollowerInfo() + TFollowerInfo() : RetryRound(0) - , FollowerAttempt(0) + , FollowerAttempt(0) , StreamCounter(0) , EpochGenStep(Max<ui64>()) , RebuildGraphCookie(1) {} void NextAttempt() { - KnownLeaderID = TActorId(); + KnownLeaderID = TActorId(); // do not touch RetryRound on retries - ++FollowerAttempt; + ++FollowerAttempt; StreamCounter = 0; // do not reset EpochGenStep for sync actuality check! } - } FollowerInfo; + } FollowerInfo; - void NextFollowerAttempt(); + void NextFollowerAttempt(); - enum class EFollowerSyncState { - NeedSync, // follower known but not connected, blocks gc - Pending, // follower connected but stream not yet started, blocks gc - Active, // follower active, blocks gc - Ignore, // could not connect to follower for too long. ignore for gc + enum class EFollowerSyncState { + NeedSync, // follower known but not connected, blocks gc + Pending, // follower connected but stream not yet started, blocks gc + Active, // follower active, blocks gc + Ignore, // could not connect to follower for too long. ignore for gc }; - struct TLeaderInfo { - ui32 FollowerAttempt; + struct TLeaderInfo { + ui32 FollowerAttempt; ui64 StreamCounter; - EFollowerSyncState SyncState; + EFollowerSyncState SyncState; TInstant LastSyncAttempt; ui64 SyncAttempt; THolder<TSchedulerCookieHolder> SyncCookieHolder; @@ -189,8 +189,8 @@ class TTablet : public TActor<TTablet> { ui32 ConfirmedGCStep; bool PresentInList; - TLeaderInfo(EFollowerSyncState syncState = EFollowerSyncState::Pending) - : FollowerAttempt(Max<ui32>()) + TLeaderInfo(EFollowerSyncState syncState = EFollowerSyncState::Pending) + : FollowerAttempt(Max<ui32>()) , StreamCounter(0) , SyncState(syncState) , LastSyncAttempt(TInstant::Zero()) @@ -200,14 +200,14 @@ class TTablet : public TActor<TTablet> { {} }; - TMap<TActorId, TLeaderInfo> LeaderInfo; + TMap<TActorId, TLeaderInfo> LeaderInfo; TDeque<std::pair<ui32, TInstant>> WaitingForGcAck; // step, commitMoment - bool InitialFollowerSyncDone; + bool InitialFollowerSyncDone; const TActorId Launcher; TActorId UserTablet; TActorId StateStorageGuardian; - TActorId FollowerStStGuardian; + TActorId FollowerStStGuardian; TIntrusivePtr<TTabletStorageInfo> Info; TIntrusivePtr<TTabletSetupInfo> SetupInfo; ui32 SuggestedGeneration; @@ -216,14 +216,14 @@ class TTablet : public TActor<TTablet> { THolder<NTabletPipe::IConnectAcceptor> PipeConnectAcceptor; TInstant BoostrapTime; TInstant ActivateTime; - bool Leader; - ui32 FollowerId; + bool Leader; + ui32 FollowerId; ui32 DiscoveredLastBlocked; ui32 GcInFly; ui32 GcInFlyStep; ui32 GcNextStep; - TResourceProfilesPtr ResourceProfiles; - TSharedQuotaPtr TxCacheQuota; + TResourceProfilesPtr ResourceProfiles; + TSharedQuotaPtr TxCacheQuota; THolder<NTracing::ITrace> IntrospectionTrace; TActorId RebuildGraphRequest; @@ -262,16 +262,16 @@ class TTablet : public TActor<TTablet> { void StartActivePhase(); void UpdateStateStorageSignature(TEvStateStorage::TEvUpdateSignature::TPtr &ev); - void TryFinishFollowerSync(); + void TryFinishFollowerSync(); void TryPumpWaitingForGc(); void HandlePingBoot(TEvTablet::TEvPing::TPtr &ev); - void HandlePingFollower(TEvTablet::TEvPing::TPtr &ev); + void HandlePingFollower(TEvTablet::TEvPing::TPtr &ev); void HandleStateStorageInfoResolve(TEvStateStorage::TEvInfo::TPtr &ev); - void HandleStateStorageLeaderResolve(TEvStateStorage::TEvInfo::TPtr &ev); - void HandleFollowerRetry(TEvTabletBase::TEvFollowerRetry::TPtr &ev); - void HandleByFollower(TEvTabletBase::TEvTryBuildFollowerGraph::TPtr &ev); - void HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev); + void HandleStateStorageLeaderResolve(TEvStateStorage::TEvInfo::TPtr &ev); + void HandleFollowerRetry(TEvTabletBase::TEvFollowerRetry::TPtr &ev); + void HandleByFollower(TEvTabletBase::TEvTryBuildFollowerGraph::TPtr &ev); + void HandleByFollower(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev); void HandleStateStorageInfoLock(TEvStateStorage::TEvInfo::TPtr &ev); @@ -279,33 +279,33 @@ class TTablet : public TActor<TTablet> { void HandleFindLatestLogEntry(TEvTabletBase::TEvFindLatestLogEntryResult::TPtr &ev); void HandleBlockBlobStorageResult(TEvTabletBase::TEvBlockBlobStorageResult::TPtr &ev); - void HandleByFollower(TEvTablet::TEvFollowerDisconnect::TPtr &ev); - void HandleByFollower(TEvTablet::TEvFollowerUpdate::TPtr &ev); - void HandleByFollower(TEvTablet::TEvFollowerAuxUpdate::TPtr &ev); - void HandleByFollower(TEvTablet::TEvFollowerRefresh::TPtr &ev); - void HandleByFollower(TEvInterconnect::TEvNodeDisconnected::TPtr &ev); - void HandleByFollower(TEvents::TEvUndelivered::TPtr &ev); - void HandleByFollower(TEvTablet::TEvPromoteToLeader::TPtr &ev); - void HandleByFollower(TEvTablet::TEvFGcAck::TPtr &ev); - void HandleByFollower(TEvTablet::TEvTabletActive::TPtr &ev); - void HandleByFollower(TEvTabletPipe::TEvConnect::TPtr &ev); - - void HandleByLeader(TEvTablet::TEvFollowerAttach::TPtr &ev); - void HandleByLeader(TEvTablet::TEvFollowerDetach::TPtr &ev); - void HandleByLeader(TEvTablet::TEvFollowerRefresh::TPtr &ev); - void HandleByLeader(TEvTablet::TEvFollowerListRefresh::TPtr &ev); - void HandleByLeader(TEvTabletBase::TEvTrySyncFollower::TPtr &ev); - void HandleByLeader(TEvTablet::TEvFollowerGcAck::TPtr &ev); - void HandleByLeader(TEvInterconnect::TEvNodeDisconnected::TPtr &ev); - void HandleByLeader(TEvents::TEvUndelivered::TPtr &ev); + void HandleByFollower(TEvTablet::TEvFollowerDisconnect::TPtr &ev); + void HandleByFollower(TEvTablet::TEvFollowerUpdate::TPtr &ev); + void HandleByFollower(TEvTablet::TEvFollowerAuxUpdate::TPtr &ev); + void HandleByFollower(TEvTablet::TEvFollowerRefresh::TPtr &ev); + void HandleByFollower(TEvInterconnect::TEvNodeDisconnected::TPtr &ev); + void HandleByFollower(TEvents::TEvUndelivered::TPtr &ev); + void HandleByFollower(TEvTablet::TEvPromoteToLeader::TPtr &ev); + void HandleByFollower(TEvTablet::TEvFGcAck::TPtr &ev); + void HandleByFollower(TEvTablet::TEvTabletActive::TPtr &ev); + void HandleByFollower(TEvTabletPipe::TEvConnect::TPtr &ev); + + void HandleByLeader(TEvTablet::TEvFollowerAttach::TPtr &ev); + void HandleByLeader(TEvTablet::TEvFollowerDetach::TPtr &ev); + void HandleByLeader(TEvTablet::TEvFollowerRefresh::TPtr &ev); + void HandleByLeader(TEvTablet::TEvFollowerListRefresh::TPtr &ev); + void HandleByLeader(TEvTabletBase::TEvTrySyncFollower::TPtr &ev); + void HandleByLeader(TEvTablet::TEvFollowerGcAck::TPtr &ev); + void HandleByLeader(TEvInterconnect::TEvNodeDisconnected::TPtr &ev); + void HandleByLeader(TEvents::TEvUndelivered::TPtr &ev); void HandleRebuildGraphResult(TEvTabletBase::TEvRebuildGraphResult::TPtr &ev); void HandleWriteZeroEntry(TEvTabletBase::TEvWriteLogResult::TPtr &ev); void Handle(TEvTablet::TEvPing::TPtr &ev); - void HandleByLeader(TEvTablet::TEvTabletActive::TPtr &ev); + void HandleByLeader(TEvTablet::TEvTabletActive::TPtr &ev); - bool CheckFollowerUpdate(const TActorId &actorId, ui32 attempt, ui64 counter); + bool CheckFollowerUpdate(const TActorId &actorId, ui32 attempt, ui64 counter); TLogEntry* MakeLogEntry(TEvTablet::TCommitInfo &commitInfo, NKikimrTabletBase::TTabletLogEntry *commitEv); TLogEntry* FindLogEntry(TEvTablet::TCommitInfo &commitInfo, NKikimrTabletBase::TTabletLogEntry &commitEv); @@ -319,18 +319,18 @@ class TTablet : public TActor<TTablet> { void CheckEntry(TGraph::TIndex::iterator it); // next funcs return next correct iterator - TMap<TActorId, TLeaderInfo>::iterator EraseFollowerInfo(TMap<TActorId, TLeaderInfo>::iterator followerIt); - TMap<TActorId, TLeaderInfo>::iterator HandleFollowerConnectionProblem(TMap<TActorId, TLeaderInfo>::iterator followerIt); + TMap<TActorId, TLeaderInfo>::iterator EraseFollowerInfo(TMap<TActorId, TLeaderInfo>::iterator followerIt); + TMap<TActorId, TLeaderInfo>::iterator HandleFollowerConnectionProblem(TMap<TActorId, TLeaderInfo>::iterator followerIt); - void TrySyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt); - void DoSyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt); + void TrySyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt); + void DoSyncToFollower(TMap<TActorId, TLeaderInfo>::iterator followerIt); void GcLogChannel(ui32 step); bool ProgressCommitQueue(); - void ProgressFollowerQueue(); - void SpreadFollowerAuxUpdate(const TString& auxUpdate); - void SendFollowerAuxUpdate(TLeaderInfo& info, const TActorId& follower, const TString& auxUpdate); + void ProgressFollowerQueue(); + void SpreadFollowerAuxUpdate(const TString& auxUpdate); + void SendFollowerAuxUpdate(TLeaderInfo& info, const TActorId& follower, const TString& auxUpdate); void Handle(TEvTabletPipe::TEvConnect::TPtr& ev); void Handle(TEvTabletPipe::TEvServerDestroyed::TPtr& ev); @@ -355,8 +355,8 @@ class TTablet : public TActor<TTablet> { void LockedInitializationPath(); void Bootstrap(); - void BootstrapFollower(); - void RetryFollowerBootstrapOrWait(); + void BootstrapFollower(); + void RetryFollowerBootstrapOrWait(); void SendIntrospectionData(); @@ -368,14 +368,14 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -388,14 +388,14 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -408,15 +408,15 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -429,15 +429,15 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -450,15 +450,15 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -471,15 +471,15 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -492,15 +492,15 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTabletPipe::TEvConnect, HandleQueued); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); } } @@ -509,27 +509,27 @@ class TTablet : public TActor<TTablet> { hFunc(TEvTablet::TEvCommit, Handle); hFunc(TEvTablet::TEvAux, Handle); hFunc(TEvTablet::TEvPreCommit, Handle); - hFunc(TEvTablet::TEvTabletActive, HandleByLeader); - hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); - hFunc(TEvTablet::TEvFollowerGcAck, HandleByLeader); - hFunc(TEvTablet::TEvFollowerListRefresh, HandleByLeader); + hFunc(TEvTablet::TEvTabletActive, HandleByLeader); + hFunc(TEvTablet::TEvFollowerAttach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerDetach, HandleByLeader); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByLeader); + hFunc(TEvTablet::TEvFollowerGcAck, HandleByLeader); + hFunc(TEvTablet::TEvFollowerListRefresh, HandleByLeader); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); + hFunc(TEvTabletBase::TEvTrySyncFollower, HandleByLeader); hFunc(TEvTabletBase::TEvWriteLogResult, Handle); hFunc(TEvStateStorage::TEvUpdateSignature, UpdateStateStorageSignature); hFunc(TEvTablet::TEvPing, Handle); hFunc(TEvTablet::TEvDemoted, Handle); - cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); + cFunc(TEvStateStorage::TEvReplicaLeaderDemoted::EventType, HandleDemoted); hFunc(TEvTablet::TEvFeatures, HandleFeatures); hFunc(TEvTablet::TEvTabletStop, HandleStop); cFunc(TEvTablet::TEvTabletStopped::EventType, HandleStopped); cFunc(TEvents::TSystem::PoisonPill, HandlePoisonPill); hFunc(TEvTabletPipe::TEvConnect, Handle); hFunc(TEvTabletPipe::TEvServerDestroyed, Handle); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); - hFunc(TEvents::TEvUndelivered, HandleByLeader); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByLeader); + hFunc(TEvents::TEvUndelivered, HandleByLeader); hFunc(TEvBlobStorage::TEvCollectGarbageResult, Handle); } } @@ -542,24 +542,24 @@ class TTablet : public TActor<TTablet> { } } - STATEFN(StateBootstrapFollower) { + STATEFN(StateBootstrapFollower) { switch (ev->GetTypeRewrite()) { - cFunc(TEvents::TEvBootstrap::EventType, BootstrapFollower); + cFunc(TEvents::TEvBootstrap::EventType, BootstrapFollower); default: Y_FAIL(); } } - STATEFN(StateResolveLeader) { + STATEFN(StateResolveLeader) { switch (ev->GetTypeRewrite()) { - hFunc(TEvTablet::TEvPromoteToLeader, HandleByFollower); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByFollower); - hFunc(TEvTablet::TEvTabletActive, HandleByFollower); + hFunc(TEvTablet::TEvPromoteToLeader, HandleByFollower); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByFollower); + hFunc(TEvTablet::TEvTabletActive, HandleByFollower); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvStateStorage::TEvInfo, HandleStateStorageLeaderResolve); - hFunc(TEvTabletBase::TEvFollowerRetry, HandleFollowerRetry); - hFunc(TEvTabletBase::TEvTryBuildFollowerGraph, HandleByFollower); - hFunc(TEvTabletBase::TEvRebuildGraphResult, HandleByFollower); + hFunc(TEvStateStorage::TEvInfo, HandleStateStorageLeaderResolve); + hFunc(TEvTabletBase::TEvFollowerRetry, HandleFollowerRetry); + hFunc(TEvTabletBase::TEvTryBuildFollowerGraph, HandleByFollower); + hFunc(TEvTabletBase::TEvRebuildGraphResult, HandleByFollower); hFunc(TEvTabletPipe::TEvConnect, Handle); hFunc(TEvTabletPipe::TEvServerDestroyed, Handle); hFunc(TEvTablet::TEvFeatures, HandleFeatures); @@ -569,21 +569,21 @@ class TTablet : public TActor<TTablet> { } } - STATEFN(StateFollowerSubscribe) { + STATEFN(StateFollowerSubscribe) { switch (ev->GetTypeRewrite()) { - hFunc(TEvTablet::TEvPromoteToLeader, HandleByFollower); - hFunc(TEvTablet::TEvFollowerDisconnect, HandleByFollower); - hFunc(TEvTablet::TEvFollowerUpdate, HandleByFollower); - hFunc(TEvTablet::TEvFollowerAuxUpdate, HandleByFollower); - hFunc(TEvTablet::TEvFollowerRefresh, HandleByFollower); - hFunc(TEvTablet::TEvFGcAck, HandleByFollower); - hFunc(TEvTablet::TEvTabletActive, HandleByFollower); + hFunc(TEvTablet::TEvPromoteToLeader, HandleByFollower); + hFunc(TEvTablet::TEvFollowerDisconnect, HandleByFollower); + hFunc(TEvTablet::TEvFollowerUpdate, HandleByFollower); + hFunc(TEvTablet::TEvFollowerAuxUpdate, HandleByFollower); + hFunc(TEvTablet::TEvFollowerRefresh, HandleByFollower); + hFunc(TEvTablet::TEvFGcAck, HandleByFollower); + hFunc(TEvTablet::TEvTabletActive, HandleByFollower); hFunc(TEvTablet::TEvUpdateConfig, Handle); - hFunc(TEvTabletBase::TEvTryBuildFollowerGraph, HandleByFollower); - hFunc(TEvTabletBase::TEvRebuildGraphResult, HandleByFollower); - hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByFollower); - hFunc(TEvents::TEvUndelivered, HandleByFollower); - hFunc(TEvTabletPipe::TEvConnect, HandleByFollower); + hFunc(TEvTabletBase::TEvTryBuildFollowerGraph, HandleByFollower); + hFunc(TEvTabletBase::TEvRebuildGraphResult, HandleByFollower); + hFunc(TEvInterconnect::TEvNodeDisconnected, HandleByFollower); + hFunc(TEvents::TEvUndelivered, HandleByFollower); + hFunc(TEvTabletPipe::TEvConnect, HandleByFollower); hFunc(TEvTabletPipe::TEvServerDestroyed, Handle); hFunc(TEvTablet::TEvFeatures, HandleFeatures); hFunc(TEvTablet::TEvTabletStop, HandleStop); @@ -601,11 +601,11 @@ public: const TActorId &launcher, TTabletStorageInfo *info, TTabletSetupInfo *setupInfo, - bool leader, - ui32 suggestedGeneration, // when leader == true - ui32 followerID, // when leader == false - TResourceProfilesPtr profiles = nullptr, - TSharedQuotaPtr txCacheQuota = nullptr + bool leader, + ui32 suggestedGeneration, // when leader == true + ui32 followerID, // when leader == false + TResourceProfilesPtr profiles = nullptr, + TSharedQuotaPtr txCacheQuota = nullptr ); TAutoPtr<IEventHandle> AfterRegister(const TActorId &self, const TActorId &parentId) override; diff --git a/ydb/core/tablet/tablet_tracing_signals.cpp b/ydb/core/tablet/tablet_tracing_signals.cpp index 3b6af225cb3..9d1923f822d 100644 --- a/ydb/core/tablet/tablet_tracing_signals.cpp +++ b/ydb/core/tablet/tablet_tracing_signals.cpp @@ -37,7 +37,7 @@ struct TSignalTypeRegistrator { Register<TOnTabletBlockBlobStorage>(NSignalTypes::TypeOnTabletBlockBlobStorage); Register<TOnTabletRebuildGraph>(NSignalTypes::TypeOnTabletRebuildGraph); Register<TOnWriteZeroEntry>(NSignalTypes::TypeOnWriteZeroEntry); - Register<TOnFollowerPromoteToLeader>(NSignalTypes::TypeOnFollowerPromoteToLeader); + Register<TOnFollowerPromoteToLeader>(NSignalTypes::TypeOnFollowerPromoteToLeader); Register<TRebuildGraphBootstrap>(NSignalTypes::TypeRebuildGraphBootstrap); Register<TErrorEntryBeyondBlocked>(NSignalTypes::TypeErrorEntryBeyondBlocked); Register<TErrorUnknownStatus>(NSignalTypes::TypeErrorUnknownStatus); @@ -65,9 +65,9 @@ private: // Singleton static TSignalTypeRegistrator SignalTypeRegistrator; -TOnTabletBootstrap::TOnTabletBootstrap(ui32 suggestedGeneration, bool leader, const TActorId& proxyID) { +TOnTabletBootstrap::TOnTabletBootstrap(ui32 suggestedGeneration, bool leader, const TActorId& proxyID) { PbSignal.SetSuggestedGeneration(suggestedGeneration); - PbSignal.SetLeader(leader); + PbSignal.SetLeader(leader); NActors::ActorIdToProto(proxyID, PbSignal.MutableStateStorageProxyID()); } @@ -239,27 +239,27 @@ void TOnWriteZeroEntry::OutText(TStringStream& str, TTimestampData& tsData, cons str << ", LastInGeneration=" << PbSignal.GetLastInGeneration() << ")" << Endl; } -TOnFollowerPromoteToLeader::TOnFollowerPromoteToLeader( +TOnFollowerPromoteToLeader::TOnFollowerPromoteToLeader( ui32 suggestedGeneration - , const TActorId& knownLeaderID - , const TActorId& followerStStGuardian + , const TActorId& knownLeaderID + , const TActorId& followerStStGuardian ) { PbSignal.SetSuggestedGeneration(suggestedGeneration); - NActors::ActorIdToProto(knownLeaderID, PbSignal.MutableKnownLeaderID()); - NActors::ActorIdToProto(followerStStGuardian, PbSignal.MutableFollowerStStGuardian()); + NActors::ActorIdToProto(knownLeaderID, PbSignal.MutableKnownLeaderID()); + NActors::ActorIdToProto(followerStStGuardian, PbSignal.MutableFollowerStStGuardian()); } -TOnFollowerPromoteToLeader::TOnFollowerPromoteToLeader(const TString& serializedSignal) +TOnFollowerPromoteToLeader::TOnFollowerPromoteToLeader(const TString& serializedSignal) : TMyBase(serializedSignal) {} -void TOnFollowerPromoteToLeader::OutText(TStringStream& str, TTimestampData& tsData, const TString& prefix) const { - TActorId knownLeaderId = NActors::ActorIdFromProto(PbSignal.GetKnownLeaderID()); - TActorId followerStStGuardianId = NActors::ActorIdFromProto(PbSignal.GetFollowerStStGuardian()); +void TOnFollowerPromoteToLeader::OutText(TStringStream& str, TTimestampData& tsData, const TString& prefix) const { + TActorId knownLeaderId = NActors::ActorIdFromProto(PbSignal.GetKnownLeaderID()); + TActorId followerStStGuardianId = NActors::ActorIdFromProto(PbSignal.GetFollowerStStGuardian()); str << prefix << TimeStamp(tsData) - << " Follower promoted to leader (SuggestedGeneration=" << PbSignal.GetSuggestedGeneration() - << ", KnownLeaderID=" << knownLeaderId.ToString() - << ", FollowerStStGuardian=" << followerStStGuardianId.ToString() << ")" << Endl; + << " Follower promoted to leader (SuggestedGeneration=" << PbSignal.GetSuggestedGeneration() + << ", KnownLeaderID=" << knownLeaderId.ToString() + << ", FollowerStStGuardian=" << followerStStGuardianId.ToString() << ")" << Endl; } TRebuildGraphBootstrap::TRebuildGraphBootstrap(ui32 blockedGen) { diff --git a/ydb/core/tablet/tablet_tracing_signals.h b/ydb/core/tablet/tablet_tracing_signals.h index e7afe922e2d..a8e73087e15 100644 --- a/ydb/core/tablet/tablet_tracing_signals.h +++ b/ydb/core/tablet/tablet_tracing_signals.h @@ -23,7 +23,7 @@ namespace NTracing { TypeOnTabletBlockBlobStorage, TypeOnTabletRebuildGraph, TypeOnWriteZeroEntry, - TypeOnFollowerPromoteToLeader, + TypeOnFollowerPromoteToLeader, TypeRebuildGraphBootstrap, TypeErrorEntryBeyondBlocked, TypeErrorUnknownStatus, @@ -46,7 +46,7 @@ namespace NTracing { NKikimrTracing::TOnTabletBootstrap, NSignalTypes::TypeOnTabletBootstrap> { public: - TOnTabletBootstrap(ui32 suggestedGeneration, bool leader, const TActorId& proxyID); + TOnTabletBootstrap(ui32 suggestedGeneration, bool leader, const TActorId& proxyID); TOnTabletBootstrap(const TString& serializedSignal); void OutText(TStringStream& str, TTimestampData& tsData, const TString& prefix) const override; }; @@ -134,16 +134,16 @@ namespace NTracing { void OutText(TStringStream& str, TTimestampData& tsData, const TString& prefix) const override; }; - class TOnFollowerPromoteToLeader : public TTraceSignal<TOnFollowerPromoteToLeader, - NKikimrTracing::TOnFollowerPromoteToLeader, - NSignalTypes::TypeOnFollowerPromoteToLeader> { + class TOnFollowerPromoteToLeader : public TTraceSignal<TOnFollowerPromoteToLeader, + NKikimrTracing::TOnFollowerPromoteToLeader, + NSignalTypes::TypeOnFollowerPromoteToLeader> { public: - TOnFollowerPromoteToLeader( + TOnFollowerPromoteToLeader( ui32 suggestedGeneration - , const TActorId& knownLeaderID - , const TActorId& followerStStGuardian + , const TActorId& knownLeaderID + , const TActorId& followerStStGuardian ); - TOnFollowerPromoteToLeader(const TString& serializedSignal); + TOnFollowerPromoteToLeader(const TString& serializedSignal); void OutText(TStringStream& str, TTimestampData& tsData, const TString& prefix) const override; }; diff --git a/ydb/core/tablet_flat/flat_bio_actor.cpp b/ydb/core/tablet_flat/flat_bio_actor.cpp index cb58e6d8c62..6a866fb3956 100644 --- a/ydb/core/tablet_flat/flat_bio_actor.cpp +++ b/ydb/core/tablet_flat/flat_bio_actor.cpp @@ -30,7 +30,7 @@ void TBlockIO::Registered(TActorSystem *sys, const TActorId&) Logger = new NUtil::TLogger(sys, NKikimrServices::SAUSAGE_BIO); } -void TBlockIO::Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) +void TBlockIO::Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (auto *ev = eh->CastAsLocal<TEvBlobStorage::TEvGetResult>()) { if (ev->Status != NKikimrProto::OK) @@ -54,7 +54,7 @@ void TBlockIO::Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) } } -void TBlockIO::Bootstrap(EPriority priority, TAutoPtr<NPageCollection::TFetch> origin) noexcept +void TBlockIO::Bootstrap(EPriority priority, TAutoPtr<NPageCollection::TFetch> origin) noexcept { Origin = origin; Priority = priority; diff --git a/ydb/core/tablet_flat/flat_bio_actor.h b/ydb/core/tablet_flat/flat_bio_actor.h index f3568e8f5e0..6de0926223a 100644 --- a/ydb/core/tablet_flat/flat_bio_actor.h +++ b/ydb/core/tablet_flat/flat_bio_actor.h @@ -10,7 +10,7 @@ namespace NTabletFlatExecutor { namespace NBlockIO { class TBlockIO : public ::NActors::IActor { - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; using EStatus = NKikimrProto::EReplyStatus; using TPagesToBlobsConverter = NPageCollection::TPagesToBlobsConverter<NPageCollection::IPageCollection>; @@ -23,8 +23,8 @@ namespace NBlockIO { private: void Registered(TActorSystem*, const TActorId&) override; - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx); - void Bootstrap(EPriority priority, TAutoPtr<NPageCollection::TFetch>) noexcept; + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx); + void Bootstrap(EPriority priority, TAutoPtr<NPageCollection::TFetch>) noexcept; void Dispatch() noexcept; void Handle(ui32 offset, TArrayRef<TLoaded>) noexcept; void Terminate(EStatus code) noexcept; @@ -32,13 +32,13 @@ namespace NBlockIO { private: const TActorId Service; const ui64 Cookie = Max<ui64>(); - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; /*_ immutable request settings */ TActorId Owner; EPriority Priority = EPriority::None; - TAutoPtr<NPageCollection::TFetch> Origin; + TAutoPtr<NPageCollection::TFetch> Origin; /*_ request operational state */ diff --git a/ydb/core/tablet_flat/flat_bio_events.h b/ydb/core/tablet_flat/flat_bio_events.h index c0a64b7128d..dae56ecca02 100644 --- a/ydb/core/tablet_flat/flat_bio_events.h +++ b/ydb/core/tablet_flat/flat_bio_events.h @@ -20,7 +20,7 @@ namespace NBlockIO { }; struct TEvFetch : public TEventLocal<TEvFetch, ui32(EEv::Fetch)> { - TEvFetch(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch) + TEvFetch(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch) : Priority(priority) , Fetch(fetch) { @@ -28,13 +28,13 @@ namespace NBlockIO { } const EPriority Priority = EPriority::None; - TAutoPtr<NPageCollection::TFetch> Fetch; + TAutoPtr<NPageCollection::TFetch> Fetch; }; struct TEvData: public TEventLocal<TEvData, ui32(EEv::Data)> { using EStatus = NKikimrProto::EReplyStatus; - TEvData(TIntrusiveConstPtr<NPageCollection::IPageCollection> origin, ui64 cookie, EStatus status) + TEvData(TIntrusiveConstPtr<NPageCollection::IPageCollection> origin, ui64 cookie, EStatus status) : Status(status) , Cookie(cookie) , Origin(origin) @@ -61,7 +61,7 @@ namespace NBlockIO { const EStatus Status; const ui64 Cookie = Max<ui64>(); - TIntrusiveConstPtr<NPageCollection::IPageCollection> Origin; + TIntrusiveConstPtr<NPageCollection::IPageCollection> Origin; TVector<NPageCollection::TLoadedPage> Blocks; }; diff --git a/ydb/core/tablet_flat/flat_boot_alter.h b/ydb/core/tablet_flat/flat_boot_alter.h index 8feed15b307..2b77a0ea768 100644 --- a/ydb/core/tablet_flat/flat_boot_alter.h +++ b/ydb/core/tablet_flat/flat_boot_alter.h @@ -34,7 +34,7 @@ namespace NBoot { Flush(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); @@ -62,7 +62,7 @@ namespace NBoot { } } - void Apply(const NPageCollection::TLargeGlobId &largeGlobId, TArrayRef<const char> body) noexcept + void Apply(const NPageCollection::TLargeGlobId &largeGlobId, TArrayRef<const char> body) noexcept { if (body) { TProtoBox<NTable::TSchemeChanges> alter(body); diff --git a/ydb/core/tablet_flat/flat_boot_back.h b/ydb/core/tablet_flat/flat_boot_back.h index ba44e6dae25..b97fc389676 100644 --- a/ydb/core/tablet_flat/flat_boot_back.h +++ b/ydb/core/tablet_flat/flat_boot_back.h @@ -60,8 +60,8 @@ namespace NBoot { }; struct TBack { - TBack(bool follower, ui64 tablet, ui32 generation) - : Follower(follower) + TBack(bool follower, ui64 tablet, ui32 generation) + : Follower(follower) , Tablet(tablet) , Generation(generation) { @@ -71,7 +71,7 @@ namespace NBoot { void Describe(IOutputStream &out) const noexcept { out - << (Follower ? "Follower" : "Leader") + << (Follower ? "Follower" : "Leader") << "{" << Tablet << ":" << Generation << ":-}"; } @@ -88,17 +88,17 @@ namespace NBoot { last.Head = Max(last.Head, epoch); } - const bool Follower = false; + const bool Follower = false; const ui64 Tablet = Max<ui64>(); const ui32 Generation = Max<ui32>(); ui64 Serial = 0; TAutoPtr<NBoot::TSteppedCookieAllocatorFactory> SteppedCookieAllocatorFactory; - TIntrusivePtr<NSnap::TWaste> Waste; - TAutoPtr<NTable::TScheme> Scheme; + TIntrusivePtr<NSnap::TWaste> Waste; + TAutoPtr<NTable::TScheme> Scheme; TAutoPtr<NTable::TDatabaseImpl> DatabaseImpl; - TAutoPtr<NRedo::TQueue> Redo; + TAutoPtr<NRedo::TQueue> Redo; NPageCollection::TLargeGlobId Snap; TDeque<TLogEntry> RedoLog; TDeque<TBody> GCELog; @@ -107,7 +107,7 @@ namespace NBoot { TDeque<TBody> TurnsLog; TDeque<TSwitch> Switches; THashMap<ui32, NTable::TSnapEdge> Edges; - THashMap<TLogoBlobID, TIntrusivePtr<TPrivatePageCache::TInfo>> PageCaches; + THashMap<TLogoBlobID, TIntrusivePtr<TPrivatePageCache::TInfo>> PageCaches; THashMap<TLogoBlobID, TSharedData> TxStatusCaches; }; diff --git a/ydb/core/tablet_flat/flat_boot_bundle.h b/ydb/core/tablet_flat/flat_boot_bundle.h index 542826d14d3..ecdec63649f 100644 --- a/ydb/core/tablet_flat/flat_boot_bundle.h +++ b/ydb/core/tablet_flat/flat_boot_bundle.h @@ -70,7 +70,7 @@ namespace NBoot { return msg.Status == NKikimrProto::OK; } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(LeftMetas); @@ -145,9 +145,9 @@ namespace NBoot { private: const ui32 Table = Max<ui32>(); - TAutoPtr<NTable::TLoader> Loader; + TAutoPtr<NTable::TLoader> Loader; TVector<NPageCollection::TLargeGlobId> LargeGlobIds; - TVector<TIntrusivePtr<TCache>> PageCollections; + TVector<TIntrusivePtr<TCache>> PageCollections; TString Legacy; TString Opaque; TVector<TString> Deltas; diff --git a/ydb/core/tablet_flat/flat_boot_env.h b/ydb/core/tablet_flat/flat_boot_env.h index a947fa8a67e..48adb0ac6d6 100644 --- a/ydb/core/tablet_flat/flat_boot_env.h +++ b/ydb/core/tablet_flat/flat_boot_env.h @@ -10,7 +10,7 @@ namespace NBoot { class TRoot : public IEnv, private IStep { public: - TRoot(TLogic *logic, TBack *state, TAutoPtr<NUtil::ILogger> logger) + TRoot(TLogic *logic, TBack *state, TAutoPtr<NUtil::ILogger> logger) : IStep(logic, state) , Logger_(logger) { @@ -19,7 +19,7 @@ namespace NBoot { ~TRoot() { - Y_VERIFY(RefCount() == 1, "Boot env shouldn't be deleted by TIntrusivePtr"); + Y_VERIFY(RefCount() == 1, "Boot env shouldn't be deleted by TIntrusivePtr"); } const NUtil::ILogger* Logger() const noexcept override @@ -59,7 +59,7 @@ namespace NBoot { } case EOp::Finish: { - TIntrusivePtr<IStep> owner = order.Step->Owner; + TIntrusivePtr<IStep> owner = order.Step->Owner; owner->HandleStep(std::move(order.Step)); break; @@ -71,7 +71,7 @@ namespace NBoot { protected: void Start() noexcept override { } - void Start(TIntrusivePtr<IStep> step) noexcept override + void Start(TIntrusivePtr<IStep> step) noexcept override { Y_VERIFY(step->Env == nullptr, "IStep is already fired"); Y_VERIFY(step->Owner, "Start called on step without an owner"); @@ -79,7 +79,7 @@ namespace NBoot { Queue.emplace_back(EOp::Start, std::move(step)); } - void Finish(TIntrusivePtr<IStep> step) noexcept override + void Finish(TIntrusivePtr<IStep> step) noexcept override { Y_VERIFY(step, "Finish called without a step"); Y_VERIFY(step->Owner, "Finish called on step without an owner"); @@ -94,7 +94,7 @@ namespace NBoot { }; struct TOrder { - TOrder(EOp op, TIntrusivePtr<IStep> step) + TOrder(EOp op, TIntrusivePtr<IStep> step) : Op(op) , Step(std::move(step)) { @@ -102,10 +102,10 @@ namespace NBoot { } const EOp Op; - TIntrusivePtr<IStep> Step; + TIntrusivePtr<IStep> Step; }; - TAutoPtr<NUtil::ILogger> Logger_; + TAutoPtr<NUtil::ILogger> Logger_; TDeque<TOrder> Queue; }; } diff --git a/ydb/core/tablet_flat/flat_boot_gclog.h b/ydb/core/tablet_flat/flat_boot_gclog.h index 793cc2c739e..ced4c722657 100644 --- a/ydb/core/tablet_flat/flat_boot_gclog.h +++ b/ydb/core/tablet_flat/flat_boot_gclog.h @@ -35,7 +35,7 @@ namespace NBoot { Flush(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); @@ -66,7 +66,7 @@ namespace NBoot { } } - void Apply(ui32 gen, ui32 step, TArrayRef<const char> body) noexcept + void Apply(ui32 gen, ui32 step, TArrayRef<const char> body) noexcept { TProtoBox<NKikimrExecutorFlat::TExternalGcEntry> proto(body); diff --git a/ydb/core/tablet_flat/flat_boot_iface.h b/ydb/core/tablet_flat/flat_boot_iface.h index 04921e2bdc2..14ecc59e21a 100644 --- a/ydb/core/tablet_flat/flat_boot_iface.h +++ b/ydb/core/tablet_flat/flat_boot_iface.h @@ -40,8 +40,8 @@ namespace NBoot { struct IEnv { virtual const NUtil::ILogger* Logger() const noexcept = 0; virtual void Describe(IOutputStream&) const noexcept = 0; - virtual void Start(TIntrusivePtr<IStep>) noexcept = 0; - virtual void Finish(TIntrusivePtr<IStep>) noexcept = 0; + virtual void Start(TIntrusivePtr<IStep>) noexcept = 0; + virtual void Finish(TIntrusivePtr<IStep>) noexcept = 0; }; class IStep : public TSimpleRefCount<IStep> { @@ -77,7 +77,7 @@ namespace NBoot { Y_FAIL("Boot IStep got an unhandled NSharedCache::TEvResult event"); } - virtual void HandleStep(TIntrusivePtr<IStep>) noexcept + virtual void HandleStep(TIntrusivePtr<IStep>) noexcept { Y_FAIL("Boot IStep got an unhandled child step result"); } @@ -112,7 +112,7 @@ namespace NBoot { protected: const EStep Kind__ = EStep::None; - const TIntrusivePtr<IStep> Owner; + const TIntrusivePtr<IStep> Owner; TLogic * const Logic = nullptr; TBack * const Back = nullptr; IEnv * const Env = nullptr; diff --git a/ydb/core/tablet_flat/flat_boot_loans.h b/ydb/core/tablet_flat/flat_boot_loans.h index 5ecebada435..d4a98224acc 100644 --- a/ydb/core/tablet_flat/flat_boot_loans.h +++ b/ydb/core/tablet_flat/flat_boot_loans.h @@ -35,7 +35,7 @@ namespace NBoot { Flush(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); @@ -63,7 +63,7 @@ namespace NBoot { } } - void Apply(const TLogoBlobID &label, TArrayRef<const char> body) noexcept + void Apply(const TLogoBlobID &label, TArrayRef<const char> body) noexcept { TProtoBox<NKikimrExecutorFlat::TBorrowedPart> proto(body); diff --git a/ydb/core/tablet_flat/flat_boot_oven.h b/ydb/core/tablet_flat/flat_boot_oven.h index c7247ccdeb2..3d3c7b402ac 100644 --- a/ydb/core/tablet_flat/flat_boot_oven.h +++ b/ydb/core/tablet_flat/flat_boot_oven.h @@ -48,7 +48,7 @@ namespace NBoot { /* Zero channel is reserved for system tablet activity */ } else if (group == NPageCollection::TLargeGlobId::InvalidGroup) { Y_Fail( - "Leader{" << Tablet << ":" << Gen << "} got reserved" + "Leader{" << Tablet << ":" << Gen << "} got reserved" << " InvalidGroup value for channel " << one.Channel); } else if (group == Max<ui32>()) { diff --git a/ydb/core/tablet_flat/flat_boot_redo.h b/ydb/core/tablet_flat/flat_boot_redo.h index 19883239d79..ec66bfac28e 100644 --- a/ydb/core/tablet_flat/flat_boot_redo.h +++ b/ydb/core/tablet_flat/flat_boot_redo.h @@ -46,7 +46,7 @@ namespace NBoot { Flush(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); diff --git a/ydb/core/tablet_flat/flat_boot_snap.h b/ydb/core/tablet_flat/flat_boot_snap.h index 846b542bdc0..0eae48284fa 100644 --- a/ydb/core/tablet_flat/flat_boot_snap.h +++ b/ydb/core/tablet_flat/flat_boot_snap.h @@ -23,7 +23,7 @@ namespace NBoot { using TTxStamp = NTable::TTxStamp; public: - TSnap(IStep *owner, TIntrusivePtr<TDependency> deps, TAutoPtr<TBody> snap) + TSnap(IStep *owner, TIntrusivePtr<TDependency> deps, TAutoPtr<TBody> snap) : IStep(owner, NBoot::EStep::Snap) , Codec(NBlockCodecs::Codec("lz4fast")) , Deps(std::move(deps)) @@ -48,7 +48,7 @@ namespace NBoot { } } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); @@ -56,7 +56,7 @@ namespace NBoot { } private: - void Apply(const NPageCollection::TLargeGlobId &snap, TArrayRef<const char> body) noexcept + void Apply(const NPageCollection::TLargeGlobId &snap, TArrayRef<const char> body) noexcept { if (EIdx::SnapLz4 == TCookie(snap.Lead.Cookie()).Index()) { Decode(snap, Codec->Decode(body)); @@ -67,7 +67,7 @@ namespace NBoot { ProcessSnap(snap), ProcessDeps(), Env->Finish(this); } - void Decode(const NPageCollection::TLargeGlobId &snap, TArrayRef<const char> body) noexcept + void Decode(const NPageCollection::TLargeGlobId &snap, TArrayRef<const char> body) noexcept { bool ok = ParseFromStringNoSizeLimit(Proto, body); Y_VERIFY(ok); @@ -294,7 +294,7 @@ namespace NBoot { void ProcessGcLogEntry(TDependency::TEntry &entry, bool snap) { - if (Back->Follower) // do nothing for followers + if (Back->Follower) // do nothing for followers return; if (auto logl = Env->Logger()->Log(ELnLev::Debug)) { @@ -354,8 +354,8 @@ namespace NBoot { private: const NBlockCodecs::ICodec *Codec = nullptr; TLeft Pending; - TIntrusivePtr<TDependency> Deps; - TAutoPtr<TBody> Snap; + TIntrusivePtr<TDependency> Deps; + TAutoPtr<TBody> Snap; NKikimrExecutorFlat::TLogSnapshot Proto; }; } diff --git a/ydb/core/tablet_flat/flat_boot_stages.h b/ydb/core/tablet_flat/flat_boot_stages.h index 4b162c7e686..8fde38a5e78 100644 --- a/ydb/core/tablet_flat/flat_boot_stages.h +++ b/ydb/core/tablet_flat/flat_boot_stages.h @@ -35,7 +35,7 @@ namespace NBoot { public: TStages() = delete; - TStages(IStep *owner, TIntrusivePtr<TDependency> deps, TAutoPtr<TBody> snap) + TStages(IStep *owner, TIntrusivePtr<TDependency> deps, TAutoPtr<TBody> snap) : IStep(owner, NBoot::EStep::Stages) , Deps(std::move(deps)) , Snap(std::move(snap)) @@ -49,7 +49,7 @@ namespace NBoot { Execute(); } - void HandleStep(TIntrusivePtr<IStep>) noexcept override + void HandleStep(TIntrusivePtr<IStep>) noexcept override { Pending -=1, Execute(); } @@ -116,7 +116,7 @@ namespace NBoot { Back->DatabaseImpl = new NTable::TDatabaseImpl(weak, Back->Scheme, &Back->Edges); - if (!Back->Follower) { + if (!Back->Follower) { Back->Redo = new NRedo::TQueue(std::move(Back->Edges)); } @@ -204,7 +204,7 @@ namespace NBoot { << " -> " << serial << "} snap on " << Back->Serial; } - if (!Back->Follower) { + if (!Back->Follower) { FinalizeLeaderLogics(result, *Back->SteppedCookieAllocatorFactory); } } @@ -214,8 +214,8 @@ namespace NBoot { private: EStage Next = EStage::Snap; /* Next stage to execute */ TLeft Pending; - TIntrusivePtr<TDependency> Deps; - TAutoPtr<TBody> Snap; + TIntrusivePtr<TDependency> Deps; + TAutoPtr<TBody> Snap; }; } } diff --git a/ydb/core/tablet_flat/flat_boot_turns.h b/ydb/core/tablet_flat/flat_boot_turns.h index 2e16e99b93b..7730e9cbb91 100644 --- a/ydb/core/tablet_flat/flat_boot_turns.h +++ b/ydb/core/tablet_flat/flat_boot_turns.h @@ -31,7 +31,7 @@ namespace NBoot { Flush(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); @@ -47,7 +47,7 @@ namespace NBoot { if (!Pending && Handled >= Back->Switches.size()) Env->Finish(this); } - void Assign(ui32 slot, TArrayRef<const char> body) noexcept + void Assign(ui32 slot, TArrayRef<const char> body) noexcept { Y_VERIFY(slot < Back->Switches.size(), "Invalid switch index"); @@ -63,7 +63,7 @@ namespace NBoot { } } - void Apply(TSwitch &entry, TArrayRef<const char> body) noexcept + void Apply(TSwitch &entry, TArrayRef<const char> body) noexcept { TProtoBox<NKikimrExecutorFlat::TTablePartSwitch> proto(body); diff --git a/ydb/core/tablet_flat/flat_boot_txstatus.h b/ydb/core/tablet_flat/flat_boot_txstatus.h index b3249e47feb..9df4153c79b 100644 --- a/ydb/core/tablet_flat/flat_boot_txstatus.h +++ b/ydb/core/tablet_flat/flat_boot_txstatus.h @@ -30,7 +30,7 @@ namespace NBoot { TryFinish(); } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(LeftBlobs); TSharedData data = load->PlainData(); diff --git a/ydb/core/tablet_flat/flat_boot_warm.h b/ydb/core/tablet_flat/flat_boot_warm.h index 8572c702b44..bca1ff0dd1c 100644 --- a/ydb/core/tablet_flat/flat_boot_warm.h +++ b/ydb/core/tablet_flat/flat_boot_warm.h @@ -48,7 +48,7 @@ namespace NBoot { } } - void HandleStep(TIntrusivePtr<IStep> step) noexcept override + void HandleStep(TIntrusivePtr<IStep> step) noexcept override { auto *load = step->ConsumeAs<TLoadBlobs>(Pending); diff --git a/ydb/core/tablet_flat/flat_comp.h b/ydb/core/tablet_flat/flat_comp.h index 4fe5180a372..2ee56626091 100644 --- a/ydb/core/tablet_flat/flat_comp.h +++ b/ydb/core/tablet_flat/flat_comp.h @@ -55,7 +55,7 @@ namespace NTable { TVector<TPartView> Parts; // Cold parts which are selected for compaction - TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; + TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; // New data will be added to cache if this flag is true bool KeepInCache = false; @@ -165,7 +165,7 @@ namespace NTable { /** * Returns row schema of the specified table */ - virtual TIntrusiveConstPtr<TRowScheme> RowScheme(ui32 table) = 0; + virtual TIntrusiveConstPtr<TRowScheme> RowScheme(ui32 table) = 0; /** * Returns schema of the specified table @@ -186,7 +186,7 @@ namespace NTable { * Returns a complete list of parts from the specified table */ virtual TVector<TPartView> TableParts(ui32 table) = 0; - virtual TVector<TIntrusiveConstPtr<TColdPart>> TableColdParts(ui32 table) = 0; + virtual TVector<TIntrusiveConstPtr<TColdPart>> TableColdParts(ui32 table) = 0; /** * Returns currently removed row versions @@ -283,10 +283,10 @@ namespace NTable { * may choose to compact some parts in addition to in-memory data, as * long as consistency guarantees are not broken. * - * When forcedCompactionId is non-zero it indicates the compaction was forced by the + * When forcedCompactionId is non-zero it indicates the compaction was forced by the * client and strategy is expected to eventually recompact everything - * up to the specified snapshot edge. forcedCompactionId must be - * monotonically growing. + * up to the specified snapshot edge. forcedCompactionId must be + * monotonically growing. * * Strategy is responsible to manage lifecycle of this compaction, * however backend may use the returned compaction id to detect when @@ -295,7 +295,7 @@ namespace NTable { virtual ui64 BeginMemCompaction( TTaskId taskId, TSnapEdge edge, - ui64 forcedCompactionId) = 0; + ui64 forcedCompactionId) = 0; /** * Called when backend needs to compact borrowed data @@ -304,10 +304,10 @@ namespace NTable { return false; } - virtual ui64 GetLastFinishedForcedCompactionId() const = 0; + virtual ui64 GetLastFinishedForcedCompactionId() const = 0; + + virtual TInstant GetLastFinishedForcedCompactionTs() const = 0; - virtual TInstant GetLastFinishedForcedCompactionTs() const = 0; - /** * Called after BeginCompaction completes successfully and replaces * the initial subset with compacted results. @@ -325,7 +325,7 @@ namespace NTable { * subparts with its existing subparts. */ virtual void PartMerged(TPartView part, ui32 level) = 0; - virtual void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) = 0; + virtual void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) = 0; /** * Called after some parts have been removed from the table diff --git a/ydb/core/tablet_flat/flat_comp_gen.cpp b/ydb/core/tablet_flat/flat_comp_gen.cpp index f45bbea2c4d..43bf95357bc 100644 --- a/ydb/core/tablet_flat/flat_comp_gen.cpp +++ b/ydb/core/tablet_flat/flat_comp_gen.cpp @@ -306,10 +306,10 @@ void TGenCompactionStrategy::Stop() { ForcedState = EForcedState::None; MaxOverloadFactor = 0.0; - CurrentForcedGenCompactionId = 0; - NextForcedGenCompactionId = 0; - FinishedForcedGenCompactionId = 0; - + CurrentForcedGenCompactionId = 0; + NextForcedGenCompactionId = 0; + FinishedForcedGenCompactionId = 0; + // Make it possible to Start again Generations.clear(); FinalState = { }; @@ -378,11 +378,11 @@ void TGenCompactionStrategy::UpdateCompactions() { } } -ui64 TGenCompactionStrategy::BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) { +ui64 TGenCompactionStrategy::BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) { Y_VERIFY(MemCompactionId == 0, "Unexpected concurrent mem compaction requests"); TExtraState extra; - if (forcedCompactionId == 0 && !Policy->Generations.empty() && ForcedState == EForcedState::None && edge.Head == TEpoch::Max()) { + if (forcedCompactionId == 0 && !Policy->Generations.empty() && ForcedState == EForcedState::None && edge.Head == TEpoch::Max()) { extra.InitFromPolicy(Policy->Generations[0]); } @@ -394,21 +394,21 @@ ui64 TGenCompactionStrategy::BeginMemCompaction(TTaskId taskId, TSnapEdge edge, extra); Y_VERIFY(MemCompactionId != 0); - if (forcedCompactionId != 0) { - if (!Generations.empty()) { - // We remember the last forced compaction we have started - ForcedMemCompactionId = MemCompactionId; - } - - switch (ForcedState) { - case EForcedState::None: - case EForcedState::Pending: - CurrentForcedGenCompactionId = forcedCompactionId; - break; - case EForcedState::Compacting: - NextForcedGenCompactionId = forcedCompactionId; - break; - } + if (forcedCompactionId != 0) { + if (!Generations.empty()) { + // We remember the last forced compaction we have started + ForcedMemCompactionId = MemCompactionId; + } + + switch (ForcedState) { + case EForcedState::None: + case EForcedState::Pending: + CurrentForcedGenCompactionId = forcedCompactionId; + break; + case EForcedState::Compacting: + NextForcedGenCompactionId = forcedCompactionId; + break; + } } return MemCompactionId; @@ -499,7 +499,7 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( } TVector<bool> checkNeeded(Generations.size()); - bool fullCompaction = false; + bool fullCompaction = false; if (generation < Generations.size()) { auto& nextGen = Generations[generation]; @@ -548,11 +548,11 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( Y_VERIFY(sourceIndex < Generations.size()); // During full compaction all other generations are idle - fullCompaction = (ForcedState == EForcedState::Compacting); + fullCompaction = (ForcedState == EForcedState::Compacting); while (sourceParts) { // Search back for the first generation that has non-empty parts - while (fullCompaction && sourceIndex > 0 && Generations[sourceIndex].Parts.empty()) { + while (fullCompaction && sourceIndex > 0 && Generations[sourceIndex].Parts.empty()) { --sourceIndex; } @@ -562,7 +562,7 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( auto& part = sourceGen.Parts.back(); Y_VERIFY(part.Label == sourcePart->Label, "Failed at gen=%u, sourceIndex=%u, full=%d, headTaken=%lu", - generation, sourceIndex, fullCompaction, sourceGen.TakenHeadParts); + generation, sourceIndex, fullCompaction, sourceGen.TakenHeadParts); Y_VERIFY(sourceGen.CompactingTailParts > 0); CachedGarbageBytes -= part.GarbageBytes; KnownParts.erase(part.Label); @@ -577,9 +577,9 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( Y_VERIFY(Generations[index].CompactingTailParts == 0); } - if (fullCompaction) { + if (fullCompaction) { ForcedState = EForcedState::None; - OnForcedGenCompactionDone(); + OnForcedGenCompactionDone(); // Will have to recheck all parent generations for (ui32 parent : xrange(1u, generation)) { @@ -681,23 +681,23 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( UpdateStats(); if (Generations) { - bool needUpdateOverload = false; + bool needUpdateOverload = false; if (ForcedState == EForcedState::None) { if (ForcedMemCompactionId && ForcedMemCompactionId != MemCompactionId) { // The forced memtable compaction has finished, start gen compaction ForcedState = EForcedState::Pending; ForcedMemCompactionId = 0; - needUpdateOverload = true; + needUpdateOverload = true; } else if (Stats.DroppedRowsPercent() >= Policy->DroppedRowsPercentToCompact && !Policy->KeepEraseMarkers) { // Table has too many dropped rows, compact everything ForcedState = EForcedState::Pending; - needUpdateOverload = true; + needUpdateOverload = true; } else if (CachedDroppedBytesPercent >= Policy->DroppedRowsPercentToCompact && !Policy->KeepEraseMarkers) { // Table has too much garbage, compact everything ForcedState = EForcedState::Pending; - needUpdateOverload = true; - } else if (CurrentForcedGenCompactionId) { - OnForcedGenCompactionDone(); + needUpdateOverload = true; + } else if (CurrentForcedGenCompactionId) { + OnForcedGenCompactionDone(); } } @@ -709,14 +709,14 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( CheckGeneration(index + 1); } } - - if (needUpdateOverload && Generations.size() > 1 && !checkNeeded[1]) { - // in case of forced compaction we must recalculate overload - // to decrease it and upper reject threshold - CheckOverload(1); - } - } else { - OnForcedGenCompactionDone(); + + if (needUpdateOverload && Generations.size() > 1 && !checkNeeded[1]) { + // in case of forced compaction we must recalculate overload + // to decrease it and upper reject threshold + CheckOverload(1); + } + } else { + OnForcedGenCompactionDone(); } UpdateOverload(); @@ -724,48 +724,48 @@ TCompactionChanges TGenCompactionStrategy::CompactionFinished( return changes; } -void TGenCompactionStrategy::OnForcedGenCompactionDone() { - if (CurrentForcedGenCompactionId) { - FinishedForcedGenCompactionId = CurrentForcedGenCompactionId; - FinishedForcedGenCompactionTs = Time->Now(); - CurrentForcedGenCompactionId = 0; - } - - if (NextForcedGenCompactionId) { - CurrentForcedGenCompactionId = NextForcedGenCompactionId; - NextForcedGenCompactionId = 0; - } - - CheckForcedGenCompactionNeeded(); -} - -void TGenCompactionStrategy::CheckForcedGenCompactionNeeded() { - // we already planned compaction - if (ForcedState != EForcedState::None || ForcedMemCompactionId) - return; - - if (CurrentForcedGenCompactionId <= FinishedForcedGenCompactionId) { - CurrentForcedGenCompactionId = 0; - return; - } - - // note that CurrentForcedGenCompactionId != 0, because of check above - if (!Generations) { - FinishedForcedGenCompactionId = CurrentForcedGenCompactionId; - FinishedForcedGenCompactionTs = Time->Now(); - CurrentForcedGenCompactionId = 0; - return; - } - - ForcedState = EForcedState::Pending; - CheckGeneration(Generations.size()); - if (Generations.size() > 1) { - // in case of forced compaction we must recalculate overload - // to decrease it and upper reject threshold - CheckOverload(1); - } -} - +void TGenCompactionStrategy::OnForcedGenCompactionDone() { + if (CurrentForcedGenCompactionId) { + FinishedForcedGenCompactionId = CurrentForcedGenCompactionId; + FinishedForcedGenCompactionTs = Time->Now(); + CurrentForcedGenCompactionId = 0; + } + + if (NextForcedGenCompactionId) { + CurrentForcedGenCompactionId = NextForcedGenCompactionId; + NextForcedGenCompactionId = 0; + } + + CheckForcedGenCompactionNeeded(); +} + +void TGenCompactionStrategy::CheckForcedGenCompactionNeeded() { + // we already planned compaction + if (ForcedState != EForcedState::None || ForcedMemCompactionId) + return; + + if (CurrentForcedGenCompactionId <= FinishedForcedGenCompactionId) { + CurrentForcedGenCompactionId = 0; + return; + } + + // note that CurrentForcedGenCompactionId != 0, because of check above + if (!Generations) { + FinishedForcedGenCompactionId = CurrentForcedGenCompactionId; + FinishedForcedGenCompactionTs = Time->Now(); + CurrentForcedGenCompactionId = 0; + return; + } + + ForcedState = EForcedState::Pending; + CheckGeneration(Generations.size()); + if (Generations.size() > 1) { + // in case of forced compaction we must recalculate overload + // to decrease it and upper reject threshold + CheckOverload(1); + } +} + void TGenCompactionStrategy::PartMerged(TPartView partView, ui32 level) { Y_VERIFY(level == 255, "Unexpected level of the merged part"); @@ -808,7 +808,7 @@ void TGenCompactionStrategy::PartMerged(TPartView partView, ui32 level) { } } -void TGenCompactionStrategy::PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) { +void TGenCompactionStrategy::PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) { Y_VERIFY(level == 255, "Unexpected level of the merged part"); const auto label = part->Label; @@ -988,7 +988,7 @@ void TGenCompactionStrategy::BeginGenCompaction(TTaskId taskId, ui32 generation) if (full) { // We just cancelled a forced compaction ForcedState = EForcedState::None; - CheckForcedGenCompactionNeeded(); + CheckForcedGenCompactionNeeded(); // Make sure to kickstart all generations for (ui32 index : xrange(Generations.size())) { @@ -1162,14 +1162,14 @@ void TGenCompactionStrategy::CheckOverload(ui32 generation) { }; // TODO: make lo and hi watermarks configurable - float loK = 1.5; - float hiK = 3; - if (generation == 1 && ShouldIncreaseOverloadWhatermarts()) { - loK *= 3; - hiK *= 3; - } - overloadFactor = Max(overloadFactor, mapToRange(genSize, genPolicy.ForceSizeToCompact*loK, genPolicy.ForceSizeToCompact*hiK)); - overloadFactor = Max(overloadFactor, mapToRange(genParts, genPolicy.ForceCountToCompact*loK, genPolicy.ForceCountToCompact*hiK)); + float loK = 1.5; + float hiK = 3; + if (generation == 1 && ShouldIncreaseOverloadWhatermarts()) { + loK *= 3; + hiK *= 3; + } + overloadFactor = Max(overloadFactor, mapToRange(genSize, genPolicy.ForceSizeToCompact*loK, genPolicy.ForceSizeToCompact*hiK)); + overloadFactor = Max(overloadFactor, mapToRange(genParts, genPolicy.ForceCountToCompact*loK, genPolicy.ForceCountToCompact*hiK)); gen.OverloadFactor = overloadFactor; } diff --git a/ydb/core/tablet_flat/flat_comp_gen.h b/ydb/core/tablet_flat/flat_comp_gen.h index 58e87449366..fc38fe705e7 100644 --- a/ydb/core/tablet_flat/flat_comp_gen.h +++ b/ydb/core/tablet_flat/flat_comp_gen.h @@ -37,16 +37,16 @@ namespace NCompGen { float GetOverloadFactor() override; ui64 GetBackingSize() override; ui64 GetBackingSize(ui64 ownerTabletId) override; - ui64 BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) override; + ui64 BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) override; bool ScheduleBorrowedCompaction() override; - ui64 GetLastFinishedForcedCompactionId() const override { return FinishedForcedGenCompactionId; } - TInstant GetLastFinishedForcedCompactionTs() const override { return FinishedForcedGenCompactionTs; } + ui64 GetLastFinishedForcedCompactionId() const override { return FinishedForcedGenCompactionId; } + TInstant GetLastFinishedForcedCompactionTs() const override { return FinishedForcedGenCompactionTs; } TCompactionChanges CompactionFinished( ui64 compactionId, THolder<TCompactionParams> params, THolder<TCompactionResult> result) override; void PartMerged(TPartView part, ui32 level) override; - void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) override; + void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) override; TCompactionChanges PartsRemoved(TArrayRef<const TLogoBlobID> parts) override; TCompactionState SnapshotState() override; TCompactionChanges ApplyChanges() override; @@ -212,9 +212,9 @@ namespace NCompGen { void BeginGenCompaction(TTaskId taskId, ui32 generation); - void OnForcedGenCompactionDone(); - void CheckForcedGenCompactionNeeded(); - + void OnForcedGenCompactionDone(); + void CheckForcedGenCompactionNeeded(); + ui32 ComputeBackgroundPriority( ui32 generation, const TCompactionPolicy::TGenerationPolicy& policy, @@ -248,10 +248,10 @@ namespace NCompGen { ForcedMemCompactionId == 0); } - bool ShouldIncreaseOverloadWhatermarts() const { - return ForcedState != EForcedState::None; - } - + bool ShouldIncreaseOverloadWhatermarts() const { + return ForcedState != EForcedState::None; + } + private: ui32 const Table; ICompactionBackend* const Backend; @@ -259,7 +259,7 @@ namespace NCompGen { ITimeProvider* const Time; const TString TaskNameSuffix; - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; ui64 MemCompactionId = 0; ui64 FinalCompactionId = 0; @@ -269,15 +269,15 @@ namespace NCompGen { ui64 ForcedMemCompactionId = 0; float MaxOverloadFactor = 0.0; - ui64 CurrentForcedGenCompactionId = 0; - ui64 NextForcedGenCompactionId = 0; - ui64 FinishedForcedGenCompactionId = 0; - TInstant FinishedForcedGenCompactionTs; - + ui64 CurrentForcedGenCompactionId = 0; + ui64 NextForcedGenCompactionId = 0; + ui64 FinishedForcedGenCompactionId = 0; + TInstant FinishedForcedGenCompactionTs; + TVector<TGeneration> Generations; TFinalState FinalState; TList<TPartInfo> FinalParts; - TList<TIntrusiveConstPtr<TColdPart>> ColdParts; + TList<TIntrusiveConstPtr<TColdPart>> ColdParts; THashMap<TLogoBlobID, ui32> KnownParts; TStats Stats; THashMap<ui64, TStats> StatsPerTablet; diff --git a/ydb/core/tablet_flat/flat_comp_shard.cpp b/ydb/core/tablet_flat/flat_comp_shard.cpp index 1adc1e081d2..a3a58f923e2 100644 --- a/ydb/core/tablet_flat/flat_comp_shard.cpp +++ b/ydb/core/tablet_flat/flat_comp_shard.cpp @@ -57,7 +57,7 @@ namespace NCompShard { const TTableInfo& Table; }; - TPartView MakePartView(TIntrusiveConstPtr<TPart> part, TIntrusiveConstPtr<TSlices> slices) noexcept { + TPartView MakePartView(TIntrusiveConstPtr<TPart> part, TIntrusiveConstPtr<TSlices> slices) noexcept { TPartView partView{ std::move(part), nullptr, std::move(slices) }; partView.Screen = partView.Slices->ToScreen(); // TODO: remove screen from TPartView return partView; @@ -507,7 +507,7 @@ namespace NCompShard { } bool TSliceSplitOp::Execute(IPages* env) { - const TIntrusiveConstPtr<TKeyNulls> nulls = Table->RowScheme->Keys; + const TIntrusiveConstPtr<TKeyNulls> nulls = Table->RowScheme->Keys; TVector<TCell> keyCellsBuffer(nulls->Size()); auto getKeyCells = [this, &nulls, &keyCellsBuffer](ui64 keyId) { @@ -688,7 +688,7 @@ namespace NCompShard { } THolder<TUnderlayMask> TUnderlayMask::Build( - TIntrusiveConstPtr<TRowScheme> rowScheme, + TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*>& input) noexcept { const TKeyNulls& nulls = *rowScheme->Keys; @@ -758,7 +758,7 @@ namespace NCompShard { return MakeHolder<TUnderlayMask>(std::move(rowScheme), std::move(results)); } - TSplitKeys::TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TSplitKeys::TKeysVec keys) + TSplitKeys::TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TSplitKeys::TKeysVec keys) : RowScheme(std::move(rowScheme)) , Keys(std::move(keys)) { @@ -766,7 +766,7 @@ namespace NCompShard { Reset(); } - TSplitKeys::TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*> bounds) + TSplitKeys::TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*> bounds) : RowScheme(std::move(rowScheme)) { auto boundsLess = [this](const TBounds* a, const TBounds* b) noexcept -> bool { @@ -1028,7 +1028,7 @@ namespace NCompShard { return AllBackingSize; } - ui64 TShardedCompactionStrategy::BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) { + ui64 TShardedCompactionStrategy::BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) { auto params = MakeHolder<TShardedCompactionParams>(); params->Table = Table; params->TaskId = taskId; @@ -1036,7 +1036,7 @@ namespace NCompShard { params->KeepInCache = true; NurseryTaken = 0; - if (edge.Head == TEpoch::Max() && Nursery && forcedCompactionId == 0) { + if (edge.Head == TEpoch::Max() && Nursery && forcedCompactionId == 0) { ui64 expectedSize = Backend->TableMemSize(Table, edge.Head); if (expectedSize > 0) { bool takeAll = ( @@ -1090,7 +1090,7 @@ namespace NCompShard { } MemCompactionId = Backend->BeginCompaction(std::move(params)); - MemCompactionForced = forcedCompactionId != 0; + MemCompactionForced = forcedCompactionId != 0; return MemCompactionId; } @@ -1291,7 +1291,7 @@ namespace NCompShard { AddParts(std::move(parts)); } - void TShardedCompactionStrategy::PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) { + void TShardedCompactionStrategy::PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) { Y_VERIFY(level == 255, "Unexpected level of the merged part"); ColdParts.emplace_back(std::move(part)); @@ -1431,7 +1431,7 @@ namespace NCompShard { right->RightKey = shard->RightKey; for (auto& kvPart : shard->Parts) { - TIntrusiveConstPtr<TPart> part = kvPart.second.Part; + TIntrusiveConstPtr<TPart> part = kvPart.second.Part; TVector<TSlice> slices(Reserve(kvPart.second.Slices.size())); for (auto& kvSlice : kvPart.second.Slices) { slices.emplace_back(kvSlice.second.Slice); @@ -1584,7 +1584,7 @@ namespace NCompShard { next = (shard != last) ? shard->Next()->Node() : nullptr; for (auto& kvPart : shard->Parts) { - TIntrusiveConstPtr<TPart> part = kvPart.second.Part; + TIntrusiveConstPtr<TPart> part = kvPart.second.Part; TVector<TSlice> slices(Reserve(kvPart.second.Slices.size())); for (auto& kvSlice : kvPart.second.Slices) { slices.emplace_back(kvSlice.second.Slice); @@ -1757,10 +1757,10 @@ namespace NCompShard { // A part/slice combination we scheduled to add struct TItem { - TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TPart> Part; TSlice Slice; - TItem(TIntrusiveConstPtr<TPart> part, TSlice slice) + TItem(TIntrusiveConstPtr<TPart> part, TSlice slice) : Part(std::move(part)) , Slice(std::move(slice)) { } @@ -1799,11 +1799,11 @@ namespace NCompShard { // A part/slice combination that crosses at least one shard boundary struct TSplitItem { - TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TPart> Part; TSlice Slice; TVector<TTableShard*> Shards; - TSplitItem(TIntrusiveConstPtr<TPart> part, TSlice slice, TTableShard* firstShard) + TSplitItem(TIntrusiveConstPtr<TPart> part, TSlice slice, TTableShard* firstShard) : Part(std::move(part)) , Slice(std::move(slice)) { @@ -2048,8 +2048,8 @@ namespace NCompShard { } TShardedCompactionStrategy::TGlobalPart* TShardedCompactionStrategy::EnsureGlobalPart( - const TIntrusiveConstPtr<TPart>& part, - const TIntrusiveConstPtr<TSlices>& slices) noexcept + const TIntrusiveConstPtr<TPart>& part, + const TIntrusiveConstPtr<TSlices>& slices) noexcept { auto* allInfo = AllParts.FindPtr(part->Label); if (!allInfo) { @@ -2118,7 +2118,7 @@ namespace NCompShard { } } - TTablePart* TShardedCompactionStrategy::EnsurePart(TTableShard* shard, TIntrusiveConstPtr<TPart> part) noexcept { + TTablePart* TShardedCompactionStrategy::EnsurePart(TTableShard* shard, TIntrusiveConstPtr<TPart> part) noexcept { auto* info = shard->Parts.FindPtr(part->Label); if (!info) { AllParts.at(part->Label).Shards.emplace_back(shard); @@ -2432,10 +2432,10 @@ namespace NCompShard { params->InputShard = shard; struct TInput { - TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TPart> Part; TVector<TSlice> Slices; TVector<TSlice> Reused; - TIntrusiveConstPtr<TSlices> ReusedRef; + TIntrusiveConstPtr<TSlices> ReusedRef; }; TEpoch maxEpoch = TEpoch::Min(); @@ -2498,16 +2498,16 @@ namespace NCompShard { std::sort(input.Slices.begin(), input.Slices.end(), [](const TSlice& a, const TSlice& b) noexcept -> bool { return a.BeginRowId() < b.BeginRowId(); }); - TIntrusiveConstPtr<TSlices> original = new TSlices(std::move(input.Slices)); - TIntrusiveConstPtr<TSlices> reused = new TSlices(std::move(input.Reused)); - TIntrusiveConstPtr<TSlices> compacted = TSlices::Subtract(original, reused); + TIntrusiveConstPtr<TSlices> original = new TSlices(std::move(input.Slices)); + TIntrusiveConstPtr<TSlices> reused = new TSlices(std::move(input.Reused)); + TIntrusiveConstPtr<TSlices> compacted = TSlices::Subtract(original, reused); // Everything we're compacting will become garbage soon if (reused && !reused->empty() && compacted && !compacted->empty()) { auto* allInfo = AllParts.FindPtr(input.Part->Label); Y_VERIFY(allInfo, "Reused part %s is not registered", input.Part->Label.ToString().c_str()); - TIntrusiveConstPtr<TSlices> afterCompaction = TSlices::Subtract(allInfo->Slices, compacted); + TIntrusiveConstPtr<TSlices> afterCompaction = TSlices::Subtract(allInfo->Slices, compacted); // Calculate how much garbage this part would have after compaction TRowId last = 0; diff --git a/ydb/core/tablet_flat/flat_comp_shard.h b/ydb/core/tablet_flat/flat_comp_shard.h index bd6d24c882b..e3024521346 100644 --- a/ydb/core/tablet_flat/flat_comp_shard.h +++ b/ydb/core/tablet_flat/flat_comp_shard.h @@ -280,7 +280,7 @@ namespace NCompShard { */ struct TTableInfo { // Current row scheme of the table, updated on schema changes - TIntrusiveConstPtr<TRowScheme> RowScheme; + TIntrusiveConstPtr<TRowScheme> RowScheme; // Current known shard keys, changed on split/merge THashMap<ui64, TSerializedCellVec> SplitKeys; @@ -333,7 +333,7 @@ namespace NCompShard { }; // Reference to the part - TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TPart> Part; // A sorted run of used slices TMap<TSliceId, TItem> Slices; @@ -388,7 +388,7 @@ namespace NCompShard { * A result of a split of a single slice over a number of shards */ struct TSliceSplitResult { - TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TPart> Part; TSlice OldSlice; TVector<TSlice> NewSlices; TVector<TTableShard*> Shards; @@ -422,7 +422,7 @@ namespace NCompShard { ISliceSplitResultConsumer* consumer, const TTableInfo* table, TVector<TTableShard*> shards, - TIntrusiveConstPtr<TPart> part, + TIntrusiveConstPtr<TPart> part, TSlice slice) : Consumer(consumer) , Table(table) @@ -454,7 +454,7 @@ namespace NCompShard { ISliceSplitResultConsumer* const Consumer; const TTableInfo* const Table; const TVector<TTableShard*> Shards; - const TIntrusiveConstPtr<TPart> Part; + const TIntrusiveConstPtr<TPart> Part; const TSlice Slice; private: @@ -463,7 +463,7 @@ namespace NCompShard { class TUnderlayMask final : public NPage::IKeySpace { public: - TUnderlayMask(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<TBounds> bounds) + TUnderlayMask(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<TBounds> bounds) : RowScheme(std::move(rowScheme)) , Bounds(std::move(bounds)) { @@ -483,7 +483,7 @@ namespace NCompShard { public: static THolder<TUnderlayMask> Build( - TIntrusiveConstPtr<TRowScheme> rowScheme, + TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*>& input) noexcept; private: @@ -491,7 +491,7 @@ namespace NCompShard { bool ValidatePosition(TCellsRef key) const noexcept; private: - TIntrusiveConstPtr<TRowScheme> RowScheme; + TIntrusiveConstPtr<TRowScheme> RowScheme; TVector<TBounds> Bounds; TVector<TBounds>::const_iterator Position; }; @@ -500,8 +500,8 @@ namespace NCompShard { public: using TKeysVec = TVector<TSerializedCellVec>; - TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TKeysVec keys); - TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*> bounds); + TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TKeysVec keys); + TSplitKeys(TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*> bounds); const TKeysVec& GetKeys() const { return Keys; @@ -519,7 +519,7 @@ namespace NCompShard { bool IsInclusive(TKeysVec::const_iterator pos) const noexcept; private: - TIntrusiveConstPtr<TRowScheme> RowScheme; + TIntrusiveConstPtr<TRowScheme> RowScheme; TKeysVec Keys; TKeysVec::const_iterator Position; TVector<bool> Inclusive; @@ -563,15 +563,15 @@ namespace NCompShard { float GetOverloadFactor() override; ui64 GetBackingSize() override; ui64 GetBackingSize(ui64 ownerTabletId) override; - ui64 BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) override; - ui64 GetLastFinishedForcedCompactionId() const override { return 0; } // TODO! - TInstant GetLastFinishedForcedCompactionTs() const override { return TInstant::Zero(); } // TODO! + ui64 BeginMemCompaction(TTaskId taskId, TSnapEdge edge, ui64 forcedCompactionId) override; + ui64 GetLastFinishedForcedCompactionId() const override { return 0; } // TODO! + TInstant GetLastFinishedForcedCompactionTs() const override { return TInstant::Zero(); } // TODO! TCompactionChanges CompactionFinished( ui64 compactionId, THolder<TCompactionParams> params, THolder<TCompactionResult> result) override; void PartMerged(TPartView part, ui32 level) override; - void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) override; + void PartMerged(TIntrusiveConstPtr<TColdPart> part, ui32 level) override; TCompactionChanges PartsRemoved(TArrayRef<const TLogoBlobID> parts) override; TCompactionChanges ApplyChanges() override; TCompactionState SnapshotState() override; @@ -602,7 +602,7 @@ namespace NCompShard { /** * Returns existing or creates a new TTablePart for the specified part */ - TTablePart* EnsurePart(TTableShard* shard, TIntrusiveConstPtr<TPart> part) noexcept; + TTablePart* EnsurePart(TTableShard* shard, TIntrusiveConstPtr<TPart> part) noexcept; /** * Reinitializes dynamic levels and related structures @@ -646,15 +646,15 @@ namespace NCompShard { }; struct TGlobalPart { - TIntrusiveConstPtr<TPart> Part; - TIntrusiveConstPtr<TSlices> Slices; + TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TSlices> Slices; TVector<TTableShard*> Shards; ui64 TotalSize = 0; ui64 GarbageSize = 0; size_t SplitBlocks = 0; }; - TGlobalPart* EnsureGlobalPart(const TIntrusiveConstPtr<TPart>& part, const TIntrusiveConstPtr<TSlices>& slices) noexcept; + TGlobalPart* EnsureGlobalPart(const TIntrusiveConstPtr<TPart>& part, const TIntrusiveConstPtr<TSlices>& slices) noexcept; void UpdateGarbageStats(TGlobalPart* allInfo) noexcept; private: @@ -666,14 +666,14 @@ namespace NCompShard { const TString TaskNameSuffix; TTableInfo TableInfo; - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; TIntrusiveListWithAutoDelete<TTableShard, TDelete> Shards; TIntrusiveList<TSliceSplitOp> PendingSliceSplits; TVector<TSliceSplitResult> SliceSplitResults; THashMap<TLogoBlobID, TGlobalPart> AllParts; // does not include nursery ui64 AllBackingSize = 0; - TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; + TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; ui64 MemCompactionId = 0; bool MemCompactionForced = false; diff --git a/ydb/core/tablet_flat/flat_database.cpp b/ydb/core/tablet_flat/flat_database.cpp index 156e56fb8ea..c4591195155 100644 --- a/ydb/core/tablet_flat/flat_database.cpp +++ b/ydb/core/tablet_flat/flat_database.cpp @@ -35,12 +35,12 @@ const TScheme& TDatabase::GetScheme() const noexcept return *DatabaseImpl->Scheme; } -TIntrusiveConstPtr<TRowScheme> TDatabase::GetRowScheme(ui32 table) const noexcept +TIntrusiveConstPtr<TRowScheme> TDatabase::GetRowScheme(ui32 table) const noexcept { return Require(table)->GetScheme(); } -TAutoPtr<TTableIt> TDatabase::Iterate(ui32 table, TRawVals key, TTagsRef tags, ELookup mode) const noexcept +TAutoPtr<TTableIt> TDatabase::Iterate(ui32 table, TRawVals key, TTagsRef tags, ELookup mode) const noexcept { Y_VERIFY(!NoMoreReadsFlag, "Trying to read after reads prohibited, table %u", table); @@ -72,7 +72,7 @@ TAutoPtr<TTableIt> TDatabase::Iterate(ui32 table, TRawVals key, TTagsRef tags, E return Require(table)->Iterate(key, tags, Env, seekBy(key, mode), TRowVersion::Max()); } -TAutoPtr<TTableIt> TDatabase::IterateExact(ui32 table, TRawVals key, TTagsRef tags, TRowVersion snapshot) const noexcept +TAutoPtr<TTableIt> TDatabase::IterateExact(ui32 table, TRawVals key, TTagsRef tags, TRowVersion snapshot) const noexcept { Y_VERIFY(!NoMoreReadsFlag, "Trying to read after reads prohibited, table %u", table); @@ -85,7 +85,7 @@ TAutoPtr<TTableIt> TDatabase::IterateExact(ui32 table, TRawVals key, TTagsRef ta return iter; } -TAutoPtr<TTableIt> TDatabase::IterateRange(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept +TAutoPtr<TTableIt> TDatabase::IterateRange(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept { Y_VERIFY(!NoMoreReadsFlag, "Trying to read after reads prohibited, table %u", table); @@ -108,7 +108,7 @@ TAutoPtr<TTableIt> TDatabase::IterateRange(ui32 table, const TKeyRange& range, T return iter; } -TAutoPtr<TTableReverseIt> TDatabase::IterateRangeReverse(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept +TAutoPtr<TTableReverseIt> TDatabase::IterateRangeReverse(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept { Y_VERIFY(!NoMoreReadsFlag, "Trying to read after reads prohibited, table %u", table); @@ -132,13 +132,13 @@ TAutoPtr<TTableReverseIt> TDatabase::IterateRangeReverse(ui32 table, const TKeyR } template<> -TAutoPtr<TTableIt> TDatabase::IterateRangeGeneric<TTableIt>(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept +TAutoPtr<TTableIt> TDatabase::IterateRangeGeneric<TTableIt>(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept { return IterateRange(table, range, tags, snapshot); } template<> -TAutoPtr<TTableReverseIt> TDatabase::IterateRangeGeneric<TTableReverseIt>(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept +TAutoPtr<TTableReverseIt> TDatabase::IterateRangeGeneric<TTableReverseIt>(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot) const noexcept { return IterateRangeReverse(table, range, tags, snapshot); } @@ -254,7 +254,7 @@ TVector<TPartView> TDatabase::GetTableParts(ui32 tableId) const { return Require(tableId)->GetAllParts(); } -TVector<TIntrusiveConstPtr<TColdPart>> TDatabase::GetTableColdParts(ui32 tableId) const { +TVector<TIntrusiveConstPtr<TColdPart>> TDatabase::GetTableColdParts(ui32 tableId) const { return Require(tableId)->GetColdParts(); } @@ -262,15 +262,15 @@ void TDatabase::EnumerateTableParts(ui32 tableId, const std::function<void(const Require(tableId)->EnumerateParts(std::move(callback)); } -void TDatabase::EnumerateTableColdParts(ui32 tableId, const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const { +void TDatabase::EnumerateTableColdParts(ui32 tableId, const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const { Require(tableId)->EnumerateColdParts(callback); } -void TDatabase::EnumerateTableTxStatusParts(ui32 tableId, const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const { +void TDatabase::EnumerateTableTxStatusParts(ui32 tableId, const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const { Require(tableId)->EnumerateTxStatusParts(callback); } -void TDatabase::EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const { +void TDatabase::EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const { DatabaseImpl->EnumerateTxStatusParts(callback); } @@ -286,10 +286,10 @@ ui64 TDatabase::GetTableIndexSize(ui32 tableId) const { return Require(tableId)->Stat().Parts.IndexBytes; } -ui64 TDatabase::GetTableSearchHeight(ui32 tableId) const { - return Require(tableId)->GetSearchHeight(); -} - +ui64 TDatabase::GetTableSearchHeight(ui32 tableId) const { + return Require(tableId)->GetSearchHeight(); +} + ui64 TDatabase::EstimateRowSize(ui32 tableId) const { return Require(tableId)->EstimateRowSize(); } @@ -330,12 +330,12 @@ ui32 TDatabase::TxSnapTable(ui32 table) return Change->Snapshots.size() - 1; } -TAutoPtr<TSubset> TDatabase::Subset(ui32 table, TArrayRef<const TLogoBlobID> bundle, TEpoch before) const +TAutoPtr<TSubset> TDatabase::Subset(ui32 table, TArrayRef<const TLogoBlobID> bundle, TEpoch before) const { return Require(table)->Subset(bundle, before); } -TAutoPtr<TSubset> TDatabase::Subset(ui32 table, TEpoch before, TRawVals from, TRawVals to) const +TAutoPtr<TSubset> TDatabase::Subset(ui32 table, TEpoch before, TRawVals from, TRawVals to) const { auto subset = Require(table)->Subset(before); @@ -355,7 +355,7 @@ TAutoPtr<TSubset> TDatabase::Subset(ui32 table, TEpoch before, TRawVals from, TR return subset; } -TAutoPtr<TSubset> TDatabase::ScanSnapshot(ui32 table, TRowVersion snapshot) +TAutoPtr<TSubset> TDatabase::ScanSnapshot(ui32 table, TRowVersion snapshot) { return Require(table)->ScanSnapshot(snapshot); } @@ -370,12 +370,12 @@ void TDatabase::ReplaceSlices(ui32 table, TBundleSlicesMap slices) return DatabaseImpl->ReplaceSlices(table, std::move(slices)); } -void TDatabase::Replace(ui32 table, TArrayRef<const TPartView> partViews, const TSubset &subset) +void TDatabase::Replace(ui32 table, TArrayRef<const TPartView> partViews, const TSubset &subset) { return DatabaseImpl->Replace(table, partViews, subset); } -void TDatabase::ReplaceTxStatus(ui32 table, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> txStatus, const TSubset &subset) +void TDatabase::ReplaceTxStatus(ui32 table, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> txStatus, const TSubset &subset) { return DatabaseImpl->ReplaceTxStatus(table, txStatus, subset); } @@ -385,12 +385,12 @@ void TDatabase::Merge(ui32 table, TPartView partView) return DatabaseImpl->Merge(table, std::move(partView)); } -void TDatabase::Merge(ui32 table, TIntrusiveConstPtr<TColdPart> part) +void TDatabase::Merge(ui32 table, TIntrusiveConstPtr<TColdPart> part) { return DatabaseImpl->Merge(table, std::move(part)); } -void TDatabase::Merge(ui32 table, TIntrusiveConstPtr<TTxStatusPart> txStatus) +void TDatabase::Merge(ui32 table, TIntrusiveConstPtr<TTxStatusPart> txStatus) { return DatabaseImpl->Merge(table, std::move(txStatus)); } @@ -560,7 +560,7 @@ TTable* TDatabase::Require(ui32 table) const noexcept return DatabaseImpl->Get(table, true).Self.Get(); } -TGarbage TDatabase::RollUp(TTxStamp stamp, TArrayRef<const char> delta, TArrayRef<const char> redo, +TGarbage TDatabase::RollUp(TTxStamp stamp, TArrayRef<const char> delta, TArrayRef<const char> redo, TMemGlobs annex) { Y_VERIFY(!annex || redo, "Annex have to be rolled up with redo log"); @@ -591,10 +591,10 @@ void TDatabase::RollUpRemoveRowVersions(ui32 table, const TRowVersion& lower, co } } -TCompactionStats TDatabase::GetCompactionStats(ui32 table) const -{ - return Require(table)->GetCompactionStats(); -} +TCompactionStats TDatabase::GetCompactionStats(ui32 table) const +{ + return Require(table)->GetCompactionStats(); +} // NOTE: This helper should be used only to dump local DB contents in GDB void DebugDumpDb(const TDatabase &db) { diff --git a/ydb/core/tablet_flat/flat_database.h b/ydb/core/tablet_flat/flat_database.h index 36b0edc5fb6..98baa8f4383 100644 --- a/ydb/core/tablet_flat/flat_database.h +++ b/ydb/core/tablet_flat/flat_database.h @@ -67,13 +67,13 @@ public: /*_ Call Next() before accessing each row including the 1st row. */ - TAutoPtr<TTableIt> Iterate(ui32 table, TRawVals key, TTagsRef tags, ELookup) const noexcept; - TAutoPtr<TTableIt> IterateExact(ui32 table, TRawVals key, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; - TAutoPtr<TTableIt> IterateRange(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; - TAutoPtr<TTableReverseIt> IterateRangeReverse(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; + TAutoPtr<TTableIt> Iterate(ui32 table, TRawVals key, TTagsRef tags, ELookup) const noexcept; + TAutoPtr<TTableIt> IterateExact(ui32 table, TRawVals key, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; + TAutoPtr<TTableIt> IterateRange(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; + TAutoPtr<TTableReverseIt> IterateRangeReverse(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; template<class TIteratorType> - TAutoPtr<TIteratorType> IterateRangeGeneric(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; + TAutoPtr<TIteratorType> IterateRangeGeneric(ui32 table, const TKeyRange& range, TTagsRef tags, TRowVersion snapshot = TRowVersion::Max()) const noexcept; // NOTE: the row refeneces data in some internal buffers that get invalidated on the next Select() or Commit() call EReady Select(ui32 table, TRawVals key, TTagsRef tags, TRowState& row, @@ -122,35 +122,35 @@ public: const TScheme& GetScheme() const noexcept; - TIntrusiveConstPtr<TRowScheme> GetRowScheme(ui32 table) const noexcept; + TIntrusiveConstPtr<TRowScheme> GetRowScheme(ui32 table) const noexcept; TPartView GetPartView(ui32 table, const TLogoBlobID &bundle) const; TVector<TPartView> GetTableParts(ui32 table) const; - TVector<TIntrusiveConstPtr<TColdPart>> GetTableColdParts(ui32 table) const; + TVector<TIntrusiveConstPtr<TColdPart>> GetTableColdParts(ui32 table) const; void EnumerateTableParts(ui32 table, const std::function<void(const TPartView&)>& callback) const; - void EnumerateTableColdParts(ui32 table, const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const; - void EnumerateTableTxStatusParts(ui32 table, const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const; - void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const; + void EnumerateTableColdParts(ui32 table, const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const; + void EnumerateTableTxStatusParts(ui32 table, const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const; + void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const; ui64 GetTableMemSize(ui32 table, TEpoch epoch = TEpoch::Max()) const; ui64 GetTableMemRowCount(ui32 tableId) const; ui64 GetTableIndexSize(ui32 table) const; - ui64 GetTableSearchHeight(ui32 table) const; + ui64 GetTableSearchHeight(ui32 table) const; ui64 EstimateRowSize(ui32 table) const; const TCounters& Counters() const noexcept; TString SnapshotToLog(ui32 table, TTxStamp); - TAutoPtr<TSubset> Subset(ui32 table, TArrayRef<const TLogoBlobID> bundle, TEpoch before) const; - TAutoPtr<TSubset> Subset(ui32 table, TEpoch before, TRawVals from, TRawVals to) const; - TAutoPtr<TSubset> ScanSnapshot(ui32 table, TRowVersion snapshot = TRowVersion::Max()); + TAutoPtr<TSubset> Subset(ui32 table, TArrayRef<const TLogoBlobID> bundle, TEpoch before) const; + TAutoPtr<TSubset> Subset(ui32 table, TEpoch before, TRawVals from, TRawVals to) const; + TAutoPtr<TSubset> ScanSnapshot(ui32 table, TRowVersion snapshot = TRowVersion::Max()); TBundleSlicesMap LookupSlices(ui32 table, TArrayRef<const TLogoBlobID> bundles) const; void ReplaceSlices(ui32 table, TBundleSlicesMap slices); - void Replace(ui32 table, TArrayRef<const TPartView>, const TSubset&); - void ReplaceTxStatus(ui32 table, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>>, const TSubset&); + void Replace(ui32 table, TArrayRef<const TPartView>, const TSubset&); + void ReplaceTxStatus(ui32 table, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>>, const TSubset&); void Merge(ui32 table, TPartView); - void Merge(ui32 table, TIntrusiveConstPtr<TColdPart>); - void Merge(ui32 table, TIntrusiveConstPtr<TTxStatusPart>); + void Merge(ui32 table, TIntrusiveConstPtr<TColdPart>); + void Merge(ui32 table, TIntrusiveConstPtr<TTxStatusPart>); void DebugDumpTable(ui32 table, IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const; void DebugDump(IOutputStream& str, const NScheme::TTypeRegistry& typeRegistry) const; @@ -160,14 +160,14 @@ public: // executor interface void Begin(TTxStamp, IPages& env); TProd Commit(TTxStamp, bool commit, TCookieAllocator* = nullptr); - TGarbage RollUp(TTxStamp, TArrayRef<const char> delta, TArrayRef<const char> redo, TMemGlobs annex); + TGarbage RollUp(TTxStamp, TArrayRef<const char> delta, TArrayRef<const char> redo, TMemGlobs annex); void RollUpRemoveRowVersions(ui32 table, const TRowVersion& lower, const TRowVersion& upper); bool ValidateCommit(TString&); - TCompactionStats GetCompactionStats(ui32 table) const; - + TCompactionStats GetCompactionStats(ui32 table) const; + private: TTable* Require(ui32 tableId) const noexcept; @@ -178,9 +178,9 @@ private: bool NoMoreReadsFlag; IPages* Env = nullptr; THolder<TChange> Change; - TAutoPtr<TAlter> Alter_; - TAutoPtr<TAnnex> Annex; - TAutoPtr<NRedo::TWriter> Redo; + TAutoPtr<TAlter> Alter_; + TAutoPtr<TAnnex> Annex; + TAutoPtr<NRedo::TWriter> Redo; mutable TDeque<TPartSimpleIt> TempIterators; // Keeps the last result of Select() valid mutable THashSet<ui32> IteratedTables; diff --git a/ydb/core/tablet_flat/flat_dbase_naked.h b/ydb/core/tablet_flat/flat_dbase_naked.h index 2a181bb9f83..493867a7f87 100644 --- a/ydb/core/tablet_flat/flat_dbase_naked.h +++ b/ydb/core/tablet_flat/flat_dbase_naked.h @@ -78,7 +78,7 @@ namespace NTable { } const ui32 Table = Max<ui32>(); - const TIntrusivePtr<TTable> Self; + const TIntrusivePtr<TTable> Self; const TTxStamp Edge = 0; /* Stamp of last snapshot */ ui64 Serial = 0; }; @@ -150,7 +150,7 @@ namespace NTable { wrap.Aggr(Stats, true /* enter */); } - void Replace(ui32 tid, TArrayRef<const TPartView> partViews, const TSubset &subset) noexcept + void Replace(ui32 tid, TArrayRef<const TPartView> partViews, const TSubset &subset) noexcept { auto &wrap = Get(tid, true); @@ -159,7 +159,7 @@ namespace NTable { wrap.Aggr(Stats, true /* enter */); } - void ReplaceTxStatus(ui32 tid, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> txStatus, const TSubset &subset) noexcept + void ReplaceTxStatus(ui32 tid, TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> txStatus, const TSubset &subset) noexcept { auto &wrap = Get(tid, true); @@ -177,7 +177,7 @@ namespace NTable { wrap.Aggr(Stats, true /* enter */); } - void Merge(ui32 tid, TIntrusiveConstPtr<TColdPart> part) noexcept + void Merge(ui32 tid, TIntrusiveConstPtr<TColdPart> part) noexcept { auto &wrap = Get(tid, true); @@ -186,7 +186,7 @@ namespace NTable { wrap.Aggr(Stats, true /* enter */); } - void Merge(ui32 tid, TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept + void Merge(ui32 tid, TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept { auto &wrap = Get(tid, true); @@ -332,7 +332,7 @@ namespace NTable { First_ = Min(First_, Serial_); } - void DoAnnex(TArrayRef<const TStdPad<NPageCollection::TGlobId>> annex) noexcept + void DoAnnex(TArrayRef<const TStdPad<NPageCollection::TGlobId>> annex) noexcept { if (Annex) { Y_VERIFY(annex.size() == Annex.size()); @@ -423,7 +423,7 @@ namespace NTable { } public: - void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) { + void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) { for (auto &it : Tables) { it.second->EnumerateTxStatusParts(callback); } @@ -442,7 +442,7 @@ namespace NTable { TVector<TMemGlob> Annex; public: - const TAutoPtr<TScheme> Scheme; + const TAutoPtr<TScheme> Scheme; TGarbage Garbage; /* Unused full table subsets */ TVector<ui32> Deleted; TDbStats Stats; diff --git a/ydb/core/tablet_flat/flat_dbase_scheme.h b/ydb/core/tablet_flat/flat_dbase_scheme.h index 95334f1c1f6..1fd5ed2b480 100644 --- a/ydb/core/tablet_flat/flat_dbase_scheme.h +++ b/ydb/core/tablet_flat/flat_dbase_scheme.h @@ -98,7 +98,7 @@ public: THashMap<ui32, TRoom> Rooms; THashMap<ui32, TFamily> Families; - TIntrusiveConstPtr<TCompactionPolicy> CompactionPolicy; + TIntrusiveConstPtr<TCompactionPolicy> CompactionPolicy; bool ColdBorrow = false; bool ByKeyFilter = false; bool EraseCacheEnabled = false; diff --git a/ydb/core/tablet_flat/flat_exec_broker.cpp b/ydb/core/tablet_flat/flat_exec_broker.cpp index 3f7a979adca..367d7a42f97 100644 --- a/ydb/core/tablet_flat/flat_exec_broker.cpp +++ b/ydb/core/tablet_flat/flat_exec_broker.cpp @@ -5,7 +5,7 @@ namespace NTabletFlatExecutor { using namespace NResourceBroker; -TBroker::TBroker(IOps* ops, TIntrusivePtr<TIdEmitter> emitter) +TBroker::TBroker(IOps* ops, TIntrusivePtr<TIdEmitter> emitter) : Ops(ops) , Emitter(std::move(emitter)) { } @@ -61,7 +61,7 @@ void TBroker::OnResourceAllocated(TTaskId taskId) { } } -void TBroker::SendToBroker(TAutoPtr<IEventBase> event) { +void TBroker::SendToBroker(TAutoPtr<IEventBase> event) { Ops->Send(MakeResourceBrokerID(), event.Release(), 0); } diff --git a/ydb/core/tablet_flat/flat_exec_broker.h b/ydb/core/tablet_flat/flat_exec_broker.h index 57118dbf629..7e2647419f4 100644 --- a/ydb/core/tablet_flat/flat_exec_broker.h +++ b/ydb/core/tablet_flat/flat_exec_broker.h @@ -45,7 +45,7 @@ namespace NTabletFlatExecutor { using IOps = NActors::IActorOps; public: - TBroker(IOps* ops, TIntrusivePtr<TIdEmitter> emitter); + TBroker(IOps* ops, TIntrusivePtr<TIdEmitter> emitter); // API implementation TTaskId SubmitTask(TString name, TResourceParams params, TResourceConsumer consumer) override; @@ -57,11 +57,11 @@ namespace NTabletFlatExecutor { void OnResourceAllocated(TTaskId taskId); private: - void SendToBroker(TAutoPtr<IEventBase> event); + void SendToBroker(TAutoPtr<IEventBase> event); private: IOps* const Ops; - TIntrusivePtr<TIdEmitter> const Emitter; + TIntrusivePtr<TIdEmitter> const Emitter; THashMap<TTaskId, TResourceConsumer> Submitted; }; diff --git a/ydb/core/tablet_flat/flat_exec_commit.h b/ydb/core/tablet_flat/flat_exec_commit.h index 5e32ccb0494..7212449c259 100644 --- a/ydb/core/tablet_flat/flat_exec_commit.h +++ b/ydb/core/tablet_flat/flat_exec_commit.h @@ -37,7 +37,7 @@ namespace NTabletFlatExecutor { out << "Commit{" << Step << " orig " << ui32(Type) << ", " << (Sync ? "S" : "-") << (Embedded ? "E" : "-") - << (FollowerAux ? "X" : "-") << " " << Refs.size() << " refs" + << (FollowerAux ? "X" : "-") << " " << Refs.size() << " refs" << ", Gc (+" << +GcDelta.Created.size() << " -" << GcDelta.Deleted.size() << ")}"; } @@ -48,9 +48,9 @@ namespace NTabletFlatExecutor { const ui32 Step = Max<ui32>(); const ECommit Type = ECommit::Misc; const bool Sync = false; - bool WaitFollowerGcAck = false; + bool WaitFollowerGcAck = false; TString Embedded; - TString FollowerAux; + TString FollowerAux; TVector<TLogoBlob> Refs; TGCBlobDelta GcDelta; TSeat *FirstTx = nullptr; diff --git a/ydb/core/tablet_flat/flat_exec_commit_mgr.h b/ydb/core/tablet_flat/flat_exec_commit_mgr.h index 9d9df73a989..20f5d5ffe10 100644 --- a/ydb/core/tablet_flat/flat_exec_commit_mgr.h +++ b/ydb/core/tablet_flat/flat_exec_commit_mgr.h @@ -94,7 +94,7 @@ namespace NTabletFlatExecutor { return NTable::TTxStamp{ Gen, Head }; } - TAutoPtr<TLogCommit> Begin(bool sync, ECommit type) noexcept + TAutoPtr<TLogCommit> Begin(bool sync, ECommit type) noexcept { const auto step = Head; @@ -111,7 +111,7 @@ namespace NTabletFlatExecutor { return new TLogCommit(sync, step, type); } - void Commit(TAutoPtr<TLogCommit> commit) noexcept + void Commit(TAutoPtr<TLogCommit> commit) noexcept { if (commit->Step != Tail || (commit->Sync && !Sync)) { Y_Fail( @@ -171,8 +171,8 @@ namespace NTabletFlatExecutor { ev->CommitTactic = Tactic; ev->References = std::move(commit.Refs); ev->EmbeddedLogBody = std::move(commit.Embedded); - ev->WaitFollowerGcAck = commit.WaitFollowerGcAck; - ev->FollowerAux = std::move(commit.FollowerAux); + ev->WaitFollowerGcAck = commit.WaitFollowerGcAck; + ev->FollowerAux = std::move(commit.FollowerAux); ev->GcDiscovered = std::move(commit.GcDelta.Created); ev->GcLeft = std::move(commit.GcDelta.Deleted); @@ -191,7 +191,7 @@ namespace NTabletFlatExecutor { ui32 Head = 0; /* Tablet current step, AKA Step0 */ ui32 *Step0 = nullptr; /* Compatability for tablet Step0 */ bool Sync = false; /* Synchromous commit in progress */ - TIntrusivePtr<NSnap::TWaste> Waste; + TIntrusivePtr<NSnap::TWaste> Waste; ETactic Tactic = ETactic::TacticDefault; TGcLogic * const GcLogic = nullptr; TMonCo * MonCo = nullptr; diff --git a/ydb/core/tablet_flat/flat_exec_memory.h b/ydb/core/tablet_flat/flat_exec_memory.h index 8a2cf6293bc..9f827bd75e8 100644 --- a/ydb/core/tablet_flat/flat_exec_memory.h +++ b/ydb/core/tablet_flat/flat_exec_memory.h @@ -42,7 +42,7 @@ namespace NTabletFlatExecutor { TMemory( NUtil::ILogger *logger, IOps *ops, - TIntrusivePtr<TIdEmitter> emitter, + TIntrusivePtr<TIdEmitter> emitter, TString taskNameSuffix = { }) : Logger(logger) , Ops(ops) @@ -311,7 +311,7 @@ namespace NTabletFlatExecutor { { GCScheduled = false; - TVector<TIntrusivePtr<TMemoryGCToken>> dropped; + TVector<TIntrusivePtr<TMemoryGCToken>> dropped; for (auto it = Tokens.begin(); it != Tokens.end(); ++it) { if ((*it)->IsDropped()) { @@ -361,7 +361,7 @@ namespace NTabletFlatExecutor { } } - void SetProfiles(TResourceProfilesPtr profiles) noexcept + void SetProfiles(TResourceProfilesPtr profiles) noexcept { Profiles = profiles ? profiles : new TResourceProfiles; } @@ -396,7 +396,7 @@ namespace NTabletFlatExecutor { seat.CurrentTxDataLimit -= seat.CapturedMemory->Size; } - void Send(TAutoPtr<IEventBase> event) + void Send(TAutoPtr<IEventBase> event) { using namespace NResourceBroker; @@ -415,12 +415,12 @@ namespace NTabletFlatExecutor { private: NUtil::ILogger * const Logger = nullptr; IOps * const Ops = nullptr; - const TIntrusivePtr<TIdEmitter> Emitter; + const TIntrusivePtr<TIdEmitter> Emitter; bool GCScheduled = false; TUsed Used; - THashSet<TIntrusivePtr<TMemoryGCToken>, TPtrHash> Tokens; - TIntrusivePtr<TResourceProfiles> Profiles; + THashSet<TIntrusivePtr<TMemoryGCToken>, TPtrHash> Tokens; + TIntrusivePtr<TResourceProfiles> Profiles; TString TaskNameSuffix; public: diff --git a/ydb/core/tablet_flat/flat_exec_read.h b/ydb/core/tablet_flat/flat_exec_read.h index ba39aa2b01c..a393f13fd03 100644 --- a/ydb/core/tablet_flat/flat_exec_read.h +++ b/ydb/core/tablet_flat/flat_exec_read.h @@ -8,7 +8,7 @@ namespace NKikimr { namespace NTabletFlatExecutor { struct TCompactionReadState { - using TPinned = THashMap<TLogoBlobID, THashMap<ui32, TIntrusivePtr<TPrivatePageCachePinPad>>>; + using TPinned = THashMap<TLogoBlobID, THashMap<ui32, TIntrusivePtr<TPrivatePageCachePinPad>>>; TCompactionReadState(ui64 readId, THolder<NTable::ICompactionRead> read) : ReadId(readId) diff --git a/ydb/core/tablet_flat/flat_exec_scans.h b/ydb/core/tablet_flat/flat_exec_scans.h index 5e96f603c95..4ab70473513 100644 --- a/ydb/core/tablet_flat/flat_exec_scans.h +++ b/ydb/core/tablet_flat/flat_exec_scans.h @@ -83,7 +83,7 @@ namespace NTabletFlatExecutor { THolder<TScanSnapshot> Snapshot; EState State = EState::None; TActorId Actor; /* Valid just after EState::Scan*/ - TAutoPtr<IScan> Scan; /* Valid before EState::Scan */ + TAutoPtr<IScan> Scan; /* Valid before EState::Scan */ ui64 Cookie = Max<ui64>(); ui64 TaskId = 0; /* Task number in res. broker */ }; @@ -117,7 +117,7 @@ namespace NTabletFlatExecutor { }; public: - TScans(NUtil::ILogger *logger, IOps *ops, TIntrusivePtr<TIdEmitter> emitter, + TScans(NUtil::ILogger *logger, IOps *ops, TIntrusivePtr<TIdEmitter> emitter, ITablet *owner, const TActorId& ownerActorId) : Logger(logger) , Ops(ops) @@ -154,7 +154,7 @@ namespace NTabletFlatExecutor { } } - ui64 Queue(ui32 table, TAutoPtr<IScan> scan, ui64 cookie, const TScanOptions& options, THolder<TScanSnapshot> snapshot) + ui64 Queue(ui32 table, TAutoPtr<IScan> scan, ui64 cookie, const TScanOptions& options, THolder<TScanSnapshot> snapshot) { auto &one = Make(table, scan, EType::Client, options, std::move(snapshot)); @@ -207,7 +207,7 @@ namespace NTabletFlatExecutor { Start(one, { }); } - ui64 StartSystem(ui32 table, TAutoPtr<IScan> scan, NOps::TConf conf, THolder<TScanSnapshot> snapshot) + ui64 StartSystem(ui32 table, TAutoPtr<IScan> scan, NOps::TConf conf, THolder<TScanSnapshot> snapshot) { auto &one = Make(table, scan, EType::System, { }, std::move(snapshot)); @@ -276,7 +276,7 @@ namespace NTabletFlatExecutor { return Cancel(*one, EState::Forget); } - TScanOutcome Release(ui64 serial, EAbort &code, TAutoPtr<IDestructable> &result) noexcept + TScanOutcome Release(ui64 serial, EAbort &code, TAutoPtr<IDestructable> &result) noexcept { auto *one = Lookup(serial, true); @@ -294,7 +294,7 @@ namespace NTabletFlatExecutor { } private: - TOne& Make(ui32 table, TAutoPtr<IScan> scan, EType type, const TScanOptions& options, THolder<TScanSnapshot> snapshot) noexcept + TOne& Make(ui32 table, TAutoPtr<IScan> scan, EType type, const TScanOptions& options, THolder<TScanSnapshot> snapshot) noexcept { /* odd NOps used to mark compactions (system scans) */ @@ -364,7 +364,7 @@ namespace NTabletFlatExecutor { bool Cancel(TOne &one, EState state) noexcept { if (one.State == EState::Task || one.State == EState::Ready) { - TAutoPtr<IDestructable> result; + TAutoPtr<IDestructable> result; Throw(one, state, EAbort::Term, result); return true; } else if (one.State == EState::Scan) { @@ -379,7 +379,7 @@ namespace NTabletFlatExecutor { return false; } - TScanOutcome Throw(TOne &one, EState last, EAbort status, TAutoPtr<IDestructable> &result) + TScanOutcome Throw(TOne &one, EState last, EAbort status, TAutoPtr<IDestructable> &result) { if (auto task = std::exchange(one.TaskId, 0)) { if (one.State == EState::Task) { @@ -431,7 +431,7 @@ namespace NTabletFlatExecutor { return out.Str(); } - void ToBroker(TAutoPtr<IEventBase> event) + void ToBroker(TAutoPtr<IEventBase> event) { using namespace NResourceBroker; @@ -447,7 +447,7 @@ namespace NTabletFlatExecutor { ui64 Serial = 0; - const TIntrusivePtr<TIdEmitter> Emitter; + const TIntrusivePtr<TIdEmitter> Emitter; ui32 CounterAlive = 0; THashMap<ui64, TOne> Scans; THashMap<ui32, TTable> Tables; /* only alive scans */ diff --git a/ydb/core/tablet_flat/flat_exec_seat.h b/ydb/core/tablet_flat/flat_exec_seat.h index 34339ffb0ad..f37d3bfb0b6 100644 --- a/ydb/core/tablet_flat/flat_exec_seat.h +++ b/ydb/core/tablet_flat/flat_exec_seat.h @@ -11,11 +11,11 @@ namespace NKikimr { namespace NTabletFlatExecutor { struct TSeat { - using TPinned = THashMap<TLogoBlobID, THashMap<ui32, TIntrusivePtr<TPrivatePageCachePinPad>>>; + using TPinned = THashMap<TLogoBlobID, THashMap<ui32, TIntrusivePtr<TPrivatePageCachePinPad>>>; TSeat(const TSeat&) = delete; - TSeat(ui32 uniqId, TAutoPtr<ITransaction> self) + TSeat(ui32 uniqId, TAutoPtr<ITransaction> self) : UniqID(uniqId) , Self(self) { @@ -32,7 +32,7 @@ namespace NTabletFlatExecutor { void Complete(const TActorContext& ctx) noexcept; const ui64 UniqID = Max<ui64>(); - const TAutoPtr<ITransaction> Self; + const TAutoPtr<ITransaction> Self; ui64 Retries = 0; TPinned Pinned; @@ -50,8 +50,8 @@ namespace NTabletFlatExecutor { ui32 NotEnoughMemoryCount = 0; ui64 TaskId = 0; - TAutoPtr<TMemoryToken> AttachedMemory; - TIntrusivePtr<TMemoryGCToken> CapturedMemory; + TAutoPtr<TMemoryToken> AttachedMemory; + TIntrusivePtr<TMemoryGCToken> CapturedMemory; TVector<std::function<void()>> OnCommitted; ETerminationReason TerminationReason = ETerminationReason::None; diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp index 55eb9514a1b..59afc462158 100644 --- a/ydb/core/tablet_flat/flat_executor.cpp +++ b/ydb/core/tablet_flat/flat_executor.cpp @@ -136,7 +136,7 @@ void TExecutor::Broken() { if (Owner) { TabletCountersForgetTablet(Owner->TabletID(), Owner->TabletType(), - Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); + Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); Owner->Detach(OwnerCtx()); } @@ -306,7 +306,7 @@ void TExecutor::Handle(TEvTablet::TEvCheckBlobstorageStatusResult::TPtr &ev) { CheckYellow(std::move(lightYellowMoveChannels), std::move(yellowStopChannels)); } -void TExecutor::ActivateFollower(const TActorContext &ctx) { +void TExecutor::ActivateFollower(const TActorContext &ctx) { if (auto logl = Logger->Log(ELnLev::Info)) logl << NFmt::Do(*this) << " activating executor"; @@ -331,27 +331,27 @@ void TExecutor::ActivateFollower(const TActorContext &ctx) { CounterCacheStaging = new NMonitoring::TCounterForPtr; CounterCacheMemTable = new NMonitoring::TCounterForPtr; - ResourceMetrics = MakeHolder<NMetrics::TResourceMetrics>(Owner->TabletID(), FollowerId, Launcher); + ResourceMetrics = MakeHolder<NMetrics::TResourceMetrics>(Owner->TabletID(), FollowerId, Launcher); PendingBlobQueue.Config.TabletID = Owner->TabletID(); PendingBlobQueue.Config.Generation = Generation(); - PendingBlobQueue.Config.Follower = true; + PendingBlobQueue.Config.Follower = true; PendingBlobQueue.Config.NoDataCounter = GetServiceCounters(AppData()->Counters, "tablets")->GetCounter("alerts_pending_nodata", true); ReadResourceProfile(); RecreatePageCollectionsCache(); ReflectSchemeSettings(); - Become(&TThis::StateFollower); + Become(&TThis::StateFollower); Stats->IsActive = true; - Stats->IsFollower = true; + Stats->IsFollower = true; PlanTransactionActivation(); Owner->ActivateExecutor(OwnerCtx()); UpdateCounters(ctx); - ApplyFollowerPostponedUpdates(); + ApplyFollowerPostponedUpdates(); } void TExecutor::Active(const TActorContext &ctx) { @@ -389,7 +389,7 @@ void TExecutor::Active(const TActorContext &ctx) { PendingBlobQueue.Config.TabletID = Owner->TabletID(); PendingBlobQueue.Config.Generation = Generation(); - PendingBlobQueue.Config.Follower = false; + PendingBlobQueue.Config.Follower = false; PendingBlobQueue.Config.NoDataCounter = GetServiceCounters(AppData()->Counters, "tablets")->GetCounter("alerts_pending_nodata", true); ReadResourceProfile(); @@ -400,7 +400,7 @@ void TExecutor::Active(const TActorContext &ctx) { Become(&TThis::StateWork); Stats->IsActive = true; - Stats->IsFollower = false; + Stats->IsFollower = false; CompactionLogic->Start(); @@ -444,18 +444,18 @@ void TExecutor::TranscriptBootOpResult(ui32 res, const TActorContext &ctx) { } } -void TExecutor::TranscriptFollowerBootOpResult(ui32 res, const TActorContext &ctx) { +void TExecutor::TranscriptFollowerBootOpResult(ui32 res, const TActorContext &ctx) { switch (res) { case TExecutorBootLogic::OpResultUnhandled: return; case TExecutorBootLogic::OpResultContinue: return; case TExecutorBootLogic::OpResultComplete: - return ActivateFollower(ctx); + return ActivateFollower(ctx); case TExecutorBootLogic::OpResultBroken: BootLogic.Destroy(); if (auto logl = Logger->Log(ELnLev::Error)) { - logl << NFmt::Do(*this) << " Broken while follower booting"; + logl << NFmt::Do(*this) << " Broken while follower booting"; } return Broken(); default: @@ -469,7 +469,7 @@ void TExecutor::PlanTransactionActivation() { const ui64 limitTxInFly = Scheme().Executor.LimitInFlyTx; while (PendingQueue->Head() && (!limitTxInFly || (Stats->TxInFly - Stats->TxPending < limitTxInFly))) { - TAutoPtr<TSeat> seat = PendingQueue->Pop(); + TAutoPtr<TSeat> seat = PendingQueue->Pop(); LWTRACK(TransactionEnqueued, seat->Self->Orbit, seat->UniqID); ActivationQueue->Push(seat.Release()); ActivateTransactionWaiting++; @@ -594,7 +594,7 @@ TExecutorCaches TExecutor::CleanupState() { caches.PageCaches = PrivatePageCache->DetachPrivatePageCache(); } if (Database) { - Database->EnumerateTxStatusParts([&caches](const TIntrusiveConstPtr<NTable::TTxStatusPart>& txStatus) { + Database->EnumerateTxStatusParts([&caches](const TIntrusiveConstPtr<NTable::TTxStatusPart>& txStatus) { caches.TxStatusCaches[txStatus->Label] = txStatus->TxStatusPage->GetRaw(); }); } @@ -602,7 +602,7 @@ TExecutorCaches TExecutor::CleanupState() { BootLogic.Destroy(); PendingBlobQueue.Clear(); - PostponedFollowerUpdates.clear(); + PostponedFollowerUpdates.clear(); PendingPartSwitches.clear(); ReadyPartSwitches = 0; Y_VERIFY(!LogicRedo); @@ -616,16 +616,16 @@ TExecutorCaches TExecutor::CleanupState() { } void TExecutor::Boot(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx) { - if (Stats->IsFollower) { + if (Stats->IsFollower) { TabletCountersForgetTablet(Owner->TabletID(), Owner->TabletType(), - Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); + Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); } RegisterTabletFlatProbes(); Become(&TThis::StateBoot); Stats->IsActive = false; - Stats->IsFollower = false; + Stats->IsFollower = false; TEvTablet::TEvBoot *msg = ev->Get(); Generation0 = msg->Generation; @@ -658,23 +658,23 @@ void TExecutor::Boot(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx) { return TranscriptBootOpResult(res, ctx); } -void TExecutor::FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) { +void TExecutor::FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) { Y_VERIFY(CurrentStateFunc() == &TThis::StateInit - || CurrentStateFunc() == &TThis::StateFollowerBoot - || CurrentStateFunc() == &TThis::StateFollower); + || CurrentStateFunc() == &TThis::StateFollowerBoot + || CurrentStateFunc() == &TThis::StateFollower); RegisterTabletFlatProbes(); - Become(&TThis::StateFollowerBoot); + Become(&TThis::StateFollowerBoot); Stats->IsActive = false; - Stats->IsFollower = true; + Stats->IsFollower = true; - TEvTablet::TEvFBoot *msg = ev->Get(); + TEvTablet::TEvFBoot *msg = ev->Get(); Generation0 = msg->Generation; Step0 = 0; Launcher = msg->Launcher; Memory->SetProfiles(msg->ResourceProfiles); - FollowerId = msg->FollowerID; + FollowerId = msg->FollowerID; const ui64 maxBootBytesInFly = 12 * 1024 * 1024; @@ -682,7 +682,7 @@ void TExecutor::FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext BootLogic.Reset(new TExecutorBootLogic(this, SelfId(), Owner->Info(), maxBootBytesInFly)); const auto res = BootLogic->ReceiveFollowerBoot(ev, std::move(executorCaches)); - return TranscriptFollowerBootOpResult(res, ctx); + return TranscriptFollowerBootOpResult(res, ctx); } void TExecutor::Restored(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx) { @@ -697,41 +697,41 @@ void TExecutor::Restored(TEvTablet::TEvRestored::TPtr &ev, const TActorContext & void TExecutor::DetachTablet(const TActorContext &) { TabletCountersForgetTablet(Owner->TabletID(), Owner->TabletType(), - Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); + Owner->Info()->TenantPathId, Stats->IsFollower, SelfId()); return PassAway(); } -void TExecutor::FollowerUpdate(THolder<TEvTablet::TFUpdateBody> upd) { +void TExecutor::FollowerUpdate(THolder<TEvTablet::TFUpdateBody> upd) { if (BootLogic) { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollowerBoot); - PostponedFollowerUpdates.emplace_back(std::move(upd)); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollowerBoot); + PostponedFollowerUpdates.emplace_back(std::move(upd)); } else if (PendingPartSwitches) { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); - PostponedFollowerUpdates.emplace_back(std::move(upd)); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); + PostponedFollowerUpdates.emplace_back(std::move(upd)); } else { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); - Y_VERIFY(PostponedFollowerUpdates.empty()); - ApplyFollowerUpdate(std::move(upd)); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); + Y_VERIFY(PostponedFollowerUpdates.empty()); + ApplyFollowerUpdate(std::move(upd)); } } -void TExecutor::FollowerAuxUpdate(TString upd) { +void TExecutor::FollowerAuxUpdate(TString upd) { if (BootLogic) { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollowerBoot); - PostponedFollowerUpdates.emplace_back(new TEvTablet::TFUpdateBody(std::move(upd))); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollowerBoot); + PostponedFollowerUpdates.emplace_back(new TEvTablet::TFUpdateBody(std::move(upd))); } else if (PendingPartSwitches) { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); - PostponedFollowerUpdates.emplace_back(new TEvTablet::TFUpdateBody(std::move(upd))); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); + PostponedFollowerUpdates.emplace_back(new TEvTablet::TFUpdateBody(std::move(upd))); } else { - Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); - Y_VERIFY(PostponedFollowerUpdates.empty()); - ApplyFollowerAuxUpdate(upd); + Y_VERIFY(CurrentStateFunc() == &TThis::StateFollower); + Y_VERIFY(PostponedFollowerUpdates.empty()); + ApplyFollowerAuxUpdate(upd); } } -void TExecutor::FollowerAttached() { - HadFollowerAttached = true; - NeedFollowerSnapshot = true; +void TExecutor::FollowerAttached() { + HadFollowerAttached = true; + NeedFollowerSnapshot = true; if (CurrentStateFunc() != &TThis::StateWork) return; @@ -739,19 +739,19 @@ void TExecutor::FollowerAttached() { MakeLogSnapshot(); } -void TExecutor::FollowerSyncComplete() { +void TExecutor::FollowerSyncComplete() { Y_VERIFY(CurrentStateFunc() == &TThis::StateWork || CurrentStateFunc() == &TThis::StateBoot); if (GcLogic) - GcLogic->FollowersSyncComplete(false); + GcLogic->FollowersSyncComplete(false); else if (BootLogic) - BootLogic->FollowersSyncComplete(); + BootLogic->FollowersSyncComplete(); else Y_FAIL("must not happens"); } -void TExecutor::FollowerGcApplied(ui32 step, TDuration followerSyncDelay) { +void TExecutor::FollowerGcApplied(ui32 step, TDuration followerSyncDelay) { if (auto logl = Logger->Log(ELnLev::Debug)) { - logl << NFmt::Do(*this) << " switch applied on followers, step " << step; + logl << NFmt::Do(*this) << " switch applied on followers, step " << step; } auto it = InFlyCompactionGcBarriers.find(step); @@ -759,8 +759,8 @@ void TExecutor::FollowerGcApplied(ui32 step, TDuration followerSyncDelay) { CheckCollectionBarrier(it->second); InFlyCompactionGcBarriers.erase(it); - if (followerSyncDelay != TDuration::Max()) - Counters->Percentile()[TExecutorCounters::TX_PERCENTILE_FOLLOWERSYNC_LATENCY].IncrementFor(followerSyncDelay.MicroSeconds()); + if (followerSyncDelay != TDuration::Max()) + Counters->Percentile()[TExecutorCounters::TX_PERCENTILE_FOLLOWERSYNC_LATENCY].IncrementFor(followerSyncDelay.MicroSeconds()); } void TExecutor::CheckCollectionBarrier(TIntrusivePtr<TBarrier> &barrier) { @@ -777,23 +777,23 @@ void TExecutor::CheckCollectionBarrier(TIntrusivePtr<TBarrier> &barrier) { barrier.Drop(); } -void TExecutor::ApplyFollowerPostponedUpdates() { - while (PostponedFollowerUpdates && !PendingPartSwitches) { - THolder<TEvTablet::TFUpdateBody> upd = std::move(PostponedFollowerUpdates.front()); - PostponedFollowerUpdates.pop_front(); +void TExecutor::ApplyFollowerPostponedUpdates() { + while (PostponedFollowerUpdates && !PendingPartSwitches) { + THolder<TEvTablet::TFUpdateBody> upd = std::move(PostponedFollowerUpdates.front()); + PostponedFollowerUpdates.pop_front(); if (upd->Step) { - ApplyFollowerUpdate(std::move(upd)); + ApplyFollowerUpdate(std::move(upd)); } else { - ApplyFollowerAuxUpdate(upd->AuxPayload); + ApplyFollowerAuxUpdate(upd->AuxPayload); } } } -void TExecutor::ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) { +void TExecutor::ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) { if (update->Step <= Step0 || CommitManager) { Y_Fail( - NFmt::Do(*this) << " got unexpected follower update to Step " + NFmt::Do(*this) << " got unexpected follower update to Step " << update->Step << ", " << NFmt::If(CommitManager.Get())); } @@ -874,13 +874,13 @@ void TExecutor::ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) { TProtoBox<NKikimrExecutorFlat::TBorrowedPart> proto(uncompressed); - // for now follower borrowed info is not cleared. + // for now follower borrowed info is not cleared. // it's not problem as by design we expect limited number of loans - BorrowLogic->RestoreFollowerBorrowedInfo(loanQu.Id, proto); + BorrowLogic->RestoreFollowerBorrowedInfo(loanQu.Id, proto); } if (partSwitches) { - NKikimrExecutorFlat::TFollowerPartSwitchAux auxProto; + NKikimrExecutorFlat::TFollowerPartSwitchAux auxProto; if (update->AuxPayload) { const TString auxBody = NPageCollection::TSlicer::Lz4()->Decode(update->AuxPayload); @@ -896,14 +896,14 @@ void TExecutor::ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) { const TProtoBox<NKikimrExecutorFlat::TTablePartSwitch> proto(uncompressed); - const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux = nullptr; + const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux = nullptr; if (proto.HasIntroducedParts() || proto.HasIntroducedTxStatus()) { Y_VERIFY(nextAuxIdx < auxProto.BySwitchAuxSize()); aux = &auxProto.GetBySwitchAux(nextAuxIdx++); } - const ui32 followerGcStep = update->NeedFollowerGcAck ? Step0 : 0; - AddFollowerPartSwitch(proto, aux, followerGcStep, Step0); + const ui32 followerGcStep = update->NeedFollowerGcAck ? Step0 : 0; + AddFollowerPartSwitch(proto, aux, followerGcStep, Step0); // Row version changes are rolled up immediately (similar to schema changes) if (proto.HasRowVersionChanges()) { @@ -923,14 +923,14 @@ void TExecutor::ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) { if (!hadPendingPartSwitches) { ApplyReadyPartSwitches(); // safe to apply switches right now } - } else if (update->NeedFollowerGcAck) { - Send(Owner->Tablet(), new TEvTablet::TEvFGcAck(Owner->TabletID(), Generation(), Step0)); + } else if (update->NeedFollowerGcAck) { + Send(Owner->Tablet(), new TEvTablet::TEvFGcAck(Owner->TabletID(), Generation(), Step0)); } } -void TExecutor::ApplyFollowerAuxUpdate(const TString &auxBody) { +void TExecutor::ApplyFollowerAuxUpdate(const TString &auxBody) { const TString aux = NPageCollection::TSlicer::Lz4()->Decode(auxBody); - TProtoBox<NKikimrExecutorFlat::TFollowerAux> proto(aux); + TProtoBox<NKikimrExecutorFlat::TFollowerAux> proto(aux); for (const auto &x : proto.GetPageCollectionsTouched()) { const TLogoBlobID &metaId = LogoBlobIDFromLogoBlobID(x.GetMetaInfoId()); @@ -970,12 +970,12 @@ void TExecutor::ApplyFollowerAuxUpdate(const TString &auxBody) { RequestFromSharedCache(req, NBlockIO::EPriority::Bkgr, EPageCollectionRequest::CacheSync); } } - - if (proto.HasUserAuxUpdate()) - Owner->OnLeaderUserAuxUpdate(std::move(proto.GetUserAuxUpdate())); + + if (proto.HasUserAuxUpdate()) + Owner->OnLeaderUserAuxUpdate(std::move(proto.GetUserAuxUpdate())); } -void TExecutor::RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch, +void TExecutor::RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch, NBlockIO::EPriority priority, EPageCollectionRequest requestCategory) { @@ -988,13 +988,13 @@ void TExecutor::RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch, 0, (ui64)requestCategory); } -void TExecutor::AddFollowerPartSwitch( +void TExecutor::AddFollowerPartSwitch( const NKikimrExecutorFlat::TTablePartSwitch &switchProto, - const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux, + const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux, ui32 updateStep, ui32 step) { auto& partSwitch = PendingPartSwitches.emplace_back(); - partSwitch.FollowerUpdateStep = updateStep; + partSwitch.FollowerUpdateStep = updateStep; partSwitch.TableId = switchProto.GetTableId(); partSwitch.Step = step; @@ -1064,7 +1064,7 @@ bool TExecutor::PrepareExternalPart(TPendingPartSwitch &partSwitch, NTable::TPar const auto& dbScheme = Database->GetScheme(); const auto& tableScheme = dbScheme.Tables.at(tableId); - if (tableScheme.ColdBorrow && !partSwitch.FollowerUpdateStep) { + if (tableScheme.ColdBorrow && !partSwitch.FollowerUpdateStep) { const auto label = pc.PageCollectionComponents.at(0).LargeGlobId.Lead; if (label.TabletID() != TabletId()) { TVector<NPageCollection::TLargeGlobId> largeGlobIds(Reserve(pc.PageCollectionComponents.size())); @@ -1217,8 +1217,8 @@ void TExecutor::Handle(TEvBlobStorage::TEvGetResult::TPtr& ev, const TActorConte void TExecutor::AdvancePendingPartSwitches() { while (PendingPartSwitches && ApplyReadyPartSwitches()) { - if (Stats->IsFollower) { - ApplyFollowerPostponedUpdates(); + if (Stats->IsFollower) { + ApplyFollowerPostponedUpdates(); } } @@ -1273,9 +1273,9 @@ void TExecutor::ApplyExternalPartSwitch(TPendingPartSwitch &partSwitch) { newParts.push_back(std::move(stage->PartView)); } - TVector<TIntrusiveConstPtr<NTable::TColdPart>> newColdParts = std::move(partSwitch.NewColdParts); + TVector<TIntrusiveConstPtr<NTable::TColdPart>> newColdParts = std::move(partSwitch.NewColdParts); - TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> newTxStatus; + TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> newTxStatus; newTxStatus.reserve(partSwitch.NewTxStatus.size()); for (auto &txStatus : partSwitch.NewTxStatus) { auto* stage = txStatus.GetStage<TPendingPartSwitch::TTxStatusResultStage>(); @@ -1313,23 +1313,23 @@ void TExecutor::ApplyExternalPartSwitch(TPendingPartSwitch &partSwitch) { Database->ReplaceSlices(partSwitch.TableId, std::move(updatedSlices)); } - if (partSwitch.FollowerUpdateStep) { + if (partSwitch.FollowerUpdateStep) { auto subset = Database->Subset(partSwitch.TableId, partSwitch.Leaving, partSwitch.Head); if (partSwitch.Head != subset->Head) { - Y_FAIL("Follower table epoch head has diverged from leader"); + Y_FAIL("Follower table epoch head has diverged from leader"); } else if (*subset && !subset->IsStickedToHead()) { - Y_FAIL("Follower table replace subset isn't sticked to head"); + Y_FAIL("Follower table replace subset isn't sticked to head"); } - Y_VERIFY(newColdParts.empty(), "Unexpected cold part at a follower"); + Y_VERIFY(newColdParts.empty(), "Unexpected cold part at a follower"); Database->Replace(partSwitch.TableId, std::move(newParts), *subset); Database->ReplaceTxStatus(partSwitch.TableId, std::move(newTxStatus), *subset); for (auto &gone : subset->Flatten) DropCachesOfBundle(*gone); - Send(Owner->Tablet(), new TEvTablet::TEvFGcAck(Owner->TabletID(), Generation(), partSwitch.FollowerUpdateStep)); + Send(Owner->Tablet(), new TEvTablet::TEvFGcAck(Owner->TabletID(), Generation(), partSwitch.FollowerUpdateStep)); } else { for (auto &partView : newParts) { Database->Merge(partSwitch.TableId, partView); @@ -1396,13 +1396,13 @@ void TExecutor::ApplyExternalPartSwitch(TPendingPartSwitch &partSwitch) { } bool TExecutor::CanExecuteTransaction() const { - return Stats->IsActive && (Stats->IsFollower || PendingPartSwitches.empty()) && !BrokenTransaction; + return Stats->IsActive && (Stats->IsFollower || PendingPartSwitches.empty()) && !BrokenTransaction; } -void TExecutor::Execute(TAutoPtr<ITransaction> self, const TActorContext &ctx) { +void TExecutor::Execute(TAutoPtr<ITransaction> self, const TActorContext &ctx) { Y_VERIFY(ActivationQueue, "attempt to execute transaction before activation"); - TAutoPtr<TSeat> seat = new TSeat(++TransactionUniqCounter, self); + TAutoPtr<TSeat> seat = new TSeat(++TransactionUniqCounter, self); LWTRACK(TransactionBegin, seat->Self->Orbit, seat->UniqID, Owner->TabletID(), TypeName(*seat->Self)); @@ -1455,7 +1455,7 @@ void TExecutor::Execute(TAutoPtr<ITransaction> self, const TActorContext &ctx) { ExecuteTransaction(seat, ctx); } -void TExecutor::ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx) { +void TExecutor::ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx) { Y_VERIFY_DEBUG(!ActiveTransaction); ActiveTransaction = true; @@ -1474,7 +1474,7 @@ void TExecutor::ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ct LWTRACK(TransactionExecuteEnd, seat->Self->Orbit, seat->UniqID, done); seat->CPUExecTime += cpuTimer.PassedReset(); - if (done && !Stats->IsFollower) { /* possible rw commit */ + if (done && !Stats->IsFollower) { /* possible rw commit */ for (auto one: env.MakeSnap) Database->TxSnapTable(one.first /* table */); } @@ -1575,8 +1575,8 @@ void TExecutor::ReleaseTxData(TSeat &seat, ui64 requested, const TActorContext & Memory->ReleaseTxData(seat); } -void TExecutor::PostponeTransaction(TAutoPtr<TSeat> seat, TPageCollectionTxEnv &env, - TAutoPtr<NTable::TChange> change, +void TExecutor::PostponeTransaction(TAutoPtr<TSeat> seat, TPageCollectionTxEnv &env, + TAutoPtr<NTable::TChange> change, THPTimer &bookkeepingTimer, const TActorContext &ctx) { if (!env.ToLoad && !seat->RequestedMemory) { Y_Fail(NFmt::Do(*this) << " " << NFmt::Do(*seat) << " type " @@ -1754,8 +1754,8 @@ void TExecutor::PostponeTransaction(TAutoPtr<TSeat> seat, TPageCollectionTxEnv & Counters->Simple()[TExecutorCounters::CACHE_PINNED_LOAD] = PrivatePageCache->GetStats().PinnedLoadSize; } -void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv &env, - TAutoPtr<NTable::TChange> change, THPTimer &bookkeepingTimer, const TActorContext &ctx) { +void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv &env, + TAutoPtr<NTable::TChange> change, THPTimer &bookkeepingTimer, const TActorContext &ctx) { const bool isReadOnly = !(change->HasAny() || env.HasChanges()); const bool isTerminated = seat->TerminationReason != ETerminationReason::None; const TTxType txType = seat->Self->GetTxType(); @@ -1782,7 +1782,7 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv const double currentExecTime = seat->CPUExecTime; if (isTerminated) { - if (Stats->IsFollower) { + if (Stats->IsFollower) { --Stats->TxInFly; Counters->Simple()[TExecutorCounters::DB_TX_IN_FLY] = Stats->TxInFly; seat->Self->Terminate(seat->TerminationReason, OwnerCtx()); @@ -1791,7 +1791,7 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv Counters->Simple()[TExecutorCounters::DB_TX_IN_FLY] = Stats->TxInFly; } } else if (isReadOnly) { - if (Stats->IsFollower) { + if (Stats->IsFollower) { // todo: extract completion counters from txloglogic --Stats->TxInFly; Counters->Simple()[TExecutorCounters::DB_TX_IN_FLY] = Stats->TxInFly; @@ -1801,13 +1801,13 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv Counters->Simple()[TExecutorCounters::DB_TX_IN_FLY] = Stats->TxInFly; } } else { - Y_VERIFY(!Stats->IsFollower); + Y_VERIFY(!Stats->IsFollower); const bool allowBatching = Scheme().Executor.AllowLogBatching; const bool force = !allowBatching || change->Scheme - || change->Annex /* Required for replication to followers */ - || change->RemovedRowVersions /* Required for replication to followers */ + || change->Annex /* Required for replication to followers */ + || change->RemovedRowVersions /* Required for replication to followers */ || env.MakeSnap || env.DropSnap || env.LoanBundle @@ -1956,7 +1956,7 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv GcLogic->HoldBarrier(barrier->Step); } - NKikimrExecutorFlat::TFollowerPartSwitchAux aux; + NKikimrExecutorFlat::TFollowerPartSwitchAux aux; if (auto *snap = env.DropSnap.Get()) { auto result = snap->SnapContext->Impl->Release(); @@ -2198,7 +2198,7 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv } if (env.BorrowUpdates) { - commit->WaitFollowerGcAck = true; + commit->WaitFollowerGcAck = true; for (auto &borrowUpdate : env.BorrowUpdates) { BorrowLogic->UpdateBorrow( borrowUpdate.first, @@ -2212,7 +2212,7 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv } if (env.LoanConfirmation) { - commit->WaitFollowerGcAck = true; + commit->WaitFollowerGcAck = true; for (auto &xupd : env.LoanConfirmation) { BorrowLogic->ConfirmUpdateLoan( xupd.first, @@ -2246,14 +2246,14 @@ void TExecutor::CommitTransactionLog(TAutoPtr<TSeat> seat, TPageCollectionTxEnv } } - if (NeedFollowerSnapshot || LogicSnap->MayFlush(false)) + if (NeedFollowerSnapshot || LogicSnap->MayFlush(false)) MakeLogSnapshot(); CompactionLogic->UpdateLogUsage(LogicRedo->GrabLogUsage()); } - if (!Stats->IsFollower && HadFollowerAttached && env.Touches) { - NKikimrExecutorFlat::TFollowerAux proto; + if (!Stats->IsFollower && HadFollowerAttached && env.Touches) { + NKikimrExecutorFlat::TFollowerAux proto; proto.MutablePageCollectionsTouched()->Reserve(env.Touches.size()); for (auto &xpair : env.Touches) { auto *px = proto.AddPageCollectionsTouched(); @@ -2290,7 +2290,7 @@ void TExecutor::MakeLogSnapshot() { if (!LogicSnap->MayFlush(true) || PendingPartSwitches) return; - NeedFollowerSnapshot = false; + NeedFollowerSnapshot = false; THPTimer makeLogSnapTimer; LogicRedo->FlushBatchedLog(); @@ -2336,7 +2336,7 @@ void TExecutor::MakeLogSnapshot() { Database->EnumerateTableParts(tableId, std::move(dump)); - auto dumpCold = [&](const TIntrusiveConstPtr<NTable::TColdPart>& part) { + auto dumpCold = [&](const TIntrusiveConstPtr<NTable::TColdPart>& part) { ui32 level = state.State.PartLevels.Value(part->Label, 255); TPageCollectionProtoHelper::Snap(snap.AddDbParts(), part, tableId, level); @@ -2344,7 +2344,7 @@ void TExecutor::MakeLogSnapshot() { Database->EnumerateTableColdParts(tableId, std::move(dumpCold)); - auto dumpTxStatus = [&](const TIntrusiveConstPtr<NTable::TTxStatusPart>& part) { + auto dumpTxStatus = [&](const TIntrusiveConstPtr<NTable::TTxStatusPart>& part) { const auto* txStatus = dynamic_cast<const NTable::TTxStatusPartStore*>(part.Get()); Y_VERIFY(txStatus); auto* p = snap.AddTxStatusParts(); @@ -2405,7 +2405,7 @@ void TExecutor::Handle(TEvPrivate::TEvActivateExecution::TPtr &ev, const TActorC if (!CanExecuteTransaction()) return; - if (TAutoPtr<TSeat> seat = ActivationQueue->Pop()) { + if (TAutoPtr<TSeat> seat = ActivationQueue->Pop()) { Y_VERIFY(ActivateTransactionWaiting > 0); ActivateTransactionWaiting--; ExecuteTransaction(seat, ctx); @@ -2444,7 +2444,7 @@ void TExecutor::Handle(TEvents::TEvFlushLog::TPtr &ev) { void TExecutor::Handle(NSharedCache::TEvRequest::TPtr &ev) { const auto priority = ev->Get()->Priority; - TAutoPtr<NPageCollection::TFetch> msg = ev->Get()->Fetch; + TAutoPtr<NPageCollection::TFetch> msg = ev->Get()->Fetch; Y_VERIFY(msg->Pages, "empty page collection request, do not do it"); @@ -2649,7 +2649,7 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext case ECommit::Snap: LogicSnap->Confirm(msg->Step); - if (NeedFollowerSnapshot) + if (NeedFollowerSnapshot) MakeLogSnapshot(); break; @@ -2657,7 +2657,7 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext { auto it = InFlyCompactionGcBarriers.find(step); Y_VERIFY(it != InFlyCompactionGcBarriers.end()); - // just check, real barrier release on follower gc ack + // just check, real barrier release on follower gc ack } // any action on snapshot commit? @@ -2718,7 +2718,7 @@ void TExecutor::StartSeat(ui64 task, TResource *cookie_) noexcept auto *cookie = CheckedCast<TMemory::TCookie*>(cookie_); auto it = PostponedTransactions.find(cookie->Seat); Y_VERIFY(it != PostponedTransactions.end()); - TAutoPtr<TSeat> seat = std::move(it->second); + TAutoPtr<TSeat> seat = std::move(it->second); PostponedTransactions.erase(it); Memory->AcquiredMemory(*seat, task); LWTRACK(TransactionEnqueued, seat->Self->Orbit, seat->UniqID); @@ -2738,11 +2738,11 @@ THolder<TScanSnapshot> TExecutor::PrepareScanSnapshot(ui32 table, const NTable:: LogicRedo->MakeLogEntry(*commit, std::move(redo), { table }, true); } - TIntrusivePtr<TBarrier> barrier = new TBarrier(commit->Step); + TIntrusivePtr<TBarrier> barrier = new TBarrier(commit->Step); CommitManager->Commit(commit); - TAutoPtr<NTable::TSubset> subset; + TAutoPtr<NTable::TSubset> subset; if (params) { subset = Database->Subset(table, { }, params->Edge.Head); @@ -2887,7 +2887,7 @@ void TExecutor::UtilizeSubset(const NTable::TSubset &subset, Counters->Cumulative()[TExecutorCounters::DB_ELOBS_ITEMS_GONE].Increment(seen.Total - seen.Seen); } -void TExecutor::ReleaseScanLocks(TIntrusivePtr<TBarrier> barrier, const NTable::TSubset &subset) +void TExecutor::ReleaseScanLocks(TIntrusivePtr<TBarrier> barrier, const NTable::TSubset &subset) { CheckCollectionBarrier(barrier); @@ -2931,7 +2931,7 @@ void TExecutor::Handle(NOps::TEvResult *ops, TProdCompact *msg, bool cancelled) const bool abandoned = cancelled || !Scheme().GetTableInfo(tableId); TProdCompact::TResults results = std::move(msg->Results); - TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> newTxStatus = std::move(msg->TxStatus); + TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> newTxStatus = std::move(msg->TxStatus); if (auto logl = Logger->Log(msg->Success ? ELnLev::Info : ELnLev::Error)) { logl @@ -2976,11 +2976,11 @@ void TExecutor::Handle(NOps::TEvResult *ops, TProdCompact *msg, bool cancelled) NKikimrExecutorFlat::TTablePartSwitch proto; proto.SetTableId(tableId); - NKikimrExecutorFlat::TFollowerPartSwitchAux aux; + NKikimrExecutorFlat::TFollowerPartSwitchAux aux; auto commit = CommitManager->Begin(true, ECommit::Data); - commit->WaitFollowerGcAck = true; + commit->WaitFollowerGcAck = true; const bool hadFrozen = bool(ops->Subset->Frozen); if (ops->Subset->Head > NTable::TEpoch::Zero()) { @@ -3235,7 +3235,7 @@ void TExecutor::UpdateCounters(const TActorContext &ctx) { const auto& dbCounters = Database->Counters(); - { /* Memory consumption of common for leader and follower components */ + { /* Memory consumption of common for leader and follower components */ Counters->Simple()[TExecutorCounters::DB_WARM_BYTES].Set(dbCounters.MemTableBytes); Counters->Simple()[TExecutorCounters::DB_META_BYTES].Set(Stats->PacksMetaBytes); Counters->Simple()[TExecutorCounters::DB_INDEX_BYTES].Set(dbCounters.Parts.IndexBytes); @@ -3247,7 +3247,7 @@ void TExecutor::UpdateCounters(const TActorContext &ctx) { Counters->Simple()[TExecutorCounters::USED_TABLET_MEMORY].Set(UsedTabletMemory); } - if (CommitManager) /* exists only on leader, mostly storage usage data */ { + if (CommitManager) /* exists only on leader, mostly storage usage data */ { auto redo = LogicRedo->LogStats(); Counters->Simple()[TExecutorCounters::LOG_REDO_COUNT].Set(redo.Items); Counters->Simple()[TExecutorCounters::LOG_REDO_MEMORY].Set(redo.Memory); @@ -3317,7 +3317,7 @@ void TExecutor::UpdateCounters(const TActorContext &ctx) { executorCounters = Counters->MakeDiffForAggr(*CountersBaseline); Counters->RememberCurrentStateAsBaseline(*CountersBaseline); - if (ResourceMetrics && !Stats->IsFollower) { + if (ResourceMetrics && !Stats->IsFollower) { // N.B. DB_UNIQUE_OUTER_BYTES is already part of DB_UNIQUE_DATA_BYTES, due to how BackingSize works // We also include DB_UNIQUE_KEEP_BYTES as unreferenced data that cannot be deleted ui64 storageSize = Counters->Simple()[TExecutorCounters::DB_UNIQUE_DATA_BYTES].Get() @@ -3344,7 +3344,7 @@ void TExecutor::UpdateCounters(const TActorContext &ctx) { auto tabletType = Owner->TabletType(); auto tenantPathId = Owner->Info()->TenantPathId; - TActorId countersAggregator = MakeTabletCountersAggregatorID(SelfId().NodeId(), Stats->IsFollower); + TActorId countersAggregator = MakeTabletCountersAggregatorID(SelfId().NodeId(), Stats->IsFollower); Send(countersAggregator, new TEvTabletCounters::TEvTabletAddCounters( CounterEventsInFlight, tabletId, tabletType, tenantPathId, executorCounters, externalTabletCounters)); @@ -3361,8 +3361,8 @@ float TExecutor::GetRejectProbability() const { if (Stats->TxInFly > 10000) return 1.0; - // Followers do not control compaction so let's always allow to read the data from follower - if (Stats->IsFollower) + // Followers do not control compaction so let's always allow to read the data from follower + if (Stats->IsFollower) return 0.0; auto sigmoid = [](float x) -> float { @@ -3451,7 +3451,7 @@ void TExecutor::DropScanSnapshot(ui64 snap) } } -ui64 TExecutor::QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options) +ui64 TExecutor::QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options) { THolder<TScanSnapshot> snapshot; @@ -3494,14 +3494,14 @@ bool TExecutor::CancelScan(ui32, ui64 serial) { return false; } -TFinishedCompactionInfo TExecutor::GetFinishedCompactionInfo(ui32 tableId) const { +TFinishedCompactionInfo TExecutor::GetFinishedCompactionInfo(ui32 tableId) const { if (CompactionLogic) { - return CompactionLogic->GetFinishedCompactionInfo(tableId); - } else { - return TFinishedCompactionInfo(); - } -} - + return CompactionLogic->GetFinishedCompactionInfo(tableId); + } else { + return TFinishedCompactionInfo(); + } +} + ui64 TExecutor::CompactBorrowed(ui32 tableId) { if (CompactionLogic) { return CompactionLogic->PrepareForceCompaction(tableId, EForceCompaction::Borrowed); @@ -3518,11 +3518,11 @@ ui64 TExecutor::CompactMemTable(ui32 tableId) { } } -ui64 TExecutor::CompactTable(ui32 tableId) { - if (CompactionLogic) { +ui64 TExecutor::CompactTable(ui32 tableId) { + if (CompactionLogic) { return CompactionLogic->PrepareForceCompaction(tableId); } else { - return 0; + return 0; } } @@ -3543,7 +3543,7 @@ STFUNC(TExecutor::StateInit) { STFUNC(TExecutor::StateBoot) { Y_VERIFY(BootLogic); switch (ev->GetTypeRewrite()) { - // N.B. must work during follower promotion to leader + // N.B. must work during follower promotion to leader HFunc(TEvPrivate::TEvActivateExecution, Handle); HFunc(TEvPrivate::TEvBrokenTransaction, Handle); HFunc(TEvents::TEvWakeup, Wakeup); @@ -3582,7 +3582,7 @@ STFUNC(TExecutor::StateWork) { TranslateCacheTouchesToSharedCache(); } -STFUNC(TExecutor::StateFollower) { +STFUNC(TExecutor::StateFollower) { Y_UNUSED(ctx); switch (ev->GetTypeRewrite()) { HFunc(TEvPrivate::TEvActivateExecution, Handle); @@ -3603,7 +3603,7 @@ STFUNC(TExecutor::StateFollower) { TranslateCacheTouchesToSharedCache(); } -STFUNC(TExecutor::StateFollowerBoot) { +STFUNC(TExecutor::StateFollowerBoot) { Y_VERIFY(BootLogic); switch (ev->GetTypeRewrite()) { // N.B. must handle activities started before resync @@ -3612,7 +3612,7 @@ STFUNC(TExecutor::StateFollowerBoot) { HFunc(TEvents::TEvWakeup, Wakeup); hFunc(TEvResourceBroker::TEvResourceAllocated, Handle); default: - return TranscriptFollowerBootOpResult(BootLogic->Receive(*ev), ctx); + return TranscriptFollowerBootOpResult(BootLogic->Receive(*ev), ctx); } } @@ -3705,7 +3705,7 @@ void TExecutor::RenderHtmlPage(NMon::TEvRemoteHttpInfo::TPtr &ev) const { if (auto *logic = BootLogic.Get()) { DIV_CLASS("row") {str << NFmt::Do(*logic); } } else if (auto *dbase = Database.Get()) { - if (CommitManager) /* Leader tablet, commit manager owner */ { + if (CommitManager) /* Leader tablet, commit manager owner */ { DIV_CLASS("row") { str << NFmt::Do(*CommitManager); } DIV_CLASS("row") { str << NFmt::Do(LogicSnap->Waste(), true);} DIV_CLASS("row") { str << NFmt::Do(*LogicSnap); } @@ -3834,17 +3834,17 @@ void TExecutor::UpdateConfig(TEvTablet::TEvUpdateConfig::TPtr &ev) { ReadResourceProfile(); } -void TExecutor::SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) { - Y_VERIFY(Stats->IsActive && !Stats->IsFollower); - - NKikimrExecutorFlat::TFollowerAux proto; - proto.SetUserAuxUpdate(std::move(upd)); - +void TExecutor::SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) { + Y_VERIFY(Stats->IsActive && !Stats->IsFollower); + + NKikimrExecutorFlat::TFollowerAux proto; + proto.SetUserAuxUpdate(std::move(upd)); + auto coded = NPageCollection::TSlicer::Lz4()->Encode(proto.SerializeAsString()); - - ctx.Send(Owner->Tablet(), new TEvTablet::TEvAux(std::move(coded))); -} - + + ctx.Send(Owner->Tablet(), new TEvTablet::TEvAux(std::move(coded))); +} + NMetrics::TResourceMetrics* TExecutor::GetResourceMetrics() const { return ResourceMetrics.Get(); } @@ -3865,7 +3865,7 @@ TString TExecutor::CheckBorrowConsistency() { knownBundles.insert(partView->Label); }); Database->EnumerateTableColdParts(tableId, - [&](const TIntrusiveConstPtr<NTable::TColdPart>& part) { + [&](const TIntrusiveConstPtr<NTable::TColdPart>& part) { knownBundles.insert(part->Label); }); } @@ -3891,7 +3891,7 @@ const NTable::TScheme& TExecutor::DatabaseScheme() return Scheme(); } -TIntrusiveConstPtr<NTable::TRowScheme> TExecutor::RowScheme(ui32 table) +TIntrusiveConstPtr<NTable::TRowScheme> TExecutor::RowScheme(ui32 table) { return Database->GetRowScheme(table); } @@ -3922,7 +3922,7 @@ TVector<NTable::TPartView> TExecutor::TableParts(ui32 table) return Database->GetTableParts(table); } -TVector<TIntrusiveConstPtr<NTable::TColdPart>> TExecutor::TableColdParts(ui32 table) +TVector<TIntrusiveConstPtr<NTable::TColdPart>> TExecutor::TableColdParts(ui32 table) { return Database->GetTableColdParts(table); } @@ -3945,7 +3945,7 @@ ui64 TExecutor::BeginCompaction(THolder<NTable::TCompactionParams> params) const ECache cache = params->KeepInCache ? ECache::Once : ECache::None; - TAutoPtr<TCompactCfg> comp = new TCompactCfg(std::move(params)); + TAutoPtr<TCompactCfg> comp = new TCompactCfg(std::move(params)); comp->Epoch = snapshot->Subset->Epoch(); /* narrows requested to actual */ comp->Layout.Final = comp->Params->IsFinal; diff --git a/ydb/core/tablet_flat/flat_executor.h b/ydb/core/tablet_flat/flat_executor.h index 7a2259f0867..df08b3a338a 100644 --- a/ydb/core/tablet_flat/flat_executor.h +++ b/ydb/core/tablet_flat/flat_executor.h @@ -146,7 +146,7 @@ struct TPendingPartSwitch { }; struct TTxStatusLoadStage { - TIntrusiveConstPtr<NTable::TTxStatusPart> TxStatus; + TIntrusiveConstPtr<NTable::TTxStatusPart> TxStatus; std::optional<TLargeGlobLoader> Loader; NTable::TEpoch Epoch; @@ -177,9 +177,9 @@ struct TPendingPartSwitch { }; struct TTxStatusResultStage { - TIntrusiveConstPtr<NTable::TTxStatusPart> TxStatus; + TIntrusiveConstPtr<NTable::TTxStatusPart> TxStatus; - explicit TTxStatusResultStage(TIntrusiveConstPtr<NTable::TTxStatusPart> txStatus) + explicit TTxStatusResultStage(TIntrusiveConstPtr<NTable::TTxStatusPart> txStatus) : TxStatus(std::move(txStatus)) { } }; @@ -256,7 +256,7 @@ struct TPendingPartSwitch { TList<TNewBundle> NewBundles; TList<TNewTxStatus> NewTxStatus; - TVector<TIntrusiveConstPtr<NTable::TColdPart>> NewColdParts; + TVector<TIntrusiveConstPtr<NTable::TColdPart>> NewColdParts; TPendingBlobs PendingBlobs; size_t PendingLoads = 0; @@ -267,7 +267,7 @@ struct TPendingPartSwitch { TVector<TBundleMove> Moves; NTable::TEpoch Head = NTable::TEpoch::Zero(); - ui32 FollowerUpdateStep = 0; + ui32 FollowerUpdateStep = 0; bool AddPendingBlob(const TLogoBlobID& id, TBlobWaiter waiter) { TPendingBlobs::insert_ctx ctx; @@ -349,12 +349,12 @@ class TExecutor struct TEvBrokenTransaction : public TEventLocal<TEvBrokenTransaction, EvBrokenTransaction> {}; }; - const TIntrusivePtr<ITimeProvider> Time = nullptr; + const TIntrusivePtr<ITimeProvider> Time = nullptr; NFlatExecutorSetup::ITablet * Owner; const TActorId OwnerActorId; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; - ui32 FollowerId = 0; + ui32 FollowerId = 0; using TActivationQueue = TOneOneQueueInplace<TSeat *, 64>; THolder<TActivationQueue, TActivationQueue::TPtrCleanDestructor> ActivationQueue; @@ -376,8 +376,8 @@ class TExecutor using TWaitingSnaps = THashMap<TTableSnapshotContext *, TIntrusivePtr<TTableSnapshotContext>>; - const TIntrusivePtr<TIdEmitter> Emitter; - TAutoPtr<TBroker> Broker; + const TIntrusivePtr<TIdEmitter> Emitter; + TAutoPtr<TBroker> Broker; TWaitingSnaps WaitingSnapshots; @@ -389,14 +389,14 @@ class TExecutor THolder<TTabletCountersBase> AppCountersBaseline; THolder<NMetrics::TResourceMetrics> ResourceMetrics; - TAutoPtr<NTable::TDatabase> Database; + TAutoPtr<NTable::TDatabase> Database; - TAutoPtr<TCommitManager> CommitManager; - TAutoPtr<TScans> Scans; - TAutoPtr<TMemory> Memory; - TAutoPtr<TLogicSnap> LogicSnap; - TAutoPtr<TLogicRedo> LogicRedo; - TAutoPtr<TLogicAlter> LogicAlter; + TAutoPtr<TCommitManager> CommitManager; + TAutoPtr<TScans> Scans; + TAutoPtr<TMemory> Memory; + TAutoPtr<TLogicSnap> LogicSnap; + TAutoPtr<TLogicRedo> LogicRedo; + TAutoPtr<TLogicAlter> LogicAlter; THolder<TExecutorGCLogic> GcLogic; THolder<TCompactionLogic> CompactionLogic; THolder<TExecutorBorrowLogic> BorrowLogic; @@ -417,16 +417,16 @@ class TExecutor ui64 CompactionReadUniqCounter = 0; bool LogBatchFlushScheduled = false; - bool HadFollowerAttached = false; - bool NeedFollowerSnapshot = false; + bool HadFollowerAttached = false; + bool NeedFollowerSnapshot = false; TCacheCacheConfig::TCounterPtr CounterCacheFresh; TCacheCacheConfig::TCounterPtr CounterCacheMemTable; TCacheCacheConfig::TCounterPtr CounterCacheStaging; - THashMap<ui32, TIntrusivePtr<TBarrier>> InFlyCompactionGcBarriers; - TDeque<THolder<TEvTablet::TFUpdateBody>> PostponedFollowerUpdates; - THashMap<ui32, TVector<TIntrusivePtr<TBarrier>>> InFlySnapCollectionBarriers; + THashMap<ui32, TIntrusivePtr<TBarrier>> InFlyCompactionGcBarriers; + TDeque<THolder<TEvTablet::TFUpdateBody>> PostponedFollowerUpdates; + THashMap<ui32, TVector<TIntrusivePtr<TBarrier>>> InFlySnapCollectionBarriers; THolder<TExecutorStatsImpl> Stats; bool HasYellowCheckInFly = false; @@ -445,13 +445,13 @@ class TExecutor void PassAway() override; void Broken(); void Active(const TActorContext &ctx); - void ActivateFollower(const TActorContext &ctx); + void ActivateFollower(const TActorContext &ctx); void RecreatePageCollectionsCache() noexcept; void ReflectSchemeSettings() noexcept; void OnYellowChannels(TVector<ui32> yellowMoveChannels, TVector<ui32> yellowStopChannels) override; void CheckYellow(TVector<ui32> &&yellowMoveChannels, TVector<ui32> &&yellowStopChannels, bool terminal = false); void SendReassignYellowChannels(const TVector<ui32> &yellowChannels); - void CheckCollectionBarrier(TIntrusivePtr<TBarrier> &barrier); + void CheckCollectionBarrier(TIntrusivePtr<TBarrier> &barrier); void UtilizeSubset(const NTable::TSubset&, const NTable::NFwd::TSeen&, THashSet<TLogoBlobID> reusedBundles, TLogCommit *commit); bool PrepareExternalPart(TPendingPartSwitch &partSwitch, NTable::TPartComponents &&pc); @@ -466,13 +466,13 @@ class TExecutor bool CanExecuteTransaction() const; void TranscriptBootOpResult(ui32 res, const TActorContext &ctx); - void TranscriptFollowerBootOpResult(ui32 res, const TActorContext &ctx); + void TranscriptFollowerBootOpResult(ui32 res, const TActorContext &ctx); void ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx); - void CommitTransactionLog(TAutoPtr<TSeat>, TPageCollectionTxEnv&, TAutoPtr<NTable::TChange>, + void CommitTransactionLog(TAutoPtr<TSeat>, TPageCollectionTxEnv&, TAutoPtr<NTable::TChange>, THPTimer &bookkeepingTimer, const TActorContext &ctx); void UnpinTransactionPages(TSeat &seat); void ReleaseTxData(TSeat &seat, ui64 requested, const TActorContext &ctx); - void PostponeTransaction(TAutoPtr<TSeat>, TPageCollectionTxEnv&, TAutoPtr<NTable::TChange>, THPTimer &bookkeepingTimer, const TActorContext &ctx); + void PostponeTransaction(TAutoPtr<TSeat>, TPageCollectionTxEnv&, TAutoPtr<NTable::TChange>, THPTimer &bookkeepingTimer, const TActorContext &ctx); void PlanTransactionActivation(); void MakeLogSnapshot(); void ActivateWaitingTransactions(TPrivatePageCache::TPage::TWaitQueuePtr waitPadsQueue); @@ -484,21 +484,21 @@ class TExecutor void TranslateCacheTouchesToSharedCache(); void RequestInMemPagesForDatabase(); void RequestInMemPagesForPartStore(ui32 tableId, const NTable::TPartView &partView); - void RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch, + void RequestFromSharedCache(TAutoPtr<NPageCollection::TFetch> fetch, NBlockIO::EPriority way, EPageCollectionRequest requestCategory); THolder<TScanSnapshot> PrepareScanSnapshot(ui32 table, const NTable::TCompactionParams* params, TRowVersion snapshot = TRowVersion::Max()); - void ReleaseScanLocks(TIntrusivePtr<TBarrier>, const NTable::TSubset&); + void ReleaseScanLocks(TIntrusivePtr<TBarrier>, const NTable::TSubset&); void StartScan(ui64 serial, ui32 table) noexcept; void StartScan(ui64 task, TResource*) noexcept; void StartSeat(ui64 task, TResource*) noexcept; void PostponedScanCleared(NResourceBroker::TEvResourceBroker::TEvResourceAllocated *msg, const TActorContext &ctx); - void ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update); - void ApplyFollowerAuxUpdate(const TString &auxBody); - void ApplyFollowerPostponedUpdates(); - void AddFollowerPartSwitch(const NKikimrExecutorFlat::TTablePartSwitch &switchProto, - const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux, ui32 updateStep, ui32 step); + void ApplyFollowerUpdate(THolder<TEvTablet::TFUpdateBody> update); + void ApplyFollowerAuxUpdate(const TString &auxBody); + void ApplyFollowerPostponedUpdates(); + void AddFollowerPartSwitch(const NKikimrExecutorFlat::TTablePartSwitch &switchProto, + const NKikimrExecutorFlat::TFollowerPartSwitchAux::TBySwitch *aux, ui32 updateStep, ui32 step); void ApplyExternalPartSwitch(TPendingPartSwitch &partSwitch); void Wakeup(TEvents::TEvWakeup::TPtr &ev, const TActorContext &ctx); @@ -530,12 +530,12 @@ class TExecutor ui64 OwnerTabletId() const override; const NTable::TScheme& DatabaseScheme() override; - TIntrusiveConstPtr<NTable::TRowScheme> RowScheme(ui32 table) override; + TIntrusiveConstPtr<NTable::TRowScheme> RowScheme(ui32 table) override; const NTable::TScheme::TTableInfo* TableScheme(ui32 table) override; ui64 TableMemSize(ui32 table, NTable::TEpoch epoch) override; NTable::TPartView TablePart(ui32 table, const TLogoBlobID& label) override; TVector<NTable::TPartView> TableParts(ui32 table) override; - TVector<TIntrusiveConstPtr<NTable::TColdPart>> TableColdParts(ui32 table) override; + TVector<TIntrusiveConstPtr<NTable::TColdPart>> TableColdParts(ui32 table) override; const NTable::TRowVersionRanges& TableRemovedRowVersions(ui32 table) override; ui64 BeginCompaction(THolder<NTable::TCompactionParams> params) override; bool CancelCompaction(ui64 compactionId) override; @@ -564,7 +564,7 @@ public: void Describe(IOutputStream &out) const noexcept override { out - << (Stats->IsFollower ? "Follower" : "Leader") + << (Stats->IsFollower ? "Follower" : "Leader") << "{" << Owner->TabletID() << ":" << Generation() << ":" << Step() << "}"; } @@ -573,27 +573,27 @@ public: void Boot(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx) override; void Restored(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx) override; void DetachTablet(const TActorContext &ctx) override; - void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) override; + void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) override; TString BorrowSnapshot(ui32 tableId, const TTableSnapshotContext& snap, TRawVals from, TRawVals to, ui64 loaner) const override; ui64 MakeScanSnapshot(ui32 table) override; void DropScanSnapshot(ui64 snapId) override; - ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options) override; + ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options) override; bool CancelScan(ui32 tableId, ui64 taskId) override; - - TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 tableId) const override; + + TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 tableId) const override; ui64 CompactBorrowed(ui32 tableId) override; ui64 CompactMemTable(ui32 tableId) override; - ui64 CompactTable(ui32 tableId) override; + ui64 CompactTable(ui32 tableId) override; bool CompactTables() override; - void FollowerAttached() override; - void FollowerSyncComplete() override; - void FollowerGcApplied(ui32 step, TDuration followerSyncDelay) override; - void FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) override; - void FollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) override; - void FollowerAuxUpdate(TString upd) override; + void FollowerAttached() override; + void FollowerSyncComplete() override; + void FollowerGcApplied(ui32 step, TDuration followerSyncDelay) override; + void FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) override; + void FollowerUpdate(THolder<TEvTablet::TFUpdateBody> update) override; + void FollowerAuxUpdate(TString upd) override; void RenderHtmlPage(NMon::TEvRemoteHttpInfo::TPtr &ev) const override; void RenderHtmlCounters(NMon::TEvRemoteHttpInfo::TPtr &ev) const override; @@ -602,8 +602,8 @@ public: void UpdateConfig(TEvTablet::TEvUpdateConfig::TPtr &ev) override; - void SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) override; - + void SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) override; + THashMap<TLogoBlobID, TVector<ui64>> GetBorrowedParts() const override; const TExecutorStats& GetStats() const override; @@ -621,8 +621,8 @@ public: STFUNC(StateInit); STFUNC(StateBoot); STFUNC(StateWork); - STFUNC(StateFollowerBoot); - STFUNC(StateFollower); + STFUNC(StateFollowerBoot); + STFUNC(StateFollower); // database interface const NTable::TScheme& Scheme() const noexcept override; diff --git a/ydb/core/tablet_flat/flat_executor.proto b/ydb/core/tablet_flat/flat_executor.proto index 43e9d642251..77588121870 100644 --- a/ydb/core/tablet_flat/flat_executor.proto +++ b/ydb/core/tablet_flat/flat_executor.proto @@ -163,8 +163,8 @@ message TCompactionState { message TRowVersionState { message TRemovedRange { - optional NKikimrProto.TRowVersion Lower = 1; - optional NKikimrProto.TRowVersion Upper = 2; + optional NKikimrProto.TRowVersion Lower = 1; + optional NKikimrProto.TRowVersion Upper = 2; } optional uint32 Table = 1; @@ -214,7 +214,7 @@ message TExternalGcEntry { repeated NKikimrProto.TLogoBlobID GcLeft = 2; } -message TFollowerPartSwitchAux { +message TFollowerPartSwitchAux { message TBySwitch { optional NKikimrProto.TLogoBlobID PartSwitchRef = 1; repeated TBundle HotBundles = 2; @@ -224,15 +224,15 @@ message TFollowerPartSwitchAux { repeated TBySwitch BySwitchAux = 1; } -message TFollowerAux { +message TFollowerAux { message TTouchByPageCollection { optional NKikimrProto.TLogoBlobID MetaInfoId = 1; repeated uint32 TouchedPages = 2; } repeated TTouchByPageCollection PageCollectionsTouched = 1; - - optional bytes UserAuxUpdate = 2; + + optional bytes UserAuxUpdate = 2; } message TDatabaseBorrowPart { diff --git a/ydb/core/tablet_flat/flat_executor_bootlogic.cpp b/ydb/core/tablet_flat/flat_executor_bootlogic.cpp index f5d143428d8..cf72960f9c4 100644 --- a/ydb/core/tablet_flat/flat_executor_bootlogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_bootlogic.cpp @@ -56,11 +56,11 @@ void TExecutorBootLogic::Describe(IOutputStream &out) const noexcept return Steps->Describe(out); } -TExecutorBootLogic::EOpResult TExecutorBootLogic::ReceiveFollowerBoot( - TEvTablet::TEvFBoot::TPtr &ev, +TExecutorBootLogic::EOpResult TExecutorBootLogic::ReceiveFollowerBoot( + TEvTablet::TEvFBoot::TPtr &ev, TExecutorCaches &&caches) { - TEvTablet::TEvFBoot *msg = ev->Get(); + TEvTablet::TEvFBoot *msg = ev->Get(); PrepareEnv(true, msg->Generation, std::move(caches)); if (msg->DependencyGraph) { @@ -68,11 +68,11 @@ TExecutorBootLogic::EOpResult TExecutorBootLogic::ReceiveFollowerBoot( } else { auto *update = msg->Update.Get(); Y_VERIFY(update->IsSnapshot); - Y_VERIFY(!update->NeedFollowerGcAck); + Y_VERIFY(!update->NeedFollowerGcAck); if (auto logl = Steps->Logger()->Log(ELnLev::Debug)) logl - << NFmt::Do(State()) << " start follower from log" + << NFmt::Do(State()) << " start follower from log" << " snapshot " << State().Generation << ":" << update->Step; TString body; @@ -120,10 +120,10 @@ void TExecutorBootLogic::PrepareEnv(bool follower, ui32 gen, TExecutorCaches cac LoadBlobQueue.Config.TabletID = Info->TabletID; LoadBlobQueue.Config.Generation = gen; - LoadBlobQueue.Config.Follower = follower; + LoadBlobQueue.Config.Follower = follower; LoadBlobQueue.Config.NoDataCounter = GetServiceCounters(AppData()->Counters, "tablets")->GetCounter("alerts_boot_nodata", true); - State_ = new NBoot::TBack(follower, Info->TabletID, gen); + State_ = new NBoot::TBack(follower, Info->TabletID, gen); State().Scheme = new NTable::TScheme; State().PageCaches = std::move(caches.PageCaches); State().TxStatusCaches = std::move(caches.TxStatusCaches); @@ -132,7 +132,7 @@ void TExecutorBootLogic::PrepareEnv(bool follower, ui32 gen, TExecutorCaches cac Result_ = new NBoot::TResult; - if (follower) { + if (follower) { /* Required for TLargeGlobId-less TPart data (Evolution < 12) */ Result().Loans = new TExecutorBorrowLogic(nullptr); @@ -149,7 +149,7 @@ void TExecutorBootLogic::PrepareEnv(bool follower, ui32 gen, TExecutorCaches cac } } -void TExecutorBootLogic::LoadEntry(TIntrusivePtr<NBoot::TLoadBlobs> entry) { +void TExecutorBootLogic::LoadEntry(TIntrusivePtr<NBoot::TLoadBlobs> entry) { if (auto logl = Steps->Logger()->Log(ELnLev::Debug)) { logl << NFmt::Do(State()) << " Loading " << NFmt::Do(entry->LargeGlobId); @@ -168,7 +168,7 @@ void TExecutorBootLogic::LoadEntry(TIntrusivePtr<NBoot::TLoadBlobs> entry) { } } -NBoot::TSpawned TExecutorBootLogic::LoadPages(NBoot::IStep *step, TAutoPtr<NPageCollection::TFetch> req) { +NBoot::TSpawned TExecutorBootLogic::LoadPages(NBoot::IStep *step, TAutoPtr<NPageCollection::TFetch> req) { auto success = Loads.insert(std::make_pair(req->PageCollection.Get(), step)).second; Y_VERIFY(success, "IPageCollection queued twice for loading"); @@ -212,7 +212,7 @@ TExecutorBootLogic::EOpResult TExecutorBootLogic::CheckCompletion() if (Loads) return OpResultContinue; - if (State().Follower || Restored) { + if (State().Follower || Restored) { if (auto logl = Steps->Logger()->Log(ELnLev::Info)) { auto spent = TAppData::TimeProvider->Now() - BootStartTime; @@ -293,10 +293,10 @@ TAutoPtr<NBoot::TResult> TExecutorBootLogic::ExtractState() noexcept { void TExecutorBootLogic::Cancel() { } -void TExecutorBootLogic::FollowersSyncComplete() { +void TExecutorBootLogic::FollowersSyncComplete() { Y_VERIFY(Result_); Y_VERIFY(Result().GcLogic); - Result().GcLogic->FollowersSyncComplete(true); + Result().GcLogic->FollowersSyncComplete(true); } TExecutorCaches TExecutorBootLogic::DetachCaches() { diff --git a/ydb/core/tablet_flat/flat_executor_bootlogic.h b/ydb/core/tablet_flat/flat_executor_bootlogic.h index 91a9288e497..34edb2d6b40 100644 --- a/ydb/core/tablet_flat/flat_executor_bootlogic.h +++ b/ydb/core/tablet_flat/flat_executor_bootlogic.h @@ -26,14 +26,14 @@ namespace NBoot { struct TBack; struct TResult { - TAutoPtr<NTable::TDatabase> Database; - TAutoPtr<TCommitManager> CommitManager; - TAutoPtr<TLogicSnap> Snap; - TAutoPtr<TLogicRedo> Redo; - TAutoPtr<TExecutorGCLogic> GcLogic; - TAutoPtr<TLogicAlter> Alter; - TAutoPtr<TCompactionLogicState> Comp; - TAutoPtr<TExecutorBorrowLogic> Loans; + TAutoPtr<NTable::TDatabase> Database; + TAutoPtr<TCommitManager> CommitManager; + TAutoPtr<TLogicSnap> Snap; + TAutoPtr<TLogicRedo> Redo; + TAutoPtr<TExecutorGCLogic> GcLogic; + TAutoPtr<TLogicAlter> Alter; + TAutoPtr<TCompactionLogicState> Comp; + TAutoPtr<TExecutorBorrowLogic> Loans; THashMap<ui32, NTable::TRowVersionRanges> RemovedRowVersions; TVector<TIntrusivePtr<TPrivatePageCache::TInfo>> PageCaches; @@ -77,11 +77,11 @@ private: TInstant BootStartTime; - const TIntrusiveConstPtr<TTabletStorageInfo> Info; + const TIntrusiveConstPtr<TTabletStorageInfo> Info; TLoadBlobQueue LoadBlobQueue; - THashMap<TLogoBlobID, TIntrusivePtr<NBoot::TLoadBlobs>> EntriesToLoad; + THashMap<TLogoBlobID, TIntrusivePtr<NBoot::TLoadBlobs>> EntriesToLoad; THashMap<const NPageCollection::IPageCollection*, TIntrusivePtr<NBoot::IStep>> Loads; ui32 GroupResolveCachedChannel; @@ -93,8 +93,8 @@ private: void PrepareEnv(bool follower, ui32 generation, TExecutorCaches caches) noexcept; ui32 GetBSGroupFor(const TLogoBlobID &logo) const; ui32 GetBSGroupID(ui32 channel, ui32 generation); - void LoadEntry(TIntrusivePtr<NBoot::TLoadBlobs>); - NBoot::TSpawned LoadPages(NBoot::IStep*, TAutoPtr<NPageCollection::TFetch> req); + void LoadEntry(TIntrusivePtr<NBoot::TLoadBlobs>); + NBoot::TSpawned LoadPages(NBoot::IStep*, TAutoPtr<NPageCollection::TFetch> req); void OnBlobLoaded(const TLogoBlobID& id, TString body, uintptr_t cookie) override; @@ -111,7 +111,7 @@ public: EOpResult ReceiveRestored(TEvTablet::TEvRestored::TPtr &ev); EOpResult Receive(::NActors::IEventHandle&); - void FollowersSyncComplete(); + void FollowersSyncComplete(); void Cancel(); TAutoPtr<NBoot::TResult> ExtractState() noexcept; diff --git a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp index 4cfda75e500..bd52264b10e 100644 --- a/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_borrowlogic.cpp @@ -105,7 +105,7 @@ bool TExecutorBorrowLogic::BundlePartiallyCompacted( } } - Y_VERIFY(commit->WaitFollowerGcAck); + Y_VERIFY(commit->WaitFollowerGcAck); if (haveChanges) { StoreBorrowProto(metaId, *info, commit); @@ -147,7 +147,7 @@ bool TExecutorBorrowLogic::BundleCompacted( } CheckLoanCompletion(metaId, *info, commit->Step); - Y_VERIFY(commit->WaitFollowerGcAck); + Y_VERIFY(commit->WaitFollowerGcAck); // must be loaned or borrowed (otherwise would be not on list) // in this case - changes must be propagated to lender before cleanup @@ -209,7 +209,7 @@ bool TExecutorBorrowLogic::BundleCompacted( } CheckLoanCompletion(bundleId, *info, commit->Step); - Y_VERIFY(commit->WaitFollowerGcAck); + Y_VERIFY(commit->WaitFollowerGcAck); // must be loaned or borrowed (otherwise would be not on list) // in this case - changes must be propagated to lender before cleanup @@ -403,7 +403,7 @@ void TExecutorBorrowLogic::UpdateBorrow( // if not local - must be loaned CheckLoanCompletion(metaInfoId, storedInfo, commit->Step); StoreBorrowProto(metaInfoId, storedInfo, commit); - Y_VERIFY(commit->WaitFollowerGcAck); + Y_VERIFY(commit->WaitFollowerGcAck); } } @@ -442,7 +442,7 @@ void TExecutorBorrowLogic::ConfirmUpdateLoan( HasFlag = !BorrowedInfo.empty(); } -void TExecutorBorrowLogic::RestoreFollowerBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto) { +void TExecutorBorrowLogic::RestoreFollowerBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto) { Y_UNUSED(blobId); const TLogoBlobID metaInfoId = LogoBlobIDFromLogoBlobID(proto.GetMetaId()); diff --git a/ydb/core/tablet_flat/flat_executor_borrowlogic.h b/ydb/core/tablet_flat/flat_executor_borrowlogic.h index 71a44e507f4..5d990b49dc0 100644 --- a/ydb/core/tablet_flat/flat_executor_borrowlogic.h +++ b/ydb/core/tablet_flat/flat_executor_borrowlogic.h @@ -159,8 +159,8 @@ public: // on bootstrap void RestoreBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto); - // for followers - void RestoreFollowerBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto); + // for followers + void RestoreFollowerBorrowedInfo(const TLogoBlobID &blobId, const NKikimrExecutorFlat::TBorrowedPart &proto); // for monitoring void OutputHtml(IOutputStream &out); diff --git a/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp b/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp index d1665c7af38..3d699e8f87b 100644 --- a/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp +++ b/ydb/core/tablet_flat/flat_executor_compaction_logic.cpp @@ -20,7 +20,7 @@ TCompactionLogicState::TTableInfo::~TTableInfo() TCompactionLogic::TCompactionLogic(NUtil::ILogger *logger, NTable::IResourceBroker *broker, NTable::ICompactionBackend *backend, - TAutoPtr<TCompactionLogicState> state, + TAutoPtr<TCompactionLogicState> state, TString taskNameSuffix) : Logger(logger) , Broker(broker) @@ -139,7 +139,7 @@ void TCompactionLogic::PrepareTableSnapshot(ui32 table, NTable::TSnapEdge edge, bool TCompactionLogic::PrepareForceCompaction() { bool ok = true; for (auto &it : State->Tables) { - ok &= PrepareForceCompaction(it.first) != 0; + ok &= PrepareForceCompaction(it.first) != 0; } return ok; } @@ -147,7 +147,7 @@ bool TCompactionLogic::PrepareForceCompaction() { ui64 TCompactionLogic::PrepareForceCompaction(ui32 table, EForceCompaction mode) { TCompactionLogicState::TTableInfo *tableInfo = State->Tables.FindPtr(table); if (!tableInfo) - return 0; + return 0; if (mode == EForceCompaction::Borrowed) { // Note: we also schedule mem table compaction below, because tx status may have borrowed data @@ -159,7 +159,7 @@ ui64 TCompactionLogic::PrepareForceCompaction(ui32 table, EForceCompaction mode) case EForcedCompactionState::None: tableInfo->ForcedCompactionState = EForcedCompactionState::PendingMem; tableInfo->ForcedCompactionMode = mode; - ++tableInfo->CurrentForcedMemCompactionId; + ++tableInfo->CurrentForcedMemCompactionId; switch (inMem.State) { case ECompactionState::Free: SubmitCompactionTask(table, 0, @@ -186,21 +186,21 @@ ui64 TCompactionLogic::PrepareForceCompaction(ui32 table, EForceCompaction mode) default: tableInfo->ForcedCompactionQueued = true; tableInfo->ForcedCompactionQueuedMode = Max(tableInfo->ForcedCompactionQueuedMode, mode); - return tableInfo->CurrentForcedMemCompactionId + 1; + return tableInfo->CurrentForcedMemCompactionId + 1; } - return tableInfo->CurrentForcedMemCompactionId; + return tableInfo->CurrentForcedMemCompactionId; +} + +TFinishedCompactionInfo TCompactionLogic::GetFinishedCompactionInfo(ui32 table) { + TCompactionLogicState::TTableInfo *tableInfo = State->Tables.FindPtr(table); + if (!tableInfo || !tableInfo->Strategy) + return TFinishedCompactionInfo(); + return TFinishedCompactionInfo( + tableInfo->Strategy->GetLastFinishedForcedCompactionId(), + tableInfo->Strategy->GetLastFinishedForcedCompactionTs()); } -TFinishedCompactionInfo TCompactionLogic::GetFinishedCompactionInfo(ui32 table) { - TCompactionLogicState::TTableInfo *tableInfo = State->Tables.FindPtr(table); - if (!tableInfo || !tableInfo->Strategy) - return TFinishedCompactionInfo(); - return TFinishedCompactionInfo( - tableInfo->Strategy->GetLastFinishedForcedCompactionId(), - tableInfo->Strategy->GetLastFinishedForcedCompactionTs()); -} - TReflectSchemeChangesResult TCompactionLogic::ReflectSchemeChanges() { TReflectSchemeChangesResult result; @@ -488,7 +488,7 @@ bool TCompactionLogic::BeginMemTableCompaction(ui64 taskId, ui32 tableId) Y_FAIL("Invalid inMem.State"); } - ui64 forcedCompactionId = 0; + ui64 forcedCompactionId = 0; if (edge.Head == NTable::TEpoch::Max() && tableInfo->ForcedCompactionState == EForcedCompactionState::PendingMem) { @@ -509,7 +509,7 @@ bool TCompactionLogic::BeginMemTableCompaction(ui64 taskId, ui32 tableId) } } - inMem.CompactionTask.CompactionId = tableInfo->Strategy->BeginMemCompaction(taskId, edge, forcedCompactionId); + inMem.CompactionTask.CompactionId = tableInfo->Strategy->BeginMemCompaction(taskId, edge, forcedCompactionId); return true; } @@ -621,7 +621,7 @@ void TCompactionLogic::BorrowedPart(ui32 tableId, NTable::TPartView partView) { tableInfo->Strategy->PartMerged(std::move(partView), 255); } -void TCompactionLogic::BorrowedPart(ui32 tableId, TIntrusiveConstPtr<NTable::TColdPart> part) { +void TCompactionLogic::BorrowedPart(ui32 tableId, TIntrusiveConstPtr<NTable::TColdPart> part) { auto *tableInfo = State->Tables.FindPtr(tableId); Y_VERIFY(tableInfo); tableInfo->Strategy->PartMerged(std::move(part), 255); diff --git a/ydb/core/tablet_flat/flat_executor_compaction_logic.h b/ydb/core/tablet_flat/flat_executor_compaction_logic.h index 12e78fba94f..b85a13a19ec 100644 --- a/ydb/core/tablet_flat/flat_executor_compaction_logic.h +++ b/ydb/core/tablet_flat/flat_executor_compaction_logic.h @@ -64,7 +64,7 @@ struct TCompactionLogicState { struct TSnapRequest { const NTable::TSnapEdge Edge; - TIntrusivePtr<TTableSnapshotContext> Context; + TIntrusivePtr<TTableSnapshotContext> Context; TSnapRequest(NTable::TSnapEdge edge, TTableSnapshotContext *context) : Edge(edge) @@ -87,7 +87,7 @@ struct TCompactionLogicState { TDeque<TSnapRequest> SnapRequests; - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; EForcedCompactionState ForcedCompactionState = EForcedCompactionState::None; bool ForcedCompactionQueued = false; @@ -95,9 +95,9 @@ struct TCompactionLogicState { EForceCompaction ForcedCompactionMode = EForceCompaction::Full; EForceCompaction ForcedCompactionQueuedMode = EForceCompaction::Full; - // monotonically growing, i.e. edge-like - ui64 CurrentForcedMemCompactionId = 0; - + // monotonically growing, i.e. edge-like + ui64 CurrentForcedMemCompactionId = 0; + bool ChangesRequested = false; TTableInfo() = default; @@ -190,7 +190,7 @@ public: NUtil::ILogger*, NTable::IResourceBroker*, NTable::ICompactionBackend*, - TAutoPtr<TCompactionLogicState>, + TAutoPtr<TCompactionLogicState>, TString taskSuffix = { }); ~TCompactionLogic(); @@ -210,13 +210,13 @@ public: void PrepareTableSnapshot(ui32 table, NTable::TSnapEdge edge, TTableSnapshotContext *snapContext); // Force compaction support - // See slightly simlified state diagram: jing.yandex-team.ru/files/eivanov89/ForcedCompactionPath.png - // or img/ForcedCompactionQueue.drawio + // See slightly simlified state diagram: jing.yandex-team.ru/files/eivanov89/ForcedCompactionPath.png + // or img/ForcedCompactionQueue.drawio bool PrepareForceCompaction(); ui64 PrepareForceCompaction(ui32 table, EForceCompaction mode = EForceCompaction::Full); - TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 table); - + TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 table); + TReflectSchemeChangesResult ReflectSchemeChanges(); void UpdateInMemStatsStep(ui32 table, ui32 steps, ui64 size); void CheckInMemStats(ui32 table); @@ -236,7 +236,7 @@ public: THolder<NTable::TCompactionParams> params); void BorrowedPart(ui32 tableId, NTable::TPartView partView); - void BorrowedPart(ui32 tableId, TIntrusiveConstPtr<NTable::TColdPart> part); + void BorrowedPart(ui32 tableId, TIntrusiveConstPtr<NTable::TColdPart> part); ui32 BorrowedPartLevel(); TTableCompactionChanges RemovedParts(ui32 tableId, TArrayRef<const TLogoBlobID> parts); diff --git a/ydb/core/tablet_flat/flat_executor_counters.cpp b/ydb/core/tablet_flat/flat_executor_counters.cpp index 05e2792849d..ddecce5206c 100644 --- a/ydb/core/tablet_flat/flat_executor_counters.cpp +++ b/ydb/core/tablet_flat/flat_executor_counters.cpp @@ -94,7 +94,7 @@ TExecutorCounters::TExecutorCounters() Percentile()[TX_PERCENTILE_TABLET_BYTES_READ].Initialize(txDataRate, false); Percentile()[TX_PERCENTILE_TABLET_BYTES_WRITTEN].Initialize(txDataRate, false); Percentile()[TX_PERCENTILE_CONSUMED_CPU].Initialize(txConsumedCpu, false); - Percentile()[TX_PERCENTILE_FOLLOWERSYNC_LATENCY].Initialize(txLatencyConfig, false); + Percentile()[TX_PERCENTILE_FOLLOWERSYNC_LATENCY].Initialize(txLatencyConfig, false); } }} diff --git a/ydb/core/tablet_flat/flat_executor_counters.h b/ydb/core/tablet_flat/flat_executor_counters.h index 412f8892766..f100bc48a00 100644 --- a/ydb/core/tablet_flat/flat_executor_counters.h +++ b/ydb/core/tablet_flat/flat_executor_counters.h @@ -126,7 +126,7 @@ namespace NTabletFlatExecutor { XX(TX_PERCENTILE_TABLET_BYTES_WRITTEN, "HIST(TabletBytesWritten)") \ XX(TX_PERCENTILE_TABLET_BYTES_READ, "HIST(TabletBytesRead)") \ XX(TX_PERCENTILE_CONSUMED_CPU, "HIST(ConsumedCPU)") \ - XX(TX_PERCENTILE_FOLLOWERSYNC_LATENCY, "FollowerSyncLatency") + XX(TX_PERCENTILE_FOLLOWERSYNC_LATENCY, "FollowerSyncLatency") class TExecutorCounters : public TTabletCountersBase { public: diff --git a/ydb/core/tablet_flat/flat_executor_gclogic.cpp b/ydb/core/tablet_flat/flat_executor_gclogic.cpp index 40b3ed7b7a4..bded66353ec 100644 --- a/ydb/core/tablet_flat/flat_executor_gclogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_gclogic.cpp @@ -155,7 +155,7 @@ ui32 TExecutorGCLogic::GetActiveGcBarrier() { return HoldBarriersSet.begin()->Step; } -void TExecutorGCLogic::FollowersSyncComplete(bool isBoot) { +void TExecutorGCLogic::FollowersSyncComplete(bool isBoot) { Y_UNUSED(isBoot); AllowGarbageCollection = true; } diff --git a/ydb/core/tablet_flat/flat_executor_gclogic.h b/ydb/core/tablet_flat/flat_executor_gclogic.h index ebf4d886a20..9c1fa568a23 100644 --- a/ydb/core/tablet_flat/flat_executor_gclogic.h +++ b/ydb/core/tablet_flat/flat_executor_gclogic.h @@ -48,7 +48,7 @@ public: void HoldBarrier(ui32 step); // holds GC on no more than this step for channels specified void ReleaseBarrier(ui32 step); ui32 GetActiveGcBarrier(); - void FollowersSyncComplete(bool isBoot); + void FollowersSyncComplete(bool isBoot); struct TIntrospection { ui64 UncommitedEntries; @@ -74,7 +74,7 @@ public: TIntrospection IntrospectStateSize() const; protected: - const TIntrusiveConstPtr<TTabletStorageInfo> TabletStorageInfo; + const TIntrusiveConstPtr<TTabletStorageInfo> TabletStorageInfo; const TAutoPtr<NPageCollection::TSteppedCookieAllocator> Cookies; const ui32 Generation; NPageCollection::TSlicer Slicer; diff --git a/ydb/core/tablet_flat/flat_executor_misc.h b/ydb/core/tablet_flat/flat_executor_misc.h index 8f9b904f9c7..a1382963bfc 100644 --- a/ydb/core/tablet_flat/flat_executor_misc.h +++ b/ydb/core/tablet_flat/flat_executor_misc.h @@ -20,7 +20,7 @@ namespace NTabletFlatExecutor { const ui32 Step = Max<ui32>(); }; - struct TCompactCfg final : public IDestructable { + struct TCompactCfg final : public IDestructable { using TConf = NTable::NPage::TConf; explicit TCompactCfg(THolder<NTable::TCompactionParams> params) @@ -39,7 +39,7 @@ namespace NTabletFlatExecutor { NTable::TTransactionSet RemovedTransactions; // The above may contain extra keys, these allow them to be narrowed TVector<TIntrusiveConstPtr<NTable::TMemTable>> Frozen; - TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; + TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; }; } diff --git a/ydb/core/tablet_flat/flat_executor_snapshot.h b/ydb/core/tablet_flat/flat_executor_snapshot.h index 27f17961fd2..fae02f7fc89 100644 --- a/ydb/core/tablet_flat/flat_executor_snapshot.h +++ b/ydb/core/tablet_flat/flat_executor_snapshot.h @@ -24,7 +24,7 @@ namespace NTabletFlatExecutor { struct TFlush { ui32 Step = Max<ui32>(); - TVector<TIntrusivePtr<TBarrier>> Barriers; + TVector<TIntrusivePtr<TBarrier>> Barriers; THashMap<TLogoBlobID, TSet<ui64>> Bundles; TMap<ui32, ui32> Moved; }; @@ -39,7 +39,7 @@ namespace NTabletFlatExecutor { Pending++; } - bool Complete(ui32 table, TIntrusivePtr<TBarrier> barrier) + bool Complete(ui32 table, TIntrusivePtr<TBarrier> barrier) { Get(table, EReady::Wait).Ready = EReady::Done; Holds.Barriers.push_back(barrier); diff --git a/ydb/core/tablet_flat/flat_executor_tx_env.h b/ydb/core/tablet_flat/flat_executor_tx_env.h index 4543c748147..e3b54db82e5 100644 --- a/ydb/core/tablet_flat/flat_executor_tx_env.h +++ b/ydb/core/tablet_flat/flat_executor_tx_env.h @@ -70,7 +70,7 @@ namespace NTabletFlatExecutor { using TLogoId = TLogoBlobID; struct TBorrowSnap { - TIntrusivePtr<TTableSnapshotContext> SnapContext; + TIntrusivePtr<TTableSnapshotContext> SnapContext; }; struct TBorrowUpdate { @@ -117,7 +117,7 @@ namespace NTabletFlatExecutor { }; struct TSnapshot { - TVector<TIntrusivePtr<TTableSnapshotContext>> Context; + TVector<TIntrusivePtr<TTableSnapshotContext>> Context; }; using TPageCollectionReadEnv::TPageCollectionReadEnv; @@ -134,7 +134,7 @@ namespace NTabletFlatExecutor { } protected: /* IExecuting, tx stage func implementation */ - void MakeSnapshot(TIntrusivePtr<TTableSnapshotContext> snap) override + void MakeSnapshot(TIntrusivePtr<TTableSnapshotContext> snap) override { Y_VERIFY(snap->TablesToSnapshot()); @@ -142,7 +142,7 @@ namespace NTabletFlatExecutor { MakeSnap[table].Context.push_back(snap); } - void DropSnapshot(TIntrusivePtr<TTableSnapshotContext> snap) override + void DropSnapshot(TIntrusivePtr<TTableSnapshotContext> snap) override { Y_VERIFY(!DropSnap, "only one snapshot per transaction"); diff --git a/ydb/core/tablet_flat/flat_executor_txloglogic.cpp b/ydb/core/tablet_flat/flat_executor_txloglogic.cpp index 51c0b8cb250..df59ddc2455 100644 --- a/ydb/core/tablet_flat/flat_executor_txloglogic.cpp +++ b/ydb/core/tablet_flat/flat_executor_txloglogic.cpp @@ -19,7 +19,7 @@ const static ui64 MaxSizeToEmbedInLog = 2048; const static ui64 MaxBytesToBatch = 2 * 1024 * 1024; const static ui64 MaxItemsToBatch = 64; -TLogicRedo::TCompletionEntry::TCompletionEntry(TAutoPtr<TSeat> seat, ui32 step) +TLogicRedo::TCompletionEntry::TCompletionEntry(TAutoPtr<TSeat> seat, ui32 step) : Step(step) , InFlyRWTransaction(seat) {} @@ -55,7 +55,7 @@ TArrayRef<const NRedo::TUsage> TLogicRedo::GrabLogUsage() const noexcept return Queue->GrabUsage(); } -bool TLogicRedo::TerminateTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx, const TActorId &ownerID) { +bool TLogicRedo::TerminateTransaction(TAutoPtr<TSeat> seat, const TActorContext &ctx, const TActorId &ownerID) { if (CompletionQueue.empty()) { const TTxType txType = seat->Self->GetTxType(); @@ -70,7 +70,7 @@ bool TLogicRedo::TerminateTransaction(TAutoPtr<TSeat> seat, const TActorContext } } -void CompleteRoTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx, TExecutorCounters *counters, TTabletCountersWithTxTypes *appTxCounters ) { +void CompleteRoTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx, TExecutorCounters *counters, TTabletCountersWithTxTypes *appTxCounters ) { const TTxType txType = seat->Self->GetTxType(); const ui64 latencyus = ui64(1000000. * seat->LatencyTimer.Passed()); @@ -92,7 +92,7 @@ void CompleteRoTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx, appTxCounters->TxCumulative(txType, COUNTER_TT_COMMITED_CPUTIME).Increment(completeTimeus); } -bool TLogicRedo::CommitROTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx) { +bool TLogicRedo::CommitROTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx) { if (CompletionQueue.empty()) { CompleteRoTransaction(seat, ownerCtx, Counters, AppTxCounters); return true; @@ -105,7 +105,7 @@ bool TLogicRedo::CommitROTransaction(TAutoPtr<TSeat> seat, const TActorContext & void TLogicRedo::FlushBatchedLog() { - if (TAutoPtr<TLogCommit> commit = Batch->Commit) { + if (TAutoPtr<TLogCommit> commit = Batch->Commit) { auto affects = Batch->Affects(); MakeLogEntry(*commit, Batch->Flush(), affects, true); CommitManager->Commit(commit); @@ -115,7 +115,7 @@ void TLogicRedo::FlushBatchedLog() } TLogicRedo::TCommitRWTransactionResult TLogicRedo::CommitRWTransaction( - TAutoPtr<TSeat> seat, NTable::TChange &change, bool force) + TAutoPtr<TSeat> seat, NTable::TChange &change, bool force) { seat->CommitTimer.Reset(); @@ -155,7 +155,7 @@ TLogicRedo::TCommitRWTransactionResult TLogicRedo::CommitRWTransaction( for (auto &one: change.Annex) { if (one.GId.Logo.Step() != commit->Step) { Y_Fail( - "Leader{" << Cookies->Tablet << ":" << Cookies->Gen << "}" + "Leader{" << Cookies->Tablet << ":" << Cookies->Gen << "}" << " got for " << NFmt::Do(*commit) << " annex blob " << one.GId.Logo << " out of step order"); } diff --git a/ydb/core/tablet_flat/flat_executor_txloglogic.h b/ydb/core/tablet_flat/flat_executor_txloglogic.h index 4282fefbb7e..1272c4f947b 100644 --- a/ydb/core/tablet_flat/flat_executor_txloglogic.h +++ b/ydb/core/tablet_flat/flat_executor_txloglogic.h @@ -27,8 +27,8 @@ class TLogicRedo { TCommitManager * const CommitManager; TAutoPtr<NPageCollection::TSteppedCookieAllocator> Cookies; - TAutoPtr<NRedo::TBatch> Batch; - TAutoPtr<NRedo::TQueue> Queue; + TAutoPtr<NRedo::TBatch> Batch; + TAutoPtr<NRedo::TQueue> Queue; NPageCollection::TSlicer Slicer; TExecutorCounters *Counters = nullptr; @@ -38,11 +38,11 @@ class TLogicRedo { ui32 Step; /* vvvv argh.... */ - TAutoPtr<TSeat> InFlyRWTransaction; - TVector<TAutoPtr<TSeat>> WaitingROTransactions; - TVector<TAutoPtr<TSeat>> WaitingTerminatedTransactions; + TAutoPtr<TSeat> InFlyRWTransaction; + TVector<TAutoPtr<TSeat>> WaitingROTransactions; + TVector<TAutoPtr<TSeat>> WaitingTerminatedTransactions; - TCompletionEntry(TAutoPtr<TSeat> seat, ui32 step); + TCompletionEntry(TAutoPtr<TSeat> seat, ui32 step); }; TDeque<TCompletionEntry> CompletionQueue; // would be graph once data-dependencies implemented @@ -50,7 +50,7 @@ class TLogicRedo { public: struct TCommitRWTransactionResult { - TAutoPtr<TLogCommit> Commit; + TAutoPtr<TLogCommit> Commit; bool NeedFlush; }; @@ -59,9 +59,9 @@ public: void Describe(IOutputStream &out) const noexcept; void InstallCounters(TExecutorCounters *counters, TTabletCountersWithTxTypes* appTxCounters); - bool TerminateTransaction(TAutoPtr<TSeat>, const TActorContext &ctx, const TActorId &ownerId); - bool CommitROTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx); - TCommitRWTransactionResult CommitRWTransaction(TAutoPtr<TSeat> seat, NTable::TChange &change, bool force); + bool TerminateTransaction(TAutoPtr<TSeat>, const TActorContext &ctx, const TActorId &ownerId); + bool CommitROTransaction(TAutoPtr<TSeat> seat, const TActorContext &ownerCtx); + TCommitRWTransactionResult CommitRWTransaction(TAutoPtr<TSeat> seat, NTable::TChange &change, bool force); void MakeLogEntry(TLogCommit&, TString redo, TArrayRef<const ui32> affects, bool embed); void FlushBatchedLog(); @@ -73,6 +73,6 @@ public: TArrayRef<const NRedo::TUsage> GrabLogUsage() const noexcept; }; -void CompleteRoTransaction(TAutoPtr<TSeat>, const TActorContext &ownerCtx, TExecutorCounters *counters, TTabletCountersWithTxTypes *appTxCounters); +void CompleteRoTransaction(TAutoPtr<TSeat>, const TActorContext &ownerCtx, TExecutorCounters *counters, TTabletCountersWithTxTypes *appTxCounters); }} diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp index 0c55429af2d..c9cf5289711 100644 --- a/ydb/core/tablet_flat/flat_executor_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut.cpp @@ -13,7 +13,7 @@ namespace NTabletFlatExecutor { struct TTxSchema : public ITransaction { - TTxSchema(TIntrusiveConstPtr<TCompactionPolicy> policy, bool groups = false) + TTxSchema(TIntrusiveConstPtr<TCompactionPolicy> policy, bool groups = false) : Policy(std::move(policy)) , Groups(groups) { } @@ -44,7 +44,7 @@ namespace NTabletFlatExecutor { ctx.Send(ctx.SelfID, new NFake::TEvReturn); } - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; const bool Groups; }; @@ -122,7 +122,7 @@ namespace NTabletFlatExecutor { const TRowVersion WriteVersion; }; - NFake::TEvExecute* MakeScheme(TIntrusiveConstPtr<TCompactionPolicy> policy, bool groups = false) + NFake::TEvExecute* MakeScheme(TIntrusiveConstPtr<TCompactionPolicy> policy, bool groups = false) { return new NFake::TEvExecute{ new TTxSchema(std::move(policy), groups) }; } @@ -234,10 +234,10 @@ namespace NTabletFlatExecutor { private: TVector<ui32> Tables; - TAutoPtr<NTable::TSubset> Subset; + TAutoPtr<NTable::TSubset> Subset; }; -struct TDummyResult: public IDestructable { +struct TDummyResult: public IDestructable { TDummyResult(ui64 count, ui64 expect) : Count(count), Expect(expect) {} @@ -276,7 +276,7 @@ public: } private: - THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override + THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { Driver = driver; Scheme = std::move(scheme); @@ -309,7 +309,7 @@ private: return EScan::Feed; } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { UNIT_ASSERT_VALUES_EQUAL((int)Abort, (int)abort); @@ -326,7 +326,7 @@ private: private: TActorId Tablet; IDriver *Driver = nullptr; - TIntrusiveConstPtr<TScheme> Scheme; + TIntrusiveConstPtr<TScheme> Scheme; ui64 StoredRows = 0; ui64 ExpectedRowId = 1; ui64 ExpectedRows = 0; @@ -419,7 +419,7 @@ class TTestFlatTablet : public TActor<TTestFlatTablet>, public TTabletExecutedFl Send(Sender, new NFake::TEvCompacted(table)); } - void ScanComplete(NTable::EAbort, TAutoPtr<IDestructable>, ui64 cookie, const TActorContext&) override + void ScanComplete(NTable::EAbort, TAutoPtr<IDestructable>, ui64 cookie, const TActorContext&) override { UNIT_ASSERT_VALUES_EQUAL(cookie, ScanCookie); Send(Sender, new TEvTestFlatTablet::TEvScanFinished); @@ -559,7 +559,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCompactionScan) { env.WaitForWakeUp(); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); policy->InMemSizeToSnapshot = 40 * 1024 *1024; policy->InMemStepsToSnapshot = 10; policy->InMemForceStepsToSnapshot = 10; @@ -1193,7 +1193,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { size_t ReqNo = 0; TAutoPtr<TMemoryToken> Token; - TTxRequestMemory(TRequests requests, size_t reqNo, TAutoPtr<TMemoryToken> token, TCfg cfg) + TTxRequestMemory(TRequests requests, size_t reqNo, TAutoPtr<TMemoryToken> token, TCfg cfg) : Cfg(cfg) , Requests(requests) , ReqNo(reqNo) @@ -1341,9 +1341,9 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { void CheckMemoryRequest(std::initializer_list<TMemoryCheckEntry> list, TTxRequestMemory::TCfg cfg = { }, - bool follower = false) + bool follower = false) { - TAutoPtr<TTxRequestMemory> event = new TTxRequestMemory({ }, 0, nullptr, cfg); + TAutoPtr<TTxRequestMemory> event = new TTxRequestMemory({ }, 0, nullptr, cfg); TTaskSequence sequence; @@ -1367,8 +1367,8 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { } } - if (follower) { - SendFollowerAsync(new NFake::TEvExecute{ event.Release() }); + if (follower) { + SendFollowerAsync(new NFake::TEvExecute{ event.Release() }); } else { SendAsync(new NFake::TEvExecute{ event.Release() }); } @@ -1382,10 +1382,10 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { WaitForWakeUp(); } - void CheckMemoryRequestFollower(std::initializer_list<TMemoryCheckEntry> list, + void CheckMemoryRequestFollower(std::initializer_list<TMemoryCheckEntry> list, TTxRequestMemory::TCfg cfg = { }) { - return CheckMemoryRequest(list, std::move(cfg), /* follower */ true); + return CheckMemoryRequest(list, std::move(cfg), /* follower */ true); } TResourceProfiles::TPtr Profile; @@ -1525,24 +1525,24 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorResourceProfile) { {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 95 << 10, {"large_transaction"}}}); } - Y_UNIT_TEST(TestExecutorRequestMemoryFollower) { + Y_UNIT_TEST(TestExecutorRequestMemoryFollower) { TMyEnvProfiles env; env.SendSync(env.Rows.MakeRows(100, 2 << 10)); - env.FireDummyFollower(1); + env.FireDummyFollower(1); // Static memory. - env.CheckMemoryRequestFollower( + env.CheckMemoryRequestFollower( {{{1}, 4 << 10, {}, true}}); // Dynamic memory. - env.CheckMemoryRequestFollower( + env.CheckMemoryRequestFollower( {{{1, 2, 3, 4, 5}, 14 << 10, {"small_transaction"}}}); // Dynamic memory. - env.CheckMemoryRequestFollower( + env.CheckMemoryRequestFollower( {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 35 << 10, {"medium_transaction"}}}); // Dynamic memory. - env.CheckMemoryRequestFollower( + env.CheckMemoryRequestFollower( {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 95 << 10, {"large_transaction"}}}); } @@ -1716,7 +1716,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorSliceOverlapScan) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 4 * 1024 * 1024; policy->Generations.push_back({0, 2, 2, ui64(-1), NLocalDb::LegacyQueueIdToTaskName(1), false}); @@ -1755,7 +1755,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorShardedCompaction) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 1024 * 1024; policy->CompactionStrategy = NKikimrSchemeOp::CompactionStrategySharded; policy->ShardPolicy.SetMinSliceSize(0); @@ -1790,7 +1790,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorShardedCompaction) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 1024; policy->CompactionStrategy = NKikimrSchemeOp::CompactionStrategySharded; policy->ShardPolicy.SetMinSliceSize(0); @@ -1825,7 +1825,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorShardedCompaction) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 1024 * 1024; policy->CompactionStrategy = NKikimrSchemeOp::CompactionStrategySharded; policy->ShardPolicy.SetMinSliceSize(0); @@ -1925,7 +1925,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorColumnGroups) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); policy->InMemSizeToSnapshot = 40 * 1024 *1024; policy->InMemStepsToSnapshot = 10; policy->InMemForceStepsToSnapshot = 10; @@ -2014,7 +2014,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorCachePressure) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 256 * 1024; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -2094,7 +2094,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorCompressedSelectRows) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 256 * 1024; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -2351,7 +2351,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorVersionedRows) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 256 * 1024; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -2469,7 +2469,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorVersionedLargeBlobs) { { using namespace NTable::NPage; - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemForceSizeToSnapshot = 256 * 1024; // Values bigger than 128 bytes stored in large blobs @@ -2745,7 +2745,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorKeepEraseMarkers) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); env.SendSync(new NFake::TEvExecute{ new TTxUpdateSchema(ESchemaVariant::KeepEraseMarkers) }); @@ -3005,7 +3005,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorMoveTableData) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(new NFake::TEvExecute{ new TTxInitSchema }); env.SendSync(new NFake::TEvExecute{ new TTxGenerateRows }); @@ -3136,14 +3136,14 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorMoveTableData) { } }; - Y_UNIT_TEST(TestMoveSnapshotFollower) { + Y_UNIT_TEST(TestMoveSnapshotFollower) { TMyEnvBase env; //env->SetLogPriority(NKikimrServices::TABLET_FLATBOOT, NActors::NLog::PRI_DEBUG); //env->SetLogPriority(NKikimrServices::TABLET_EXECUTOR, NActors::NLog::PRI_DEBUG); env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - env.FireDummyFollower(1); + env.FireDummyFollower(1); env.SendSync(new NFake::TEvExecute{ new TTxInitSchema }); env.SendSync(new NFake::TEvExecute{ new TTxGenerateRows }); @@ -3153,24 +3153,24 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorMoveTableData) { env.SendSync(move->Start()); env.SendSync(new NFake::TEvExecute{ new TTxDropTable(TRowsModel::TableId + 1) }); - // Find the last completed leader step - ui32 leaderStep; - env.SendSync(new NFake::TEvExecute{ new TTxCheckStep(leaderStep) }); - --leaderStep; + // Find the last completed leader step + ui32 leaderStep; + env.SendSync(new NFake::TEvExecute{ new TTxCheckStep(leaderStep) }); + --leaderStep; - // Wait for that step to be synced to follower + // Wait for that step to be synced to follower while (true) { - ui32 followerStep; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); - if (followerStep >= leaderStep) { + ui32 followerStep; + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); + if (followerStep >= leaderStep) { break; } } - // Check resulting data on a follower + // Check resulting data on a follower { TString data; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); UNIT_ASSERT_VALUES_EQUAL(data, "Key 1 = Upsert value = Set key1update\n" "Key 2 = Upsert value = Set key2base\n" @@ -3188,23 +3188,23 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorMoveTableData) { env.SendSync(new NFake::TEvCompact(TRowsModel::TableId)); env.WaitFor<NFake::TEvCompacted>(); - // Find the last completed leader step - env.SendSync(new NFake::TEvExecute{ new TTxCheckStep(leaderStep) }); - --leaderStep; + // Find the last completed leader step + env.SendSync(new NFake::TEvExecute{ new TTxCheckStep(leaderStep) }); + --leaderStep; - // Wait for that step to be synced to follower + // Wait for that step to be synced to follower while (true) { - ui32 followerStep; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); - if (followerStep >= leaderStep) { + ui32 followerStep; + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); + if (followerStep >= leaderStep) { break; } } - // Check resulting data on a follower + // Check resulting data on a follower { TString data; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); UNIT_ASSERT_VALUES_EQUAL(data, "Key 1 = Upsert value = Set key1update\n" "Key 2 = Upsert value = Set key2base\n" @@ -3219,7 +3219,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorMoveTableData) { } -Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { +Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { struct TTxCheckStep : public ITransaction { ui32& Step; @@ -3310,7 +3310,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { } }; - Y_UNIT_TEST(BasicFollowerRead) { + Y_UNIT_TEST(BasicFollowerRead) { TMyEnvBase env; TRowsModel rows; @@ -3318,31 +3318,31 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { //env->SetLogPriority(NKikimrServices::TABLET_EXECUTOR, NActors::NLog::PRI_DEBUG); env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - env.FireDummyFollower(1); + env.FireDummyFollower(1); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); // Insert some test rows (without waiting for completion) - ui32 lastLeaderStep = 0; + ui32 lastLeaderStep = 0; for (i64 key = 1; key <= 5; ++key) { - env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(key, lastLeaderStep) }); + env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(key, lastLeaderStep) }); } - // Wait for follower to sync with the last leader step + // Wait for follower to sync with the last leader step while (true) { - ui32 followerStep = 0; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); - if (followerStep >= lastLeaderStep) { + ui32 followerStep = 0; + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); + if (followerStep >= lastLeaderStep) { break; } } - // Test read from follower + // Test read from follower { TString data; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); UNIT_ASSERT_VALUES_EQUAL(data, "Key 1 = Upsert value = Set key1value\n" "Key 2 = Upsert value = Set key2value\n" @@ -3352,7 +3352,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { } } - struct TFollowerEarlyRebootObserver { + struct TFollowerEarlyRebootObserver { using EEventAction = TTestActorRuntimeBase::EEventAction; enum class EState { @@ -3368,8 +3368,8 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { TTestActorRuntimeBase::TEventObserver PrevObserverFunc; EState State = EState::WaitForAttach; - TActorId FollowerTabletActor; - TActorId LeaderTabletActor; + TActorId FollowerTabletActor; + TActorId LeaderTabletActor; ui32 SnapshotStep = 0; THolder<IEventHandle> SnapshotCommitResult; bool Detached = false; @@ -3390,9 +3390,9 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { TAutoPtr<IEventHandle>& ev) { switch (ev->GetTypeRewrite()) { - HFunc(TEvTablet::TEvFollowerAttach, Handle); - HFunc(TEvTablet::TEvFollowerDetach, Handle); - HFunc(TEvTablet::TEvFollowerUpdate, Handle); + HFunc(TEvTablet::TEvFollowerAttach, Handle); + HFunc(TEvTablet::TEvFollowerDetach, Handle); + HFunc(TEvTablet::TEvFollowerUpdate, Handle); HFunc(TEvTablet::TEvCommit, Handle); HFunc(TEvTabletBase::TEvWriteLogResult, Handle); default: @@ -3402,38 +3402,38 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { return ev ? EEventAction::PROCESS : EEventAction::DROP; } - void Handle(TEvTablet::TEvFollowerAttach::TPtr& ev, TTestActorRuntimeBase& ctx) { + void Handle(TEvTablet::TEvFollowerAttach::TPtr& ev, TTestActorRuntimeBase& ctx) { if (State == EState::WaitForAttach) { if (Debug) { - Cerr << "See first follower attach, waiting for snapshot" << Endl; + Cerr << "See first follower attach, waiting for snapshot" << Endl; } - // On attach we kill the follower - FollowerTabletActor = ev->Sender; - LeaderTabletActor = ev->GetRecipientRewrite(); + // On attach we kill the follower + FollowerTabletActor = ev->Sender; + LeaderTabletActor = ev->GetRecipientRewrite(); // We will be blocking the next snapshot State = EState::WaitForSnapshot; } else if (State == EState::WaitForSecondAttach) { if (Debug) { - Cerr << "See second follower attach, unblocking result for first snapshot" << Endl; + Cerr << "See second follower attach, unblocking result for first snapshot" << Endl; } State = EState::Idle; UnblockSnapshot(ctx); } } - void Handle(TEvTablet::TEvFollowerDetach::TPtr&, TTestActorRuntimeBase& ctx) { + void Handle(TEvTablet::TEvFollowerDetach::TPtr&, TTestActorRuntimeBase& ctx) { if (Debug) { - Cerr << "See follower detach, waking up" << Endl; + Cerr << "See follower detach, waking up" << Endl; } ctx.Send(new IEventHandle(Edge, Edge, new TEvents::TEvWakeup()), 0, true); Detached = true; } - void Handle(TEvTablet::TEvFollowerUpdate::TPtr& ev, TTestActorRuntimeBase&) { + void Handle(TEvTablet::TEvFollowerUpdate::TPtr& ev, TTestActorRuntimeBase&) { ui32 step = ev->Get()->Record.GetStep(); bool snapshot = ev->Get()->Record.GetIsSnapshot(); if (Debug) { - Cerr << "See follower update, step=" << step << " snapshot=" << snapshot << Endl; + Cerr << "See follower update, step=" << step << " snapshot=" << snapshot << Endl; } } @@ -3447,9 +3447,9 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { State = EState::BlockSnapshotCommit; // Send poison pill via actor system if (Debug) { - Cerr << "...killing the follower tablet" << Endl; + Cerr << "...killing the follower tablet" << Endl; } - ctx.Send(new IEventHandle(FollowerTabletActor, LeaderTabletActor, new TEvents::TEvPoison()), 0, true); + ctx.Send(new IEventHandle(FollowerTabletActor, LeaderTabletActor, new TEvents::TEvPoison()), 0, true); } } @@ -3481,7 +3481,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { }; // Regression test for KIKIMR-7745 - Y_UNIT_TEST(FollowerEarlyRebootHoles) { + Y_UNIT_TEST(FollowerEarlyRebootHoles) { TMyEnvBase env; TRowsModel rows; @@ -3490,46 +3490,46 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); - TFollowerEarlyRebootObserver observer; + TFollowerEarlyRebootObserver observer; observer.Edge = env.Edge; //observer.Debug = true; observer.Install(env.Env); - // Start follower (it will die almost immediately) - env.FireDummyFollower(1, false); + // Start follower (it will die almost immediately) + env.FireDummyFollower(1, false); env.WaitForGone(); env.WaitForWakeUp(); // Insert some test rows (without waiting for completion) - ui32 lastLeaderStep = 0; + ui32 lastLeaderStep = 0; for (i64 key = 1; key <= 5; ++key) { - env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(key, lastLeaderStep) }); + env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(key, lastLeaderStep) }); } - // Start another follower + // Start another follower observer.ReadyForSecondAttach(); - env.FireDummyFollower(1); + env.FireDummyFollower(1); - // Add one more commit (follower step is only updated on rollup) - env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(6, lastLeaderStep) }); + // Add one more commit (follower step is only updated on rollup) + env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(6, lastLeaderStep) }); - // Wait for follower to sync with the last leader step + // Wait for follower to sync with the last leader step while (true) { - ui32 followerStep = 0; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); - if (followerStep >= lastLeaderStep) { + ui32 followerStep = 0; + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckStep(followerStep) }); + if (followerStep >= lastLeaderStep) { break; } } - // Test read from follower + // Test read from follower { TString data; - env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); + env.SendFollowerSync(new NFake::TEvExecute{ new TTxCheckRows(data) }); UNIT_ASSERT_VALUES_EQUAL(data, "Key 1 = Upsert value = Set key1value\n" "Key 2 = Upsert value = Set key2value\n" @@ -3547,9 +3547,9 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorFollower) { Y_UNIT_TEST_SUITE(TFlatTableExecutorRejectProbability) { struct TTxMultiSchema : public ITransaction { - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; - explicit TTxMultiSchema(const TIntrusiveConstPtr<TCompactionPolicy>& policy) + explicit TTxMultiSchema(const TIntrusiveConstPtr<TCompactionPolicy>& policy) : Policy(policy) { } @@ -3605,7 +3605,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorRejectProbability) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -3631,7 +3631,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorRejectProbability) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -3658,7 +3658,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorRejectProbability) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(rows.MakeScheme(std::move(policy))); @@ -3684,7 +3684,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorRejectProbability) { env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp)); - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; env.SendSync(new NFake::TEvExecute{ new TTxMultiSchema(policy) }); @@ -3753,7 +3753,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCold) { }; struct TTxInitColdSchema : public ITransaction { - TTxInitColdSchema(TIntrusiveConstPtr<TCompactionPolicy> policy) + TTxInitColdSchema(TIntrusiveConstPtr<TCompactionPolicy> policy) : Policy(std::move(policy)) { } @@ -3778,7 +3778,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCold) { ctx.Send(ctx.SelfID, new NFake::TEvReturn); } - TIntrusiveConstPtr<TCompactionPolicy> Policy; + TIntrusiveConstPtr<TCompactionPolicy> Policy; }; struct TTxLoanSnapshot : public ITransaction { @@ -3839,7 +3839,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCold) { // Init schema { - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); env.SendSync(rows.MakeScheme(std::move(policy))); } @@ -3876,7 +3876,7 @@ Y_UNIT_TEST_SUITE(TFlatTableCold) { // Init destination schema with a cold table flag enabled { - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy(); env.SendSync(new NFake::TEvExecute{ new TTxInitColdSchema(std::move(policy)) }); } @@ -3962,7 +3962,7 @@ Y_UNIT_TEST_SUITE(TFlatTableLongTx) { }; struct TTxInitSchema : public ITransaction { - TTxInitSchema(TIntrusiveConstPtr<TCompactionPolicy> policy = nullptr) + TTxInitSchema(TIntrusiveConstPtr<TCompactionPolicy> policy = nullptr) : Policy(std::move(policy)) { } @@ -3988,7 +3988,7 @@ Y_UNIT_TEST_SUITE(TFlatTableLongTx) { ctx.Send(ctx.SelfID, new NFake::TEvReturn); } - const TIntrusiveConstPtr<TCompactionPolicy> Policy; + const TIntrusiveConstPtr<TCompactionPolicy> Policy; }; struct TTxCommitLongTx : public ITransaction { diff --git a/ydb/core/tablet_flat/flat_executor_ut_common.h b/ydb/core/tablet_flat/flat_executor_ut_common.h index 4bb64eb7bda..ca88e903d08 100644 --- a/ydb/core/tablet_flat/flat_executor_ut_common.h +++ b/ydb/core/tablet_flat/flat_executor_ut_common.h @@ -106,7 +106,7 @@ namespace NTabletFlatExecutor { void WaitFor(size_t num = 1) { for (; num > 0; num--) { - TAutoPtr<IEventHandle> handle; + TAutoPtr<IEventHandle> handle; Env.GrabEdgeEventRethrow<TEv>(handle); } } diff --git a/ydb/core/tablet_flat/flat_executor_ut_large.cpp b/ydb/core/tablet_flat/flat_executor_ut_large.cpp index f0c16f7ce78..6bd3cc712ba 100644 --- a/ydb/core/tablet_flat/flat_executor_ut_large.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut_large.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TFlatTableLongTxLarge) { }; struct TTxInitSchema : public ITransaction { - TTxInitSchema(TIntrusiveConstPtr<TCompactionPolicy> policy = nullptr) + TTxInitSchema(TIntrusiveConstPtr<TCompactionPolicy> policy = nullptr) : Policy(std::move(policy)) { } @@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TFlatTableLongTxLarge) { ctx.Send(ctx.SelfID, new NFake::TEvReturn); } - const TIntrusiveConstPtr<TCompactionPolicy> Policy; + const TIntrusiveConstPtr<TCompactionPolicy> Policy; }; struct TTxCommitLongTx : public ITransaction { @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TFlatTableLongTxLarge) { // A special compaction policy that compacts small mem tables often // However the data will not be compacted and not kept in the cache // This is needed to limit the memory pressure for this test - TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; + TIntrusivePtr<TCompactionPolicy> policy = new TCompactionPolicy; policy->InMemSizeToSnapshot = 24ull * 1024 * 1024; policy->InMemStepsToSnapshot = 4; policy->InMemForceStepsToSnapshot = 4; diff --git a/ydb/core/tablet_flat/flat_fwd_blobs.h b/ydb/core/tablet_flat/flat_fwd_blobs.h index bd0e197343b..583ba48ee80 100644 --- a/ydb/core/tablet_flat/flat_fwd_blobs.h +++ b/ydb/core/tablet_flat/flat_fwd_blobs.h @@ -17,7 +17,7 @@ namespace NFwd { public: using TEdges = TVector<ui32>; - TBlobs(TIntrusiveConstPtr<NPage::TFrames> frames, TIntrusiveConstPtr<TSlices> slices, TEdges edge, bool trace) + TBlobs(TIntrusiveConstPtr<NPage::TFrames> frames, TIntrusiveConstPtr<TSlices> slices, TEdges edge, bool trace) : Edge(std::move(edge)) , Frames(std::move(frames)) , Filter(std::move(slices)) @@ -81,12 +81,12 @@ namespace NFwd { return Trace ? Trace->Unwrap() : TDeque<TScreen::THole>{ }; } - TIntrusiveConstPtr<NPage::TFrames> GetFrames() const noexcept + TIntrusiveConstPtr<NPage::TFrames> GetFrames() const noexcept { return Frames; } - TIntrusiveConstPtr<TSlices> GetSlices() const noexcept + TIntrusiveConstPtr<TSlices> GetSlices() const noexcept { return Filter.GetSlices(); } @@ -227,14 +227,14 @@ namespace NFwd { private: const TVector<ui32> Edge; /* Desired bytes limit of blobs */ - const TIntrusiveConstPtr<NPage::TFrames> Frames; + const TIntrusiveConstPtr<NPage::TFrames> Frames; const TSlicesRowFilter Filter; TVector<ui8> Tags; /* Ever used col tags on env */ TPageId Lower = 0; /* Pinned frame lower bound ref */ TPageId Upper = 0; /* Pinned frame upper bound ref */ TPageId Grow = Max<TPageId>(); /* Edge page of loading process */ - TAutoPtr<THoles> Trace; + TAutoPtr<THoles> Trace; /*_ Forward cache line state */ diff --git a/ydb/core/tablet_flat/flat_fwd_cache.h b/ydb/core/tablet_flat/flat_fwd_cache.h index b091181d094..f5ff3f5033d 100644 --- a/ydb/core/tablet_flat/flat_fwd_cache.h +++ b/ydb/core/tablet_flat/flat_fwd_cache.h @@ -57,7 +57,7 @@ namespace NFwd { public: TCache() = delete; - TCache(const NPage::TIndex& index, const TIntrusiveConstPtr<TSlices>& bounds = nullptr) + TCache(const NPage::TIndex& index, const TIntrusiveConstPtr<TSlices>& bounds = nullptr) : Index(index, 1, bounds) { } diff --git a/ydb/core/tablet_flat/flat_fwd_env.h b/ydb/core/tablet_flat/flat_fwd_env.h index dc9f4935c60..93c17490f64 100644 --- a/ydb/core/tablet_flat/flat_fwd_env.h +++ b/ydb/core/tablet_flat/flat_fwd_env.h @@ -59,11 +59,11 @@ namespace NFwd { public: const ui64 Cookie = Max<ui64>(); - const TIntrusiveConstPtr<IPageCollection> PageCollection; + const TIntrusiveConstPtr<IPageCollection> PageCollection; const TAutoPtr<IPageLoadingLogic> PageLoadingLogic; const ui32 Slot = Max<ui32>(); bool Grow = false; /* Should call Forward(...) for preloading */ - TAutoPtr<TFetch> Fetch; + TAutoPtr<TFetch> Fetch; }; struct TEnv: public IPages { @@ -72,7 +72,7 @@ namespace NFwd { struct TEgg { TAutoPtr<IPageLoadingLogic> PageLoadingLogic; - TIntrusiveConstPtr<IPageCollection> PageCollection; + TIntrusiveConstPtr<IPageCollection> PageCollection; }; public: @@ -186,7 +186,7 @@ namespace NFwd { std::accumulate(Queues.begin(), Queues.end(), Total, aggr); } - TAutoPtr<TFetch> GrabFetches() noexcept + TAutoPtr<TFetch> GrabFetches() noexcept { while (auto *q = Queue ? Queue.PopFront() : nullptr) { if (std::exchange(q->Grow, false)) @@ -204,7 +204,7 @@ namespace NFwd { return nullptr; } - TAutoPtr<TSeen> GrabTraces() noexcept + TAutoPtr<TSeen> GrabTraces() noexcept { TDeque<TSieve> sieves(Parts.size() - ColdParts.size() + 1); @@ -305,7 +305,7 @@ namespace NFwd { } } - TEgg MakeCache(const TPart *part, NPage::TGroupId groupId, TIntrusiveConstPtr<TSlices> bounds) const noexcept + TEgg MakeCache(const TPart *part, NPage::TGroupId groupId, TIntrusiveConstPtr<TSlices> bounds) const noexcept { auto *partStore = dynamic_cast<const TPartStore*>(part); @@ -319,7 +319,7 @@ namespace NFwd { return { new NFwd::TCache(index, bounds), cache->PageCollection }; } - TEgg MakeExtern(const TPart *part, TIntrusiveConstPtr<TSlices> bounds) const noexcept + TEgg MakeExtern(const TPart *part, TIntrusiveConstPtr<TSlices> bounds) const noexcept { if (auto blobs = part->Blobs) { /* Should always materialize key columns to values since @@ -349,7 +349,7 @@ namespace NFwd { } } - TEgg MakeOuter(const TPart *part, TIntrusiveConstPtr<TSlices> bounds) const noexcept + TEgg MakeOuter(const TPart *part, TIntrusiveConstPtr<TSlices> bounds) const noexcept { if (auto small = part->Small) { auto *partStore = CheckedCast<const TPartStore*>(part); diff --git a/ydb/core/tablet_flat/flat_fwd_sieve.h b/ydb/core/tablet_flat/flat_fwd_sieve.h index 39364e11a7d..3e161415fa7 100644 --- a/ydb/core/tablet_flat/flat_fwd_sieve.h +++ b/ydb/core/tablet_flat/flat_fwd_sieve.h @@ -15,9 +15,9 @@ namespace NFwd { TSieve() { }; TSieve( - TIntrusiveConstPtr<NPage::TExtBlobs> blobs, - TIntrusiveConstPtr<NPage::TFrames> frames, - TIntrusiveConstPtr<TSlices> slices, + TIntrusiveConstPtr<NPage::TExtBlobs> blobs, + TIntrusiveConstPtr<NPage::TFrames> frames, + TIntrusiveConstPtr<TSlices> slices, THoles holes) : Blobs(std::move(blobs)) , Frames(std::move(frames)) @@ -71,8 +71,8 @@ namespace NFwd { } } - TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; - TIntrusiveConstPtr<NPage::TFrames> Frames; + TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; + TIntrusiveConstPtr<NPage::TFrames> Frames; TSlicesRowFilter Filter; TDeque<TScreen::THole> Holes; }; diff --git a/ydb/core/tablet_flat/flat_fwd_warmed.h b/ydb/core/tablet_flat/flat_fwd_warmed.h index d5f3bfd7094..1e8adbbbf17 100644 --- a/ydb/core/tablet_flat/flat_fwd_warmed.h +++ b/ydb/core/tablet_flat/flat_fwd_warmed.h @@ -67,7 +67,7 @@ namespace NFwd { const TArrayRef<const ui32> Tags; const ui32 Edge = Max<ui32>(); ui64 Offset = Max<ui64>(); - TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; + TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; TDynBitMap Touches; }; } diff --git a/ydb/core/tablet_flat/flat_iterator.h b/ydb/core/tablet_flat/flat_iterator.h index e1b46d0b20f..60195c17b44 100644 --- a/ydb/core/tablet_flat/flat_iterator.h +++ b/ydb/core/tablet_flat/flat_iterator.h @@ -242,8 +242,8 @@ public: ~TTableItBase(); - void Push(TAutoPtr<TMemIt>); - void Push(TAutoPtr<TRunIt>); + void Push(TAutoPtr<TMemIt>); + void Push(TAutoPtr<TRunIt>); void StopBefore(TArrayRef<const TCell> key); void StopAfter(TArrayRef<const TCell> key); @@ -492,7 +492,7 @@ inline void TTableItBase<TIteratorOps>::AddNotReadyIterator(TIteratorId itId) { } template<class TIteratorOps> -inline void TTableItBase<TIteratorOps>::Push(TAutoPtr<TMemIt> it) +inline void TTableItBase<TIteratorOps>::Push(TAutoPtr<TMemIt> it) { if (it && it->IsValid()) { TIteratorId itId = { EType::Mem, ui16(MemIters.size()), AdjustEpoch(it->MemTable->Epoch) }; @@ -504,7 +504,7 @@ inline void TTableItBase<TIteratorOps>::Push(TAutoPtr<TMemIt> it) } template<class TIteratorOps> -inline void TTableItBase<TIteratorOps>::Push(TAutoPtr<TRunIt> it) +inline void TTableItBase<TIteratorOps>::Push(TAutoPtr<TRunIt> it) { TIteratorId itId = { EType::Run, ui16(RunIters.size()), AdjustEpoch(it->Epoch()) }; diff --git a/ydb/core/tablet_flat/flat_load_blob_queue.cpp b/ydb/core/tablet_flat/flat_load_blob_queue.cpp index 35a5df79acb..3c97b4a5359 100644 --- a/ydb/core/tablet_flat/flat_load_blob_queue.cpp +++ b/ydb/core/tablet_flat/flat_load_blob_queue.cpp @@ -11,7 +11,7 @@ namespace { const TLoadBlobQueueConfig& Config; friend IOutputStream& operator<<(IOutputStream& out, const TLogPrefix& value) { - out << (value.Config.Follower ? "Follower" : "Leader") + out << (value.Config.Follower ? "Follower" : "Leader") << "{" << value.Config.TabletID << ":" << value.Config.Generation << ":-} "; return out; } diff --git a/ydb/core/tablet_flat/flat_load_blob_queue.h b/ydb/core/tablet_flat/flat_load_blob_queue.h index 0cc535e27fa..8892e4f29f5 100644 --- a/ydb/core/tablet_flat/flat_load_blob_queue.h +++ b/ydb/core/tablet_flat/flat_load_blob_queue.h @@ -12,7 +12,7 @@ namespace NTabletFlatExecutor { struct TLoadBlobQueueConfig { ui64 TabletID = 0; ui32 Generation = 0; - bool Follower = false; + bool Follower = false; NMonitoring::TDynamicCounters::TCounterPtr NoDataCounter; ui64 MaxBytesInFly = 12 * 1024 * 1024; NKikimrBlobStorage::EGetHandleClass ReadPrio = NKikimrBlobStorage::FastRead; diff --git a/ydb/core/tablet_flat/flat_mem_iter.h b/ydb/core/tablet_flat/flat_mem_iter.h index 74beba8122e..5d1c4fdf25d 100644 --- a/ydb/core/tablet_flat/flat_mem_iter.h +++ b/ydb/core/tablet_flat/flat_mem_iter.h @@ -20,7 +20,7 @@ namespace NTable { using TCells = TArrayRef<const TCell>; TMemIt(const TMemTable* memTable, - TIntrusiveConstPtr<TKeyNulls> nulls, + TIntrusiveConstPtr<TKeyNulls> nulls, const TRemap* remap, IPages *env, NMem::TTreeIterator iterator) @@ -36,12 +36,12 @@ namespace NTable { Y_VERIFY(Remap, "Remap cannot be NULL"); } - static TAutoPtr<TMemIt> Make( + static TAutoPtr<TMemIt> Make( const TMemTable& memTable, const NMem::TTreeSnapshot& snapshot, TCells key, ESeek seek, - TIntrusiveConstPtr<TKeyNulls> nulls, + TIntrusiveConstPtr<TKeyNulls> nulls, const TRemap *remap, IPages *env, EDirection direction = EDirection::Forward) noexcept @@ -349,7 +349,7 @@ namespace NTable { public: const TMemTable *MemTable = nullptr; - const TIntrusiveConstPtr<TKeyNulls> Nulls; + const TIntrusiveConstPtr<TKeyNulls> Nulls; const TRemap* Remap = nullptr; IPages * const Env = nullptr; ui64 InvisibleRowSkips = 0; diff --git a/ydb/core/tablet_flat/flat_mem_warm.h b/ydb/core/tablet_flat/flat_mem_warm.h index 811a31b69e5..96bb9d65fad 100644 --- a/ydb/core/tablet_flat/flat_mem_warm.h +++ b/ydb/core/tablet_flat/flat_mem_warm.h @@ -431,7 +431,7 @@ namespace NMem { public: const TEpoch Epoch; - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; private: NMem::TBlobs Blobs; diff --git a/ydb/core/tablet_flat/flat_ops_compact.h b/ydb/core/tablet_flat/flat_ops_compact.h index 97f404c5a9c..2ac81c4113a 100644 --- a/ydb/core/tablet_flat/flat_ops_compact.h +++ b/ydb/core/tablet_flat/flat_ops_compact.h @@ -22,7 +22,7 @@ namespace NKikimr { namespace NTabletFlatExecutor { - struct TProdCompact: public IDestructable { + struct TProdCompact: public IDestructable { struct TResult { NTable::TPartView Part; TDeque<NTable::TScreen::THole> Growth; @@ -45,7 +45,7 @@ namespace NTabletFlatExecutor { bool Success = false; ui32 Step = Max<ui32>(); TResults Results; - TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; + TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; THolder<NTable::TCompactionParams> Params; TVector<ui32> YellowMoveChannels; TVector<ui32> YellowStopChannels; @@ -58,13 +58,13 @@ namespace NTabletFlatExecutor { using TWriter = NTable::TPartWriter; using TBundle = NWriter::TBundle; using TStorage = TIntrusivePtr<TTabletStorageInfo>; - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; public: constexpr static ui64 MaxFlight = 20ll * (1ll << 20); - TOpsCompact(TActorId owner, TLogoBlobID mask, TAutoPtr<TCompactCfg> conf) + TOpsCompact(TActorId owner, TLogoBlobID mask, TAutoPtr<TCompactCfg> conf) : ::NActors::IActor(static_cast<TReceiveFunc>(&TOpsCompact::Inbox), NKikimrServices::TActivity::OPS_COMPACT_A) , Mask(mask) , Owner(owner) @@ -94,7 +94,7 @@ namespace NTabletFlatExecutor { Logger = new NUtil::TLogger(sys, NKikimrServices::OPS_COMPACT); } - THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override + THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { TActivationContext::AsActorContext().RegisterWithSameMailbox(this); @@ -299,7 +299,7 @@ namespace NTabletFlatExecutor { TxStatus.emplace_back(new NTable::TTxStatusPartStore(dataId, Conf->Epoch, data)); } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { const auto fail = Failed || !Finished || abort != EAbort::None; @@ -393,7 +393,7 @@ namespace NTabletFlatExecutor { return scan; } - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (auto *ev = eh->CastAsLocal<TEvPutResult>()) { Handle(*ev); @@ -512,20 +512,20 @@ namespace NTabletFlatExecutor { private: const TLogoBlobID Mask; const TActorId Owner; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; IDriver * Driver = nullptr; THolder<TCompactCfg> Conf; - TIntrusiveConstPtr<TScheme> Scheme; - TAutoPtr<TBundle> Bundle; - TAutoPtr<TWriter> Writer; + TIntrusiveConstPtr<TScheme> Scheme; + TAutoPtr<TBundle> Bundle; + TAutoPtr<TWriter> Writer; NTable::TWritten Stat; TVector<TBundle::TResult> Results; - TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; + TVector<TIntrusiveConstPtr<NTable::TTxStatusPart>> TxStatus; const NScheme::TTypeRegistry * Registry = nullptr; bool Finished = false; bool Failed = false;/* Failed to write blobs */ - TAutoPtr<TSpent> Spent; /* Blockage on write stats */ + TAutoPtr<TSpent> Spent; /* Blockage on write stats */ ui64 Blobs = 0; /* Blobs produced by writer */ ui64 Writing = 0; /* Bytes flying to storage */ ui64 Flushing = 0; /* Bytes flushing to storage */ diff --git a/ydb/core/tablet_flat/flat_page_blobs.h b/ydb/core/tablet_flat/flat_page_blobs.h index e0d1a104c68..c5fdb7571ea 100644 --- a/ydb/core/tablet_flat/flat_page_blobs.h +++ b/ydb/core/tablet_flat/flat_page_blobs.h @@ -93,7 +93,7 @@ namespace NPage { return page < Array.size() ? Array[page] : Empty; } - bool Verify(ui32 page, TArrayRef<const char> data) const noexcept override + bool Verify(ui32 page, TArrayRef<const char> data) const noexcept override { return data && data.size() == Array.at(page).Bytes(); } diff --git a/ydb/core/tablet_flat/flat_page_label.cpp b/ydb/core/tablet_flat/flat_page_label.cpp index aeea08b33f6..2dba1043705 100644 --- a/ydb/core/tablet_flat/flat_page_label.cpp +++ b/ydb/core/tablet_flat/flat_page_label.cpp @@ -55,7 +55,7 @@ namespace NPage { } } - TSharedData THello::Wrap(TArrayRef<const char> plain, EPage page, ui16 version) noexcept + TSharedData THello::Wrap(TArrayRef<const char> plain, EPage page, ui16 version) noexcept { Y_VERIFY(!(version >> 15), "Version can use only 15 bits"); @@ -70,7 +70,7 @@ namespace NPage { return blob; } - TString THello::WrapString(TArrayRef<const char> plain, EPage page, ui16 version) noexcept + TString THello::WrapString(TArrayRef<const char> plain, EPage page, ui16 version) noexcept { Y_VERIFY(!(version >> 15), "Version can use only 15 bits"); diff --git a/ydb/core/tablet_flat/flat_page_label.h b/ydb/core/tablet_flat/flat_page_label.h index 5da21470f0b..eadf70983e7 100644 --- a/ydb/core/tablet_flat/flat_page_label.h +++ b/ydb/core/tablet_flat/flat_page_label.h @@ -35,7 +35,7 @@ namespace NPage { return Type == kind; } - TArrayRef<const char> operator*() const noexcept + TArrayRef<const char> operator*() const noexcept { return Page; } @@ -43,12 +43,12 @@ namespace NPage { EPage Type; ui16 Version; ECodec Codec; - TArrayRef<const char> Page; + TArrayRef<const char> Page; }; TResult Read(TArrayRef<const char>, EPage type = EPage::Undef) const noexcept; - static TSharedData Wrap(TArrayRef<const char>, EPage, ui16 version) noexcept; - static TString WrapString(TArrayRef<const char>, EPage, ui16 version) noexcept; + static TSharedData Wrap(TArrayRef<const char>, EPage, ui16 version) noexcept; + static TString WrapString(TArrayRef<const char>, EPage, ui16 version) noexcept; }; } diff --git a/ydb/core/tablet_flat/flat_page_writer.h b/ydb/core/tablet_flat/flat_page_writer.h index 1e0698a6fc8..005d3dd54c9 100644 --- a/ydb/core/tablet_flat/flat_page_writer.h +++ b/ydb/core/tablet_flat/flat_page_writer.h @@ -534,7 +534,7 @@ namespace NPage { } public: - const TIntrusiveConstPtr<TPartScheme> Scheme; + const TIntrusiveConstPtr<TPartScheme> Scheme; private: const TPgSize PageSize = 8 * 1024; @@ -555,7 +555,7 @@ namespace NPage { class TIndexWriter { public: - TIndexWriter(TIntrusiveConstPtr<TPartScheme> scheme, const TConf &conf, TGroupId groupId) + TIndexWriter(TIntrusiveConstPtr<TPartScheme> scheme, const TConf &conf, TGroupId groupId) : Scheme(std::move(scheme)) , MinSize(conf.Groups[groupId.Index].IndexMin) , GroupId(groupId) @@ -629,7 +629,7 @@ namespace NPage { } public: - const TIntrusiveConstPtr<TPartScheme> Scheme; + const TIntrusiveConstPtr<TPartScheme> Scheme; private: const TPgSize MinSize = 8 * 1024; diff --git a/ydb/core/tablet_flat/flat_part_forward.h b/ydb/core/tablet_flat/flat_part_forward.h index 64cb6454149..8c0ec51b9a2 100644 --- a/ydb/core/tablet_flat/flat_part_forward.h +++ b/ydb/core/tablet_flat/flat_part_forward.h @@ -28,7 +28,7 @@ namespace NTable { TPageId PageId = Max<TPageId>(); }; - explicit TForward(const TIndex& index, ui32 trace, const TIntrusiveConstPtr<TSlices>& bounds = nullptr) + explicit TForward(const TIndex& index, ui32 trace, const TIntrusiveConstPtr<TSlices>& bounds = nullptr) : Trace(Max(ui32(1), trace)) , Tail(index->Begin()) , Head(index->Begin()) diff --git a/ydb/core/tablet_flat/flat_part_iface.h b/ydb/core/tablet_flat/flat_part_iface.h index 41ec93545d0..9be72fc735a 100644 --- a/ydb/core/tablet_flat/flat_part_iface.h +++ b/ydb/core/tablet_flat/flat_part_iface.h @@ -36,7 +36,7 @@ namespace NTable { virtual ~IPageWriter() = default; virtual TPageId Write(TSharedData page, EPage type, ui32 group) = 0; virtual TPageId WriteOuter(TSharedData) noexcept = 0; - virtual void WriteInplace(TPageId page, TArrayRef<const char> body) = 0; + virtual void WriteInplace(TPageId page, TArrayRef<const char> body) = 0; virtual NPageCollection::TGlobId WriteLarge(TString blob, ui64 ref) noexcept = 0; virtual void Finish(TString overlay) noexcept = 0; }; diff --git a/ydb/core/tablet_flat/flat_part_iter_multi.h b/ydb/core/tablet_flat/flat_part_iter_multi.h index b64adbb217a..b26d83b378a 100644 --- a/ydb/core/tablet_flat/flat_part_iter_multi.h +++ b/ydb/core/tablet_flat/flat_part_iter_multi.h @@ -669,7 +669,7 @@ namespace NTable { using TCells = NPage::TCells; using TGroupId = NPage::TGroupId; - TPartSimpleIt(const TPart* part, TTagsRef tags, TIntrusiveConstPtr<TKeyNulls> nulls, IPages* env) + TPartSimpleIt(const TPart* part, TTagsRef tags, TIntrusiveConstPtr<TKeyNulls> nulls, IPages* env) : Part(part) , Env(env) , Pinout(Part->Scheme->MakePinout(tags)) @@ -1172,7 +1172,7 @@ namespace NTable { private: const TPinout Pinout; - const TIntrusiveConstPtr<TKeyNulls> Nulls; + const TIntrusiveConstPtr<TKeyNulls> Nulls; TPartGroupKeyIt Main; @@ -1211,7 +1211,7 @@ namespace NTable { public: using TCells = NPage::TCells; - TRunIt(const TRun& run, TTagsRef tags, TIntrusiveConstPtr<TKeyNulls> nulls, IPages* env) + TRunIt(const TRun& run, TTagsRef tags, TIntrusiveConstPtr<TKeyNulls> nulls, IPages* env) : Run(run) , Tags(tags) , Nulls(std::move(nulls)) @@ -1582,7 +1582,7 @@ namespace NTable { public: const TRun& Run; TTagsRef const Tags; - TIntrusiveConstPtr<TKeyNulls> const Nulls; + TIntrusiveConstPtr<TKeyNulls> const Nulls; IPages* const Env; ui64 InvisibleRowSkips = 0; diff --git a/ydb/core/tablet_flat/flat_part_keys.h b/ydb/core/tablet_flat/flat_part_keys.h index fcf0e4e6cae..457e5c24fb5 100644 --- a/ydb/core/tablet_flat/flat_part_keys.h +++ b/ydb/core/tablet_flat/flat_part_keys.h @@ -12,7 +12,7 @@ namespace NTable { public: using TCache = NTabletFlatExecutor::TPrivatePageCache::TInfo; - TKeysEnv(const TPart *part, TIntrusivePtr<TCache> cache) + TKeysEnv(const TPart *part, TIntrusivePtr<TCache> cache) : Part(part) , Cache(std::move(cache)) { @@ -50,7 +50,7 @@ namespace NTable { Y_VERIFY(bool(NeedPages) == has, "Loader does not have some ne"); } - TAutoPtr<NPageCollection::TFetch> GetFetches() + TAutoPtr<NPageCollection::TFetch> GetFetches() { if (NeedPages) { TVector<TPageId> pages(NeedPages.begin(), NeedPages.end()); @@ -71,7 +71,7 @@ namespace NTable { private: const TPart* Part; - TIntrusivePtr<TCache> Cache; + TIntrusivePtr<TCache> Cache; THashMap<TPageId, TSharedData> ExtraPages; THashSet<TPageId> NeedPages; }; @@ -85,14 +85,14 @@ namespace NTable { } - TIntrusivePtr<TSlices> Do(TIntrusiveConstPtr<TScreen> screen) + TIntrusivePtr<TSlices> Do(TIntrusiveConstPtr<TScreen> screen) { if (!screen) { // Use a full screen to simplify logic below screen = new TScreen({ TScreen::THole(true) }); } - TIntrusivePtr<TSlices> run = new TSlices; + TIntrusivePtr<TSlices> run = new TSlices; bool ok = SeekLastRow(); diff --git a/ydb/core/tablet_flat/flat_part_laid.h b/ydb/core/tablet_flat/flat_part_laid.h index 29a80329057..50aec4bcb12 100644 --- a/ydb/core/tablet_flat/flat_part_laid.h +++ b/ydb/core/tablet_flat/flat_part_laid.h @@ -8,7 +8,7 @@ namespace NKikimr { namespace NTable { - using TBundleSlicesMap = THashMap<TLogoBlobID, TIntrusiveConstPtr<TSlices>>; + using TBundleSlicesMap = THashMap<TLogoBlobID, TIntrusiveConstPtr<TSlices>>; struct TPartView { explicit operator bool() const @@ -47,9 +47,9 @@ namespace NTable { return TPartView{ Part->CloneWithEpoch(epoch), Screen, Slices }; } - TIntrusiveConstPtr<TPart> Part; - TIntrusiveConstPtr<TScreen> Screen; - TIntrusiveConstPtr<TSlices> Slices; + TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TScreen> Screen; + TIntrusiveConstPtr<TSlices> Slices; }; struct TWritten { diff --git a/ydb/core/tablet_flat/flat_part_loader.cpp b/ydb/core/tablet_flat/flat_part_loader.cpp index 6729a74f334..1e09175596f 100644 --- a/ydb/core/tablet_flat/flat_part_loader.cpp +++ b/ydb/core/tablet_flat/flat_part_loader.cpp @@ -9,7 +9,7 @@ namespace NKikimr { namespace NTable { -TLoader::TLoader(TVector<TIntrusivePtr<TCache>> pageCollections, +TLoader::TLoader(TVector<TIntrusivePtr<TCache>> pageCollections, TString legacy, TString opaque, TVector<TString> deltas, @@ -118,7 +118,7 @@ void TLoader::StageParseMeta() noexcept } } -TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept +TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept { Y_VERIFY(!PartView, "PartView already initialized in CreatePartView stage"); Y_VERIFY(Packs && Packs.front()); @@ -234,7 +234,7 @@ TAutoPtr<NPageCollection::TFetch> TLoader::StageCreatePartView() noexcept return nullptr; } -TAutoPtr<NPageCollection::TFetch> TLoader::StageSliceBounds() noexcept +TAutoPtr<NPageCollection::TFetch> TLoader::StageSliceBounds() noexcept { Y_VERIFY(PartView, "Cannot generate bounds for a missing part"); diff --git a/ydb/core/tablet_flat/flat_part_loader.h b/ydb/core/tablet_flat/flat_part_loader.h index 7545a696900..ab3d02d1d1f 100644 --- a/ydb/core/tablet_flat/flat_part_loader.h +++ b/ydb/core/tablet_flat/flat_part_loader.h @@ -38,15 +38,15 @@ namespace NTable { } - TLoader(TVector<TIntrusivePtr<TCache>>, TString legacy, TString opaque, + TLoader(TVector<TIntrusivePtr<TCache>>, TString legacy, TString opaque, TVector<TString> deltas = { }, TEpoch epoch = NTable::TEpoch::Max()); ~TLoader(); - TVector<TAutoPtr<NPageCollection::TFetch>> Run() + TVector<TAutoPtr<NPageCollection::TFetch>> Run() { while (Stage < EStage::Result) { - TAutoPtr<NPageCollection::TFetch> fetch; + TAutoPtr<NPageCollection::TFetch> fetch; switch (Stage) { case EStage::Meta: @@ -149,7 +149,7 @@ namespace NTable { return page == Max<TPageId>() ? nullptr : Packs[0]->Lookup(page); } - void ParseMeta(TArrayRef<const char> plain) noexcept + void ParseMeta(TArrayRef<const char> plain) noexcept { TMemoryInput stream(plain.data(), plain.size()); bool parsed = Root.ParseFromArcadiaStream(&stream); @@ -158,12 +158,12 @@ namespace NTable { } void StageParseMeta() noexcept; - TAutoPtr<NPageCollection::TFetch> StageCreatePartView() noexcept; - TAutoPtr<NPageCollection::TFetch> StageSliceBounds() noexcept; + TAutoPtr<NPageCollection::TFetch> StageCreatePartView() noexcept; + TAutoPtr<NPageCollection::TFetch> StageSliceBounds() noexcept; void StageDeltas() noexcept; private: - TVector<TIntrusivePtr<TCache>> Packs; + TVector<TIntrusivePtr<TCache>> Packs; const TString Legacy; const TString Opaque; const TVector<TString> Deltas; @@ -185,6 +185,6 @@ namespace NTable { TRowVersion MaxRowVersion; NProto::TRoot Root; TPartView PartView; - TAutoPtr<TKeysEnv> KeysEnv; + TAutoPtr<TKeysEnv> KeysEnv; }; }} diff --git a/ydb/core/tablet_flat/flat_part_outset.h b/ydb/core/tablet_flat/flat_part_outset.h index b6783929056..08ffc5925e4 100644 --- a/ydb/core/tablet_flat/flat_part_outset.h +++ b/ydb/core/tablet_flat/flat_part_outset.h @@ -11,7 +11,7 @@ namespace NTable { // fully identified by this LargeGlobId NPageCollection::TLargeGlobId LargeGlobId; // loaded meta page - TIntrusiveConstPtr<NPageCollection::TPageCollection> Packet; + TIntrusiveConstPtr<NPageCollection::TPageCollection> Packet; TVector<NPageCollection::TLoadedPage> Sticky; void ParsePacket(TSharedData meta); diff --git a/ydb/core/tablet_flat/flat_part_overlay.cpp b/ydb/core/tablet_flat/flat_part_overlay.cpp index b08a28e1e1d..d0e635e807a 100644 --- a/ydb/core/tablet_flat/flat_part_overlay.cpp +++ b/ydb/core/tablet_flat/flat_part_overlay.cpp @@ -76,7 +76,7 @@ TString TOverlay::Encode() const noexcept return encoded; } -TOverlay TOverlay::Decode(TArrayRef<const char> opaque, TArrayRef<const char> opaqueExt) noexcept +TOverlay TOverlay::Decode(TArrayRef<const char> opaque, TArrayRef<const char> opaqueExt) noexcept { TOverlay overlay; @@ -171,7 +171,7 @@ void TOverlay::Validate() const noexcept } } -void TOverlay::ApplyDelta(TArrayRef<const char> rawDelta) noexcept +void TOverlay::ApplyDelta(TArrayRef<const char> rawDelta) noexcept { NProto::TOverlayDelta plain; @@ -180,7 +180,7 @@ void TOverlay::ApplyDelta(TArrayRef<const char> rawDelta) noexcept } if (auto removedSlices = SlicesFromProto(plain.GetRemovedSlices())) { - TIntrusiveConstPtr<TSlices> removed = new TSlices(std::move(removedSlices)); + TIntrusiveConstPtr<TSlices> removed = new TSlices(std::move(removedSlices)); if (!TSlices::SupersetByRowId(Slices, removed)) { Y_Fail("Removing slices that are not a subset of existing slices"); } @@ -199,7 +199,7 @@ void TOverlay::ApplyDelta(TArrayRef<const char> rawDelta) noexcept } } -TString TOverlay::EncodeRemoveSlices(const TIntrusiveConstPtr<TSlices>& slices) noexcept +TString TOverlay::EncodeRemoveSlices(const TIntrusiveConstPtr<TSlices>& slices) noexcept { NProto::TOverlayDelta plain; diff --git a/ydb/core/tablet_flat/flat_part_overlay.h b/ydb/core/tablet_flat/flat_part_overlay.h index fe5cf0a67c5..4c6cee0e5fa 100644 --- a/ydb/core/tablet_flat/flat_part_overlay.h +++ b/ydb/core/tablet_flat/flat_part_overlay.h @@ -8,13 +8,13 @@ namespace NKikimr { namespace NTable { struct TOverlay { - static TOverlay Decode(TArrayRef<const char> opaque, TArrayRef<const char> ext) noexcept; + static TOverlay Decode(TArrayRef<const char> opaque, TArrayRef<const char> ext) noexcept; TString Encode() const noexcept; void Validate() const noexcept; - void ApplyDelta(TArrayRef<const char> delta) noexcept; + void ApplyDelta(TArrayRef<const char> delta) noexcept; - static TString EncodeRemoveSlices(const TIntrusiveConstPtr<TSlices>& slices) noexcept; + static TString EncodeRemoveSlices(const TIntrusiveConstPtr<TSlices>& slices) noexcept; static TString EncodeChangeSlices(TConstArrayRef<TSlice> slices) noexcept; /** @@ -24,8 +24,8 @@ namespace NTable { */ static TString MaybeUnsplitSlices(const TString& opaque, size_t maxSize = 1024 * 1024) noexcept; - TIntrusiveConstPtr<TScreen> Screen; - TIntrusiveConstPtr<TSlices> Slices; + TIntrusiveConstPtr<TScreen> Screen; + TIntrusiveConstPtr<TSlices> Slices; }; } diff --git a/ydb/core/tablet_flat/flat_part_scheme.h b/ydb/core/tablet_flat/flat_part_scheme.h index 6a05a70b600..06c3681ee22 100644 --- a/ydb/core/tablet_flat/flat_part_scheme.h +++ b/ydb/core/tablet_flat/flat_part_scheme.h @@ -50,7 +50,7 @@ namespace NTable { TPartScheme(const TPartScheme &scheme) = delete; explicit TPartScheme(TArrayRef<const TColInfo> cols); - static TIntrusiveConstPtr<TPartScheme> Parse(TArrayRef<const char>, bool labeled); + static TIntrusiveConstPtr<TPartScheme> Parse(TArrayRef<const char>, bool labeled); /** * Makes a sorted pin mapping for non-key columns @@ -128,7 +128,7 @@ namespace NTable { TGroupInfo HistoryGroup; TVector<TColumn> HistoryColumns; - TIntrusiveConstPtr<TKeyNulls> HistoryKeys; + TIntrusiveConstPtr<TKeyNulls> HistoryKeys; private: THashMap<TTag, const TColumn*> Tag2DataInfo; diff --git a/ydb/core/tablet_flat/flat_part_screen.h b/ydb/core/tablet_flat/flat_part_screen.h index bd3e89680e7..d66ad4e387f 100644 --- a/ydb/core/tablet_flat/flat_part_screen.h +++ b/ydb/core/tablet_flat/flat_part_screen.h @@ -96,14 +96,14 @@ namespace NTable { TScreen(TVec holes) : Holes(std::move(holes)) { } - static THole Iter(const TIntrusiveConstPtr<TScreen> &ref, size_t &on, TRowId rowId, int dir) + static THole Iter(const TIntrusiveConstPtr<TScreen> &ref, size_t &on, TRowId rowId, int dir) { on = ref ? ref->Lookup(rowId, dir) : Max<size_t>(); return ref ? ref->Hole(on) : THole(true); } - static THole Next(const TIntrusiveConstPtr<TScreen> &ref, size_t &on, int dir) + static THole Next(const TIntrusiveConstPtr<TScreen> &ref, size_t &on, int dir) { return ref ? ref->Hole(on += dir) : THole(false); } @@ -170,7 +170,7 @@ namespace NTable { } } - static TIntrusiveConstPtr<TScreen> Cut(TIntrusiveConstPtr<TScreen> scr, THole hole) noexcept + static TIntrusiveConstPtr<TScreen> Cut(TIntrusiveConstPtr<TScreen> scr, THole hole) noexcept { if (hole == THole(true)) { return scr; @@ -208,7 +208,7 @@ namespace NTable { } } - static TIntrusiveConstPtr<TScreen> Join(TIntrusiveConstPtr<TScreen> one, TIntrusiveConstPtr<TScreen> two) + static TIntrusiveConstPtr<TScreen> Join(TIntrusiveConstPtr<TScreen> one, TIntrusiveConstPtr<TScreen> two) { if (one == nullptr || one->Size() == 0) { return two; diff --git a/ydb/core/tablet_flat/flat_part_shrink.h b/ydb/core/tablet_flat/flat_part_shrink.h index 16983258253..f6c7cc6485b 100644 --- a/ydb/core/tablet_flat/flat_part_shrink.h +++ b/ydb/core/tablet_flat/flat_part_shrink.h @@ -15,7 +15,7 @@ namespace NTable { public: using TCells = TArrayRef<const TCell>; - TShrink(IPages *env, TIntrusiveConstPtr<TKeyNulls> nulls) + TShrink(IPages *env, TIntrusiveConstPtr<TKeyNulls> nulls) : Env(env) , Nulls(nulls) { @@ -87,7 +87,7 @@ namespace NTable { public: IPages * const Env = nullptr; - TIntrusiveConstPtr<TKeyNulls> Nulls; + TIntrusiveConstPtr<TKeyNulls> Nulls; size_t Skipped = 0; TVector<TPartView> PartView; }; diff --git a/ydb/core/tablet_flat/flat_part_slice.cpp b/ydb/core/tablet_flat/flat_part_slice.cpp index 9461cf52708..48755d3bf47 100644 --- a/ydb/core/tablet_flat/flat_part_slice.cpp +++ b/ydb/core/tablet_flat/flat_part_slice.cpp @@ -10,7 +10,7 @@ namespace NTable { namespace { -void PrintCells(IOutputStream& out, TArrayRef<const TCell> cells, const TNulls& nulls) noexcept +void PrintCells(IOutputStream& out, TArrayRef<const TCell> cells, const TNulls& nulls) noexcept { out << '{'; size_t pos = 0; @@ -230,7 +230,7 @@ void TSlices::Validate() const noexcept } } -TIntrusiveConstPtr<TScreen> TSlices::ToScreen() const noexcept +TIntrusiveConstPtr<TScreen> TSlices::ToScreen() const noexcept { TVector<TScreen::THole> holes; auto it = IterateRowRanges(); @@ -242,7 +242,7 @@ TIntrusiveConstPtr<TScreen> TSlices::ToScreen() const noexcept return new TScreen(std::move(holes)); } -bool TSlices::EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept +bool TSlices::EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept { if (!a || !b) { return !a == !b; @@ -259,7 +259,7 @@ bool TSlices::EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiv return bool(ait) == bool(bit); } -bool TSlices::SupersetByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept +bool TSlices::SupersetByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept { if (!a || !b) { return !a == !b; @@ -288,9 +288,9 @@ bool TSlices::SupersetByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntru } } -TIntrusiveConstPtr<TSlices> TSlices::Subtract( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b) noexcept +TIntrusiveConstPtr<TSlices> TSlices::Subtract( + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b) noexcept { if (!a || a->empty() || !b || b->empty()) { return a; // there's nothing to remove @@ -375,9 +375,9 @@ TIntrusiveConstPtr<TSlices> TSlices::Subtract( return new TSlices(std::move(result)); } -TIntrusiveConstPtr<TSlices> TSlices::Merge( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b) noexcept +TIntrusiveConstPtr<TSlices> TSlices::Merge( + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b) noexcept { if (!b || b->empty()) { return a; @@ -425,8 +425,8 @@ TIntrusiveConstPtr<TSlices> TSlices::Merge( return new TSlices(std::move(r)); } -TIntrusiveConstPtr<TSlices> TSlices::Cut( - TIntrusiveConstPtr<TSlices> run, +TIntrusiveConstPtr<TSlices> TSlices::Cut( + TIntrusiveConstPtr<TSlices> run, TRowId beginRowId, TRowId endRowId, TConstArrayRef<TCell> beginKey, @@ -469,7 +469,7 @@ TIntrusiveConstPtr<TSlices> TSlices::Cut( // No modifications necessary return run; } - TIntrusivePtr<TSlices> result = new TSlices; + TIntrusivePtr<TSlices> result = new TSlices; result->reserve(end - begin); result->insert(result->end(), begin, end); if (!result->empty()) { @@ -491,7 +491,7 @@ TIntrusiveConstPtr<TSlices> TSlices::Cut( return result; } -TIntrusiveConstPtr<TSlices> TSlices::Replace(TIntrusiveConstPtr<TSlices> run, TConstArrayRef<TSlice> slices) noexcept +TIntrusiveConstPtr<TSlices> TSlices::Replace(TIntrusiveConstPtr<TSlices> run, TConstArrayRef<TSlice> slices) noexcept { Y_VERIFY(run && !run->empty()); Y_VERIFY(slices); @@ -566,7 +566,7 @@ TLevels::iterator TLevels::AddLevel() return Levels.begin(); } -TLevels::TAddResult TLevels::Add(TIntrusiveConstPtr<TPart> part, const TSlice& slice) +TLevels::TAddResult TLevels::Add(TIntrusiveConstPtr<TPart> part, const TSlice& slice) { Y_VERIFY_S(part->Epoch >= MaxEpoch, "Adding part " << part->Label.ToString() << " (epoch " << part->Epoch << ") to levels with max epoch " << MaxEpoch); @@ -596,14 +596,14 @@ TLevels::TAddResult TLevels::Add(TIntrusiveConstPtr<TPart> part, const TSlice& s return TAddResult{ insertLevel, pos }; } -void TLevels::Add(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run) +void TLevels::Add(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run) { for (const auto& slice : *run) { Add(part, slice); } } -void TLevels::AddContiguous(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run) +void TLevels::AddContiguous(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run) { if (run->empty()) { return; diff --git a/ydb/core/tablet_flat/flat_part_slice.h b/ydb/core/tablet_flat/flat_part_slice.h index 4a00d5e0408..d0f361ef589 100644 --- a/ydb/core/tablet_flat/flat_part_slice.h +++ b/ydb/core/tablet_flat/flat_part_slice.h @@ -336,16 +336,16 @@ namespace NTable { /** * Converts run to a matching screen */ - TIntrusiveConstPtr<TScreen> ToScreen() const noexcept; + TIntrusiveConstPtr<TScreen> ToScreen() const noexcept; /** * Returns a special run that includes all possible rows * * Currently only used in tests when bounds are unavailable */ - static TIntrusiveConstPtr<TSlices> All() noexcept + static TIntrusiveConstPtr<TSlices> All() noexcept { - TIntrusivePtr<TSlices> run = new TSlices; + TIntrusivePtr<TSlices> run = new TSlices; run->emplace_back(); return run; } @@ -353,31 +353,31 @@ namespace NTable { /** * Returns true if both a and b have matching row id ranges */ - static bool EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; + static bool EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; /** * Returns true if a is a superset of b */ - static bool SupersetByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; + static bool SupersetByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; /** * Returns the result of removing b from a */ - static TIntrusiveConstPtr<TSlices> Subtract(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; + static TIntrusiveConstPtr<TSlices> Subtract(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; /** * Merges two sorted runs * Runs may intersect in which case they are merged */ - static TIntrusiveConstPtr<TSlices> Merge(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; + static TIntrusiveConstPtr<TSlices> Merge(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) noexcept; /** * Cuts run using [begin,end) range of row ids, with specified keys * Will only leave slices that potentially intersect with the range * Slices that are cut may be adjusted to the specified keys */ - static TIntrusiveConstPtr<TSlices> Cut( - TIntrusiveConstPtr<TSlices> run, + static TIntrusiveConstPtr<TSlices> Cut( + TIntrusiveConstPtr<TSlices> run, TRowId beginRowId, TRowId endRowId, TConstArrayRef<TCell> beginKey, @@ -386,7 +386,7 @@ namespace NTable { /** * Replaces row ranges with new slices in the specified run */ - static TIntrusiveConstPtr<TSlices> Replace(TIntrusiveConstPtr<TSlices> run, TConstArrayRef<TSlice> slices) noexcept; + static TIntrusiveConstPtr<TSlices> Replace(TIntrusiveConstPtr<TSlices> run, TConstArrayRef<TSlice> slices) noexcept; /** * Walks backwards until the first potential intersection with [0, rowId] range @@ -462,7 +462,7 @@ namespace NTable { { } - TSlicesRowFilter(TIntrusiveConstPtr<TSlices> slices) + TSlicesRowFilter(TIntrusiveConstPtr<TSlices> slices) : Slices(std::move(slices)) { if (Slices) { @@ -491,13 +491,13 @@ namespace NTable { return Current != Slices->end() && Current->Has(rowBegin, rowEnd); } - TIntrusiveConstPtr<TSlices> GetSlices() const noexcept + TIntrusiveConstPtr<TSlices> GetSlices() const noexcept { return Slices; } private: - TIntrusiveConstPtr<TSlices> Slices; + TIntrusiveConstPtr<TSlices> Slices; mutable TSlices::const_iterator Current; }; @@ -506,7 +506,7 @@ namespace NTable { */ class TRun { struct TItem { - const TIntrusiveConstPtr<TPart> Part; + const TIntrusiveConstPtr<TPart> Part; const TSlice Slice; }; @@ -660,12 +660,12 @@ namespace NTable { Y_FORCE_INLINE iterator begin() { return Slices.begin(); } Y_FORCE_INLINE iterator end() { return Slices.end(); } - std::pair<iterator, bool> Insert(TIntrusiveConstPtr<TPart> part, const TSlice& slice) + std::pair<iterator, bool> Insert(TIntrusiveConstPtr<TPart> part, const TSlice& slice) { return Slices.insert(TItem{ std::move(part), slice }); } - iterator Insert(const_iterator hint, TIntrusiveConstPtr<TPart> part, const TSlice& slice) + iterator Insert(const_iterator hint, TIntrusiveConstPtr<TPart> part, const TSlice& slice) { return Slices.insert(hint, TItem{ std::move(part), slice }); } @@ -783,7 +783,7 @@ namespace NTable { TRun::iterator Position; }; - explicit TLevels(TIntrusiveConstPtr<TKeyNulls> nulls) + explicit TLevels(TIntrusiveConstPtr<TKeyNulls> nulls) : Nulls(std::move(nulls)) { } @@ -797,11 +797,11 @@ namespace NTable { Y_FORCE_INLINE iterator begin() { return Levels.begin(); } Y_FORCE_INLINE iterator end() { return Levels.end(); } - TAddResult Add(TIntrusiveConstPtr<TPart> part, const TSlice& slice); + TAddResult Add(TIntrusiveConstPtr<TPart> part, const TSlice& slice); - void Add(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run); + void Add(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run); - void AddContiguous(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run); + void AddContiguous(TIntrusiveConstPtr<TPart> part, const TIntrusiveConstPtr<TSlices>& run); TEpoch GetMaxEpoch() const { return MaxEpoch; @@ -811,7 +811,7 @@ namespace NTable { iterator AddLevel(); private: - TIntrusiveConstPtr<TKeyNulls> Nulls; + TIntrusiveConstPtr<TKeyNulls> Nulls; TItems Levels; TEpoch MaxEpoch = TEpoch::Min(); }; diff --git a/ydb/core/tablet_flat/flat_part_store.h b/ydb/core/tablet_flat/flat_part_store.h index 5054290078e..ee0bc2324bc 100644 --- a/ydb/core/tablet_flat/flat_part_store.h +++ b/ydb/core/tablet_flat/flat_part_store.h @@ -79,7 +79,7 @@ public: return PageCollections[groupId.Index]->PageCollection->Page(id).Size; } - TIntrusiveConstPtr<TPart> CloneWithEpoch(TEpoch epoch) const override + TIntrusiveConstPtr<TPart> CloneWithEpoch(TEpoch epoch) const override { return new TPartStore(*this, epoch); } @@ -100,7 +100,7 @@ public: return (lob == ELargeObj::Extern ? Pseudo : PageCollections.at(Groups)).Get(); } - TAutoPtr<NPageCollection::TFetch> DataPages() const noexcept + TAutoPtr<NPageCollection::TFetch> DataPages() const noexcept { TVector<TPageId> pages; @@ -115,7 +115,7 @@ public: static TVector<TIntrusivePtr<TCache>> Construct(TVector<TPageCollectionComponents> components) noexcept { - TVector<TIntrusivePtr<TCache>> caches; + TVector<TIntrusivePtr<TCache>> caches; for (auto &one: components) { caches.emplace_back(new TCache(std::move(one.Packet))); @@ -127,17 +127,17 @@ public: return caches; } - static TArrayRef<const TIntrusivePtr<TCache>> Storages(const TPartView &partView) noexcept + static TArrayRef<const TIntrusivePtr<TCache>> Storages(const TPartView &partView) noexcept { auto *part = partView.As<TPartStore>(); Y_VERIFY(!partView || part, "Got an unexpected type of TPart part"); - return part ? part->PageCollections : TArrayRef<const TIntrusivePtr<TCache>> { }; + return part ? part->PageCollections : TArrayRef<const TIntrusivePtr<TCache>> { }; } - TVector<TIntrusivePtr<TCache>> PageCollections; - TIntrusivePtr<TCache> Pseudo; /* Cache for NPage::TBlobs */ + TVector<TIntrusivePtr<TCache>> PageCollections; + TIntrusivePtr<TCache> Pseudo; /* Cache for NPage::TBlobs */ }; class TTxStatusPartStore : public TTxStatusPart, public IBorrowBundle { diff --git a/ydb/core/tablet_flat/flat_part_writer.h b/ydb/core/tablet_flat/flat_part_writer.h index 7c2c5bfb77c..4e04732cd9c 100644 --- a/ydb/core/tablet_flat/flat_part_writer.h +++ b/ydb/core/tablet_flat/flat_part_writer.h @@ -37,7 +37,7 @@ namespace NTable { TPartWriter() = delete; TPartWriter(const TPartWriter&) = delete; - TPartWriter(TIntrusiveConstPtr<TPartScheme> scheme, TTagsRef tags, IPageWriter& pager, + TPartWriter(TIntrusiveConstPtr<TPartScheme> scheme, TTagsRef tags, IPageWriter& pager, const NPage::TConf &conf, TEpoch epoch) : Final(conf.Final) , SmallEdge(conf.SmallEdge) @@ -666,7 +666,7 @@ namespace NTable { return Pager.Write(std::move(page), type, group); } - void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept + void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept { NSan::CheckMemIsInitialized(body.data(), body.size()); @@ -802,7 +802,7 @@ namespace NTable { return { ELargeObj::Extern, ref }; } - TSharedData Encode(TArrayRef<const char> page, ECodec codec, bool force) noexcept + TSharedData Encode(TArrayRef<const char> page, ECodec codec, bool force) noexcept { Y_VERIFY(codec == ECodec::LZ4, "Only LZ4 encoding allowed"); @@ -883,7 +883,7 @@ namespace NTable { NPage::IKeySpace* const UnderlayMask; NPage::ISplitKeys* const SplitKeys; const TRowVersion MinRowVersion; - const TIntrusiveConstPtr<TPartScheme> Scheme; + const TIntrusiveConstPtr<TPartScheme> Scheme; const ICodec *CodecImpl = nullptr; IPageWriter& Pager; @@ -916,7 +916,7 @@ namespace NTable { TPgSize FirstKeyIndexSize = 0; TPgSize LastKeyIndexSize = 0; - TGroupState(const TIntrusiveConstPtr<TPartScheme>& scheme, const NPage::TConf& conf, TTagsRef tags, NPage::TGroupId groupId) + TGroupState(const TIntrusiveConstPtr<TPartScheme>& scheme, const NPage::TConf& conf, TTagsRef tags, NPage::TGroupId groupId) : ForceCompression(conf.Groups[groupId.Index].ForceCompression) , Codec(conf.Groups[groupId.Index].Codec) , Data(scheme, conf, tags, groupId) @@ -976,7 +976,7 @@ namespace NTable { bool Versioned = false; } Current; - TIntrusivePtr<TSlices> Slices; + TIntrusivePtr<TSlices> Slices; const TSharedData SchemeData; diff --git a/ydb/core/tablet_flat/flat_range_cache_ut.cpp b/ydb/core/tablet_flat/flat_range_cache_ut.cpp index b2b96d1714e..b5211519d90 100644 --- a/ydb/core/tablet_flat/flat_range_cache_ut.cpp +++ b/ydb/core/tablet_flat/flat_range_cache_ut.cpp @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TFlatEraseCacheTest) { TVector<NScheme::TTypeIdOrder> types; types.emplace_back(NScheme::NTypeIds::Uint64); TVector<TCell> defs(1); - TIntrusiveConstPtr<TKeyNulls> nulls = TKeyNulls::Make(types, defs); + TIntrusiveConstPtr<TKeyNulls> nulls = TKeyNulls::Make(types, defs); // Empty default config TKeyRangeCache cache(*nulls, { }); // Empty keys, both inclusive diff --git a/ydb/core/tablet_flat/flat_redo_player.h b/ydb/core/tablet_flat/flat_redo_player.h index d38ab704afa..4662f972a75 100644 --- a/ydb/core/tablet_flat/flat_redo_player.h +++ b/ydb/core/tablet_flat/flat_redo_player.h @@ -13,9 +13,9 @@ namespace NRedo { class TReader { public: - TReader(TArrayRef<const char> plain): Plain(plain), On(Plain.data()) { } + TReader(TArrayRef<const char> plain): Plain(plain), On(Plain.data()) { } - TArrayRef<const char> Next() noexcept + TArrayRef<const char> Next() noexcept { if (On >= Plain.end()) { return { nullptr, size_t(0) }; @@ -30,7 +30,7 @@ namespace NRedo { } private: - TArrayRef<const char> Plain; + TArrayRef<const char> Plain; const char *On = nullptr; }; @@ -39,7 +39,7 @@ namespace NRedo { public: TPlayer(TBase &base) : Base(base) { } - void Replay(TArrayRef<const char> plain) + void Replay(TArrayRef<const char> plain) { TReader iter(plain); @@ -58,7 +58,7 @@ namespace NRedo { } private: - void Handle(const TChunk* label, const TArrayRef<const char> chunk) + void Handle(const TChunk* label, const TArrayRef<const char> chunk) { switch (label->Event) { case ERedo::Noop: @@ -86,7 +86,7 @@ namespace NRedo { Y_FAIL("Unexpected rodo log chunk type"); } - void HandleLegacy(const TChunk_Legacy* label, const TArrayRef<const char> chunk) + void HandleLegacy(const TChunk_Legacy* label, const TArrayRef<const char> chunk) { if (!Base.NeedIn(label->RootId)) { return; @@ -115,7 +115,7 @@ namespace NRedo { } private: - void DoBegin(const TArrayRef<const char> chunk) + void DoBegin(const TArrayRef<const char> chunk) { if (chunk.size() < sizeof(TEvBegin_v0)) { Y_Fail("EvBegin event is tool small, " << chunk.size() << "b"); @@ -132,7 +132,7 @@ namespace NRedo { } } - void DoAnnex(const TArrayRef<const char> chunk) + void DoAnnex(const TArrayRef<const char> chunk) { Y_VERIFY(chunk.size() >= sizeof(TEvAnnex)); @@ -144,7 +144,7 @@ namespace NRedo { Base.DoAnnex({ raw, ev->Items }); } - void DoFlush(const TArrayRef<const char> chunk) + void DoFlush(const TArrayRef<const char> chunk) { Y_VERIFY(chunk.size() >= sizeof(TEvFlush)); @@ -154,7 +154,7 @@ namespace NRedo { Base.DoFlush(ev->Table, ev->Stamp, TEpoch(ev->Epoch)); } - void DoUpdate(const TArrayRef<const char> chunk) + void DoUpdate(const TArrayRef<const char> chunk) { auto *ev = reinterpret_cast<const TEvUpdate*>(chunk.data()); @@ -178,7 +178,7 @@ namespace NRedo { } } - void DoUpdateTx(const TArrayRef<const char> chunk) + void DoUpdateTx(const TArrayRef<const char> chunk) { auto *ev = reinterpret_cast<const TEvUpdate*>(chunk.data()); @@ -195,7 +195,7 @@ namespace NRedo { } } - void DoCommitTx(const TArrayRef<const char> chunk) + void DoCommitTx(const TArrayRef<const char> chunk) { auto *ev = reinterpret_cast<const TEvCommitTx*>(chunk.data()); @@ -206,7 +206,7 @@ namespace NRedo { } } - void DoRemoveTx(const TArrayRef<const char> chunk) + void DoRemoveTx(const TArrayRef<const char> chunk) { auto *ev = reinterpret_cast<const TEvRemoveTx*>(chunk.data()); @@ -215,7 +215,7 @@ namespace NRedo { } } - void DoUpdateLegacy(const TArrayRef<const char> chunk) + void DoUpdateLegacy(const TArrayRef<const char> chunk) { const char *buf = chunk.begin(); auto *op = (const TEvUpdate_Legacy*)buf; @@ -226,7 +226,7 @@ namespace NRedo { Base.DoUpdate(op->OpHeader.RootId, ERowOp::Upsert, KeyVec, OpsVec, TRowVersion::Min()); } - void DoEraseLegacy(const TArrayRef<const char> chunk) + void DoEraseLegacy(const TArrayRef<const char> chunk) { const char *buf = chunk.begin(); auto *op = (const TEvErase_Legacy*)buf; @@ -236,7 +236,7 @@ namespace NRedo { Base.DoUpdate(op->OpHeader.RootId, ERowOp::Erase, KeyVec, { }, TRowVersion::Min()); } - void DoFlushLegacy(const TArrayRef<const char> chunk) + void DoFlushLegacy(const TArrayRef<const char> chunk) { Y_VERIFY(chunk.size() >= sizeof(TEvFlush_Legacy)); diff --git a/ydb/core/tablet_flat/flat_row_nulls.h b/ydb/core/tablet_flat/flat_row_nulls.h index 0aadd15ae4a..f4e664b7ccf 100644 --- a/ydb/core/tablet_flat/flat_row_nulls.h +++ b/ydb/core/tablet_flat/flat_row_nulls.h @@ -27,7 +27,7 @@ namespace NTable { protected: template<class TSelf> - static TIntrusiveConstPtr<TSelf> Make( + static TIntrusiveConstPtr<TSelf> Make( TArrayRef<const TType> types, TArrayRef<const TOrder> order, TArrayRef<const TCell> defs) noexcept @@ -117,7 +117,7 @@ namespace NTable { } public: - static TIntrusiveConstPtr<TRowNulls> Make( + static TIntrusiveConstPtr<TRowNulls> Make( TArrayRef<const TType> types, TArrayRef<const TCell> defs) noexcept { @@ -142,7 +142,7 @@ namespace NTable { } public: - static TIntrusiveConstPtr<TKeyNulls> Make( + static TIntrusiveConstPtr<TKeyNulls> Make( TArrayRef<const TOrder> order, TArrayRef<const TCell> defs) noexcept { diff --git a/ydb/core/tablet_flat/flat_row_scheme.h b/ydb/core/tablet_flat/flat_row_scheme.h index 01539138915..fc750a12793 100644 --- a/ydb/core/tablet_flat/flat_row_scheme.h +++ b/ydb/core/tablet_flat/flat_row_scheme.h @@ -28,7 +28,7 @@ namespace NTable { Cells[idx] = cell; } - TIntrusiveConstPtr<TNullsType> operator*() const noexcept + TIntrusiveConstPtr<TNullsType> operator*() const noexcept { return TNullsType::Make(Types, Cells); } @@ -39,8 +39,8 @@ namespace NTable { TRowScheme( TVector<TColInfo> cols, - TIntrusiveConstPtr<TKeyNulls> keys, - TIntrusiveConstPtr<TRowNulls> nulls, + TIntrusiveConstPtr<TKeyNulls> keys, + TIntrusiveConstPtr<TRowNulls> nulls, TVector<ui32> families) : Cols(std::move(cols)) , Keys(std::move(keys)) @@ -53,7 +53,7 @@ namespace NTable { public: template<typename TGet, typename TSeq> - static TIntrusiveConstPtr<TRowScheme> Make(const TSeq &cols_, TGet) + static TIntrusiveConstPtr<TRowScheme> Make(const TSeq &cols_, TGet) { size_t keyCount = 0; TSet<ui32> familySet; @@ -151,8 +151,8 @@ namespace NTable { public: const TVector<TColInfo> Cols; - const TIntrusiveConstPtr<TKeyNulls> Keys; - const TIntrusiveConstPtr<TRowNulls> Nulls; + const TIntrusiveConstPtr<TKeyNulls> Keys; + const TIntrusiveConstPtr<TRowNulls> Nulls; const TVector<ui32> Families; // per-group families private: diff --git a/ydb/core/tablet_flat/flat_sausage_fetch.h b/ydb/core/tablet_flat/flat_sausage_fetch.h index 851ba3e7b7b..3654b9e745e 100644 --- a/ydb/core/tablet_flat/flat_sausage_fetch.h +++ b/ydb/core/tablet_flat/flat_sausage_fetch.h @@ -8,7 +8,7 @@ namespace NKikimr { namespace NPageCollection { struct TFetch { - TFetch(ui64 cookie, TIntrusiveConstPtr<IPageCollection> pageCollection, TVector<ui32> pages) + TFetch(ui64 cookie, TIntrusiveConstPtr<IPageCollection> pageCollection, TVector<ui32> pages) : Cookie(cookie) , PageCollection(std::move(pageCollection)) , Pages(std::move(pages)) @@ -25,7 +25,7 @@ namespace NPageCollection { const ui64 Cookie = Max<ui64>(); - TIntrusiveConstPtr<IPageCollection> PageCollection; + TIntrusiveConstPtr<IPageCollection> PageCollection; TVector<ui32> Pages; }; diff --git a/ydb/core/tablet_flat/flat_sausage_gut.h b/ydb/core/tablet_flat/flat_sausage_gut.h index 646a0ee4947..50ba86805e0 100644 --- a/ydb/core/tablet_flat/flat_sausage_gut.h +++ b/ydb/core/tablet_flat/flat_sausage_gut.h @@ -16,7 +16,7 @@ namespace NPageCollection { virtual TInfo Page(ui32 page) const noexcept = 0; virtual TBorder Bounds(ui32 page) const noexcept = 0; virtual TGlobId Glob(ui32 blob) const noexcept = 0; - virtual bool Verify(ui32 page, TArrayRef<const char>) const noexcept = 0; + virtual bool Verify(ui32 page, TArrayRef<const char>) const noexcept = 0; virtual size_t BackingSize() const noexcept = 0; }; diff --git a/ydb/core/tablet_flat/flat_sausage_packet.h b/ydb/core/tablet_flat/flat_sausage_packet.h index 8861da1be4e..7b53ed6bc7d 100644 --- a/ydb/core/tablet_flat/flat_sausage_packet.h +++ b/ydb/core/tablet_flat/flat_sausage_packet.h @@ -44,7 +44,7 @@ namespace NPageCollection { return Meta.Page(page); } - bool Verify(ui32 page, TArrayRef<const char> body) const noexcept override + bool Verify(ui32 page, TArrayRef<const char> body) const noexcept override { return Meta.Page(page).Size == body.size() diff --git a/ydb/core/tablet_flat/flat_sausage_record.h b/ydb/core/tablet_flat/flat_sausage_record.h index 982ba136d48..73badbcd0e2 100644 --- a/ydb/core/tablet_flat/flat_sausage_record.h +++ b/ydb/core/tablet_flat/flat_sausage_record.h @@ -33,7 +33,7 @@ namespace NPageCollection { return Blobs.emplace_back(one), *this; } - ui32 Push(ui32 type, TArrayRef<const char> body) + ui32 Push(ui32 type, TArrayRef<const char> body) { Index.push_back({ Offset += body.size(), Inbound.size() }); Extra.push_back({ type, Checksum(body) }); @@ -41,7 +41,7 @@ namespace NPageCollection { return Index.size() - 1; } - void PushInplace(ui32 page, TArrayRef<const char> body) + void PushInplace(ui32 page, TArrayRef<const char> body) { Y_VERIFY(Index && page == Index.size() - 1); diff --git a/ydb/core/tablet_flat/flat_sausage_writer.h b/ydb/core/tablet_flat/flat_sausage_writer.h index e98dab06bd1..c7cda9e2a47 100644 --- a/ydb/core/tablet_flat/flat_sausage_writer.h +++ b/ydb/core/tablet_flat/flat_sausage_writer.h @@ -23,7 +23,7 @@ namespace NPageCollection { return Record.Pages() || Blobs || Buffer; } - ui32 AddPage(const TArrayRef<const char> body, ui32 type) + ui32 AddPage(const TArrayRef<const char> body, ui32 type) { for (size_t offset = 0; offset < body.size(); ) { if (Buffer.capacity() == 0 && Block != Max<ui32>()) @@ -41,7 +41,7 @@ namespace NPageCollection { return Record.Push(type, body); } - void AddInplace(ui32 page, TArrayRef<const char> body) + void AddInplace(ui32 page, TArrayRef<const char> body) { Record.PushInplace(page, body); } diff --git a/ydb/core/tablet_flat/flat_sausagecache.cpp b/ydb/core/tablet_flat/flat_sausagecache.cpp index 08e4cac7020..4d396e8f758 100644 --- a/ydb/core/tablet_flat/flat_sausagecache.cpp +++ b/ydb/core/tablet_flat/flat_sausagecache.cpp @@ -15,7 +15,7 @@ TPrivatePageCache::TPage::TPage(ui32 size, ui32 pageId, TInfo* info) , Info(info) {} -TPrivatePageCache::TInfo::TInfo(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection) +TPrivatePageCache::TInfo::TInfo(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection) : Id(pageCollection->Label()) , PageCollection(std::move(pageCollection)) , Users(0) diff --git a/ydb/core/tablet_flat/flat_sausagecache.h b/ydb/core/tablet_flat/flat_sausagecache.h index 613ae829836..ac040eb0171 100644 --- a/ydb/core/tablet_flat/flat_sausagecache.h +++ b/ydb/core/tablet_flat/flat_sausagecache.h @@ -226,11 +226,11 @@ public: } const TLogoBlobID Id; - const TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; + const TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; TPageMap<THolder<TPage>> PageMap; ui64 Users; - explicit TInfo(TIntrusiveConstPtr<NPageCollection::IPageCollection> pack); + explicit TInfo(TIntrusiveConstPtr<NPageCollection::IPageCollection> pack); TInfo(const TInfo &info); }; diff --git a/ydb/core/tablet_flat/flat_scan_actor.h b/ydb/core/tablet_flat/flat_scan_actor.h index f88e494e486..5cbf2797a03 100644 --- a/ydb/core/tablet_flat/flat_scan_actor.h +++ b/ydb/core/tablet_flat/flat_scan_actor.h @@ -46,7 +46,7 @@ namespace NOps { return NKikimrServices::TActivity::TABLET_OPS_HOST_A; } - TDriver(ui64 serial, TAutoPtr<IScan> scan, TConf args, THolder<TScanSnapshot> snapshot) + TDriver(ui64 serial, TAutoPtr<IScan> scan, TConf args, THolder<TScanSnapshot> snapshot) : TActor(&TDriver::StateBoot) , NTable::TFeed(scan.Release(), *snapshot->Subset, snapshot->Snapshot) , Serial(serial) @@ -108,9 +108,9 @@ namespace NOps { }; struct TEvLoadPages : public TEventLocal<TEvLoadPages, EvLoadPages> { - TAutoPtr<NPageCollection::TFetch> Request; + TAutoPtr<NPageCollection::TFetch> Request; - TEvLoadPages(TAutoPtr<NPageCollection::TFetch> request) + TEvLoadPages(TAutoPtr<NPageCollection::TFetch> request) : Request(std::move(request)) { } }; @@ -168,7 +168,7 @@ namespace NOps { Y_VERIFY(!PageCollections[slot]); auto& loader = PageCollectionLoaders[slot]; if (loader.Apply(msg->BlobId, std::move(msg->Body))) { - TIntrusiveConstPtr<NPageCollection::IPageCollection> pack = + TIntrusiveConstPtr<NPageCollection::IPageCollection> pack = new NPageCollection::TPageCollection(Part->LargeGlobIds[slot], loader.ExtractSharedData()); PageCollections[slot] = new TPrivatePageCache::TInfo(std::move(pack)); Y_VERIFY(PageCollectionsLeft > 0); @@ -232,7 +232,7 @@ namespace NOps { private: TActorId Owner; TIntrusiveConstPtr<TColdPartStore> Part; - TVector<TIntrusivePtr<TPrivatePageCache::TInfo>> PageCollections; + TVector<TIntrusivePtr<TPrivatePageCache::TInfo>> PageCollections; TVector<NPageCollection::TLargeGlobIdRestoreState> PageCollectionLoaders; size_t PageCollectionsLeft = 0; std::optional<NTable::TLoader> Loader; @@ -292,7 +292,7 @@ namespace NOps { return Cache.Get(); } - TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>& part) noexcept override + TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>& part) noexcept override { const auto label = part->Label; auto itLoaded = ColdPartLoaded.find(label); @@ -725,12 +725,12 @@ namespace NOps { private: const ui64 Serial = 0; const NOps::TConf Args; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; TActorId Owner; THolder<TScanSnapshot> Snapshot; - TAutoPtr<TEnv> Cache; /* NFwd scan read ahead cache */ - TAutoPtr<TSpent> Spent; /* NBlockIO read blockage stats */ + TAutoPtr<TEnv> Cache; /* NFwd scan read ahead cache */ + TAutoPtr<TSpent> Spent; /* NBlockIO read blockage stats */ ui64 Depth = 0; ui64 Resets = 0; diff --git a/ydb/core/tablet_flat/flat_scan_eggs.h b/ydb/core/tablet_flat/flat_scan_eggs.h index d234cb35448..fb1bbcd9c3b 100644 --- a/ydb/core/tablet_flat/flat_scan_eggs.h +++ b/ydb/core/tablet_flat/flat_scan_eggs.h @@ -22,8 +22,8 @@ namespace NTabletFlatExecutor { struct TScanSnapshot { const ui32 Table; - TIntrusivePtr<TBarrier> Barrier; - TAutoPtr<NTable::TSubset> Subset; + TIntrusivePtr<TBarrier> Barrier; + TAutoPtr<NTable::TSubset> Subset; TRowVersion Snapshot; }; diff --git a/ydb/core/tablet_flat/flat_scan_events.h b/ydb/core/tablet_flat/flat_scan_events.h index 405ec614a52..730f94b0754 100644 --- a/ydb/core/tablet_flat/flat_scan_events.h +++ b/ydb/core/tablet_flat/flat_scan_events.h @@ -24,7 +24,7 @@ namespace NOps { using EAbort = NTable::EAbort; TEvResult(ui64 serial, EAbort abort, THolder<TScanSnapshot> snapshot, - TAutoPtr<IDestructable> result) + TAutoPtr<IDestructable> result) : Serial(serial) , Status(abort) , Result(result) @@ -36,10 +36,10 @@ namespace NOps { ui64 Serial = 0; EAbort Status = EAbort::None; - TAutoPtr<IDestructable> Result; - TIntrusivePtr<TBarrier> Barrier; - TAutoPtr<NTable::TSubset> Subset; - TAutoPtr<NTable::NFwd::TSeen> Trace; /* Seen blobs but not materialized */ + TAutoPtr<IDestructable> Result; + TIntrusivePtr<TBarrier> Barrier; + TAutoPtr<NTable::TSubset> Subset; + TAutoPtr<NTable::NFwd::TSeen> Trace; /* Seen blobs but not materialized */ }; struct TEvScanStat : public TEventLocal<TEvScanStat, ui32(EEv::ScanStat)> { diff --git a/ydb/core/tablet_flat/flat_scan_feed.h b/ydb/core/tablet_flat/flat_scan_feed.h index 8bc7e353421..c6784dac337 100644 --- a/ydb/core/tablet_flat/flat_scan_feed.h +++ b/ydb/core/tablet_flat/flat_scan_feed.h @@ -252,7 +252,7 @@ namespace NTable { private: virtual IPages* MakeEnv() noexcept = 0; - virtual TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>& part) noexcept = 0; + virtual TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>& part) noexcept = 0; EReady NotifyPageFault() noexcept { @@ -504,7 +504,7 @@ namespace NTable { THolder<TLevels> Levels; TLead Lead; TBoots Boots; - TAutoPtr<TTableIt> Iter; + TAutoPtr<TTableIt> Iter; ui64 Seeks = Max<ui64>(); ESeekState SeekState; bool OnPause = false; diff --git a/ydb/core/tablet_flat/flat_scan_iface.h b/ydb/core/tablet_flat/flat_scan_iface.h index 7b2cca3cdf2..6b0fa8e42d7 100644 --- a/ydb/core/tablet_flat/flat_scan_iface.h +++ b/ydb/core/tablet_flat/flat_scan_iface.h @@ -31,7 +31,7 @@ namespace NTable { At the end IDriver calls Finish() once requesting a product. After this IScan is left on its own and impl. have to take care of all owned resources and self object in particular. It is allowed for - IScan to return self as an IDestructable product. + IScan to return self as an IDestructable product. Limitations and caveats: @@ -78,7 +78,7 @@ namespace NTable { }; - class IScan : public IDestructable { + class IScan : public IDestructable { public: using TRow = NTable::TRowState; using IDriver = NTable::IDriver; @@ -112,10 +112,10 @@ namespace NTable { TConf Conf; /* Scan conveyer configuration */ }; - virtual THello Prepare(IDriver*, TIntrusiveConstPtr<TScheme>) noexcept = 0; + virtual THello Prepare(IDriver*, TIntrusiveConstPtr<TScheme>) noexcept = 0; virtual EScan Seek(TLead&, ui64 seq) noexcept = 0; virtual EScan Feed(TArrayRef<const TCell>, const TRow&) noexcept = 0; - virtual TAutoPtr<IDestructable> Finish(EAbort) noexcept = 0; + virtual TAutoPtr<IDestructable> Finish(EAbort) noexcept = 0; virtual void Describe(IOutputStream&) const noexcept = 0; /** diff --git a/ydb/core/tablet_flat/flat_stat_part.h b/ydb/core/tablet_flat/flat_stat_part.h index 7b0ce8fcf2f..230f94f04c5 100644 --- a/ydb/core/tablet_flat/flat_stat_part.h +++ b/ydb/core/tablet_flat/flat_stat_part.h @@ -97,7 +97,7 @@ private: // This shouldn't be a problem for big parts with many pages class TPartIndexIterator { public: - TPartIndexIterator(TIntrusiveConstPtr<TPart> part, TIntrusiveConstPtr<TKeyNulls> keys) + TPartIndexIterator(TIntrusiveConstPtr<TPart> part, TIntrusiveConstPtr<TKeyNulls> keys) : Part(std::move(part)) , KeyColumns(std::move(keys)) { @@ -196,8 +196,8 @@ private: }; private: - TIntrusiveConstPtr<TPart> Part; - TIntrusiveConstPtr<TKeyNulls> KeyColumns; + TIntrusiveConstPtr<TPart> Part; + TIntrusiveConstPtr<TKeyNulls> KeyColumns; NPage::TIndex::TIter Pos; NPage::TIndex::TIter End; TSmallVec<TCell> CurrentKey; @@ -212,8 +212,8 @@ private: // if page start key is not screened then the whole previous page is added to stats class TScreenedPartIndexIterator { public: - TScreenedPartIndexIterator(TPartView partView, TIntrusiveConstPtr<TKeyNulls> keyColumns, - TIntrusiveConstPtr<NPage::TFrames> small) + TScreenedPartIndexIterator(TPartView partView, TIntrusiveConstPtr<TKeyNulls> keyColumns, + TIntrusiveConstPtr<NPage::TFrames> small) : PartIter(partView.Part, keyColumns) , Screen(std::move(partView.Screen)) , Small(std::move(small)) @@ -307,8 +307,8 @@ private: private: TPartIndexIterator PartIter; - TIntrusiveConstPtr<TScreen> Screen; - TIntrusiveConstPtr<NPage::TFrames> Small; /* Inverted index for small blobs */ + TIntrusiveConstPtr<TScreen> Screen; + TIntrusiveConstPtr<NPage::TFrames> Small; /* Inverted index for small blobs */ size_t CurrentHoleIdx = 0; TScreen::THole CurrentHole; ui64 CurrentRowCount = 0; diff --git a/ydb/core/tablet_flat/flat_stat_table.h b/ydb/core/tablet_flat/flat_stat_table.h index fdc1dce7ee8..8a892b8a67c 100644 --- a/ydb/core/tablet_flat/flat_stat_table.h +++ b/ydb/core/tablet_flat/flat_stat_table.h @@ -13,7 +13,7 @@ namespace NTable { // Iterates over all parts and maintains total row count and data size class TStatsIterator { public: - explicit TStatsIterator(TIntrusiveConstPtr<TKeyNulls> keyColumns) + explicit TStatsIterator(TIntrusiveConstPtr<TKeyNulls> keyColumns) : KeyColumns(keyColumns) , Heap(TIterKeyGreater{ this }) {} @@ -102,7 +102,7 @@ private: return it->IsValid(); } - TIntrusiveConstPtr<TKeyNulls> KeyColumns; + TIntrusiveConstPtr<TKeyNulls> KeyColumns; THolderVector<TScreenedPartIndexIterator> Iterators; TPriorityQueue<TScreenedPartIndexIterator*, TSmallVec<TScreenedPartIndexIterator*>, TIterKeyGreater> Heap; TSerializedCellVec CurrentKey; diff --git a/ydb/core/tablet_flat/flat_store_hotdog.h b/ydb/core/tablet_flat/flat_store_hotdog.h index 7d5c9cd6574..1a2953bf409 100644 --- a/ydb/core/tablet_flat/flat_store_hotdog.h +++ b/ydb/core/tablet_flat/flat_store_hotdog.h @@ -41,7 +41,7 @@ namespace NTabletFlatExecutor { static void Snap(NKikimrExecutorFlat::TLogTableSnap *snap, const TIntrusiveConstPtr<TColdPart> &part, ui32 table, ui32 level); void Do(TBundle *bundle, const TPartView &partView); - void Do(TBundle *bundle, const TIntrusiveConstPtr<TColdPart> &part); + void Do(TBundle *bundle, const TIntrusiveConstPtr<TColdPart> &part); void Do(TBundle *bundle, const TPartComponents &pc); static TPartComponents MakePageCollectionComponents(const TBundle &proto, bool unsplit = false); diff --git a/ydb/core/tablet_flat/flat_table.cpp b/ydb/core/tablet_flat/flat_table.cpp index 6a71107a742..686a4042687 100644 --- a/ydb/core/tablet_flat/flat_table.cpp +++ b/ydb/core/tablet_flat/flat_table.cpp @@ -49,16 +49,16 @@ void TTable::SetScheme(const TScheme::TTableInfo &table) } } -TIntrusiveConstPtr<TRowScheme> TTable::GetScheme() const noexcept +TIntrusiveConstPtr<TRowScheme> TTable::GetScheme() const noexcept { return Scheme; } -TAutoPtr<TSubset> TTable::Subset(TArrayRef<const TLogoBlobID> bundle, TEpoch head) +TAutoPtr<TSubset> TTable::Subset(TArrayRef<const TLogoBlobID> bundle, TEpoch head) { head = Min(head, Epoch); - TAutoPtr<TSubset> subset = new TSubset(head, Scheme); + TAutoPtr<TSubset> subset = new TSubset(head, Scheme); if (head > TEpoch::Zero()) { for (auto &x : Frozen) { @@ -90,11 +90,11 @@ TAutoPtr<TSubset> TTable::Subset(TArrayRef<const TLogoBlobID> bundle, TEpoch hea return subset; } -TAutoPtr<TSubset> TTable::Subset(TEpoch head) const noexcept +TAutoPtr<TSubset> TTable::Subset(TEpoch head) const noexcept { head = Min(head, Epoch); - TAutoPtr<TSubset> subset = new TSubset(head, Scheme); + TAutoPtr<TSubset> subset = new TSubset(head, Scheme); for (const auto &it : TxStatus) { if (it.second->Epoch < head) { @@ -122,9 +122,9 @@ TAutoPtr<TSubset> TTable::Subset(TEpoch head) const noexcept return subset; } -TAutoPtr<TSubset> TTable::ScanSnapshot(TRowVersion snapshot) noexcept +TAutoPtr<TSubset> TTable::ScanSnapshot(TRowVersion snapshot) noexcept { - TAutoPtr<TSubset> subset = new TSubset(Epoch, Scheme); + TAutoPtr<TSubset> subset = new TSubset(Epoch, Scheme); // TODO: we could filter LSM by the provided snapshot version, but it // cannot be a simple if condition since row versions may intersect in @@ -153,7 +153,7 @@ TAutoPtr<TSubset> TTable::ScanSnapshot(TRowVersion snapshot) noexcept return subset; } -TAutoPtr<TSubset> TTable::Unwrap() noexcept +TAutoPtr<TSubset> TTable::Unwrap() noexcept { Snapshot(); @@ -194,7 +194,7 @@ void TTable::ReplaceSlices(TBundleSlicesMap slices) noexcept } } -void TTable::Replace(TArrayRef<const TPartView> partViews, const TSubset &subset) noexcept +void TTable::Replace(TArrayRef<const TPartView> partViews, const TSubset &subset) noexcept { for (const auto &partView : partViews) { Y_VERIFY(partView, "Replace(...) shouldn't get empty parts"); @@ -322,7 +322,7 @@ void TTable::Replace(TArrayRef<const TPartView> partViews, const TSubset &subset ErasedKeysCache.Reset(); } -void TTable::ReplaceTxStatus(TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> newTxStatus, const TSubset &subset) noexcept +void TTable::ReplaceTxStatus(TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>> newTxStatus, const TSubset &subset) noexcept { for (auto &part : subset.TxStatus) { Y_VERIFY(part, "Unexpected empty TTxStatusPart in TSubset"); @@ -378,7 +378,7 @@ void TTable::Merge(TPartView partView) noexcept ErasedKeysCache.Reset(); } -void TTable::Merge(TIntrusiveConstPtr<TColdPart> part) noexcept +void TTable::Merge(TIntrusiveConstPtr<TColdPart> part) noexcept { Y_VERIFY(part, "Merge(...) shouldn't get empty parts"); @@ -405,7 +405,7 @@ void TTable::Merge(TIntrusiveConstPtr<TColdPart> part) noexcept Levels.Reset(); } -void TTable::Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept +void TTable::Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept { Y_VERIFY(txStatus, "Unexpected empty TTxStatusPart"); @@ -484,18 +484,18 @@ const TLevels& TTable::GetLevels() const noexcept return *Levels; } -ui64 TTable::GetSearchHeight() const noexcept -{ - if (!ColdParts.empty()) - return 0; - - ui64 height = GetLevels().size() + Frozen.size(); - if (Mutable) - ++height; - - return height; -} - +ui64 TTable::GetSearchHeight() const noexcept +{ + if (!ColdParts.empty()) + return 0; + + ui64 height = GetLevels().size() + Frozen.size(); + if (Mutable) + ++height; + + return height; +} + TVector<TIntrusiveConstPtr<TMemTable>> TTable::GetMemTables() const noexcept { TVector<TIntrusiveConstPtr<TMemTable>> vec(Frozen.begin(), Frozen.end()); @@ -679,14 +679,14 @@ TMemTable& TTable::MemTable() *(Mutable ? Mutable : (Mutable = new TMemTable(Scheme, Epoch, Annexed))); } -TAutoPtr<TTableIt> TTable::Iterate(TRawVals key_, TTagsRef tags, IPages* env, ESeek seek, TRowVersion snapshot) const noexcept +TAutoPtr<TTableIt> TTable::Iterate(TRawVals key_, TTagsRef tags, IPages* env, ESeek seek, TRowVersion snapshot) const noexcept { Y_VERIFY(ColdParts.empty(), "Cannot iterate with cold parts"); const TCelled key(key_, *Scheme->Keys, false); const ui64 limit = seek == ESeek::Exact ? 1 : Max<ui64>(); - TAutoPtr<TTableIt> dbIter(new TTableIt(Scheme.Get(), tags, limit, snapshot, CommittedTransactions)); + TAutoPtr<TTableIt> dbIter(new TTableIt(Scheme.Get(), tags, limit, snapshot, CommittedTransactions)); if (Mutable) { dbIter->Push(TMemIt::Make(*Mutable, Mutable->Immediate(), key, seek, Scheme->Keys, &dbIter->Remap, env, EDirection::Forward)); @@ -717,14 +717,14 @@ TAutoPtr<TTableIt> TTable::Iterate(TRawVals key_, TTagsRef tags, IPages* env, ES return dbIter; } -TAutoPtr<TTableReverseIt> TTable::IterateReverse(TRawVals key_, TTagsRef tags, IPages* env, ESeek seek, TRowVersion snapshot) const noexcept +TAutoPtr<TTableReverseIt> TTable::IterateReverse(TRawVals key_, TTagsRef tags, IPages* env, ESeek seek, TRowVersion snapshot) const noexcept { Y_VERIFY(ColdParts.empty(), "Cannot iterate with cold parts"); const TCelled key(key_, *Scheme->Keys, false); const ui64 limit = seek == ESeek::Exact ? 1 : Max<ui64>(); - TAutoPtr<TTableReverseIt> dbIter(new TTableReverseIt(Scheme.Get(), tags, limit, snapshot, CommittedTransactions)); + TAutoPtr<TTableReverseIt> dbIter(new TTableReverseIt(Scheme.Get(), tags, limit, snapshot, CommittedTransactions)); if (Mutable) { dbIter->Push(TMemIt::Make(*Mutable, Mutable->Immediate(), key, seek, Scheme->Keys, &dbIter->Remap, env, EDirection::Reverse)); @@ -909,27 +909,27 @@ bool TTable::RemoveRowVersions(const TRowVersion& lower, const TRowVersion& uppe return RemovedRowVersions.Add(lower, upper); } -TCompactionStats TTable::GetCompactionStats() const -{ - TCompactionStats stats; - stats.MemRowCount = GetMemRowCount(); - stats.MemDataSize = GetMemSize(); - stats.MemDataWaste = GetMemWaste(); - - for (auto &it: ColdParts) - stats.PartOwners.insert(it.second->Label.TabletID()); - - for (auto &it: Flatten) - stats.PartOwners.insert(it.second->Label.TabletID()); - +TCompactionStats TTable::GetCompactionStats() const +{ + TCompactionStats stats; + stats.MemRowCount = GetMemRowCount(); + stats.MemDataSize = GetMemSize(); + stats.MemDataWaste = GetMemWaste(); + + for (auto &it: ColdParts) + stats.PartOwners.insert(it.second->Label.TabletID()); + + for (auto &it: Flatten) + stats.PartOwners.insert(it.second->Label.TabletID()); + for (auto &it: TxStatus) stats.PartOwners.insert(it.second->Label.TabletID()); - stats.PartCount = Flatten.size() + ColdParts.size(); - - return stats; -} - + stats.PartCount = Flatten.size() + ColdParts.size(); + + return stats; +} + void TPartStats::Add(const TPartView& partView) { PartsCount += 1; diff --git a/ydb/core/tablet_flat/flat_table.h b/ydb/core/tablet_flat/flat_table.h index be87fd1cf57..a1fdeb97093 100644 --- a/ydb/core/tablet_flat/flat_table.h +++ b/ydb/core/tablet_flat/flat_table.h @@ -32,7 +32,7 @@ class TKeyRangeCache; class TTable: public TAtomicRefCount<TTable> { public: - using TOpsRef = TArrayRef<const TUpdateOp>; + using TOpsRef = TArrayRef<const TUpdateOp>; using TMemGlob = NPageCollection::TMemGlob; struct TStat { @@ -66,7 +66,7 @@ public: void SetScheme(const TScheme::TTableInfo& tableScheme); - TIntrusiveConstPtr<TRowScheme> GetScheme() const noexcept; + TIntrusiveConstPtr<TRowScheme> GetScheme() const noexcept; TEpoch Snapshot() noexcept; @@ -75,10 +75,10 @@ public: return Epoch; } - TAutoPtr<TSubset> Subset(TArrayRef<const TLogoBlobID> bundle, TEpoch edge); - TAutoPtr<TSubset> Subset(TEpoch edge) const noexcept; - TAutoPtr<TSubset> ScanSnapshot(TRowVersion snapshot = TRowVersion::Max()) noexcept; - TAutoPtr<TSubset> Unwrap() noexcept; /* full Subset(..) + final Replace(..) */ + TAutoPtr<TSubset> Subset(TArrayRef<const TLogoBlobID> bundle, TEpoch edge); + TAutoPtr<TSubset> Subset(TEpoch edge) const noexcept; + TAutoPtr<TSubset> ScanSnapshot(TRowVersion snapshot = TRowVersion::Max()) noexcept; + TAutoPtr<TSubset> Unwrap() noexcept; /* full Subset(..) + final Replace(..) */ /** * Returns current slices for bundles @@ -99,8 +99,8 @@ public: be displaced from table with Clean() method eventually. */ - void Replace(TArrayRef<const TPartView>, const TSubset&) noexcept; - void ReplaceTxStatus(TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>>, const TSubset&) noexcept; + void Replace(TArrayRef<const TPartView>, const TSubset&) noexcept; + void ReplaceTxStatus(TArrayRef<const TIntrusiveConstPtr<TTxStatusPart>>, const TSubset&) noexcept; /*_ Special interface for clonig flatten part of table for outer usage. Cook some TPartView with Subset(...) method and/or TShrink tool first and @@ -108,8 +108,8 @@ public: */ void Merge(TPartView partView) noexcept; - void Merge(TIntrusiveConstPtr<TColdPart> part) noexcept; - void Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept; + void Merge(TIntrusiveConstPtr<TColdPart> part) noexcept; + void Merge(TIntrusiveConstPtr<TTxStatusPart> txStatus) noexcept; void ProcessCheckTransactions() noexcept; /** @@ -117,17 +117,17 @@ public: */ const TLevels& GetLevels() const noexcept; - /** - * Returns search height if there are no cold parts, 0 otherwise - */ - ui64 GetSearchHeight() const noexcept; - + /** + * Returns search height if there are no cold parts, 0 otherwise + */ + ui64 GetSearchHeight() const noexcept; + /* Hack for filling external blobs in TMemTable tables with data */ TVector<TIntrusiveConstPtr<TMemTable>> GetMemTables() const noexcept; - TAutoPtr<TTableIt> Iterate(TRawVals key, TTagsRef tags, IPages* env, ESeek, TRowVersion snapshot) const noexcept; - TAutoPtr<TTableReverseIt> IterateReverse(TRawVals key, TTagsRef tags, IPages* env, ESeek, TRowVersion snapshot) const noexcept; + TAutoPtr<TTableIt> Iterate(TRawVals key, TTagsRef tags, IPages* env, ESeek, TRowVersion snapshot) const noexcept; + TAutoPtr<TTableReverseIt> IterateReverse(TRawVals key, TTagsRef tags, IPages* env, ESeek, TRowVersion snapshot) const noexcept; TReady Select(TRawVals key, TTagsRef tags, IPages* env, TRowState& row, ui64 flg, TRowVersion snapshot, TDeque<TPartSimpleIt>& tempIterators) const noexcept; @@ -160,9 +160,9 @@ public: return parts; } - TVector<TIntrusiveConstPtr<TColdPart>> GetColdParts() const + TVector<TIntrusiveConstPtr<TColdPart>> GetColdParts() const { - TVector<TIntrusiveConstPtr<TColdPart>> parts(Reserve(ColdParts.size())); + TVector<TIntrusiveConstPtr<TColdPart>> parts(Reserve(ColdParts.size())); for (auto& x : ColdParts) { parts.emplace_back(x.second); @@ -178,14 +178,14 @@ public: } } - void EnumerateColdParts(const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const + void EnumerateColdParts(const std::function<void(const TIntrusiveConstPtr<TColdPart>&)>& callback) const { for (auto& x : ColdParts) { callback(x.second); } } - void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const + void EnumerateTxStatusParts(const std::function<void(const TIntrusiveConstPtr<TTxStatusPart>&)>& callback) const { for (auto& x : TxStatus) { callback(x.second); @@ -263,8 +263,8 @@ public: return RemovedRowVersions; } - TCompactionStats GetCompactionStats() const; - + TCompactionStats GetCompactionStats() const; + void FillTxStatusCache(THashMap<TLogoBlobID, TSharedData>& cache) const noexcept; private: @@ -277,18 +277,18 @@ private: private: struct TOpenTransaction { THashSet<TIntrusiveConstPtr<TMemTable>> Mem; - THashSet<TIntrusiveConstPtr<TPart>> Parts; + THashSet<TIntrusiveConstPtr<TPart>> Parts; }; private: TEpoch Epoch; /* Monotonic table change number, with holes */ ui64 Annexed = 0; /* Monotonic serial of attached external blobs */ - TIntrusiveConstPtr<TRowScheme> Scheme; + TIntrusiveConstPtr<TRowScheme> Scheme; TIntrusivePtr<TMemTable> Mutable; TSet<TIntrusiveConstPtr<TMemTable>, TOrderByEpoch<TMemTable>> Frozen; THashMap<TLogoBlobID, TPartView> Flatten; - THashMap<TLogoBlobID, TIntrusiveConstPtr<TColdPart>> ColdParts; - THashMap<TLogoBlobID, TIntrusiveConstPtr<TTxStatusPart>> TxStatus; + THashMap<TLogoBlobID, TIntrusiveConstPtr<TColdPart>> ColdParts; + THashMap<TLogoBlobID, TIntrusiveConstPtr<TTxStatusPart>> TxStatus; TEpoch FlattenEpoch = TEpoch::Min(); /* Current maximum flatten epoch */ TStat Stat_; mutable THolder<TLevels> Levels; diff --git a/ydb/core/tablet_flat/flat_table_misc.h b/ydb/core/tablet_flat/flat_table_misc.h index 5671b9ef207..9ffe2f3cd35 100644 --- a/ydb/core/tablet_flat/flat_table_misc.h +++ b/ydb/core/tablet_flat/flat_table_misc.h @@ -6,7 +6,7 @@ namespace NTable { template<typename TItem> struct TOrderByEpoch { - using TUnit = TIntrusiveConstPtr<TItem>; + using TUnit = TIntrusiveConstPtr<TItem>; bool operator()(const TUnit &left, const TUnit &right) const noexcept { diff --git a/ydb/core/tablet_flat/flat_table_part.cpp b/ydb/core/tablet_flat/flat_table_part.cpp index 709d531fa44..235229cc35e 100644 --- a/ydb/core/tablet_flat/flat_table_part.cpp +++ b/ydb/core/tablet_flat/flat_table_part.cpp @@ -29,7 +29,7 @@ TPartScheme::TPartScheme(TArrayRef<const TColInfo> cols) FillHistoricSlots(); } -TIntrusiveConstPtr<TPartScheme> TPartScheme::Parse(TArrayRef<const char> raw, bool labeled) +TIntrusiveConstPtr<TPartScheme> TPartScheme::Parse(TArrayRef<const char> raw, bool labeled) { if (labeled) { /* New styled scheme blob prepended with generic TLabel data */ diff --git a/ydb/core/tablet_flat/flat_table_part.h b/ydb/core/tablet_flat/flat_table_part.h index b26fc211488..aa555c515bd 100644 --- a/ydb/core/tablet_flat/flat_table_part.h +++ b/ydb/core/tablet_flat/flat_table_part.h @@ -48,18 +48,18 @@ namespace NTable { struct TEgg { TEpoch Epoch; - TIntrusiveConstPtr<TPartScheme> Scheme; + TIntrusiveConstPtr<TPartScheme> Scheme; TSharedData Index; - TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; - TIntrusiveConstPtr<NPage::TBloom> ByKey; - TIntrusiveConstPtr<NPage::TFrames> Large; - TIntrusiveConstPtr<NPage::TFrames> Small; + TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; + TIntrusiveConstPtr<NPage::TBloom> ByKey; + TIntrusiveConstPtr<NPage::TFrames> Large; + TIntrusiveConstPtr<NPage::TFrames> Small; TVector<TSharedData> GroupIndexes; TVector<TSharedData> HistoricIndexes; TRowVersion MinRowVersion; TRowVersion MaxRowVersion; - TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats; - TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats; + TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats; + TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats; }; struct TStat { @@ -119,7 +119,7 @@ namespace NTable { /** * Returns a cloned part with Epoch changed to the specified epoch */ - virtual TIntrusiveConstPtr<TPart> CloneWithEpoch(TEpoch epoch) const = 0; + virtual TIntrusiveConstPtr<TPart> CloneWithEpoch(TEpoch epoch) const = 0; virtual ui64 DataSize() const = 0; virtual ui64 BackingSize() const = 0; @@ -176,16 +176,16 @@ namespace NTable { public: const TLogoBlobID Label; const TEpoch Epoch; - const TIntrusiveConstPtr<TPartScheme> Scheme; - const TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; - const TIntrusiveConstPtr<NPage::TFrames> Large; - const TIntrusiveConstPtr<NPage::TFrames> Small; + const TIntrusiveConstPtr<TPartScheme> Scheme; + const TIntrusiveConstPtr<NPage::TExtBlobs> Blobs; + const TIntrusiveConstPtr<NPage::TFrames> Large; + const TIntrusiveConstPtr<NPage::TFrames> Small; const NPage::TIndex Index; const TVector<NPage::TIndex> GroupIndexes; const TVector<NPage::TIndex> HistoricIndexes; - const TIntrusiveConstPtr<NPage::TBloom> ByKey; - const TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats; - const TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats; + const TIntrusiveConstPtr<NPage::TBloom> ByKey; + const TIntrusiveConstPtr<NPage::TGarbageStats> GarbageStats; + const TIntrusiveConstPtr<NPage::TTxIdStatsPage> TxIdStats; const TStat Stat; const size_t Groups; const size_t IndexesRawSize; @@ -198,7 +198,7 @@ namespace NTable { */ class TTxStatusPart : public virtual TThrRefBase { public: - TTxStatusPart(const TLogoBlobID &label, TEpoch epoch, TIntrusiveConstPtr<NPage::TTxStatusPage> txStatusPage) + TTxStatusPart(const TLogoBlobID &label, TEpoch epoch, TIntrusiveConstPtr<NPage::TTxStatusPage> txStatusPage) : Label(label) , Epoch(epoch) , TxStatusPage(std::move(txStatusPage)) @@ -217,7 +217,7 @@ namespace NTable { public: const TLogoBlobID Label; const TEpoch Epoch; - const TIntrusiveConstPtr<NPage::TTxStatusPage> TxStatusPage; + const TIntrusiveConstPtr<NPage::TTxStatusPage> TxStatusPage; }; } diff --git a/ydb/core/tablet_flat/flat_table_part_ut.cpp b/ydb/core/tablet_flat/flat_table_part_ut.cpp index 2d04f675dca..185265a95ef 100644 --- a/ydb/core/tablet_flat/flat_table_part_ut.cpp +++ b/ydb/core/tablet_flat/flat_table_part_ut.cpp @@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { /* This is legacy place for UT, do not put here more tests */ - static TIntrusiveConstPtr<NPage::TFrames> CookFrames() + static TIntrusiveConstPtr<NPage::TFrames> CookFrames() { NPage::TFrameWriter writer(3); @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { "Unexpected " << eggs.Parts.size() << " results"); auto fnIterate = [&dbgOut, &typeRegistry] (TIntrusiveConstPtr<TPartStore> part, TIntrusiveConstPtr<TScreen> screen, - TIntrusiveConstPtr<TRowScheme> scheme, TIntrusiveConstPtr<NPage::TFrames> frames) -> std::pair<ui64, ui64> { + TIntrusiveConstPtr<TRowScheme> scheme, TIntrusiveConstPtr<NPage::TFrames> frames) -> std::pair<ui64, ui64> { TScreenedPartIndexIterator idxIter(TPartView{part, screen, nullptr}, scheme->Keys, std::move(frames)); ui64 rowCount = 0; @@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide all" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({}); + TIntrusiveConstPtr<TScreen> screen = new TScreen({}); auto res = fnIterate(eggs.At(0), screen, eggs.Scheme, nullptr); UNIT_ASSERT_VALUES_EQUAL_C(res.first, 0, "RowCount should be 0"); UNIT_ASSERT_VALUES_EQUAL_C(res.second, 0, "DataSize should be 0"); @@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide none" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(true)}); + TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(true)}); auto res = fnIterate(eggs.At(0), screen, eggs.Scheme, nullptr); UNIT_ASSERT_VALUES_EQUAL_C(res.first, expectedRowCount, "RowCount doesn't match"); UNIT_ASSERT_VALUES_EQUAL_C(res.second, expectedTotalSize, "DataSize doesn't match"); @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide 2 pages" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(0,150), TScreen::THole(550, 10000)}); + TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(0,150), TScreen::THole(550, 10000)}); auto res = fnIterate(eggs.At(0), screen, eggs.Scheme, nullptr); UNIT_ASSERT_VALUES_EQUAL_C(res.first, expectedRowCount - 400, "RowCount doesn't match"); UNIT_ASSERT_VALUES_EQUAL_C(res.second, expectedTotalSize - REAL_PAGE_SIZE*2, "DataSize doesn't match"); @@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide all except 3 pages" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(150, 400)}); + TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(150, 400)}); auto res = fnIterate(eggs.At(0), screen, eggs.Scheme, nullptr); UNIT_ASSERT_VALUES_EQUAL_C(res.first, 250, "RowCount doesn't match"); UNIT_ASSERT_VALUES_EQUAL_C(res.second, REAL_PAGE_SIZE*3, "DataSize doesn't match"); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide 2 rows in one page - we just ignore this" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(0,150), TScreen::THole(152, 10000)}); + TIntrusiveConstPtr<TScreen> screen = new TScreen({TScreen::THole(0,150), TScreen::THole(152, 10000)}); auto res = fnIterate(eggs.At(0), screen, eggs.Scheme, nullptr); UNIT_ASSERT_VALUES_EQUAL_C(res.first, expectedRowCount - 2, "RowCount doesn't match"); UNIT_ASSERT_VALUES_EQUAL_C(res.second, expectedTotalSize, "DataSize doesn't match"); @@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { dbgOut << "Hide 4 pages in 3 different ranges" << Endl; { - TIntrusiveConstPtr<TScreen> screen = new TScreen({ + TIntrusiveConstPtr<TScreen> screen = new TScreen({ TScreen::THole(400, 600), TScreen::THole(850, 950), TScreen::THole(1200, 10000) @@ -204,7 +204,7 @@ Y_UNIT_TEST_SUITE(TLegacy) { auto frames = CookFrames(); // This screen takes two pages, one of them has 4 small blobs, 1800 total bytes - TIntrusiveConstPtr<TScreen> screen = new TScreen({ + TIntrusiveConstPtr<TScreen> screen = new TScreen({ TScreen::THole(169, 338), TScreen::THole(845, 1014) }); @@ -270,13 +270,13 @@ Y_UNIT_TEST_SUITE(TLegacy) { UNIT_ASSERT_C(eggs2.Parts.size() == 1, "Unexpected " << eggs2.Parts.size() << " results"); - TIntrusiveConstPtr<TScreen> screen1 = new TScreen({ + TIntrusiveConstPtr<TScreen> screen1 = new TScreen({ TScreen::THole(400, 600), TScreen::THole(700, 800), TScreen::THole(1200, 100000) }); - TIntrusiveConstPtr<TScreen> screen2 = new TScreen({ + TIntrusiveConstPtr<TScreen> screen2 = new TScreen({ TScreen::THole(2400, 2600), TScreen::THole(2700, 2800), TScreen::THole(4200, 100000) diff --git a/ydb/core/tablet_flat/flat_table_stats.h b/ydb/core/tablet_flat/flat_table_stats.h index 9107bde145e..5b600dcf13a 100644 --- a/ydb/core/tablet_flat/flat_table_stats.h +++ b/ydb/core/tablet_flat/flat_table_stats.h @@ -38,13 +38,13 @@ namespace NTable { ui64 Invisible = 0; }; - struct TCompactionStats { - THashSet<ui64> PartOwners; - ui64 PartCount = 0; - ui64 MemRowCount = 0; - ui64 MemDataSize = 0; - ui64 MemDataWaste = 0; - }; - + struct TCompactionStats { + THashSet<ui64> PartOwners; + ui64 PartCount = 0; + ui64 MemRowCount = 0; + ui64 MemDataSize = 0; + ui64 MemDataWaste = 0; + }; + } } diff --git a/ydb/core/tablet_flat/flat_table_subset.h b/ydb/core/tablet_flat/flat_table_subset.h index ad858661ea8..bffbf5a1271 100644 --- a/ydb/core/tablet_flat/flat_table_subset.h +++ b/ydb/core/tablet_flat/flat_table_subset.h @@ -91,7 +91,7 @@ namespace NTable { return minVersion; } - TSubset(TEpoch head, TIntrusiveConstPtr<TRowScheme> scheme) + TSubset(TEpoch head, TIntrusiveConstPtr<TRowScheme> scheme) : Head(head) , Scheme(std::move(scheme)) { } @@ -104,7 +104,7 @@ namespace NTable { { } // This constructor is mainly for tests - TSubset(TEpoch head, TIntrusiveConstPtr<TRowScheme> scheme, TVector<TPartView> flatten) + TSubset(TEpoch head, TIntrusiveConstPtr<TRowScheme> scheme, TVector<TPartView> flatten) : Head(head) , Scheme(std::move(scheme)) , Flatten(std::move(flatten)) @@ -112,15 +112,15 @@ namespace NTable { const TEpoch Head; - TIntrusiveConstPtr<TRowScheme> Scheme; + TIntrusiveConstPtr<TRowScheme> Scheme; TVector<TMemTableSnapshot> Frozen; TVector<TPartView> Flatten; - TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; + TVector<TIntrusiveConstPtr<TColdPart>> ColdParts; TTransactionMap<TRowVersion> CommittedTransactions; TTransactionSet RemovedTransactions; - TVector<TIntrusiveConstPtr<TTxStatusPart>> TxStatus; + TVector<TIntrusiveConstPtr<TTxStatusPart>> TxStatus; }; - using TGarbage = TVector<TAutoPtr<TSubset>>; /* data of deleted tables */ + using TGarbage = TVector<TAutoPtr<TSubset>>; /* data of deleted tables */ } } diff --git a/ydb/core/tablet_flat/flat_writer_blocks.h b/ydb/core/tablet_flat/flat_writer_blocks.h index 38f8e87dd08..b35da85e166 100644 --- a/ydb/core/tablet_flat/flat_writer_blocks.h +++ b/ydb/core/tablet_flat/flat_writer_blocks.h @@ -38,9 +38,9 @@ namespace NWriter { return Writer || Regular || Sticky; } - TIntrusivePtr<TCache> Finish() noexcept + TIntrusivePtr<TCache> Finish() noexcept { - TIntrusivePtr<TCache> pageCollection; + TIntrusivePtr<TCache> pageCollection; if (auto meta = Writer.Finish(false /* omit empty page collection */)) { for (auto &glob : Writer.Grab()) @@ -71,19 +71,19 @@ namespace NWriter { return pageId; } - void WriteInplace(TPageId page, TArrayRef<const char> body) + void WriteInplace(TPageId page, TArrayRef<const char> body) { Writer.AddInplace(page, body); } private: - TIntrusivePtr<TCache> MakePageCollection(TSharedData body) noexcept + TIntrusivePtr<TCache> MakePageCollection(TSharedData body) noexcept { auto largeGlobId = CutToChunks(body); auto *pack = new NPageCollection::TPageCollection(largeGlobId, std::move(body)); - TIntrusivePtr<TCache> cache = new TCache(pack); + TIntrusivePtr<TCache> cache = new TCache(pack); const bool sticky = (Cache == ECache::Ever); @@ -96,7 +96,7 @@ namespace NWriter { return cache; } - NPageCollection::TLargeGlobId CutToChunks(TArrayRef<const char> body) + NPageCollection::TLargeGlobId CutToChunks(TArrayRef<const char> body) { return Cone->Put(0, Channel, body, Writer.Block); } diff --git a/ydb/core/tablet_flat/flat_writer_bundle.h b/ydb/core/tablet_flat/flat_writer_bundle.h index 08f7f90bb9f..d489e51e9df 100644 --- a/ydb/core/tablet_flat/flat_writer_bundle.h +++ b/ydb/core/tablet_flat/flat_writer_bundle.h @@ -15,7 +15,7 @@ namespace NWriter { struct TResult { using TCache = TPrivatePageCache::TInfo; - TVector<TIntrusivePtr<TCache>> PageCollections; + TVector<TIntrusivePtr<TCache>> PageCollections; TDeque<NTable::TScreen::THole> Growth; TString Overlay; }; @@ -58,7 +58,7 @@ namespace NWriter { return std::move(Results_); } - NPageCollection::TLargeGlobId WriteExtra(TArrayRef<const char> body) noexcept + NPageCollection::TLargeGlobId WriteExtra(TArrayRef<const char> body) noexcept { return Put(/* data cookieRange */ 1, ExtraChannel, body, Groups[0].Block); } @@ -75,7 +75,7 @@ namespace NWriter { Blocks.back()->Write(std::move(page), EPage::Opaque); } - void WriteInplace(TPageId page, TArrayRef<const char> body) override + void WriteInplace(TPageId page, TArrayRef<const char> body) override { Blocks[0]->WriteInplace(page, body); } @@ -153,7 +153,7 @@ namespace NWriter { TBanks Banks; TVector<NPageCollection::TGlob> Blobs; TVector<THolder<TBlocks>> Blocks; - TAutoPtr<NTable::TScreen::TCook> Growth; + TAutoPtr<NTable::TScreen::TCook> Growth; TVector<TResult> Results_; }; diff --git a/ydb/core/tablet_flat/img/ForcedCompactionPath.drawio b/ydb/core/tablet_flat/img/ForcedCompactionPath.drawio index 93487c787c3..0d72478a7f8 100644 --- a/ydb/core/tablet_flat/img/ForcedCompactionPath.drawio +++ b/ydb/core/tablet_flat/img/ForcedCompactionPath.drawio @@ -1 +1 @@ -<mxfile host="drawio.yandex-team.ru" modified="2021-10-01T10:53:18.644Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 YaBrowser/21.8.0.1716 Yowser/2.5 Safari/537.36" etag="RSkPFFk8RhCT1XBSn7Io" version="12.7.0" type="device"><diagram id="6qUEMAEqJytyNpZO1J5A" name="Page-1">7V1bc5s4GP01frQHSQjwY5NedmfaTmezs9s+EiPbbAm4GCdOf/0KkADJAnPHiZM8BD4kAeLo6LtJmaHbh+On0N5tvwQO8WZQc44z9H4GoQ40nf6JJc+pBGINpZJN6DqpDOSCO/c3YUKNSQ+uQ/ZCwSgIvMjdicJV4PtkFQkyOwyDJ7HYOvDEu+7sDTkR3K1s71T6r+tE21RqQTOX/0HczZbfGRjL9MqDzQuzN9lvbSd4KojQhxm6DYMgSo8ejrfEi3uP90ta72PJ1ezBQuJHdSr88/h82MG7vx+/evf+7e/5LXa+zg2YNvNoewf2xuxpo2feBWFw8B0St6LN0M3T1o3I3c5exVef6Fensm304NEzQA/XrufdBl4QJnXRGse/VL6PwuAnKVwxkp+4RuBHBXn6Q+XswUgYkWPpK4OsIykESfBAovCZFmEV5sDgOGL4myN2/pR/TAB4oW3hSy41JrQZgjZZ83kn0wPWzw36XAevus/1Ol2OkaLLAUBD9bkK5oYXsa4Q+t74dQj4hfk+IaR3tADQd8f8Ij3asL9JK/dc8DEIV8T5Qh5ugwf6wSI38P90aPWk6RhSt1mVUKxzF9kRyUp+DXzCS9I3vpdvSGXpk3OxBCDaJ5QiyXnw2Ptdyptr9xgDTkaTYxNrvVKiaWWR+3VPqEGmiBqgn6IGqsZpJuwdM6gUMydfoxuIqjHzvS1mRHyooPSyMWNIiMGTI0a/DJapj5hvxHdcf3NFRCOBxtTMBZ4aNsg87VWHaqHsNAijbbAJfNv7kEtvRA0hL/M5CHasx/8jUfTMVGr7EAVURLz7RAeN+9ClWq74icjRjb7HLS4wO/tRuPL+yG6WnDzzE592wffiSVYnPskrJWe81uoQPiYPD7LPGr9y9UelPRQcwhWp6Er2LSM73JDoHLefgiQknh25j+JzqL53UvVdGNrPhQK7wPWjfaHlb7Egx54JkAC+JbBEjf1c+aVWWX4uzaFNyyO4lLCcvmGO7Kyr2oOd6p8jTas5N350fXe/pXg7IcWvQWIUxswYG5vET0xJXo+e/DqQQ16xzaxKuSqSmNBzNz49XlF4E8pxN3w0vmMXHlzHSQc5oS9p3ydNxcOGIYy2i29m+D2VePY98W7s1c9NQghFMyD5qWJNZjOz9meZpVoceBWEVcqx2gItoSEaAeyWzQaYArFgoZliy/R2DLdZQ8F6vafDX+blHtCLz4O3r7mZVy+bnl/6PGwsIBbnYqAtDHQ6GWtoYWLFfFyQ9z4ll5PUhdqLV6/J6Qo3w8h6nDnWzNYXaJQU8/rNRiwBB6pMAE1JOUPxDcdklU+QjvB3sUc71hw8e793V2rtnR//EDT5Jto7q1Whv/eossNuKnvhm2HFaOeyropHphzxycqSWCR9T1atSukGktZtyk7PtCdOWupLhQEq93MfrHRDNq7PSKnunDO5chw/HTe0ecf0qCkDTY1aDgZtofFwAI+QdcMrd4bBhVxpOKUYqLzrLclLdD1og5DXeefKUO4J9BK4TiaotkyHlpKDFtYjuqZulbkUcOJRpEHdGKA8OvDGor2zKByZRTNkwYUu+uAgXuhwNGJVuRt6Ida6Pt2cS38Urw2vFdZlSmNSrVDXJKo022qFCEst1STL3qA2pceDVnY6xrsnp8BOrFdtsdIZeKFpyFrqBtTorCpSHcVgfBWZCFumubSQ0RjGltDgXDJyh+M3qDJFroPfjJr8pk/Kb1jit2VrftMlfluOzG8cWcM754oKHKe3a40eneE1WMVrhiXymt5ce0NLkdiARI0DMpvKPGjKbG3N2xZ+wAmYrSSGOBKzIdQXs2X28VTMVp511DOz/UXYx4faTeygD9PCe/qC0RvHqTkOVepuGHTV3ZCou6HRCK5H0/SFBSz0mgSHpyQ4KPGbBSStvi6/nZi4ckND09tohmlNenszTYv0VqnCWVpHFQ6AyUxTVTD/OkxT8yXwmy4FFwzcUn/T5XCsvO5naH6zxuK3SsP0jdUKrIYNLLAaFKG27MhqmZqW2aVSEwPS2nIoWqsbqm1Ga8VQbZK7XozSKpLZJ6BBOCUNXoAd2zRcm63s4uFaMEK41qg0ki8owzyveAWmcwVFlXIz5V4LS/yJuo2l4WkXlXufe57k60DyY5P1Dm+KQQF8lmTuiIpBd28O0ER7Z7R1DagPf7XCnXPG2JksEWtS28WA+kKMTFh6S++MBUQIWnJye1+TtibnJ1hm5YOdVDCW1Yvd5DeRyg+jFqDRfOe98/Kbl73Ay0u9ipetzpHEqbxQqM8EsBbGWtFUO7ekt292fgshjuaDQqOtya2V/PVGbcXlSqCK2syuHva5lN+ahZOHJzeeR9vBKIJNjSJa5y4K7Yhs4i7+RHp2gYoL1/wY1uIqNyaqD0/Vkjpx64dS7DVIxJGWxGUZ9QUmRSoqlXmqv51UrNN5rpmx0G5/jG7mDJ83s6ly9Nh0Xadlycw57P4XQJPW7BpatU1wUkFnRkKpEQG7lcdM4RrWF6la6zmYM8gjyYJfOuXO8gW/3UI/U43EVgEHcSyOqMNqNYcihh3HYieixefByPfk5HBDTZL8Z+VrzYuu7pu42/1mrvBXuavB3DrZlEexrwFUzcWDTca4fNeTngnrW0jirkrQ0w9XDaIG1E9SmyyJA/PNctvSTxZugdgSd9zhFkLnxXVjGRq8LwbnuOIGjNfJXkDOy1Ftyjgye5VvyzJcAuF9nwmEl6FvXXzeGoZ1Ka/r7n/d8Hje7dEPG0lbQl0pIUEpfzneGkOx3c/InDRa0t9rMwFbaWFFQhozjFF3ETs+A+JYCZMcv/Ns0/rLzXrBqmTDQcIKRbvB6Wfh5SW4G1/AYpj6GC/ZCWmcSdcoNwF6hmK/y39flurXDIX7rb2Ln2LtkSOLYE+CTL2afbUF0HQ5AQBfPPee359oDL/eFSuaWBFEG1vNHG3tXP+Ou6F2wD+jVA5DdYOlMdY2ebsGGVoF/KiSaojMqePqgBwdRpIDqXkNBKE0coYI4nXf/61x8sLnYOOuuoypV5OwQIElRW5VKQt6PxkL9DT/L20pfvJ/doc+/A8=</diagram></mxfile>
\ No newline at end of file +<mxfile host="drawio.yandex-team.ru" modified="2021-10-01T10:53:18.644Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 YaBrowser/21.8.0.1716 Yowser/2.5 Safari/537.36" etag="RSkPFFk8RhCT1XBSn7Io" version="12.7.0" type="device"><diagram id="6qUEMAEqJytyNpZO1J5A" name="Page-1">7V1bc5s4GP01frQHSQjwY5NedmfaTmezs9s+EiPbbAm4GCdOf/0KkADJAnPHiZM8BD4kAeLo6LtJmaHbh+On0N5tvwQO8WZQc44z9H4GoQ40nf6JJc+pBGINpZJN6DqpDOSCO/c3YUKNSQ+uQ/ZCwSgIvMjdicJV4PtkFQkyOwyDJ7HYOvDEu+7sDTkR3K1s71T6r+tE21RqQTOX/0HczZbfGRjL9MqDzQuzN9lvbSd4KojQhxm6DYMgSo8ejrfEi3uP90ta72PJ1ezBQuJHdSr88/h82MG7vx+/evf+7e/5LXa+zg2YNvNoewf2xuxpo2feBWFw8B0St6LN0M3T1o3I3c5exVef6Fensm304NEzQA/XrufdBl4QJnXRGse/VL6PwuAnKVwxkp+4RuBHBXn6Q+XswUgYkWPpK4OsIykESfBAovCZFmEV5sDgOGL4myN2/pR/TAB4oW3hSy41JrQZgjZZ83kn0wPWzw36XAevus/1Ol2OkaLLAUBD9bkK5oYXsa4Q+t74dQj4hfk+IaR3tADQd8f8Ij3asL9JK/dc8DEIV8T5Qh5ugwf6wSI38P90aPWk6RhSt1mVUKxzF9kRyUp+DXzCS9I3vpdvSGXpk3OxBCDaJ5QiyXnw2Ptdyptr9xgDTkaTYxNrvVKiaWWR+3VPqEGmiBqgn6IGqsZpJuwdM6gUMydfoxuIqjHzvS1mRHyooPSyMWNIiMGTI0a/DJapj5hvxHdcf3NFRCOBxtTMBZ4aNsg87VWHaqHsNAijbbAJfNv7kEtvRA0hL/M5CHasx/8jUfTMVGr7EAVURLz7RAeN+9ClWq74icjRjb7HLS4wO/tRuPL+yG6WnDzzE592wffiSVYnPskrJWe81uoQPiYPD7LPGr9y9UelPRQcwhWp6Er2LSM73JDoHLefgiQknh25j+JzqL53UvVdGNrPhQK7wPWjfaHlb7Egx54JkAC+JbBEjf1c+aVWWX4uzaFNyyO4lLCcvmGO7Kyr2oOd6p8jTas5N350fXe/pXg7IcWvQWIUxswYG5vET0xJXo+e/DqQQ16xzaxKuSqSmNBzNz49XlF4E8pxN3w0vmMXHlzHSQc5oS9p3ydNxcOGIYy2i29m+D2VePY98W7s1c9NQghFMyD5qWJNZjOz9meZpVoceBWEVcqx2gItoSEaAeyWzQaYArFgoZliy/R2DLdZQ8F6vafDX+blHtCLz4O3r7mZVy+bnl/6PGwsIBbnYqAtDHQ6GWtoYWLFfFyQ9z4ll5PUhdqLV6/J6Qo3w8h6nDnWzNYXaJQU8/rNRiwBB6pMAE1JOUPxDcdklU+QjvB3sUc71hw8e793V2rtnR//EDT5Jto7q1Whv/eossNuKnvhm2HFaOeyropHphzxycqSWCR9T1atSukGktZtyk7PtCdOWupLhQEq93MfrHRDNq7PSKnunDO5chw/HTe0ecf0qCkDTY1aDgZtofFwAI+QdcMrd4bBhVxpOKUYqLzrLclLdD1og5DXeefKUO4J9BK4TiaotkyHlpKDFtYjuqZulbkUcOJRpEHdGKA8OvDGor2zKByZRTNkwYUu+uAgXuhwNGJVuRt6Ida6Pt2cS38Urw2vFdZlSmNSrVDXJKo022qFCEst1STL3qA2pceDVnY6xrsnp8BOrFdtsdIZeKFpyFrqBtTorCpSHcVgfBWZCFumubSQ0RjGltDgXDJyh+M3qDJFroPfjJr8pk/Kb1jit2VrftMlfluOzG8cWcM754oKHKe3a40eneE1WMVrhiXymt5ce0NLkdiARI0DMpvKPGjKbG3N2xZ+wAmYrSSGOBKzIdQXs2X28VTMVp511DOz/UXYx4faTeygD9PCe/qC0RvHqTkOVepuGHTV3ZCou6HRCK5H0/SFBSz0mgSHpyQ4KPGbBSStvi6/nZi4ckND09tohmlNenszTYv0VqnCWVpHFQ6AyUxTVTD/OkxT8yXwmy4FFwzcUn/T5XCsvO5naH6zxuK3SsP0jdUKrIYNLLAaFKG27MhqmZqW2aVSEwPS2nIoWqsbqm1Ga8VQbZK7XozSKpLZJ6BBOCUNXoAd2zRcm63s4uFaMEK41qg0ki8owzyveAWmcwVFlXIz5V4LS/yJuo2l4WkXlXufe57k60DyY5P1Dm+KQQF8lmTuiIpBd28O0ER7Z7R1DagPf7XCnXPG2JksEWtS28WA+kKMTFh6S++MBUQIWnJye1+TtibnJ1hm5YOdVDCW1Yvd5DeRyg+jFqDRfOe98/Kbl73Ay0u9ipetzpHEqbxQqM8EsBbGWtFUO7ekt292fgshjuaDQqOtya2V/PVGbcXlSqCK2syuHva5lN+ahZOHJzeeR9vBKIJNjSJa5y4K7Yhs4i7+RHp2gYoL1/wY1uIqNyaqD0/Vkjpx64dS7DVIxJGWxGUZ9QUmRSoqlXmqv51UrNN5rpmx0G5/jG7mDJ83s6ly9Nh0Xadlycw57P4XQJPW7BpatU1wUkFnRkKpEQG7lcdM4RrWF6la6zmYM8gjyYJfOuXO8gW/3UI/U43EVgEHcSyOqMNqNYcihh3HYieixefByPfk5HBDTZL8Z+VrzYuu7pu42/1mrvBXuavB3DrZlEexrwFUzcWDTca4fNeTngnrW0jirkrQ0w9XDaIG1E9SmyyJA/PNctvSTxZugdgSd9zhFkLnxXVjGRq8LwbnuOIGjNfJXkDOy1Ftyjgye5VvyzJcAuF9nwmEl6FvXXzeGoZ1Ka/r7n/d8Hje7dEPG0lbQl0pIUEpfzneGkOx3c/InDRa0t9rMwFbaWFFQhozjFF3ETs+A+JYCZMcv/Ns0/rLzXrBqmTDQcIKRbvB6Wfh5SW4G1/AYpj6GC/ZCWmcSdcoNwF6hmK/y39flurXDIX7rb2Ln2LtkSOLYE+CTL2afbUF0HQ5AQBfPPee359oDL/eFSuaWBFEG1vNHG3tXP+Ou6F2wD+jVA5DdYOlMdY2ebsGGVoF/KiSaojMqePqgBwdRpIDqXkNBKE0coYI4nXf/61x8sLnYOOuuoypV5OwQIElRW5VKQt6PxkL9DT/L20pfvJ/doc+/A8=</diagram></mxfile>
\ No newline at end of file diff --git a/ydb/core/tablet_flat/logic_redo_batch.h b/ydb/core/tablet_flat/logic_redo_batch.h index 484615cf8be..4ddf977ddbe 100644 --- a/ydb/core/tablet_flat/logic_redo_batch.h +++ b/ydb/core/tablet_flat/logic_redo_batch.h @@ -40,7 +40,7 @@ namespace NRedo { return out; } - TAutoPtr<TLogCommit> Commit; + TAutoPtr<TLogCommit> Commit; ui64 Bytes = 0; TVector<TString> Bodies; diff --git a/ydb/core/tablet_flat/logic_redo_queue.h b/ydb/core/tablet_flat/logic_redo_queue.h index 26bda6a5a6f..c8851bba646 100644 --- a/ydb/core/tablet_flat/logic_redo_queue.h +++ b/ydb/core/tablet_flat/logic_redo_queue.h @@ -98,7 +98,7 @@ namespace NRedo { auto logos = snap.MutableNonSnapLogBodies(); - while (TAutoPtr<TEntry> entry = was->Pop()) { + while (TAutoPtr<TEntry> entry = was->Pop()) { if (entry->FilterTables(Edges)) { for (auto blobId : entry->LargeGlobId.Blobs()) { LogoBlobIDFromLogoBlobID(blobId, logos->Add()); diff --git a/ydb/core/tablet_flat/logic_snap_main.h b/ydb/core/tablet_flat/logic_snap_main.h index 3bce3653f4b..89e1ea74870 100644 --- a/ydb/core/tablet_flat/logic_snap_main.h +++ b/ydb/core/tablet_flat/logic_snap_main.h @@ -90,7 +90,7 @@ namespace NTabletFlatExecutor { ui32 Pending = 0; TAutoPtr<NPageCollection::TSteppedCookieAllocator> Cookies; NPageCollection::TSlicer Slicer; - TIntrusivePtr<NSnap::TWaste> Waste_; + TIntrusivePtr<NSnap::TWaste> Waste_; NPageCollection::TLargeGlobId Last; }; diff --git a/ydb/core/tablet_flat/protos/flat_table_part.proto b/ydb/core/tablet_flat/protos/flat_table_part.proto index 3146c4df207..61fa39e9573 100644 --- a/ydb/core/tablet_flat/protos/flat_table_part.proto +++ b/ydb/core/tablet_flat/protos/flat_table_part.proto @@ -1,5 +1,5 @@ import "ydb/core/protos/base.proto"; - + package NKikimr.NTable.NProto; option java_package = "ru.yandex.kikimr.proto"; @@ -50,8 +50,8 @@ message TRoot { // NTable::TPart page collection metablob optional TEvol Evol = 6; optional TStat Stat = 7; // Some stats collected on compaction optional TLayout Layout = 8;// Non-data pages layout information - optional NKikimrProto.TRowVersion MinRowVersion = 9; - optional NKikimrProto.TRowVersion MaxRowVersion = 10; + optional NKikimrProto.TRowVersion MinRowVersion = 9; + optional NKikimrProto.TRowVersion MaxRowVersion = 10; } message TSliceBounds { diff --git a/ydb/core/tablet_flat/shared_cache_events.h b/ydb/core/tablet_flat/shared_cache_events.h index 52141dd3db4..e7ed55be964 100644 --- a/ydb/core/tablet_flat/shared_cache_events.h +++ b/ydb/core/tablet_flat/shared_cache_events.h @@ -54,10 +54,10 @@ namespace NSharedCache { }; struct TEvAttach : public TEventLocal<TEvAttach, EvAttach> { - TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; + TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; TActorId Owner; - TEvAttach(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection, TActorId owner) + TEvAttach(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection, TActorId owner) : PageCollection(std::move(pageCollection)) , Owner(owner) { @@ -67,10 +67,10 @@ namespace NSharedCache { struct TEvRequest : public TEventLocal<TEvRequest, EvRequest> { const EPriority Priority; - TAutoPtr<NPageCollection::TFetch> Fetch; + TAutoPtr<NPageCollection::TFetch> Fetch; TActorId Owner; - TEvRequest(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch, TActorId owner) + TEvRequest(EPriority priority, TAutoPtr<NPageCollection::TFetch> fetch, TActorId owner) : Priority(priority) , Fetch(fetch) , Owner(owner) @@ -82,7 +82,7 @@ namespace NSharedCache { struct TEvResult : public TEventLocal<TEvResult, EvResult> { using EStatus = NKikimrProto::EReplyStatus; - TEvResult(TIntrusiveConstPtr<NPageCollection::IPageCollection> origin, ui64 cookie, EStatus status) + TEvResult(TIntrusiveConstPtr<NPageCollection::IPageCollection> origin, ui64 cookie, EStatus status) : Status(status) , Cookie(cookie) , Origin(origin) @@ -117,7 +117,7 @@ namespace NSharedCache { const EStatus Status; const ui64 Cookie; - const TIntrusiveConstPtr<NPageCollection::IPageCollection> Origin; + const TIntrusiveConstPtr<NPageCollection::IPageCollection> Origin; TVector<TLoaded> Loaded; }; diff --git a/ydb/core/tablet_flat/shared_sausagecache.cpp b/ydb/core/tablet_flat/shared_sausagecache.cpp index 5b68f5f92a9..c60c30202ba 100644 --- a/ydb/core/tablet_flat/shared_sausagecache.cpp +++ b/ydb/core/tablet_flat/shared_sausagecache.cpp @@ -104,7 +104,7 @@ class TSharedPageCache : public TActor<TSharedPageCache> { }; struct TRequest : public TSimpleRefCount<TRequest> { - TRequest(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection) + TRequest(TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection) : Label(pageCollection->Label()) , PageCollection(std::move(pageCollection)) { @@ -115,7 +115,7 @@ class TSharedPageCache : public TActor<TSharedPageCache> { TActorId Source; /* receiver of read results */ TActorId Owner; /* receiver of NBlockIO::TEvStat*/ NBlockIO::EPriority Priority; - TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; + TIntrusiveConstPtr<NPageCollection::IPageCollection> PageCollection; ui64 EventCookie = 0; ui64 RequestCookie = 0; ui64 PendingBlocks = 0; @@ -124,7 +124,7 @@ class TSharedPageCache : public TActor<TSharedPageCache> { }; struct TExpectant { - TDeque<std::pair<TIntrusivePtr<TRequest>, ui32>> SourceRequests; // waiting request, index in ready blocks for page + TDeque<std::pair<TIntrusivePtr<TRequest>, ui32>> SourceRequests; // waiting request, index in ready blocks for page }; struct TCollection { @@ -141,7 +141,7 @@ class TSharedPageCache : public TActor<TSharedPageCache> { struct TRequestQueue { struct TPagesToRequest : public TIntrusiveListItem<TPagesToRequest> { - TIntrusivePtr<TRequest> Request; + TIntrusivePtr<TRequest> Request; }; struct TByActorRequest { @@ -160,7 +160,7 @@ class TSharedPageCache : public TActor<TSharedPageCache> { TIntrusivePtr<TSharedPageGCList> GCList = new TSharedPageGCList; TActorId Owner; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; THashMap<TLogoBlobID, TCollection> Collections; THashMap<TActorId, TCollectionsOwner> CollectionsOwners; diff --git a/ydb/core/tablet_flat/tablet_flat_executed.cpp b/ydb/core/tablet_flat/tablet_flat_executed.cpp index b9b8c5c746c..4b3c15490c5 100644 --- a/ydb/core/tablet_flat/tablet_flat_executed.cpp +++ b/ydb/core/tablet_flat/tablet_flat_executed.cpp @@ -29,12 +29,12 @@ IExecutor* TTabletExecutedFlat::CreateExecutor(const TActorContext &ctx) { return Executor(); } -void TTabletExecutedFlat::Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) { +void TTabletExecutedFlat::Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) { Y_UNUSED(ctx); Execute(transaction); } -void TTabletExecutedFlat::Execute(TAutoPtr<ITransaction> transaction) { +void TTabletExecutedFlat::Execute(TAutoPtr<ITransaction> transaction) { if (transaction) static_cast<TExecutor*>(Executor())->Execute(transaction, ExecutorCtx(*TlsActivationContext)); } @@ -44,7 +44,7 @@ const NTable::TScheme& TTabletExecutedFlat::Scheme() const noexcept { } void TTabletExecutedFlat::Handle(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx) { - // Notify sys tablet that leader supports graceful shutdown + // Notify sys tablet that leader supports graceful shutdown ctx.Send(Tablet(), new TEvTablet::TEvFeatures(TEvTablet::TEvFeatures::GracefulStop)); const auto& msg = *ev->Get(); @@ -57,35 +57,35 @@ void TTabletExecutedFlat::Handle(TEvTablet::TEvRestored::TPtr &ev, const TActorC Executor()->Restored(ev, ExecutorCtx(ctx)); } -void TTabletExecutedFlat::Handle(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) { +void TTabletExecutedFlat::Handle(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) { UpdateTabletInfo(ev->Get()->TabletStorageInfo); - CreateExecutor(ctx)->FollowerBoot(ev, ExecutorCtx(ctx)); + CreateExecutor(ctx)->FollowerBoot(ev, ExecutorCtx(ctx)); TxCacheQuota = ev->Get()->TxCacheQuota; } -void TTabletExecutedFlat::Handle(TEvTablet::TEvFUpdate::TPtr &ev) { - Executor()->FollowerUpdate(std::move(ev->Get()->Update)); +void TTabletExecutedFlat::Handle(TEvTablet::TEvFUpdate::TPtr &ev) { + Executor()->FollowerUpdate(std::move(ev->Get()->Update)); } -void TTabletExecutedFlat::Handle(TEvTablet::TEvFAuxUpdate::TPtr &ev) { - Executor()->FollowerAuxUpdate(std::move(ev->Get()->AuxUpdate)); +void TTabletExecutedFlat::Handle(TEvTablet::TEvFAuxUpdate::TPtr &ev) { + Executor()->FollowerAuxUpdate(std::move(ev->Get()->AuxUpdate)); } -void TTabletExecutedFlat::Handle(TEvTablet::TEvNewFollowerAttached::TPtr &ev) { +void TTabletExecutedFlat::Handle(TEvTablet::TEvNewFollowerAttached::TPtr &ev) { Y_UNUSED(ev); if (Executor()) - Executor()->FollowerAttached(); + Executor()->FollowerAttached(); } -void TTabletExecutedFlat::Handle(TEvTablet::TEvFollowerSyncComplete::TPtr &ev) { +void TTabletExecutedFlat::Handle(TEvTablet::TEvFollowerSyncComplete::TPtr &ev) { Y_UNUSED(ev); if (Executor()) - Executor()->FollowerSyncComplete(); + Executor()->FollowerSyncComplete(); } -void TTabletExecutedFlat::Handle(TEvTablet::TEvFollowerGcApplied::TPtr &ev) { +void TTabletExecutedFlat::Handle(TEvTablet::TEvFollowerGcApplied::TPtr &ev) { auto *msg = ev->Get(); - Executor()->FollowerGcApplied(msg->Step, msg->FollowerSyncDelay); + Executor()->FollowerGcApplied(msg->Step, msg->FollowerSyncDelay); } void TTabletExecutedFlat::Handle(TEvTablet::TEvUpdateConfig::TPtr &ev) { @@ -199,7 +199,7 @@ void TTabletExecutedFlat::RenderHtmlPage(NMon::TEvRemoteHttpInfo::TPtr &ev, cons DIV_CLASS("col-md-12") {str << "Tablet type: " << TTabletTypes::TypeToStr((TTabletTypes::EType)TabletType()); } } DIV_CLASS("row") { - DIV_CLASS("col-md-12") {str << "Tablet id: " << TabletID() << (Executor()->GetStats().IsFollower ? " Follower" : " Leader"); } + DIV_CLASS("col-md-12") {str << "Tablet id: " << TabletID() << (Executor()->GetStats().IsFollower ? " Follower" : " Leader"); } } DIV_CLASS("row") { DIV_CLASS("col-md-12") {str << "Tablet generation: " << Executor()->Generation();} @@ -221,7 +221,7 @@ void TTabletExecutedFlat::RenderHtmlPage(NMon::TEvRemoteHttpInfo::TPtr &ev, cons DIV_CLASS("col-md-12") {str << "<a href=\"tablets/executorInternals?" << queryString << "\">Executor DB internals</a>";} } DIV_CLASS("row") { - DIV_CLASS("col-md-12") {str << "<a href=\"tablets?FollowerID=" << TabletID() << "\">Connect to follower</a>";} + DIV_CLASS("col-md-12") {str << "<a href=\"tablets?FollowerID=" << TabletID() << "\">Connect to follower</a>";} } DIV_CLASS("row") { DIV_CLASS("col-md-12") {str << "<a href=\"tablets?SsId=" << TabletID() << "\">State Storage</a>";} @@ -244,12 +244,12 @@ bool TTabletExecutedFlat::HandleDefaultEvents(STFUNC_SIG) { switch (ev->GetTypeRewrite()) { HFunc(TEvTablet::TEvBoot, Handle); HFunc(TEvTablet::TEvRestored, Handle); - HFunc(TEvTablet::TEvFBoot, Handle); - hFunc(TEvTablet::TEvFUpdate, Handle); - hFunc(TEvTablet::TEvFAuxUpdate, Handle); - hFunc(TEvTablet::TEvFollowerGcApplied, Handle); - hFunc(TEvTablet::TEvNewFollowerAttached, Handle); - hFunc(TEvTablet::TEvFollowerSyncComplete, Handle); + HFunc(TEvTablet::TEvFBoot, Handle); + hFunc(TEvTablet::TEvFUpdate, Handle); + hFunc(TEvTablet::TEvFAuxUpdate, Handle); + hFunc(TEvTablet::TEvFollowerGcApplied, Handle); + hFunc(TEvTablet::TEvNewFollowerAttached, Handle); + hFunc(TEvTablet::TEvFollowerSyncComplete, Handle); HFunc(TEvTablet::TEvTabletStop, HandleTabletStop); HFunc(TEvTablet::TEvTabletDead, HandleTabletDead); HFunc(TEvTablet::TEvLocalMKQL, HandleLocalMKQL); @@ -267,14 +267,14 @@ bool TTabletExecutedFlat::HandleDefaultEvents(STFUNC_SIG) { void TTabletExecutedFlat::StateInitImpl(STFUNC_SIG) { switch (ev->GetTypeRewrite()) { HFunc(TEvTablet::TEvBoot, Handle); - HFunc(TEvTablet::TEvFBoot, Handle); - hFunc(TEvTablet::TEvFUpdate, Handle); - hFunc(TEvTablet::TEvFAuxUpdate, Handle); - hFunc(TEvTablet::TEvFollowerGcApplied, Handle); + HFunc(TEvTablet::TEvFBoot, Handle); + hFunc(TEvTablet::TEvFUpdate, Handle); + hFunc(TEvTablet::TEvFAuxUpdate, Handle); + hFunc(TEvTablet::TEvFollowerGcApplied, Handle); HFunc(TEvTablet::TEvRestored, Handle); HFunc(TEvTablet::TEvTabletStop, HandleTabletStop); HFunc(TEvTablet::TEvTabletDead, HandleTabletDead); - hFunc(TEvTablet::TEvFollowerSyncComplete, Handle); + hFunc(TEvTablet::TEvFollowerSyncComplete, Handle); hFunc(TEvTablet::TEvUpdateConfig, Handle); HFunc(NMon::TEvRemoteHttpInfo, RenderHtmlPage); default: diff --git a/ydb/core/tablet_flat/tablet_flat_executed.h b/ydb/core/tablet_flat/tablet_flat_executed.h index 4b84bee7072..117d7532bb3 100644 --- a/ydb/core/tablet_flat/tablet_flat_executed.h +++ b/ydb/core/tablet_flat/tablet_flat_executed.h @@ -10,9 +10,9 @@ class TExecutor; struct IMiniKQLFactory { virtual ~IMiniKQLFactory() = default; - virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalMKQL::TPtr&) = 0; - virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalSchemeTx::TPtr&) = 0; - virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalReadColumns::TPtr&) = 0; + virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalMKQL::TPtr&) = 0; + virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalSchemeTx::TPtr&) = 0; + virtual TAutoPtr<ITransaction> Make(TEvTablet::TEvLocalReadColumns::TPtr&) = 0; }; class TTabletExecutedFlat : public NFlatExecutorSetup::ITablet { @@ -23,8 +23,8 @@ protected: IExecutor* Executor() const { return Executor0; } const TInstant StartTime() const { return StartTime0; } - void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx); - void Execute(TAutoPtr<ITransaction> transaction); + void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx); + void Execute(TAutoPtr<ITransaction> transaction); const NTable::TScheme& Scheme() const noexcept; @@ -45,12 +45,12 @@ protected: void Handle(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx); void Handle(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx); - void Handle(TEvTablet::TEvFollowerSyncComplete::TPtr&); - void Handle(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx); - void Handle(TEvTablet::TEvFUpdate::TPtr&); - void Handle(TEvTablet::TEvFAuxUpdate::TPtr&); - void Handle(TEvTablet::TEvFollowerGcApplied::TPtr&); - void Handle(TEvTablet::TEvNewFollowerAttached::TPtr&); + void Handle(TEvTablet::TEvFollowerSyncComplete::TPtr&); + void Handle(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx); + void Handle(TEvTablet::TEvFUpdate::TPtr&); + void Handle(TEvTablet::TEvFAuxUpdate::TPtr&); + void Handle(TEvTablet::TEvFollowerGcApplied::TPtr&); + void Handle(TEvTablet::TEvNewFollowerAttached::TPtr&); void Handle(TEvTablet::TEvUpdateConfig::TPtr&); void HandleTabletStop(TEvTablet::TEvTabletStop::TPtr &ev, const TActorContext &ctx); @@ -82,11 +82,11 @@ private: IExecutor* CreateExecutor(const TActorContext &ctx); private: - TAutoPtr<IMiniKQLFactory> Factory; + TAutoPtr<IMiniKQLFactory> Factory; IExecutor *Executor0; TInstant StartTime0; - TSharedQuotaPtr TxCacheQuota; + TSharedQuotaPtr TxCacheQuota; }; }} diff --git a/ydb/core/tablet_flat/tablet_flat_executor.cpp b/ydb/core/tablet_flat/tablet_flat_executor.cpp index a6990161ce9..f69991ece9c 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.cpp +++ b/ydb/core/tablet_flat/tablet_flat_executor.cpp @@ -24,7 +24,7 @@ namespace NFlatExecutorSetup { Y_UNUSED(ctx); } - void ITablet::ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx) + void ITablet::ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx) { Y_UNUSED(status); Y_UNUSED(prod); diff --git a/ydb/core/tablet_flat/tablet_flat_executor.h b/ydb/core/tablet_flat/tablet_flat_executor.h index 7b813007d2f..075ebce354b 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.h +++ b/ydb/core/tablet_flat/tablet_flat_executor.h @@ -77,7 +77,7 @@ private: class TMemoryToken { public: - TMemoryToken(TIntrusivePtr<TMemoryGCToken> gcToken) + TMemoryToken(TIntrusivePtr<TMemoryGCToken> gcToken) : GCToken(gcToken) {} @@ -85,7 +85,7 @@ public: GCToken->Drop(); } - const TIntrusivePtr<TMemoryGCToken> GCToken; + const TIntrusivePtr<TMemoryGCToken> GCToken; }; struct IExecuting { @@ -93,8 +93,8 @@ struct IExecuting { virtual ~IExecuting() = default; - virtual void MakeSnapshot(TIntrusivePtr<TTableSnapshotContext>) = 0; - virtual void DropSnapshot(TIntrusivePtr<TTableSnapshotContext>) = 0; + virtual void MakeSnapshot(TIntrusivePtr<TTableSnapshotContext>) = 0; + virtual void DropSnapshot(TIntrusivePtr<TTableSnapshotContext>) = 0; virtual void MoveSnapshot(const TTableSnapshotContext&, ui32 src, ui32 dst) = 0; virtual void ClearSnapshot(const TTableSnapshotContext&) = 0; virtual void LoanTable(ui32 tableId, const TString &partsInfo) = 0; // attach table parts to table (called on part destination) @@ -171,14 +171,14 @@ public: return std::move(MemoryToken); } - TIntrusivePtr<TMemoryGCToken> GetMemoryGCToken() const { return MemoryGCToken; } + TIntrusivePtr<TMemoryGCToken> GetMemoryGCToken() const { return MemoryGCToken; } private: const ui64 MemoryLimit; const ui64 TaskId; ui64 RequestedMemory; ui32 NotEnoughMemoryCount; - TIntrusivePtr<TMemoryGCToken> MemoryGCToken; + TIntrusivePtr<TMemoryGCToken> MemoryGCToken; TAutoPtr<TMemoryToken> MemoryToken; }; @@ -237,18 +237,18 @@ struct TCompactedPartLoans { {} }; -struct TFinishedCompactionInfo { - ui64 Edge = 0; - TInstant FullCompactionTs; - - TFinishedCompactionInfo() = default; - - TFinishedCompactionInfo(ui64 edge, TInstant ts) - : Edge(edge) - , FullCompactionTs(ts) - {} -}; - +struct TFinishedCompactionInfo { + ui64 Edge = 0; + TInstant FullCompactionTs; + + TFinishedCompactionInfo() = default; + + TFinishedCompactionInfo(ui64 edge, TInstant ts) + : Edge(edge) + , FullCompactionTs(ts) + {} +}; + enum class ETerminationReason { None = 0, MemoryLimitExceeded = 1, @@ -304,7 +304,7 @@ public: struct TExecutorStats { bool IsActive = false; - bool IsFollower = false; + bool IsFollower = false; bool IsAnyChannelYellowMove = false; bool IsAnyChannelYellowStop = false; ui64 TxInFly = 0; @@ -443,15 +443,15 @@ namespace NFlatExecutorSetup { virtual void CompletedLoansChanged(const TActorContext &ctx); // would be no-op in default implementation virtual void CompactionComplete(ui32 tableId, const TActorContext &ctx); // would be no-op in default implementation - virtual void ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx); + virtual void ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx); virtual bool ReassignChannelsEnabled() const; // memory usage excluding transactions and executor cache. virtual ui64 GetMemoryUsage() const { return 50 << 10; } - virtual void OnLeaderUserAuxUpdate(TString) { /* default */ } - + virtual void OnLeaderUserAuxUpdate(TString) { /* default */ } + // create transaction? protected: ITablet(TTabletStorageInfo *info, const TActorId &tablet) @@ -476,25 +476,25 @@ namespace NFlatExecutorSetup { struct IExecutor : TNonCopyable { virtual ~IExecutor() {} - // tablet assigned as leader, could begin loading + // tablet assigned as leader, could begin loading virtual void Boot(TEvTablet::TEvBoot::TPtr &ev, const TActorContext &ctx) = 0; - // tablet generation restoration complete, tablet could act as leader + // tablet generation restoration complete, tablet could act as leader virtual void Restored(TEvTablet::TEvRestored::TPtr &ev, const TActorContext &ctx) = 0; // die! virtual void DetachTablet(const TActorContext &ctx) = 0; - // tablet assigned as follower (or follower connection refreshed), must begin loading - virtual void FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) = 0; - // next follower incremental update - virtual void FollowerUpdate(THolder<TEvTablet::TFUpdateBody> upd) = 0; - virtual void FollowerAuxUpdate(TString upd) = 0; - virtual void FollowerAttached() = 0; - // all known followers are synced to us (called once) - virtual void FollowerSyncComplete() = 0; - // all followers had completed log with requested gc-barrier - virtual void FollowerGcApplied(ui32 step, TDuration followerSyncDelay) = 0; + // tablet assigned as follower (or follower connection refreshed), must begin loading + virtual void FollowerBoot(TEvTablet::TEvFBoot::TPtr &ev, const TActorContext &ctx) = 0; + // next follower incremental update + virtual void FollowerUpdate(THolder<TEvTablet::TFUpdateBody> upd) = 0; + virtual void FollowerAuxUpdate(TString upd) = 0; + virtual void FollowerAttached() = 0; + // all known followers are synced to us (called once) + virtual void FollowerSyncComplete() = 0; + // all followers had completed log with requested gc-barrier + virtual void FollowerGcApplied(ui32 step, TDuration followerSyncDelay) = 0; - virtual void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) = 0; + virtual void Execute(TAutoPtr<ITransaction> transaction, const TActorContext &ctx) = 0; /* Make blob with data required for table bootstapping. Note: 1. Once non-trivial blob obtained and commited in tx all of its @@ -507,17 +507,17 @@ namespace NFlatExecutorSetup { // Prepare snapshot which can later be used for scan task. virtual ui64 MakeScanSnapshot(ui32 table) = 0; virtual void DropScanSnapshot(ui64 snapId) = 0; - virtual ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options = TScanOptions()) = 0; + virtual ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options = TScanOptions()) = 0; virtual bool CancelScan(ui32 tableId, ui64 taskId) = 0; - // edge and ts of last full compaction - virtual TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 tableId) const = 0; - + // edge and ts of last full compaction + virtual TFinishedCompactionInfo GetFinishedCompactionInfo(ui32 tableId) const = 0; + // Forces full compaction of the specified table in the near future - // Returns 0 if can't compact, otherwise compaction ID + // Returns 0 if can't compact, otherwise compaction ID virtual ui64 CompactBorrowed(ui32 tableId) = 0; virtual ui64 CompactMemTable(ui32 tableId) = 0; - virtual ui64 CompactTable(ui32 tableId) = 0; + virtual ui64 CompactTable(ui32 tableId) = 0; virtual bool CompactTables() = 0; virtual void RenderHtmlPage(NMon::TEvRemoteHttpInfo::TPtr&) const = 0; @@ -528,8 +528,8 @@ namespace NFlatExecutorSetup { virtual void UpdateConfig(TEvTablet::TEvUpdateConfig::TPtr&) = 0; - virtual void SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) = 0; - + virtual void SendUserAuxUpdateToFollowers(TString upd, const TActorContext &ctx) = 0; + // Returns parts owned by this tablet and borrowed by other tablets virtual THashMap<TLogoBlobID, TVector<ui64>> GetBorrowedParts() const = 0; diff --git a/ydb/core/tablet_flat/test/libs/exec/dummy.h b/ydb/core/tablet_flat/test/libs/exec/dummy.h index 7a711ed159c..5c6e2f5b4f1 100644 --- a/ydb/core/tablet_flat/test/libs/exec/dummy.h +++ b/ydb/core/tablet_flat/test/libs/exec/dummy.h @@ -23,7 +23,7 @@ namespace NFake { }; public: - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; using TInfo = TTabletStorageInfo; using TEvDead = TEvTablet::TEvTabletDead; @@ -42,7 +42,7 @@ namespace NFake { } private: - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx) { if (auto *ev = eh->CastAsLocal<NFake::TEvExecute>()) { Y_VERIFY(State == EState::Work, "Cannot handle TX now"); @@ -67,7 +67,7 @@ namespace NFake { if (std::exchange(State, EState::Stop) != EState::Stop) { /* This hack stops TExecutor before TOwner death. TOwner unbale to wait for tablet death and may yield false - TEvGone to leader actor on handling its own TEvPoison. + TEvGone to leader actor on handling its own TEvPoison. */ Executor()->DetachTablet(ctx), Detach(ctx); @@ -84,7 +84,7 @@ namespace NFake { } } - void Enqueue(TEventHandlePtr &eh, const ::NActors::TActorContext&) override + void Enqueue(TEventHandlePtr &eh, const ::NActors::TActorContext&) override { const auto *name = TypeName(*eh->GetBase()).c_str(); diff --git a/ydb/core/tablet_flat/test/libs/exec/events.h b/ydb/core/tablet_flat/test/libs/exec/events.h index 224a037d973..b6aeb3e82f6 100644 --- a/ydb/core/tablet_flat/test/libs/exec/events.h +++ b/ydb/core/tablet_flat/test/libs/exec/events.h @@ -51,7 +51,7 @@ namespace NFake { struct TEvExecute : public TEventLocal<TEvExecute, EvExecute> { using ITransaction = NTabletFlatExecutor::ITransaction; - TEvExecute(TAutoPtr<ITransaction> func) { + TEvExecute(TAutoPtr<ITransaction> func) { THolder<ITransaction> h(func.Release()); Funcs.push_back(std::move(h)); } diff --git a/ydb/core/tablet_flat/test/libs/exec/helper.h b/ydb/core/tablet_flat/test/libs/exec/helper.h index 4b559ba8cac..09fe4e0f549 100644 --- a/ydb/core/tablet_flat/test/libs/exec/helper.h +++ b/ydb/core/tablet_flat/test/libs/exec/helper.h @@ -11,14 +11,14 @@ namespace NFake { struct TStarter { using TMake = TTabletSetupInfo::TTabletCreationFunc; - IActor* Do(TActorId user, ui32 retry, ui32 tablet, TMake make, ui32 followerId = 0) noexcept + IActor* Do(TActorId user, ui32 retry, ui32 tablet, TMake make, ui32 followerId = 0) noexcept { const auto simple = TMailboxType::Simple; auto *info = MakeTabletInfo(tablet); auto *setup = new TTabletSetupInfo(make, simple, 0, simple, 0); - return new NFake::TOwner(user, retry, info, setup, followerId); + return new NFake::TOwner(user, retry, info, setup, followerId); } static TStorageInfo* MakeTabletInfo(ui64 tablet) noexcept diff --git a/ydb/core/tablet_flat/test/libs/exec/leader.h b/ydb/core/tablet_flat/test/libs/exec/leader.h index a8f4fe6fde3..f964c4b33c3 100644 --- a/ydb/core/tablet_flat/test/libs/exec/leader.h +++ b/ydb/core/tablet_flat/test/libs/exec/leader.h @@ -11,7 +11,7 @@ namespace NKikimr { namespace NFake { - class TLeader: public ::NActors::IActor { + class TLeader: public ::NActors::IActor { enum class EState { Lock = 0, /* Do not start shutdown process */ Free = 1, /* Start to shut as Head will gone */ @@ -22,8 +22,8 @@ namespace NFake { public: using ELnLev = NUtil::ELnLev; - TLeader(ui32 head, TAtomic &stopped) - : ::NActors::IActor(static_cast<TReceiveFunc>(&TLeader::Inbox), NKikimrServices::TActivity::FAKE_ENV_A) + TLeader(ui32 head, TAtomic &stopped) + : ::NActors::IActor(static_cast<TReceiveFunc>(&TLeader::Inbox), NKikimrServices::TActivity::FAKE_ENV_A) , Time(TAppData::TimeProvider.Get()) , Edge(head) /* Live until this runlevel exists */ , Stopped(stopped) @@ -44,7 +44,7 @@ namespace NFake { Sys->RegisterLocalService(TWorld::Where(EPath::Root), SelfId()); } - void Inbox(TAutoPtr<::NActors::IEventHandle> &eh, const ::NActors::TActorContext&) + void Inbox(TAutoPtr<::NActors::IEventHandle> &eh, const ::NActors::TActorContext&) { if (auto *fire = eh->CastAsLocal<NFake::TEvFire>()) { DoFire(fire->Level, fire->Alias, fire->Cmd); @@ -89,7 +89,7 @@ namespace NFake { } else if (auto logl = Logger->Log(ELnLev::Abort)) { logl - << "Leader got gone event from actor " << actor + << "Leader got gone event from actor " << actor << ", but it hasn't been registered in runlevels"; } } @@ -171,7 +171,7 @@ namespace NFake { TActorSystem * Sys = nullptr; const TDuration Gran{ TDuration::Seconds(1) }; const TDuration Delay{ TDuration::Seconds(32) }; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; EState State = EState::Lock; bool Wait = false; TInstant Start = TInstant::Max(); diff --git a/ydb/core/tablet_flat/test/libs/exec/logger.h b/ydb/core/tablet_flat/test/libs/exec/logger.h index ec094e5a778..471f00b8441 100644 --- a/ydb/core/tablet_flat/test/libs/exec/logger.h +++ b/ydb/core/tablet_flat/test/libs/exec/logger.h @@ -21,7 +21,7 @@ namespace NFake { } - void Put(TInstant stamp, ui32 level, EComp comp, TArrayRef<const char> line) noexcept + void Put(TInstant stamp, ui32 level, EComp comp, TArrayRef<const char> line) noexcept { Y_VERIFY(line.size() < 8192 * 16, "Too large log line"); @@ -78,7 +78,7 @@ namespace NFake { using EPrio = ::NActors::NLog::EPriority; using ELnLev = NUtil::ELnLev; - TLogEnv(ITimeProvider *time, ELnLev level,TIntrusivePtr<TSink> sink) + TLogEnv(ITimeProvider *time, ELnLev level,TIntrusivePtr<TSink> sink) : Time(time) , Level(level) , Sink(std::move(sink)) @@ -108,23 +108,23 @@ namespace NFake { private: ITimeProvider * const Time = nullptr; const ELnLev Level = ELnLev::Warn; - const TIntrusivePtr<TSink> Sink; + const TIntrusivePtr<TSink> Sink; }; class TLogFwd : public ::NActors::IActor { public: - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; - TLogFwd(TIntrusivePtr<TSink> sink) + TLogFwd(TIntrusivePtr<TSink> sink) : ::NActors::IActor(static_cast<TReceiveFunc>(&TLogFwd::Inbox), IActor::LOG_ACTOR) , Sink(std::move(sink)) { } private: - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (auto *ev = eh->CastAsLocal<NActors::NLog::TEvLog>()) { Sink->Put(ev->Stamp, ev->Level.Raw, ev->Component, ev->Line); @@ -138,7 +138,7 @@ namespace NFake { } private: - TIntrusivePtr<TSink> Sink; + TIntrusivePtr<TSink> Sink; }; } diff --git a/ydb/core/tablet_flat/test/libs/exec/nanny.h b/ydb/core/tablet_flat/test/libs/exec/nanny.h index 494bf96462c..9b00928c8e4 100644 --- a/ydb/core/tablet_flat/test/libs/exec/nanny.h +++ b/ydb/core/tablet_flat/test/libs/exec/nanny.h @@ -67,7 +67,7 @@ namespace NFake { class TNanny : public ::NActors::IActor { - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; public: @@ -116,7 +116,7 @@ namespace NFake { Owner = owner, StartTablet(); } - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (auto *ev = eh->CastAsLocal<NFake::TEvResult>()) { Handle(*ev); @@ -195,12 +195,12 @@ namespace NFake { private: const ui64 MyId = MakeTabletID(0, 0, 1); - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; TActorId Owner; TActorId Tablet; ui64 TxInFlight = 0; EDo State = EDo::Born; - TAutoPtr<NTable::ITestDb> Fake; + TAutoPtr<NTable::ITestDb> Fake; }; } diff --git a/ydb/core/tablet_flat/test/libs/exec/owner.h b/ydb/core/tablet_flat/test/libs/exec/owner.h index 6f3b373a971..f3e3d7363c8 100644 --- a/ydb/core/tablet_flat/test/libs/exec/owner.h +++ b/ydb/core/tablet_flat/test/libs/exec/owner.h @@ -18,18 +18,18 @@ namespace NFake { class TOwner final : public ::NActors::IActor { public: - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; using TInfo = TTabletStorageInfo; using TSetup = TTabletSetupInfo; - TOwner(TActorId user, ui32 limit, TIntrusivePtr<TInfo> info, TIntrusivePtr<TSetup> setup, ui32 followerId) + TOwner(TActorId user, ui32 limit, TIntrusivePtr<TInfo> info, TIntrusivePtr<TSetup> setup, ui32 followerId) : ::NActors::IActor(static_cast<TReceiveFunc>(&TOwner::Inbox), NKikimrServices::TActivity::FAKE_ENV_A) , Info(std::move(info)) , Setup(std::move(setup)) , User(user) , Limit(Max(ui32(1), limit)) - , FollowerId(followerId) + , FollowerId(followerId) { Y_VERIFY(TTabletTypes::TYPE_INVALID != Info->TabletType); } @@ -43,7 +43,7 @@ namespace NFake { sys->Send(SelfId(), new TEvents::TEvBootstrap); } - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext &ctx) { if (auto *ev = eh->CastAsLocal<TEvTablet::TEvTabletDead>()) { @@ -93,10 +93,10 @@ namespace NFake { auto &profile = AppData(ctx)->ResourceProfiles; - if (FollowerId == 0) { + if (FollowerId == 0) { Agent = Setup->Tablet(Info.Get(), SelfId(), ctx, 0, profile); } else { - Agent = Setup->Follower(Info.Get(), SelfId(), ctx, FollowerId, profile); + Agent = Setup->Follower(Info.Get(), SelfId(), ctx, FollowerId, profile); } Y_VERIFY(Agent, "Failed to start new tablet actor"); @@ -113,16 +113,16 @@ namespace NFake { } private: - TIntrusivePtr<TInfo> Info; - TIntrusivePtr<TSetup> Setup; - TAutoPtr<NUtil::ILogger> Logger; + TIntrusivePtr<TInfo> Info; + TIntrusivePtr<TSetup> Setup; + TAutoPtr<NUtil::ILogger> Logger; TActorId Owner; TActorId Agent; TActorId User; ui32 Borns = 0; ui32 Limit = 1; - const ui32 FollowerId; + const ui32 FollowerId; bool Alive = false; }; diff --git a/ydb/core/tablet_flat/test/libs/exec/runner.h b/ydb/core/tablet_flat/test/libs/exec/runner.h index 4d5a0cbb0bb..3b58ab814b4 100644 --- a/ydb/core/tablet_flat/test/libs/exec/runner.h +++ b/ydb/core/tablet_flat/test/libs/exec/runner.h @@ -1,7 +1,7 @@ #pragma once #include "config.h" -#include "leader.h" +#include "leader.h" #include "owner.h" #include "events.h" #include "logger.h" @@ -50,7 +50,7 @@ namespace NFake { Env.SetDispatchTimeout(DEFAULT_DISPATCH_TIMEOUT); Env.SetLogPriority(NKikimrServices::FAKE_ENV, NActors::NLog::PRI_INFO); - Leader = Env.Register(new NFake::TLeader(8, Stopped), 0); + Leader = Env.Register(new NFake::TLeader(8, Stopped), 0); NFake::TConf conf; @@ -66,16 +66,16 @@ namespace NFake { return &Env; } - void FireTablet(TActorId user, ui32 tablet, TStarter::TMake make, ui32 followerId = 0) + void FireTablet(TActorId user, ui32 tablet, TStarter::TMake make, ui32 followerId = 0) { const auto mbx = EMail::Simple; - RunOn(7, { }, TStarter().Do(user, 1, tablet, std::move(make), followerId), mbx); + RunOn(7, { }, TStarter().Do(user, 1, tablet, std::move(make), followerId), mbx); } - void FireFollower(TActorId user, ui32 tablet, TStarter::TMake make, ui32 followerId) + void FireFollower(TActorId user, ui32 tablet, TStarter::TMake make, ui32 followerId) { - FireTablet(user, tablet, make, followerId); + FireTablet(user, tablet, make, followerId); } void AddService(TActorId service, IActor *actor, EMail box) @@ -83,7 +83,7 @@ namespace NFake { Env.AddLocalService(service, TActorSetupCmd(actor, box, 0), 0); } - void RunTest(TAutoPtr<IActor> actor) noexcept + void RunTest(TAutoPtr<IActor> actor) noexcept { return RunOn(8, { }, actor.Release(), EMail::Simple); } @@ -92,7 +92,7 @@ namespace NFake { { auto *event = new NFake::TEvFire{ lvl, alias, { actor, box, 0 } }; - Env.SingleSys()->Send(Leader, event); + Env.SingleSys()->Send(Leader, event); } void Finalize() @@ -214,11 +214,11 @@ namespace NFake { ITimeProvider * const Time = nullptr; const ui32 NodeId = Max<ui32>(); const TVector<TString> Names; /* { Component -> Name } */ - const TIntrusivePtr<TSink> Sink; - const TAutoPtr<TLogEnv> Logger; + const TIntrusivePtr<TSink> Sink; + const TAutoPtr<TLogEnv> Logger; private: - TActorId Leader; + TActorId Leader; TAtomic Stopped = 0; }; diff --git a/ydb/core/tablet_flat/test/libs/exec/storage.h b/ydb/core/tablet_flat/test/libs/exec/storage.h index 7b2a981cf27..76a937c4f8b 100644 --- a/ydb/core/tablet_flat/test/libs/exec/storage.h +++ b/ydb/core/tablet_flat/test/libs/exec/storage.h @@ -9,7 +9,7 @@ namespace NFake { class TStorage : public ::NActors::IActor { public: - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; using NStore = TEvBlobStorage; @@ -29,7 +29,7 @@ namespace NFake { Logger = new NUtil::TLogger(sys, NKikimrServices::FAKE_ENV); } - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (auto *ev = eh->CastAsLocal<NStore::TEvPut>()) { @@ -72,7 +72,7 @@ namespace NFake { } } - void Reply(TEventHandlePtr &eh, IEventBase *ev) + void Reply(TEventHandlePtr &eh, IEventBase *ev) { Send(eh->Sender, ev, 0, eh->Cookie); } @@ -97,7 +97,7 @@ namespace NFake { const ui32 Group = NPageCollection::TLargeGlobId::InvalidGroup; TActorId Owner; - TAutoPtr<NUtil::ILogger> Logger; + TAutoPtr<NUtil::ILogger> Logger; TAutoPtr<NFake::TProxyDS> Model; ui64 PutItems = 0; diff --git a/ydb/core/tablet_flat/test/libs/exec/warden.h b/ydb/core/tablet_flat/test/libs/exec/warden.h index 8073b5b4005..cc2afbde883 100644 --- a/ydb/core/tablet_flat/test/libs/exec/warden.h +++ b/ydb/core/tablet_flat/test/libs/exec/warden.h @@ -24,7 +24,7 @@ namespace NFake { }; public: - using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; + using TEventHandlePtr = TAutoPtr<::NActors::IEventHandle>; using ELnLev = NUtil::ELnLev; TWarden(ui32 groups) @@ -44,7 +44,7 @@ namespace NFake { Logger = new NUtil::TLogger(sys, NKikimrServices::FAKE_ENV); } - void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) + void Inbox(TEventHandlePtr &eh, const ::NActors::TActorContext&) { if (ShouldForward(eh->GetTypeRewrite())) { auto proxy = eh.Get()->GetForwardOnNondeliveryRecipient(); @@ -157,8 +157,8 @@ namespace NFake { public: TActorSystem * Sys = nullptr; - TAutoPtr<NUtil::ILogger> Logger; - TActorId Owner; /* ActorID of the leader proceess */ + TAutoPtr<NUtil::ILogger> Logger; + TActorId Owner; /* ActorID of the leader proceess */ ui32 Alive = 0; /* Groups in EState::{Fired,Shut} */ bool Shutting = false; /* Storages is being in shutted */ std::array<EState, 32> State{ }; diff --git a/ydb/core/tablet_flat/test/libs/exec/world.h b/ydb/core/tablet_flat/test/libs/exec/world.h index 7945f1cdc19..576ff162f26 100644 --- a/ydb/core/tablet_flat/test/libs/exec/world.h +++ b/ydb/core/tablet_flat/test/libs/exec/world.h @@ -10,7 +10,7 @@ namespace NFake { using EMail = NActors::TMailboxType::EType; enum class EPath : ui16 { - Root = 0, /* The leader actor, shuts the system */ + Root = 0, /* The leader actor, shuts the system */ }; struct TWorld { diff --git a/ydb/core/tablet_flat/test/libs/rows/heap.h b/ydb/core/tablet_flat/test/libs/rows/heap.h index 000ec01642e..c50decaa2d8 100644 --- a/ydb/core/tablet_flat/test/libs/rows/heap.h +++ b/ydb/core/tablet_flat/test/libs/rows/heap.h @@ -23,7 +23,7 @@ namespace NTest { TRowsHeap(size_t heap) : Heap(new TGrowHeap(heap)) { } - TRowsHeap(TIntrusivePtr<TGrowHeap> heap) : Heap(std::move(heap)) { } + TRowsHeap(TIntrusivePtr<TGrowHeap> heap) : Heap(std::move(heap)) { } template<typename TRand> TIter Any(TRand &rnd) const noexcept @@ -78,7 +78,7 @@ namespace NTest { } private: - TIntrusivePtr<TGrowHeap> Heap; + TIntrusivePtr<TGrowHeap> Heap; TDeque<TRow> Rows; }; diff --git a/ydb/core/tablet_flat/test/libs/rows/layout.h b/ydb/core/tablet_flat/test/libs/rows/layout.h index 79b71e7215f..36e64feac08 100644 --- a/ydb/core/tablet_flat/test/libs/rows/layout.h +++ b/ydb/core/tablet_flat/test/libs/rows/layout.h @@ -61,7 +61,7 @@ namespace NTest{ return *Scheme; } - TIntrusiveConstPtr<TRowScheme> RowScheme() const noexcept + TIntrusiveConstPtr<TRowScheme> RowScheme() const noexcept { return Scheme; } @@ -74,7 +74,7 @@ namespace NTest{ private: TVector<NTable::TColumn> Cols; TVector<NTable::TTag> Tags_; - TIntrusiveConstPtr<TRowScheme> Scheme; + TIntrusiveConstPtr<TRowScheme> Scheme; }; } } diff --git a/ydb/core/tablet_flat/test/libs/rows/mass.h b/ydb/core/tablet_flat/test/libs/rows/mass.h index eaeca1b3219..3997a46ee05 100644 --- a/ydb/core/tablet_flat/test/libs/rows/mass.h +++ b/ydb/core/tablet_flat/test/libs/rows/mass.h @@ -14,7 +14,7 @@ namespace NTest { class IModel { public: - IModel(TIntrusiveConstPtr<TRowScheme> scheme) : Scheme(scheme) { } + IModel(TIntrusiveConstPtr<TRowScheme> scheme) : Scheme(scheme) { } virtual ~IModel() = default; virtual TRow Make(ui64 seq, bool hole) noexcept = 0; @@ -22,12 +22,12 @@ namespace NTest { virtual void Check(TArrayRef<const ui64>) const = 0; virtual void Describe(IOutputStream&) const noexcept = 0; - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; }; class TMass { public: - TMass(TAutoPtr<IModel> model, ui64 caps, ui64 seed = 0, float holes = 0.1) + TMass(TAutoPtr<IModel> model, ui64 caps, ui64 seed = 0, float holes = 0.1) : Model(model) , Heap(new TGrowHeap(64 * 1024)) , Saved(Heap) @@ -77,8 +77,8 @@ namespace NTest { } } - const TAutoPtr<IModel> Model; - TIntrusivePtr<TGrowHeap> Heap; + const TAutoPtr<IModel> Model; + TIntrusivePtr<TGrowHeap> Heap; TRowsHeap Saved; TRowsHeap Holes; }; diff --git a/ydb/core/tablet_flat/test/libs/rows/rows.h b/ydb/core/tablet_flat/test/libs/rows/rows.h index 57029ef88a5..8bde29ceac5 100644 --- a/ydb/core/tablet_flat/test/libs/rows/rows.h +++ b/ydb/core/tablet_flat/test/libs/rows/rows.h @@ -62,7 +62,7 @@ namespace NTest { TCell Cell; }; - TRow(TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(512)) + TRow(TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(512)) : Heap(heap) { Cols.reserve(8); @@ -177,7 +177,7 @@ namespace NTest { } private: - TIntrusivePtr<TGrowHeap> Heap; + TIntrusivePtr<TGrowHeap> Heap; TVector<TUpdate> Cols; }; diff --git a/ydb/core/tablet_flat/test/libs/table/test_comp.h b/ydb/core/tablet_flat/test/libs/table/test_comp.h index 46d53089045..d6095c2a788 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_comp.h +++ b/ydb/core/tablet_flat/test/libs/table/test_comp.h @@ -27,7 +27,7 @@ namespace NTest { return Env; } - TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>&) noexcept override { + TPartView LoadPart(const TIntrusiveConstPtr<TColdPart>&) noexcept override { Y_FAIL("not supported in test scans"); } @@ -39,7 +39,7 @@ namespace NTest { TCompaction() : TCompaction(nullptr) { } - TCompaction(TAutoPtr<IPages> env, TConf conf = { }, ui32 ret = Max<ui32>()) + TCompaction(TAutoPtr<IPages> env, TConf conf = { }, ui32 ret = Max<ui32>()) : Conf(conf) , Retries(ret) , Env(env ? env : new TTestEnv) @@ -57,7 +57,7 @@ namespace NTest { return Do(eggs.Scheme, { &eggs } ); } - TPartEggs Do(TIntrusiveConstPtr<TRowScheme> scheme, TVector<const TPartEggs*> eggs) + TPartEggs Do(TIntrusiveConstPtr<TRowScheme> scheme, TVector<const TPartEggs*> eggs) { TVector<TPartView> partView; @@ -124,7 +124,7 @@ namespace NTest { } private: - virtual THello Prepare(IDriver*, TIntrusiveConstPtr<TScheme>) noexcept override + virtual THello Prepare(IDriver*, TIntrusiveConstPtr<TScheme>) noexcept override { Y_FAIL("IScan::Prepare(...) isn't used in test env compaction"); } @@ -176,7 +176,7 @@ namespace NTest { return Failed = 0, EScan::Feed; } - TAutoPtr<IDestructable> Finish(EAbort) noexcept override + TAutoPtr<IDestructable> Finish(EAbort) noexcept override { Y_FAIL("IScan::Finish(...) shouldn't be called in test env"); } @@ -191,9 +191,9 @@ namespace NTest { const ui32 Retries = Max<ui32>(); ui32 Serial = 0; ui32 Failed = 0; - TAutoPtr<IPages> Env; + TAutoPtr<IPages> Env; TVector<ui32> Tags; - TAutoPtr<TPartWriter> Writer; + TAutoPtr<TPartWriter> Writer; }; } diff --git a/ydb/core/tablet_flat/test/libs/table/test_cooker.h b/ydb/core/tablet_flat/test/libs/table/test_cooker.h index 0fde19dd098..d6a6426a97d 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_cooker.h +++ b/ydb/core/tablet_flat/test/libs/table/test_cooker.h @@ -18,7 +18,7 @@ namespace NTest { } - TCooker(TIntrusiveConstPtr<TRowScheme> scheme, TEpoch epoch = TEpoch::Zero()) + TCooker(TIntrusiveConstPtr<TRowScheme> scheme, TEpoch epoch = TEpoch::Zero()) : Table(new TMemTable(std::move(scheme), epoch, 0)) , Tool(*Table->Scheme) { diff --git a/ydb/core/tablet_flat/test/libs/table/test_curtain.h b/ydb/core/tablet_flat/test/libs/table/test_curtain.h index 314a4efca31..3c85a4e1ef7 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_curtain.h +++ b/ydb/core/tablet_flat/test/libs/table/test_curtain.h @@ -16,7 +16,7 @@ namespace NTest { TRowsHeap::TIter Begin; TRowsHeap::TIter End; - TIntrusiveConstPtr<TScreen> Screen; + TIntrusiveConstPtr<TScreen> Screen; }; TCurtain(const TPartEggs &eggs): Wrap(eggs, { new TTestEnv, 0 }) { } @@ -99,7 +99,7 @@ namespace NTest { lastEnd = hole.End; } - TIntrusiveConstPtr<TSlices> result = new TSlices(std::move(slices)); + TIntrusiveConstPtr<TSlices> result = new TSlices(std::move(slices)); result->Validate(); return result; } diff --git a/ydb/core/tablet_flat/test/libs/table/test_dbase.h b/ydb/core/tablet_flat/test/libs/table/test_dbase.h index e19964c7b03..fd931a54839 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_dbase.h +++ b/ydb/core/tablet_flat/test/libs/table/test_dbase.h @@ -24,12 +24,12 @@ namespace NTest { enum class EPlay { Boot = 1, /* Apply redo log through base booter */ - Redo = 2, /* Roll up redo log through follower iface */ + Redo = 2, /* Roll up redo log through follower iface */ }; struct TDbExec : public TSteps<TDbExec> { using TRow = NTest::TRow; - using TRedoLog = TDeque<TAutoPtr<TChange>>; + using TRedoLog = TDeque<TAutoPtr<TChange>>; using TSteppedCookieAllocator = NPageCollection::TSteppedCookieAllocator; using TCheckIter = TChecker<NTest::TWrapDbIter, TDatabase&>; @@ -49,9 +49,9 @@ namespace NTest { ui32 Pad0; }; - static TAutoPtr<TDatabase> Make(TAutoPtr<TSchemeChanges> delta) + static TAutoPtr<TDatabase> Make(TAutoPtr<TSchemeChanges> delta) { - TAutoPtr<TScheme> scheme = new TScheme; + TAutoPtr<TScheme> scheme = new TScheme; TSchemeModifier(*scheme).Apply(*delta); @@ -60,7 +60,7 @@ namespace NTest { TDbExec() : Base(new TDatabase) { Birth(); } - TDbExec(TAutoPtr<TSchemeChanges> delta) : Base(Make(delta)) { } + TDbExec(TAutoPtr<TSchemeChanges> delta) : Base(Make(delta)) { } const TRedoLog& GetLog() const noexcept { return RedoLog; } @@ -169,7 +169,7 @@ namespace NTest { TDbExec& Compact(ui32 table, bool last = true) { - TAutoPtr<TSubset> subset; + TAutoPtr<TSubset> subset; if (last /* make full subset */) { subset = Base->Subset(table, TEpoch::Max(), { }, { }); @@ -195,7 +195,7 @@ namespace NTest { materialize it on this compaction. */ - TAutoPtr<IPages> env = new TForwardEnv(128, 256, keys, Max<ui32>()); + TAutoPtr<IPages> env = new TForwardEnv(128, 256, keys, Max<ui32>()); auto eggs = TCompaction(env, conf).Do(*subset, logo); @@ -222,7 +222,7 @@ namespace NTest { WriteVersion = TRowVersion::Min(); if (play == EPlay::Boot) { - TAutoPtr<TScheme> scheme = new TScheme; + TAutoPtr<TScheme> scheme = new TScheme; for (auto &change: RedoLog) { if (auto &raw = change->Scheme) { @@ -409,14 +409,14 @@ namespace NTest { } private: - TAutoPtr<TDatabase> Base; + TAutoPtr<TDatabase> Base; std::optional<TTestEnv> Env; ui32 Gen = 0; ui32 Step = 0; ui32 Last = Max<ui32>(); bool Altered = false; EOnTx OnTx = EOnTx::None; - TIntrusiveConstPtr<TRowScheme> Scheme; + TIntrusiveConstPtr<TRowScheme> Scheme; TRedoLog RedoLog; TAutoPtr<TSteppedCookieAllocator> Annex; TRowVersion ReadVersion = TRowVersion::Max(); diff --git a/ydb/core/tablet_flat/test/libs/table/test_envs.h b/ydb/core/tablet_flat/test/libs/table/test_envs.h index b5503d26ca8..52066ddd339 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_envs.h +++ b/ydb/core/tablet_flat/test/libs/table/test_envs.h @@ -180,7 +180,7 @@ namespace NTest { private: const ui32 Room = Max<ui32>(); TVector<TPageId> Fetch; - TIntrusiveConstPtr<TStore> Store; + TIntrusiveConstPtr<TStore> Store; TAutoPtr<NFwd::IPageLoadingLogic> PageLoadingLogic; bool Grow = false; }; diff --git a/ydb/core/tablet_flat/test/libs/table/test_iter.h b/ydb/core/tablet_flat/test/libs/table/test_iter.h index b0f7e1c2793..f4010ab2b61 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_iter.h +++ b/ydb/core/tablet_flat/test/libs/table/test_iter.h @@ -21,7 +21,7 @@ namespace NTest { struct TConf { TConf() = default; - TConf(TAutoPtr<IPages> env, ui64 retry = 0, bool erased = true) + TConf(TAutoPtr<IPages> env, ui64 retry = 0, bool erased = true) : Env(env) , Retry(retry) , Erased(erased) @@ -29,7 +29,7 @@ namespace NTest { } - TAutoPtr<IPages> Env; + TAutoPtr<IPages> Env; ui64 Retry = 0; bool Erased = true; /* do not hide ERowOp::Erase */ }; @@ -56,7 +56,7 @@ namespace NTest { } template<typename TEnv> - TAutoPtr<TEnv> Displace(TAutoPtr<IPages> env) noexcept + TAutoPtr<TEnv> Displace(TAutoPtr<IPages> env) noexcept { auto *origin = std::exchange(Env, env).Release(); auto *casted = dynamic_cast<TEnv*>(origin); @@ -66,7 +66,7 @@ namespace NTest { return casted; } - TChecker& ReplaceEnv(TAutoPtr<IPages> env) + TChecker& ReplaceEnv(TAutoPtr<IPages> env) { return Displace<IPages>(env), *this; } @@ -320,7 +320,7 @@ namespace NTest { const ui64 Erased = true; ui64 Hoped = 0; EReady Ready = EReady::Gone; - TAutoPtr<IPages> Env; + TAutoPtr<IPages> Env; TWrap Wrap; const TRowScheme &Scheme; }; diff --git a/ydb/core/tablet_flat/test/libs/table/test_make.h b/ydb/core/tablet_flat/test/libs/table/test_make.h index ea34c8f75a2..8bd0e14d6d4 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_make.h +++ b/ydb/core/tablet_flat/test/libs/table/test_make.h @@ -24,7 +24,7 @@ namespace NTest { }; struct TPart : IBand { - TPart(TIntrusiveConstPtr<TScheme> scheme, TEpoch epoch, ui32, NPage::TConf conf, const TLogoBlobID &token) + TPart(TIntrusiveConstPtr<TScheme> scheme, TEpoch epoch, ui32, NPage::TConf conf, const TLogoBlobID &token) : Epoch(epoch) , Cook(std::move(scheme), conf, token, epoch) { @@ -41,7 +41,7 @@ namespace NTest { }; struct TMem : IBand { - TMem(TIntrusiveConstPtr<TScheme> scheme, TEpoch epoch, ui32) + TMem(TIntrusiveConstPtr<TScheme> scheme, TEpoch epoch, ui32) : Cooker(std::move(scheme), epoch) { @@ -77,9 +77,9 @@ namespace NTest { return cook.Add(Saved.begin(), Saved.end()).Finish(); } - TAutoPtr<TSubset> Mixed(ui32 frozen, ui32 flatten, THash hash) + TAutoPtr<TSubset> Mixed(ui32 frozen, ui32 flatten, THash hash) { - TDeque<TAutoPtr<IBand>> bands; + TDeque<TAutoPtr<IBand>> bands; for (auto it: xrange(flatten)) { TLogoBlobID token(0, 0, ++Serial, 0, 0, 0); @@ -94,7 +94,7 @@ namespace NTest { bands[hash(row) % slots]->Add(row); } - TAutoPtr<TSubset> subset = new TSubset(TEpoch::FromIndex(bands.size()), Scheme); + TAutoPtr<TSubset> subset = new TSubset(TEpoch::FromIndex(bands.size()), Scheme); for (auto &one: bands) { if (auto *mem = dynamic_cast<TMem*>(one.Get())) { @@ -124,7 +124,7 @@ namespace NTest { const NPage::TConf Pages { true, 7 * 1024 }; ui32 Serial = 0; const TRowsHeap &Saved; - TIntrusiveConstPtr<TScheme> Scheme; + TIntrusiveConstPtr<TScheme> Scheme; }; } diff --git a/ydb/core/tablet_flat/test/libs/table/test_part.h b/ydb/core/tablet_flat/test/libs/table/test_part.h index be09caeda3d..e1dde28eeaa 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_part.h +++ b/ydb/core/tablet_flat/test/libs/table/test_part.h @@ -28,7 +28,7 @@ namespace NTest { public: TPartStore(TIntrusiveConstPtr<TStore> store, TLogoBlobID label, TEgg egg, TStat stat, - TIntrusiveConstPtr<TSlices> slices) + TIntrusiveConstPtr<TSlices> slices) : TPart(label, egg, stat) , Store(std::move(store)) , Slices(std::move(slices)) @@ -51,13 +51,13 @@ namespace NTest { return Store->GetPage(groupId.Index, id)->size(); } - TIntrusiveConstPtr<NTable::TPart> CloneWithEpoch(NTable::TEpoch epoch) const override + TIntrusiveConstPtr<NTable::TPart> CloneWithEpoch(NTable::TEpoch epoch) const override { return new TPartStore(*this, epoch); } - const TIntrusiveConstPtr<TStore> Store; - const TIntrusiveConstPtr<TSlices> Slices; + const TIntrusiveConstPtr<TStore> Store; + const TIntrusiveConstPtr<TSlices> Slices; }; class TTestEnv: public IPages { @@ -119,8 +119,8 @@ namespace NTest { return { Lone(), nullptr, Lone()->Slices }; } - TAutoPtr<TWritten> Written; - TIntrusiveConstPtr<TRowScheme> Scheme; + TAutoPtr<TWritten> Written; + TIntrusiveConstPtr<TRowScheme> Scheme; TVector<TIntrusiveConstPtr<TPartStore>> Parts; }; diff --git a/ydb/core/tablet_flat/test/libs/table/test_store.h b/ydb/core/tablet_flat/test/libs/table/test_store.h index 1ab6f0497ea..bdd506663a3 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_store.h +++ b/ydb/core/tablet_flat/test/libs/table/test_store.h @@ -150,9 +150,9 @@ namespace NTest { } } - static TIntrusivePtr<TStore> Restore(IInputStream &in) + static TIntrusivePtr<TStore> Restore(IInputStream &in) { - TIntrusivePtr<TStore> storage(new TStore(1)); + TIntrusivePtr<TStore> storage(new TStore(1)); NPage::TLabel label; while (auto got = in.Load(&label, sizeof(label))) { @@ -231,7 +231,7 @@ namespace NTest { return id; } - void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept + void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept { Y_VERIFY(page == Scheme); diff --git a/ydb/core/tablet_flat/test/libs/table/test_writer.h b/ydb/core/tablet_flat/test/libs/table/test_writer.h index 898818879c3..5df2014cd64 100644 --- a/ydb/core/tablet_flat/test/libs/table/test_writer.h +++ b/ydb/core/tablet_flat/test/libs/table/test_writer.h @@ -25,7 +25,7 @@ namespace NTest { class TLoader { /* Test env clone for NTable::TLoader */ public: - TLoader(TIntrusiveConstPtr<TStore> store, TString overlay) + TLoader(TIntrusiveConstPtr<TStore> store, TString overlay) : Store(std::move(store)) , Overlay(std::move(overlay)) { @@ -135,7 +135,7 @@ namespace NTest { } private: - TIntrusiveConstPtr<TStore> Store; + TIntrusiveConstPtr<TStore> Store; const TString Overlay; }; @@ -151,7 +151,7 @@ namespace NTest { } - TPartEggs Flush(TIntrusiveConstPtr<TRowScheme> scheme, const TWritten &written) + TPartEggs Flush(TIntrusiveConstPtr<TRowScheme> scheme, const TWritten &written) { Y_VERIFY(!Store, "Writer has not been flushed"); Y_VERIFY(written.Parts == Parts.size()); @@ -171,7 +171,7 @@ namespace NTest { return Back().Write(page, type, group); } - void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept override + void WriteInplace(TPageId page, TArrayRef<const char> body) noexcept override { Back().WriteInplace(page, body); } @@ -203,9 +203,9 @@ namespace NTest { private: const size_t Groups; ui32 NextGlobOffset = 0; - TIntrusivePtr<TStore> Store; + TIntrusivePtr<TStore> Store; TAutoPtr<NPageCollection::TCookieAllocator> CookieAllocator; - TAutoPtr<TScreen::TCook> Growth = new TScreen::TCook; + TAutoPtr<TScreen::TCook> Growth = new TScreen::TCook; TVector<TIntrusiveConstPtr<TPartStore>> Parts; }; @@ -229,7 +229,7 @@ namespace NTest { } TPartCook( - TIntrusiveConstPtr<TRowScheme> rows, + TIntrusiveConstPtr<TRowScheme> rows, const NPage::TConf &opts, const TLogoBlobID &token = TLogoBlobID(1, 2, 3, 1, 0, 0), TEpoch epoch = TEpoch::Zero()) @@ -372,10 +372,10 @@ namespace NTest { } private: - TIntrusiveConstPtr<TRowScheme> Scheme; + TIntrusiveConstPtr<TRowScheme> Scheme; TWriterBundle Pages; TMap<TTag, TPos> Remap; - TAutoPtr<TPartWriter> Writer; + TAutoPtr<TPartWriter> Writer; TOwnedCellVec LastKey; TRowVersion NextVersion = TRowVersion::Min(); ui64 NextTxId = 0; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_dbase.h b/ydb/core/tablet_flat/test/libs/table/wrap_dbase.h index 8823872d305..aa162bf0f19 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_dbase.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_dbase.h @@ -9,7 +9,7 @@ namespace NTest { template<class TIter> struct TWrapDbIterImpl { - TWrapDbIterImpl(TDatabase &base, ui32 table, TIntrusiveConstPtr<TRowScheme> scheme, + TWrapDbIterImpl(TDatabase &base, ui32 table, TIntrusiveConstPtr<TRowScheme> scheme, TRowVersion snapshot = TRowVersion::Max()) : Scheme(std::move(scheme)) , Base(base) @@ -82,13 +82,13 @@ namespace NTest { } public: - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; TDatabase &Base; private: const ui32 Table = Max<ui32>(); const TRowVersion Snapshot; - TAutoPtr<TIter> Iter; + TAutoPtr<TIter> Iter; }; using TWrapDbIter = TWrapDbIterImpl<TTableIt>; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_iter.h b/ydb/core/tablet_flat/test/libs/table/wrap_iter.h index 0c12a01a8a2..9cd855141f9 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_iter.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_iter.h @@ -99,8 +99,8 @@ namespace NTest { } public: - const TIntrusiveConstPtr<TRowScheme> Scheme; - const TIntrusiveConstPtr<TKeyNulls> Nulls; + const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TKeyNulls> Nulls; const TFrozen Frozen; const TFlatten Flatten; const TRowVersion Snapshot; @@ -108,7 +108,7 @@ namespace NTest { private: IPages *Env = nullptr; TLevels Levels; - TAutoPtr<TIter> Iter; + TAutoPtr<TIter> Iter; }; using TWrapIter = TWrapIterImpl<TTableIt>; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_part.h b/ydb/core/tablet_flat/test/libs/table/wrap_part.h index 71ada525fe5..2cf16dae9ec 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_part.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_part.h @@ -15,7 +15,7 @@ namespace NTest { template<EDirection Direction> struct TWrapPartImpl { - TWrapPartImpl(const TPartEggs &eggs, TIntrusiveConstPtr<TSlices> slices = nullptr, + TWrapPartImpl(const TPartEggs &eggs, TIntrusiveConstPtr<TSlices> slices = nullptr, bool defaults = true) : Eggs(eggs) , Scheme(eggs.Scheme) @@ -35,7 +35,7 @@ namespace NTest { } private: - void AddPart(TIntrusiveConstPtr<TPart> part, const TSlices &slices) + void AddPart(TIntrusiveConstPtr<TPart> part, const TSlices &slices) { for (const auto &slice : slices) { auto got = Run.FindInsertHint(part.Get(), slice); @@ -150,7 +150,7 @@ namespace NTest { } const TPartEggs Eggs; - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; const TRemap Remap_; const bool Defaults = true; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_select.h b/ydb/core/tablet_flat/test/libs/table/wrap_select.h index aea564c3a80..06069a8d01a 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_select.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_select.h @@ -9,7 +9,7 @@ namespace NTest { struct TWrapDbSelect { - TWrapDbSelect(TDatabase &base, ui32 table, TIntrusiveConstPtr<TRowScheme> scheme, + TWrapDbSelect(TDatabase &base, ui32 table, TIntrusiveConstPtr<TRowScheme> scheme, TRowVersion snapshot = TRowVersion::Max()) : Scheme(std::move(scheme)) , Remap_(TRemap::Full(*Scheme)) @@ -58,7 +58,7 @@ namespace NTest { } public: - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; const TRemap Remap_; TDatabase &Base; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_warm.h b/ydb/core/tablet_flat/test/libs/table/wrap_warm.h index a32ffb6ec0d..059cac1a21e 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_warm.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_warm.h @@ -89,14 +89,14 @@ namespace NTest { } const TIntrusiveConstPtr<TMemTable> Table; - const TIntrusiveConstPtr<TRowScheme> Scheme; + const TIntrusiveConstPtr<TRowScheme> Scheme; const TRemap Remap_; const bool Defaults = true; private: IPages *Env = nullptr; TRowState State; - TAutoPtr<TMemIt> Iter; + TAutoPtr<TMemIt> Iter; }; using TWrapMemtable = TWrapMemtableImpl<EDirection::Forward>; diff --git a/ydb/core/tablet_flat/test/tool/perf/app.h b/ydb/core/tablet_flat/test/tool/perf/app.h index 9abe4a45181..96f1e81d5a2 100644 --- a/ydb/core/tablet_flat/test/tool/perf/app.h +++ b/ydb/core/tablet_flat/test/tool/perf/app.h @@ -111,7 +111,7 @@ namespace NPerf { auto rows = args.Value<ui64>(32768); const TString kind = args.Token("small"); - TAutoPtr<NTest::IModel> model; + TAutoPtr<NTest::IModel> model; if (kind == "2cols") { model = new NTest::TModel2Cols; @@ -152,10 +152,10 @@ namespace NPerf { private: int LLev = 1; - TAutoPtr<TLogger> Logger; + TAutoPtr<TLogger> Logger; ui64 Test = 0xffffffff; /* Bitmask of tests to perform */ NPerf::TConf Conf; - TAutoPtr<NTest::TMass> Mass; + TAutoPtr<NTest::TMass> Mass; NTest::ESponge Sponge = ESponge::Murmur; }; diff --git a/ydb/core/tablet_flat/test/tool/perf/do_iter.h b/ydb/core/tablet_flat/test/tool/perf/do_iter.h index 5fc7ae78a2d..d30b9cb16aa 100644 --- a/ydb/core/tablet_flat/test/tool/perf/do_iter.h +++ b/ydb/core/tablet_flat/test/tool/perf/do_iter.h @@ -23,7 +23,7 @@ namespace NPerf { } - static TAutoPtr<TSubset> Make(const TMass &mass, ui32 parts, bool mixed) + static TAutoPtr<TSubset> Make(const TMass &mass, ui32 parts, bool mixed) { using namespace NTest; diff --git a/ydb/core/tablet_flat/test/tool/perf/do_mem.h b/ydb/core/tablet_flat/test/tool/perf/do_mem.h index 8e55917404b..1a83c4f7626 100644 --- a/ydb/core/tablet_flat/test/tool/perf/do_mem.h +++ b/ydb/core/tablet_flat/test/tool/perf/do_mem.h @@ -70,9 +70,9 @@ namespace NPerf { private: TIntrusivePtr<TMemTable> Table; - TIntrusiveConstPtr<TKeyNulls> Nulls; + TIntrusiveConstPtr<TKeyNulls> Nulls; TRemap Remap; - TAutoPtr<TMemIt> Iter; + TAutoPtr<TMemIt> Iter; TRowState State; }; diff --git a/ydb/core/tablet_flat/test/tool/surg/main.cpp b/ydb/core/tablet_flat/test/tool/surg/main.cpp index 7985e920272..c196de6a7ee 100644 --- a/ydb/core/tablet_flat/test/tool/surg/main.cpp +++ b/ydb/core/tablet_flat/test/tool/surg/main.cpp @@ -85,7 +85,7 @@ namespace NTest { << Endl; } - void DoAnnex(TArrayRef<const TStdPad<NPageCollection::TGlobId>> annex) noexcept + void DoAnnex(TArrayRef<const TStdPad<NPageCollection::TGlobId>> annex) noexcept { Out << " | Annex " << annex.size() << " items" << Endl; diff --git a/ydb/core/tablet_flat/ut/flat_comp_ut_common.h b/ydb/core/tablet_flat/ut/flat_comp_ut_common.h index 6f4ca036cf7..66702b8c3f2 100644 --- a/ydb/core/tablet_flat/ut/flat_comp_ut_common.h +++ b/ydb/core/tablet_flat/ut/flat_comp_ut_common.h @@ -1,407 +1,407 @@ -#pragma once - +#pragma once + #include <ydb/core/tablet_flat/flat_comp.h> #include <ydb/core/tablet_flat/flat_cxx_database.h> #include <ydb/core/tablet_flat/util_fmt_line.h> - + #include <ydb/core/tablet_flat/test/libs/table/test_part.h> #include <ydb/core/tablet_flat/test/libs/table/test_comp.h> - -#include <library/cpp/time_provider/time_provider.h> - -namespace NKikimr { -namespace NTable { -namespace NTest { - -class TSimpleBackend : public ICompactionBackend { -public: - TSimpleBackend() { - SwitchGen(); - } - - NIceDb::TNiceDb Begin() noexcept { - Annex->Switch(++Step, /* require step switch */ true); + +#include <library/cpp/time_provider/time_provider.h> + +namespace NKikimr { +namespace NTable { +namespace NTest { + +class TSimpleBackend : public ICompactionBackend { +public: + TSimpleBackend() { + SwitchGen(); + } + + NIceDb::TNiceDb Begin() noexcept { + Annex->Switch(++Step, /* require step switch */ true); DB.Begin({ Gen, Step }, Env.emplace()); - return DB; - } - - void Commit() noexcept { - DB.Commit({ Gen, Step }, true, Annex.Get()); + return DB; + } + + void Commit() noexcept { + DB.Commit({ Gen, Step }, true, Annex.Get()); Env.reset(); - } - - TSnapEdge SnapshotTable(ui32 table) noexcept { - const auto scn = DB.Head().Serial + 1; - TTxStamp txStamp(Gen, ++Step); - DB.SnapshotToLog(table, txStamp); - Y_VERIFY(scn == DB.Head().Serial); - auto chg = DB.Head(table); - return { txStamp, chg.Epoch }; - } - + } + + TSnapEdge SnapshotTable(ui32 table) noexcept { + const auto scn = DB.Head().Serial + 1; + TTxStamp txStamp(Gen, ++Step); + DB.SnapshotToLog(table, txStamp); + Y_VERIFY(scn == DB.Head().Serial); + auto chg = DB.Head(table); + return { txStamp, chg.Epoch }; + } + ui64 OwnerTabletId() const override { return 123; } - const TScheme& DatabaseScheme() override { - return DB.GetScheme(); - } - - TIntrusiveConstPtr<NKikimr::NTable::TRowScheme> RowScheme(ui32 table) override { - return DB.GetRowScheme(table); - } - - const TScheme::TTableInfo* TableScheme(ui32 table) override { - auto* info = DB.GetScheme().GetTableInfo(table); - Y_VERIFY(info, "Unexpected table"); - return info; - } - - ui64 TableMemSize(ui32 table, TEpoch epoch) override { - return DB.GetTableMemSize(table, epoch); - } - + const TScheme& DatabaseScheme() override { + return DB.GetScheme(); + } + + TIntrusiveConstPtr<NKikimr::NTable::TRowScheme> RowScheme(ui32 table) override { + return DB.GetRowScheme(table); + } + + const TScheme::TTableInfo* TableScheme(ui32 table) override { + auto* info = DB.GetScheme().GetTableInfo(table); + Y_VERIFY(info, "Unexpected table"); + return info; + } + + ui64 TableMemSize(ui32 table, TEpoch epoch) override { + return DB.GetTableMemSize(table, epoch); + } + TPartView TablePart(ui32 table, const TLogoBlobID& label) override { auto partView = DB.GetPartView(table, label); Y_VERIFY(partView, "Unexpected part %s", label.ToString().c_str()); return partView; - } - + } + TVector<TPartView> TableParts(ui32 table) override { - return DB.GetTableParts(table); - } - - TVector<TIntrusiveConstPtr<TColdPart>> TableColdParts(ui32 table) override { - return DB.GetTableColdParts(table); - } - - const TRowVersionRanges& TableRemovedRowVersions(ui32 table) override { - return DB.GetRemovedRowVersions(table); - } - - ui64 BeginCompaction(THolder<TCompactionParams> params) override { - Y_VERIFY(params); - ui64 compactionId = NextCompactionId_++; - StartedCompactions[compactionId] = std::move(params); - return compactionId; - } - - bool CancelCompaction(ui64 compactionId) override { - return StartedCompactions.erase(compactionId) > 0; - } - - ui64 BeginRead(THolder<ICompactionRead> read) override { - Y_VERIFY(read); - ui64 readId = NextReadId_++; - PendingReads[readId] = std::move(read); - return readId; - } - - bool CancelRead(ui64 readId) override { - return PendingReads.erase(readId) > 0; - } - - void RequestChanges(ui32 table) override { - Y_VERIFY(table == 1, "Unexpected table"); - ChangesRequested_ = true; - } - - bool CheckChangesFlag() { - return std::exchange(ChangesRequested_, false); - } - - struct TReadResult { - ui64 ReadId; - bool Completed; - }; - - TReadResult RunRead(IPages* env) { - Y_VERIFY(PendingReads, "There are no pending reads"); - ui64 readId = PendingReads.begin()->first; - return RunRead(readId, env); - } - - TReadResult RunRead(ui64 readId, IPages* env) { - auto it = PendingReads.find(readId); - Y_VERIFY(it != PendingReads.end()); - bool completed = it->second->Execute(env); - if (completed) { - PendingReads.erase(readId); - } - return { readId, completed }; - } - - struct TRunCompactionResult { - ui64 CompactionId; - THolder<TCompactionParams> Params; - THolder<TCompactionResult> Result; - }; - - TRunCompactionResult RunCompaction() { - Y_VERIFY(StartedCompactions, "There are no started compactions"); - ui64 compactionId = StartedCompactions.begin()->first; - return RunCompaction(compactionId); - } - - TRunCompactionResult RunCompaction(ui64 compactionId) { - auto it = StartedCompactions.find(compactionId); - Y_VERIFY(it != StartedCompactions.end()); - auto params = std::move(it->second); - StartedCompactions.erase(it); - auto result = RunCompaction(params.Get()); - return { compactionId, std::move(params), std::move(result) }; - } - - THolder<TCompactionResult> RunCompaction(const TCompactionParams* params) { - if (params->Edge.Head == TEpoch::Max()) { - SnapshotTable(params->Table); - } - - auto subset = DB.Subset(params->Table, { }, params->Edge.Head); - if (params->Parts) { - subset->Flatten.insert(subset->Flatten.end(), params->Parts.begin(), params->Parts.end()); - } - - Y_VERIFY(!*subset || subset->IsStickedToHead()); - - const auto& scheme = DB.GetScheme(); - auto* family = scheme.DefaultFamilyFor(params->Table); - auto* policy = scheme.GetTableInfo(params->Table)->CompactionPolicy.Get(); - - NPage::TConf conf(params->IsFinal, policy->MinDataPageSize); - conf.UnderlayMask = params->UnderlayMask.Get(); - conf.SplitKeys = params->SplitKeys.Get(); - conf.Group(0).Codec = family->Codec; - conf.SmallEdge = family->Small; - conf.LargeEdge = family->Large; - conf.MaxRows = subset->MaxRows(); - conf.ByKeyFilter = scheme.GetTableInfo(params->Table)->ByKeyFilter; - - // Don't care about moving blobs by reference - TAutoPtr<IPages> env = new TTestEnv; - - // Template for new blobs - TLogoBlobID logo(123, Gen, ++Step, 0, 0, 0); - - auto eggs = TCompaction(env, conf).Do(*subset, logo); - + return DB.GetTableParts(table); + } + + TVector<TIntrusiveConstPtr<TColdPart>> TableColdParts(ui32 table) override { + return DB.GetTableColdParts(table); + } + + const TRowVersionRanges& TableRemovedRowVersions(ui32 table) override { + return DB.GetRemovedRowVersions(table); + } + + ui64 BeginCompaction(THolder<TCompactionParams> params) override { + Y_VERIFY(params); + ui64 compactionId = NextCompactionId_++; + StartedCompactions[compactionId] = std::move(params); + return compactionId; + } + + bool CancelCompaction(ui64 compactionId) override { + return StartedCompactions.erase(compactionId) > 0; + } + + ui64 BeginRead(THolder<ICompactionRead> read) override { + Y_VERIFY(read); + ui64 readId = NextReadId_++; + PendingReads[readId] = std::move(read); + return readId; + } + + bool CancelRead(ui64 readId) override { + return PendingReads.erase(readId) > 0; + } + + void RequestChanges(ui32 table) override { + Y_VERIFY(table == 1, "Unexpected table"); + ChangesRequested_ = true; + } + + bool CheckChangesFlag() { + return std::exchange(ChangesRequested_, false); + } + + struct TReadResult { + ui64 ReadId; + bool Completed; + }; + + TReadResult RunRead(IPages* env) { + Y_VERIFY(PendingReads, "There are no pending reads"); + ui64 readId = PendingReads.begin()->first; + return RunRead(readId, env); + } + + TReadResult RunRead(ui64 readId, IPages* env) { + auto it = PendingReads.find(readId); + Y_VERIFY(it != PendingReads.end()); + bool completed = it->second->Execute(env); + if (completed) { + PendingReads.erase(readId); + } + return { readId, completed }; + } + + struct TRunCompactionResult { + ui64 CompactionId; + THolder<TCompactionParams> Params; + THolder<TCompactionResult> Result; + }; + + TRunCompactionResult RunCompaction() { + Y_VERIFY(StartedCompactions, "There are no started compactions"); + ui64 compactionId = StartedCompactions.begin()->first; + return RunCompaction(compactionId); + } + + TRunCompactionResult RunCompaction(ui64 compactionId) { + auto it = StartedCompactions.find(compactionId); + Y_VERIFY(it != StartedCompactions.end()); + auto params = std::move(it->second); + StartedCompactions.erase(it); + auto result = RunCompaction(params.Get()); + return { compactionId, std::move(params), std::move(result) }; + } + + THolder<TCompactionResult> RunCompaction(const TCompactionParams* params) { + if (params->Edge.Head == TEpoch::Max()) { + SnapshotTable(params->Table); + } + + auto subset = DB.Subset(params->Table, { }, params->Edge.Head); + if (params->Parts) { + subset->Flatten.insert(subset->Flatten.end(), params->Parts.begin(), params->Parts.end()); + } + + Y_VERIFY(!*subset || subset->IsStickedToHead()); + + const auto& scheme = DB.GetScheme(); + auto* family = scheme.DefaultFamilyFor(params->Table); + auto* policy = scheme.GetTableInfo(params->Table)->CompactionPolicy.Get(); + + NPage::TConf conf(params->IsFinal, policy->MinDataPageSize); + conf.UnderlayMask = params->UnderlayMask.Get(); + conf.SplitKeys = params->SplitKeys.Get(); + conf.Group(0).Codec = family->Codec; + conf.SmallEdge = family->Small; + conf.LargeEdge = family->Large; + conf.MaxRows = subset->MaxRows(); + conf.ByKeyFilter = scheme.GetTableInfo(params->Table)->ByKeyFilter; + + // Don't care about moving blobs by reference + TAutoPtr<IPages> env = new TTestEnv; + + // Template for new blobs + TLogoBlobID logo(123, Gen, ++Step, 0, 0, 0); + + auto eggs = TCompaction(env, conf).Do(*subset, logo); + TVector<TPartView> parts(Reserve(eggs.Parts.size())); - for (auto& part : eggs.Parts) { - parts.push_back({ part, nullptr, part->Slices }); - Y_VERIFY(parts.back()); - } - - auto partsCopy = parts; - DB.Replace(params->Table, partsCopy, *subset); - - return MakeHolder<TCompactionResult>(subset->Epoch(), std::move(parts)); - } - - void ApplyChanges(ui32 table, TCompactionChanges changes) { - auto& state = TableState[table]; - for (auto& kv : changes.StateChanges) { - if (kv.second) { - state[kv.first] = std::move(kv.second); - } else { - state.erase(kv.first); - } - } - - for (auto& change : changes.SliceChanges) { + for (auto& part : eggs.Parts) { + parts.push_back({ part, nullptr, part->Slices }); + Y_VERIFY(parts.back()); + } + + auto partsCopy = parts; + DB.Replace(params->Table, partsCopy, *subset); + + return MakeHolder<TCompactionResult>(subset->Epoch(), std::move(parts)); + } + + void ApplyChanges(ui32 table, TCompactionChanges changes) { + auto& state = TableState[table]; + for (auto& kv : changes.StateChanges) { + if (kv.second) { + state[kv.first] = std::move(kv.second); + } else { + state.erase(kv.first); + } + } + + for (auto& change : changes.SliceChanges) { auto partView = DB.GetPartView(table, change.Label); Y_VERIFY(partView, "Cannot find part %s", change.Label.ToString().c_str()); auto replaced = TSlices::Replace(partView.Slices, change.NewSlices); - DB.ReplaceSlices(table, {{ change.Label, std::move(replaced) }}); - } - } - - void SimpleMemCompaction(ui32 table) { - TCompactionParams params; - params.Table = table; - params.Edge.Head = TEpoch::Max(); - RunCompaction(¶ms); - } - - void SimpleMemCompaction(ICompactionStrategy* strategy, bool forced = false) { - ui64 forcedCompactionId = forced ? 1 : 0; - ui64 compactionId = strategy->BeginMemCompaction(0, { 0, TEpoch::Max() }, forcedCompactionId); - auto outcome = RunCompaction(compactionId); - const ui32 table = outcome.Params->Table; - auto changes = strategy->CompactionFinished( - compactionId, std::move(outcome.Params), std::move(outcome.Result)); - ApplyChanges(table, std::move(changes)); - } - - bool SimpleTableCompaction(ui32 table, IResourceBroker* broker, ICompactionStrategy* strategy) { - for (auto& kv : StartedCompactions) { - if (kv.second->Table == table) { - ui64 compactionId = kv.first; - auto outcome = RunCompaction(compactionId); - broker->FinishTask(outcome.Params->TaskId, EResourceStatus::Finished); - auto changes = strategy->CompactionFinished( - compactionId, - std::move(outcome.Params), - std::move(outcome.Result)); - ApplyChanges(table, std::move(changes)); - return true; - } - } - - return false; - } - - TString DumpKeyRanges(ui32 table, bool dumpStep = false) { - struct TKeyRange : public TBounds { - TEpoch Epoch; - ui32 Step; - - TKeyRange(const TBounds& bounds, TEpoch epoch, ui32 step) - : TBounds(bounds) - , Epoch(epoch) - , Step(step) - { } - - TString ToString(const TKeyNulls& nulls, bool dumpStep) const { - TStringStream s; - Describe(s, nulls); - s << "@" << Epoch; - if (dumpStep) { - s << "/" << Step; - } - return std::move(s.Str()); - } - }; - - const TKeyNulls& nulls = *DB.GetRowScheme(table)->Keys; - auto keyRangeLess = [&nulls](const TKeyRange& a, const TKeyRange& b) -> bool { - if (auto cmp = ComparePartKeys(a.FirstKey.GetCells(), b.FirstKey.GetCells(), nulls)) { - return cmp < 0; - } - if (a.FirstInclusive != b.FirstInclusive) { - return a.FirstInclusive && !b.FirstInclusive; - } - if (auto cmp = ComparePartKeys(a.LastKey.GetCells(), b.LastKey.GetCells(), nulls)) { - return cmp < 0; - } - if (a.LastInclusive != b.LastInclusive) { - return !a.LastInclusive && b.LastInclusive; - } - return a.Epoch < b.Epoch; - }; - - TVector<TKeyRange> keyRanges; + DB.ReplaceSlices(table, {{ change.Label, std::move(replaced) }}); + } + } + + void SimpleMemCompaction(ui32 table) { + TCompactionParams params; + params.Table = table; + params.Edge.Head = TEpoch::Max(); + RunCompaction(¶ms); + } + + void SimpleMemCompaction(ICompactionStrategy* strategy, bool forced = false) { + ui64 forcedCompactionId = forced ? 1 : 0; + ui64 compactionId = strategy->BeginMemCompaction(0, { 0, TEpoch::Max() }, forcedCompactionId); + auto outcome = RunCompaction(compactionId); + const ui32 table = outcome.Params->Table; + auto changes = strategy->CompactionFinished( + compactionId, std::move(outcome.Params), std::move(outcome.Result)); + ApplyChanges(table, std::move(changes)); + } + + bool SimpleTableCompaction(ui32 table, IResourceBroker* broker, ICompactionStrategy* strategy) { + for (auto& kv : StartedCompactions) { + if (kv.second->Table == table) { + ui64 compactionId = kv.first; + auto outcome = RunCompaction(compactionId); + broker->FinishTask(outcome.Params->TaskId, EResourceStatus::Finished); + auto changes = strategy->CompactionFinished( + compactionId, + std::move(outcome.Params), + std::move(outcome.Result)); + ApplyChanges(table, std::move(changes)); + return true; + } + } + + return false; + } + + TString DumpKeyRanges(ui32 table, bool dumpStep = false) { + struct TKeyRange : public TBounds { + TEpoch Epoch; + ui32 Step; + + TKeyRange(const TBounds& bounds, TEpoch epoch, ui32 step) + : TBounds(bounds) + , Epoch(epoch) + , Step(step) + { } + + TString ToString(const TKeyNulls& nulls, bool dumpStep) const { + TStringStream s; + Describe(s, nulls); + s << "@" << Epoch; + if (dumpStep) { + s << "/" << Step; + } + return std::move(s.Str()); + } + }; + + const TKeyNulls& nulls = *DB.GetRowScheme(table)->Keys; + auto keyRangeLess = [&nulls](const TKeyRange& a, const TKeyRange& b) -> bool { + if (auto cmp = ComparePartKeys(a.FirstKey.GetCells(), b.FirstKey.GetCells(), nulls)) { + return cmp < 0; + } + if (a.FirstInclusive != b.FirstInclusive) { + return a.FirstInclusive && !b.FirstInclusive; + } + if (auto cmp = ComparePartKeys(a.LastKey.GetCells(), b.LastKey.GetCells(), nulls)) { + return cmp < 0; + } + if (a.LastInclusive != b.LastInclusive) { + return !a.LastInclusive && b.LastInclusive; + } + return a.Epoch < b.Epoch; + }; + + TVector<TKeyRange> keyRanges; for (auto& partView : TableParts(table)) { for (auto& slice : *partView.Slices) { keyRanges.emplace_back(slice, partView->Epoch, partView->Label.Step()); - } - } - std::sort(keyRanges.begin(), keyRanges.end(), keyRangeLess); - - TString result; - for (auto& keyRange : keyRanges) { - if (result) { - result.append(' '); - } - result += keyRange.ToString(nulls, dumpStep); - } - return result; - } - -private: - void SwitchGen() { - ++Gen; - Step = 0; + } + } + std::sort(keyRanges.begin(), keyRanges.end(), keyRangeLess); + + TString result; + for (auto& keyRange : keyRanges) { + if (result) { + result.append(' '); + } + result += keyRange.ToString(nulls, dumpStep); + } + return result; + } + +private: + void SwitchGen() { + ++Gen; + Step = 0; Annex.Reset(new NPageCollection::TSteppedCookieAllocator(123, ui64(Gen) << 32, { 0, 999 }, {{ 1, 7 }})); - } - -public: - TDatabase DB; + } + +public: + TDatabase DB; std::optional<TTestEnv> Env; - THashMap<ui64, THolder<ICompactionRead>> PendingReads; - THashMap<ui64, THolder<TCompactionParams>> StartedCompactions; - THashMap<ui32, THashMap<ui64, TString>> TableState; - -private: + THashMap<ui64, THolder<ICompactionRead>> PendingReads; + THashMap<ui64, THolder<TCompactionParams>> StartedCompactions; + THashMap<ui32, THashMap<ui64, TString>> TableState; + +private: THolder<NPageCollection::TSteppedCookieAllocator> Annex; - ui32 Gen = 0; - ui32 Step = 0; - - ui64 NextReadId_ = 1; - ui64 NextCompactionId_ = 1; - - bool ChangesRequested_ = false; -}; - -class TSimpleBroker : public IResourceBroker { -public: - TTaskId SubmitTask(TString name, TResourceParams params, TResourceConsumer consumer) override { - Y_UNUSED(name); - Y_UNUSED(params); - auto taskId = NextTaskId_++; - Pending_[taskId] = consumer; - return taskId; - } - - void UpdateTask(TTaskId taskId, TResourceParams params) override { - Y_UNUSED(taskId); - Y_UNUSED(params); - } - - void FinishTask(TTaskId taskId, EResourceStatus status) override { - Y_UNUSED(status); - Running_.erase(taskId); - } - - bool CancelTask(TTaskId taskId) override { - return Pending_.erase(taskId) > 0; - } - - bool HasPending() const { - return bool(Pending_); - } - - bool HasRunning() const { - return bool(Running_); - } - - bool RunPending() { - if (auto it = Pending_.begin(); it != Pending_.end()) { - auto taskId = it->first; - auto consumer = std::move(it->second); - Pending_.erase(it); - Running_.insert(taskId); - consumer(taskId); - return true; - } - return false; - } - -private: - TTaskId NextTaskId_ = 1; - THashMap<TTaskId, TResourceConsumer> Pending_; - THashSet<TTaskId> Running_; -}; - -class TSimpleTime : public ITimeProvider { -public: - TInstant Now() override { - return Now_; - } - - void Move(TInstant now) { - Now_ = now; - } - -private: - TInstant Now_; -}; - -struct TSimpleLogger : public NUtil::ILogger { - NUtil::TLogLn Log(NUtil::ELnLev level) const noexcept override { - return { nullptr, level }; - } -}; - -} // NTable -} // Kikimr -} // NTest + ui32 Gen = 0; + ui32 Step = 0; + + ui64 NextReadId_ = 1; + ui64 NextCompactionId_ = 1; + + bool ChangesRequested_ = false; +}; + +class TSimpleBroker : public IResourceBroker { +public: + TTaskId SubmitTask(TString name, TResourceParams params, TResourceConsumer consumer) override { + Y_UNUSED(name); + Y_UNUSED(params); + auto taskId = NextTaskId_++; + Pending_[taskId] = consumer; + return taskId; + } + + void UpdateTask(TTaskId taskId, TResourceParams params) override { + Y_UNUSED(taskId); + Y_UNUSED(params); + } + + void FinishTask(TTaskId taskId, EResourceStatus status) override { + Y_UNUSED(status); + Running_.erase(taskId); + } + + bool CancelTask(TTaskId taskId) override { + return Pending_.erase(taskId) > 0; + } + + bool HasPending() const { + return bool(Pending_); + } + + bool HasRunning() const { + return bool(Running_); + } + + bool RunPending() { + if (auto it = Pending_.begin(); it != Pending_.end()) { + auto taskId = it->first; + auto consumer = std::move(it->second); + Pending_.erase(it); + Running_.insert(taskId); + consumer(taskId); + return true; + } + return false; + } + +private: + TTaskId NextTaskId_ = 1; + THashMap<TTaskId, TResourceConsumer> Pending_; + THashSet<TTaskId> Running_; +}; + +class TSimpleTime : public ITimeProvider { +public: + TInstant Now() override { + return Now_; + } + + void Move(TInstant now) { + Now_ = now; + } + +private: + TInstant Now_; +}; + +struct TSimpleLogger : public NUtil::ILogger { + NUtil::TLogLn Log(NUtil::ELnLev level) const noexcept override { + return { nullptr, level }; + } +}; + +} // NTable +} // Kikimr +} // NTest diff --git a/ydb/core/tablet_flat/ut/flat_test_db.h b/ydb/core/tablet_flat/ut/flat_test_db.h index e0013ffdc8e..ed0af81c68a 100644 --- a/ydb/core/tablet_flat/ut/flat_test_db.h +++ b/ydb/core/tablet_flat/ut/flat_test_db.h @@ -50,10 +50,10 @@ public: }; class TFlatDbIterator : public ITestIterator { - TAutoPtr<TTableIt> Iter; + TAutoPtr<TTableIt> Iter; public: - explicit TFlatDbIterator(TAutoPtr<TTableIt> iter) + explicit TFlatDbIterator(TAutoPtr<TTableIt> iter) : Iter(iter) {} diff --git a/ydb/core/tablet_flat/ut/ut_bloom.cpp b/ydb/core/tablet_flat/ut/ut_bloom.cpp index c3060f91f9f..0ba3f5b6629 100644 --- a/ydb/core/tablet_flat/ut/ut_bloom.cpp +++ b/ydb/core/tablet_flat/ut/ut_bloom.cpp @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(Bloom) { static const NTest::TMass Mass0(new NTest::TModelS3Hash, 24000, 42, 0.5); struct TCooker { - static TIntrusiveConstPtr<NPage::TBloom> Make(const TMass &mass, float rate) + static TIntrusiveConstPtr<NPage::TBloom> Make(const TMass &mass, float rate) { TCooker cooker(*mass.Model->Scheme, mass.Saved.Size(), rate); @@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(Bloom) { return Writer.Add(key), *this; } - TIntrusiveConstPtr<NPage::TBloom> Flush() noexcept + TIntrusiveConstPtr<NPage::TBloom> Flush() noexcept { return new NPage::TBloom(Writer.Make()); } @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(Bloom) { }; struct TRater { - TRater(const TRowScheme &scheme, TIntrusiveConstPtr<NPage::TBloom> page) + TRater(const TRowScheme &scheme, TIntrusiveConstPtr<NPage::TBloom> page) : Tool(scheme) , Page(std::move(page)) { @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(Bloom) { public: const NTest::TRowTool Tool; - const TIntrusiveConstPtr<NPage::TBloom> Page; + const TIntrusiveConstPtr<NPage::TBloom> Page; }; static TAlter MakeAlter(const ui32 table = 1) @@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(Bloom) { me.To(10).Begin().Apply(*MakeAlter()).Commit(); - const TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(128 * 1024); + const TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(128 * 1024); TDeque<NTest::TRow> ladder; diff --git a/ydb/core/tablet_flat/ut/ut_comp_gen.cpp b/ydb/core/tablet_flat/ut/ut_comp_gen.cpp index 587548e3549..94ef1b5a924 100644 --- a/ydb/core/tablet_flat/ut/ut_comp_gen.cpp +++ b/ydb/core/tablet_flat/ut/ut_comp_gen.cpp @@ -1,99 +1,99 @@ -#include "flat_comp_ut_common.h" - +#include "flat_comp_ut_common.h" + #include <ydb/core/tablet_flat/flat_comp_gen.h> - -#include <library/cpp/testing/unittest/registar.h> - -constexpr ui32 Table = 1; - -namespace NKikimr { -namespace NTable { -namespace NCompGen { - -using namespace NTest; - -Y_UNIT_TEST_SUITE(TGenCompaction) { - - struct Schema : NIceDb::Schema { - struct Data : Table<1> { - struct Key : Column<1, NScheme::NTypeIds::Uint64> { }; - struct Value : Column<2, NScheme::NTypeIds::Uint32> { }; - - using TKey = TableKey<Key>; - using TColumns = TableColumns<Key, Value>; - }; - - using TTables = SchemaTables<Data>; - }; - - Y_UNIT_TEST(ShouldIncreaseOverloadWhenForceCompaction) { - TSimpleBackend backend; - TSimpleBroker broker; - TSimpleLogger logger; - TSimpleTime time; - - // Initialize the schema - { - auto db = backend.Begin(); - db.Materialize<Schema>(); - - TCompactionPolicy policy; - - // almost randome values except forceCountToCompact = 1 and forceSizeToCompact = 100 GB - TCompactionPolicy::TGenerationPolicy genPolicy(1, 1, 1, 10*1024*1024*1024, "whoknows", true); - - for (size_t i = 0; i < 5; ++i) { - policy.Generations.push_back(genPolicy); - } - - backend.DB.Alter().SetCompactionPolicy(Table, policy); - - backend.Commit(); - } - - TGenCompactionStrategy strategy(Table, &backend, &broker, &time, "suffix"); - strategy.Start({ }); - - const ui64 rowsPerTx = 16 * 1024; - for (ui64 index = 0; index < 3; ++index) { - const ui64 base = index; - auto db = backend.Begin(); - for (ui64 seq = 0; seq < rowsPerTx; ++seq) { - db.Table<Schema::Data>().Key(base + seq * 3).Update<Schema::Data::Value>(42); - } - backend.Commit(); - backend.SimpleMemCompaction(&strategy); - } - - UNIT_ASSERT_VALUES_EQUAL(backend.TableParts(Table).size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 1); - UNIT_ASSERT(strategy.AllowForcedCompaction()); - - // run forced mem compaction - backend.SimpleMemCompaction(&strategy, true); - - // forced compaction is in progress (waiting resource broker to start gen compaction) - UNIT_ASSERT(!strategy.AllowForcedCompaction()); - UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 0); - - // finish forced compaction - while (broker.HasPending()) { - UNIT_ASSERT(broker.RunPending()); - if (backend.StartedCompactions.empty()) - continue; - - auto result = backend.RunCompaction(); - auto changes = strategy.CompactionFinished( - result.CompactionId, std::move(result.Params), std::move(result.Result)); - backend.ApplyChanges(Table, std::move(changes)); - } - - UNIT_ASSERT(strategy.AllowForcedCompaction()); - UNIT_ASSERT_VALUES_EQUAL(backend.TableParts(Table).size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 0); - } -}; - -} // NCompGen -} // NTable -} // NKikimr + +#include <library/cpp/testing/unittest/registar.h> + +constexpr ui32 Table = 1; + +namespace NKikimr { +namespace NTable { +namespace NCompGen { + +using namespace NTest; + +Y_UNIT_TEST_SUITE(TGenCompaction) { + + struct Schema : NIceDb::Schema { + struct Data : Table<1> { + struct Key : Column<1, NScheme::NTypeIds::Uint64> { }; + struct Value : Column<2, NScheme::NTypeIds::Uint32> { }; + + using TKey = TableKey<Key>; + using TColumns = TableColumns<Key, Value>; + }; + + using TTables = SchemaTables<Data>; + }; + + Y_UNIT_TEST(ShouldIncreaseOverloadWhenForceCompaction) { + TSimpleBackend backend; + TSimpleBroker broker; + TSimpleLogger logger; + TSimpleTime time; + + // Initialize the schema + { + auto db = backend.Begin(); + db.Materialize<Schema>(); + + TCompactionPolicy policy; + + // almost randome values except forceCountToCompact = 1 and forceSizeToCompact = 100 GB + TCompactionPolicy::TGenerationPolicy genPolicy(1, 1, 1, 10*1024*1024*1024, "whoknows", true); + + for (size_t i = 0; i < 5; ++i) { + policy.Generations.push_back(genPolicy); + } + + backend.DB.Alter().SetCompactionPolicy(Table, policy); + + backend.Commit(); + } + + TGenCompactionStrategy strategy(Table, &backend, &broker, &time, "suffix"); + strategy.Start({ }); + + const ui64 rowsPerTx = 16 * 1024; + for (ui64 index = 0; index < 3; ++index) { + const ui64 base = index; + auto db = backend.Begin(); + for (ui64 seq = 0; seq < rowsPerTx; ++seq) { + db.Table<Schema::Data>().Key(base + seq * 3).Update<Schema::Data::Value>(42); + } + backend.Commit(); + backend.SimpleMemCompaction(&strategy); + } + + UNIT_ASSERT_VALUES_EQUAL(backend.TableParts(Table).size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 1); + UNIT_ASSERT(strategy.AllowForcedCompaction()); + + // run forced mem compaction + backend.SimpleMemCompaction(&strategy, true); + + // forced compaction is in progress (waiting resource broker to start gen compaction) + UNIT_ASSERT(!strategy.AllowForcedCompaction()); + UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 0); + + // finish forced compaction + while (broker.HasPending()) { + UNIT_ASSERT(broker.RunPending()); + if (backend.StartedCompactions.empty()) + continue; + + auto result = backend.RunCompaction(); + auto changes = strategy.CompactionFinished( + result.CompactionId, std::move(result.Params), std::move(result.Result)); + backend.ApplyChanges(Table, std::move(changes)); + } + + UNIT_ASSERT(strategy.AllowForcedCompaction()); + UNIT_ASSERT_VALUES_EQUAL(backend.TableParts(Table).size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(strategy.GetOverloadFactor(), 0); + } +}; + +} // NCompGen +} // NTable +} // NKikimr diff --git a/ydb/core/tablet_flat/ut/ut_comp_shard.cpp b/ydb/core/tablet_flat/ut/ut_comp_shard.cpp index 791315e38a5..525063d30cc 100644 --- a/ydb/core/tablet_flat/ut/ut_comp_shard.cpp +++ b/ydb/core/tablet_flat/ut/ut_comp_shard.cpp @@ -1,5 +1,5 @@ -#include "flat_comp_ut_common.h" - +#include "flat_comp_ut_common.h" + #include <ydb/core/tablet_flat/flat_comp_shard.h> #include <ydb/core/tablet_flat/test/libs/table/test_envs.h> diff --git a/ydb/core/tablet_flat/ut/ut_compaction_multi.cpp b/ydb/core/tablet_flat/ut/ut_compaction_multi.cpp index 1df99a04755..6687e80e4a7 100644 --- a/ydb/core/tablet_flat/ut/ut_compaction_multi.cpp +++ b/ydb/core/tablet_flat/ut/ut_compaction_multi.cpp @@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TCompactionMulti) { } void RunMainEdgeTest( - TIntrusiveConstPtr<TRowScheme> scheme, + TIntrusiveConstPtr<TRowScheme> scheme, const TRowsHeap& rows, const NPage::TConf& initialConf, bool strictPageSize = true, diff --git a/ydb/core/tablet_flat/ut/ut_db_iface.cpp b/ydb/core/tablet_flat/ut/ut_db_iface.cpp index e9809925978..9843e5a6033 100644 --- a/ydb/core/tablet_flat/ut/ut_db_iface.cpp +++ b/ydb/core/tablet_flat/ut/ut_db_iface.cpp @@ -323,7 +323,7 @@ Y_UNIT_TEST_SUITE(DBase) { Y_UNIT_TEST(WideKey) { - const TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(128 * 1024); + const TIntrusivePtr<TGrowHeap> heap = new TGrowHeap(128 * 1024); for (auto keys: { 128, 512, 1024, 4096, 8192, 9999 }) { auto alter = MakeAlter(); diff --git a/ydb/core/tablet_flat/ut/ut_forward.cpp b/ydb/core/tablet_flat/ut/ut_forward.cpp index 11a35c4c8a3..246d3c70b37 100644 --- a/ydb/core/tablet_flat/ut/ut_forward.cpp +++ b/ydb/core/tablet_flat/ut/ut_forward.cpp @@ -17,7 +17,7 @@ namespace { struct TWrap : public NTest::TSteps<TWrap>, protected NFwd::IPageLoadingQueue { using TFrames = NPage::TFrames; - TWrap(TIntrusiveConstPtr<TFrames> frames, TIntrusiveConstPtr<TSlices> run, ui32 edge, ui64 aLo = 999, ui64 aHi = 999) + TWrap(TIntrusiveConstPtr<TFrames> frames, TIntrusiveConstPtr<TSlices> run, ui32 edge, ui64 aLo = 999, ui64 aHi = 999) : Large(std::move(frames)) , Run(std::move(run)) , Edge(edge) @@ -29,7 +29,7 @@ namespace { Cache = new NFwd::TBlobs(Large, Run, edges, true); } - TWrap(TIntrusiveConstPtr<TFrames> frames, ui32 edge, ui64 aLo = 999, ui64 aHi = 999) + TWrap(TIntrusiveConstPtr<TFrames> frames, ui32 edge, ui64 aLo = 999, ui64 aHi = 999) : TWrap(std::move(frames), TSlices::All(), edge, aLo, aHi) { } @@ -114,8 +114,8 @@ namespace { } public: - const TIntrusiveConstPtr<TFrames> Large; - const TIntrusiveConstPtr<TSlices> Run; + const TIntrusiveConstPtr<TFrames> Large; + const TIntrusiveConstPtr<TSlices> Run; const ui32 Edge = Max<ui32>(); const ui64 AheadLo = 0; const ui64 AheadHi = Max<ui64>(); @@ -130,7 +130,7 @@ namespace { Y_UNIT_TEST_SUITE(NFwd) { - static TIntrusiveConstPtr<NPage::TFrames> Cook() + static TIntrusiveConstPtr<NPage::TFrames> Cook() { NPage::TFrameWriter writer(3); @@ -243,7 +243,7 @@ Y_UNIT_TEST_SUITE(NFwd) { const auto blobs = new NPage::TExtBlobs(out.Make(), { }); - TIntrusiveConstPtr<NPage::TFrames> frames; + TIntrusiveConstPtr<NPage::TFrames> frames; { NPage::TFrameWriter writer(3); @@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(NFwd) { } // Construct a run with [13,27] and [33,35] ranges - TIntrusivePtr<TSlices> run = new TSlices; + TIntrusivePtr<TSlices> run = new TSlices; { run->emplace_back( TSerializedCellVec(), // key not important @@ -365,7 +365,7 @@ Y_UNIT_TEST_SUITE(NFwd) { Y_UNIT_TEST(Filtered) { - TIntrusivePtr<TSlices> run = new TSlices; + TIntrusivePtr<TSlices> run = new TSlices; run->emplace_back(TSlice({ }, { }, 0, 15, true, false)); run->emplace_back(TSlice({ }, { }, 18, 22, true, true)); TWrap wrap(Cook(), run, Max<ui32>(), 999, 999); diff --git a/ydb/core/tablet_flat/ut/ut_iterator.cpp b/ydb/core/tablet_flat/ut/ut_iterator.cpp index b047e4ae24d..c14bad7cb44 100644 --- a/ydb/core/tablet_flat/ut/ut_iterator.cpp +++ b/ydb/core/tablet_flat/ut/ut_iterator.cpp @@ -30,7 +30,7 @@ namespace { const NTest::TMass Mass0(new NTest::TModelStd(false), 6666); - static void VerifySingleLevelNonTrivial(const TAutoPtr<TSubset>& subset) + static void VerifySingleLevelNonTrivial(const TAutoPtr<TSubset>& subset) { /* parts form a single run and have non-trivial pages */ TLevels levels(subset->Scheme->Keys); diff --git a/ydb/core/tablet_flat/ut/ut_memtable.cpp b/ydb/core/tablet_flat/ut/ut_memtable.cpp index 0ad10ac4fa9..d5b6c328648 100644 --- a/ydb/core/tablet_flat/ut/ut_memtable.cpp +++ b/ydb/core/tablet_flat/ut/ut_memtable.cpp @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(Memtable) { using namespace NTest; - TIntrusiveConstPtr<TRowScheme> BasicRowLayout() noexcept + TIntrusiveConstPtr<TRowScheme> BasicRowLayout() noexcept { return TLayoutCook() diff --git a/ydb/core/tablet_flat/ut/ut_other.cpp b/ydb/core/tablet_flat/ut/ut_other.cpp index 82ac005a2d3..ea1c287283e 100644 --- a/ydb/core/tablet_flat/ut/ut_other.cpp +++ b/ydb/core/tablet_flat/ut/ut_other.cpp @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(NOther) { const TLogoBlobID mask(1, 3, 7, 0, 0, 0); - TAutoPtr<NWriter::TBundle> bundle = new NWriter::TBundle(mask, conf); + TAutoPtr<NWriter::TBundle> bundle = new NWriter::TBundle(mask, conf); if (auto *out = static_cast<NTable::IPageWriter*>(bundle.Get())) { for (auto seq: xrange(7)) diff --git a/ydb/core/tablet_flat/ut/ut_rename_table_column.cpp b/ydb/core/tablet_flat/ut/ut_rename_table_column.cpp index 1145fe68ac4..46b3a856eee 100644 --- a/ydb/core/tablet_flat/ut/ut_rename_table_column.cpp +++ b/ydb/core/tablet_flat/ut/ut_rename_table_column.cpp @@ -4,324 +4,324 @@ #include <ydb/core/tablet_flat/tablet_flat_executed.h> #include <ydb/core/tablet_flat/test/libs/exec/dummy.h> #include <ydb/core/tablet_flat/test/libs/exec/runner.h> - -#include <library/cpp/testing/unittest/registar.h> - -namespace NKikimr { -namespace NTabletFlatExecutor { - -struct Schema1 : NIceDb::Schema { - struct RegularTable1 : Table<1> { - struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; - struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<Key>; - using TColumns = TableColumns<Key, Value>; - }; - - struct TableToRename : Table<2> { - struct KeyToRename : Column<1, NScheme::NTypeIds::Uint32> {}; - struct ValueToRename : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<KeyToRename>; - using TColumns = TableColumns<KeyToRename, ValueToRename>; - }; - - struct RegularTable2 : Table<3> { - struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; - struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<Key>; - using TColumns = TableColumns<Key, Value>; - }; - - using TTables = SchemaTables<RegularTable1, TableToRename, RegularTable2>; - using TSettings = SchemaSettings<ExecutorLogBatching<true>, - ExecutorLogFlushPeriod<TDuration::MicroSeconds(512).GetValue()>>; -}; - -struct Schema2 : NIceDb::Schema { - struct RegularTable1 : Table<1> { - struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; - struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<Key>; - using TColumns = TableColumns<Key, Value>; - }; - - struct TableRenamed : Table<2> { - struct KeyRenamed : Column<1, NScheme::NTypeIds::Uint32> {}; - struct ValueRenamed : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<KeyRenamed>; - using TColumns = TableColumns<KeyRenamed, ValueRenamed>; - }; - - struct RegularTable2 : Table<3> { - struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; - struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; - using TKey = TableKey<Key>; - using TColumns = TableColumns<Key, Value>; - }; - - using TTables = SchemaTables<RegularTable1, TableRenamed, RegularTable2>; - using TSettings = SchemaSettings<ExecutorLogBatching<true>, - ExecutorLogFlushPeriod<TDuration::MicroSeconds(512).GetValue()>>; -}; - -template<typename TSchema> -struct TTxInitSchema : public ITransaction { - const TActorId Owner; - - TTxInitSchema(TActorId owner) : Owner(owner) { } - - bool Execute(TTransactionContext &txc, const TActorContext &) override { - NIceDb::TNiceDb(txc.DB).Materialize<TSchema>(); - - return true; - } - - void Complete(const TActorContext &ctx) override { - ctx.Send(ctx.SelfID, new NFake::TEvReturn); - } -}; - -using TTxInitSchema1 = TTxInitSchema<Schema1>; -using TTxInitSchema2 = TTxInitSchema<Schema2>; - -struct TTxStore : public ITransaction { - const TActorId Owner; - - TTxStore(TActorId owner) : Owner(owner) { } - - bool Execute(TTransactionContext &txc, const TActorContext &) override { - NIceDb::TNiceDb db(txc.DB); - - db.Table<Schema1::RegularTable1>().Key(1) - .Update<Schema1::RegularTable1::Value>(10); - db.Table<Schema1::RegularTable2>().Key(2) - .Update<Schema1::RegularTable2::Value>(20); - db.Table<Schema1::TableToRename>().Key(0xdead) - .Update<Schema1::TableToRename::ValueToRename>(0xbeaf); - - return true; - } - - void Complete(const TActorContext &ctx) override { - ctx.Send(Owner, new NFake::TEvResult); - } -}; - -struct TTxSelect1: public ITransaction { - const TActorId Owner; - - TTxSelect1(TActorId owner) : Owner(owner) { } - - bool Execute(TTransactionContext &txc, const TActorContext &) override { - NIceDb::TNiceDb db(txc.DB); - - auto row1 = db.Table<Schema1::RegularTable1>().Key(1).Select(); - auto row2 = db.Table<Schema1::RegularTable2>().Key(2).Select(); - - auto row = db.Table<Schema1::TableToRename>().Key(0xdead).Select(); - - if (!row1.IsReady() || !row2.IsReady() || !row.IsReady()) - return false; - - UNIT_ASSERT_VALUES_EQUAL(row1.GetValue<Schema1::RegularTable1::Value>(), 10); - UNIT_ASSERT_VALUES_EQUAL(row2.GetValue<Schema1::RegularTable2::Value>(), 20); - - // the main purpose of this test - UNIT_ASSERT_VALUES_EQUAL(row.GetValue<Schema1::TableToRename::ValueToRename>(), 0xbeaf); - - return true; - }; - - void Complete(const TActorContext &ctx) override { - ctx.Send(ctx.SelfID, new NFake::TEvReturn); - } -}; - -struct TTxSelect2: public ITransaction { - const TActorId Owner; - - TTxSelect2(TActorId owner) : Owner(owner) { } - - bool Execute(TTransactionContext &txc, const TActorContext &) override { - NIceDb::TNiceDb db(txc.DB); - - auto row1 = db.Table<Schema2::RegularTable1>().Key(1).Select(); - auto row2 = db.Table<Schema2::RegularTable2>().Key(2).Select(); - - auto row = db.Table<Schema2::TableRenamed>().Key(0xdead).Select(); - - if (!row1.IsReady() || !row2.IsReady() || !row.IsReady()) - return false; - - UNIT_ASSERT_VALUES_EQUAL(row1.GetValue<Schema2::RegularTable1::Value>(), 10); - UNIT_ASSERT_VALUES_EQUAL(row2.GetValue<Schema2::RegularTable2::Value>(), 20); - - // the main purpose of this test - UNIT_ASSERT_VALUES_EQUAL(row.GetValue<Schema2::TableRenamed::ValueRenamed>(), 0xbeaf); - - return true; - }; - - void Complete(const TActorContext &ctx) override { - ctx.Send(ctx.SelfID, new NFake::TEvReturn); - } -}; - -struct TEnv : public NFake::TRunner { - TEnv() - : Edge(Env.AllocateEdgeActor()) - { - FireDummyTablet(); - - SendSync(new NFake::TEvExecute{ new TTxInitSchema1(Edge) }); - - SendAsync(new NFake::TEvExecute{ new TTxStore(Edge) }); - WaitFor<NFake::TEvResult>(); - - SendSync(new NFake::TEvExecute{ new TTxSelect1(Edge) }, /* retry = */ true); - } - - void FireDummyTablet() - { - FireTablet(Edge, Tablet, [this](const TActorId &tablet, TTabletStorageInfo *info) { - return new NFake::TDummy(tablet, info, Edge); - }); - - WaitFor<NFake::TEvReady>(); - } - - void SendSync(IEventBase *event, bool retry = false, bool gone = false) - { - const auto wretry = PipeCfgRetries(); - const auto basic = NTabletPipe::TClientConfig(); - - Env.SendToPipe(Tablet, Edge, event, 0, retry ? wretry : basic); - - gone ? WaitForGone() : WaitForWakeUp(); - } - - void SendAsync(IEventBase *event) - { - Env.SendToPipe(Tablet, Edge, event); - } - - void RestartTablet() - { - SendSync(new TEvents::TEvPoison, false, true); - FireDummyTablet(); - } - - void WaitForWakeUp() { WaitFor<TEvents::TEvWakeup>(); } - void WaitForGone() { WaitFor<TEvents::TEvGone>(); } - - template<typename TEv> - typename TEv::TPtr GrabEdgeEvent() - { - return Env.GrabEdgeEventRethrow<TEv>(Edge); - } - - template<typename TEv> - void WaitFor(size_t num = 1) - { - for (; num > 0; num--) { - TAutoPtr<IEventHandle> handle; - Env.GrabEdgeEventRethrow<TEv>(handle); - } - } - - static NTabletPipe::TClientConfig PipeCfgRetries() - { - NTabletPipe::TClientConfig pipeConfig; - pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); - return pipeConfig; - } - - const ui32 Tablet = MakeTabletID(0, 0, 1); - const TActorId Edge; -}; - -Y_UNIT_TEST_SUITE(TFlatTableRenameTableAndColumn) { - - Y_UNIT_TEST(TestSchema1ToSchema2NoRestart) { - TEnv env; - - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }); - - env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); - }; - - Y_UNIT_TEST(TestSchema1ToSchema2) { - TEnv env; - - env.RestartTablet(); - - // Check initial data - env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); - - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }); - - env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // Check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); - } - - Y_UNIT_TEST(TestSchema1ToSchema2ToSchema1) { - TEnv env; - - env.RestartTablet(); - - // Update to Schema2 - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // Update back to Schema1 - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema1(env.Edge) }, /* retry = */ true); - - // Check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // Check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); - }; - - Y_UNIT_TEST(TestSchema1ToSchema2ToSchema1ToSchema2) { - TEnv env; - - env.RestartTablet(); - - // Update to Schema2 - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // Update back to Schema1 - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema1(env.Edge) }, /* retry = */ true); - - // Check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // Check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); - - // Update to Schema2 - env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); - env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); - - env.RestartTablet(); - - // finally check data - env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); - }; -} - -} // namespace NTabletFlatExecutor + +#include <library/cpp/testing/unittest/registar.h> + +namespace NKikimr { +namespace NTabletFlatExecutor { + +struct Schema1 : NIceDb::Schema { + struct RegularTable1 : Table<1> { + struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; + struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<Key>; + using TColumns = TableColumns<Key, Value>; + }; + + struct TableToRename : Table<2> { + struct KeyToRename : Column<1, NScheme::NTypeIds::Uint32> {}; + struct ValueToRename : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<KeyToRename>; + using TColumns = TableColumns<KeyToRename, ValueToRename>; + }; + + struct RegularTable2 : Table<3> { + struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; + struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<Key>; + using TColumns = TableColumns<Key, Value>; + }; + + using TTables = SchemaTables<RegularTable1, TableToRename, RegularTable2>; + using TSettings = SchemaSettings<ExecutorLogBatching<true>, + ExecutorLogFlushPeriod<TDuration::MicroSeconds(512).GetValue()>>; +}; + +struct Schema2 : NIceDb::Schema { + struct RegularTable1 : Table<1> { + struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; + struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<Key>; + using TColumns = TableColumns<Key, Value>; + }; + + struct TableRenamed : Table<2> { + struct KeyRenamed : Column<1, NScheme::NTypeIds::Uint32> {}; + struct ValueRenamed : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<KeyRenamed>; + using TColumns = TableColumns<KeyRenamed, ValueRenamed>; + }; + + struct RegularTable2 : Table<3> { + struct Key : Column<1, NScheme::NTypeIds::Uint32> {}; + struct Value : Column<2, NScheme::NTypeIds::Uint32> {}; + using TKey = TableKey<Key>; + using TColumns = TableColumns<Key, Value>; + }; + + using TTables = SchemaTables<RegularTable1, TableRenamed, RegularTable2>; + using TSettings = SchemaSettings<ExecutorLogBatching<true>, + ExecutorLogFlushPeriod<TDuration::MicroSeconds(512).GetValue()>>; +}; + +template<typename TSchema> +struct TTxInitSchema : public ITransaction { + const TActorId Owner; + + TTxInitSchema(TActorId owner) : Owner(owner) { } + + bool Execute(TTransactionContext &txc, const TActorContext &) override { + NIceDb::TNiceDb(txc.DB).Materialize<TSchema>(); + + return true; + } + + void Complete(const TActorContext &ctx) override { + ctx.Send(ctx.SelfID, new NFake::TEvReturn); + } +}; + +using TTxInitSchema1 = TTxInitSchema<Schema1>; +using TTxInitSchema2 = TTxInitSchema<Schema2>; + +struct TTxStore : public ITransaction { + const TActorId Owner; + + TTxStore(TActorId owner) : Owner(owner) { } + + bool Execute(TTransactionContext &txc, const TActorContext &) override { + NIceDb::TNiceDb db(txc.DB); + + db.Table<Schema1::RegularTable1>().Key(1) + .Update<Schema1::RegularTable1::Value>(10); + db.Table<Schema1::RegularTable2>().Key(2) + .Update<Schema1::RegularTable2::Value>(20); + db.Table<Schema1::TableToRename>().Key(0xdead) + .Update<Schema1::TableToRename::ValueToRename>(0xbeaf); + + return true; + } + + void Complete(const TActorContext &ctx) override { + ctx.Send(Owner, new NFake::TEvResult); + } +}; + +struct TTxSelect1: public ITransaction { + const TActorId Owner; + + TTxSelect1(TActorId owner) : Owner(owner) { } + + bool Execute(TTransactionContext &txc, const TActorContext &) override { + NIceDb::TNiceDb db(txc.DB); + + auto row1 = db.Table<Schema1::RegularTable1>().Key(1).Select(); + auto row2 = db.Table<Schema1::RegularTable2>().Key(2).Select(); + + auto row = db.Table<Schema1::TableToRename>().Key(0xdead).Select(); + + if (!row1.IsReady() || !row2.IsReady() || !row.IsReady()) + return false; + + UNIT_ASSERT_VALUES_EQUAL(row1.GetValue<Schema1::RegularTable1::Value>(), 10); + UNIT_ASSERT_VALUES_EQUAL(row2.GetValue<Schema1::RegularTable2::Value>(), 20); + + // the main purpose of this test + UNIT_ASSERT_VALUES_EQUAL(row.GetValue<Schema1::TableToRename::ValueToRename>(), 0xbeaf); + + return true; + }; + + void Complete(const TActorContext &ctx) override { + ctx.Send(ctx.SelfID, new NFake::TEvReturn); + } +}; + +struct TTxSelect2: public ITransaction { + const TActorId Owner; + + TTxSelect2(TActorId owner) : Owner(owner) { } + + bool Execute(TTransactionContext &txc, const TActorContext &) override { + NIceDb::TNiceDb db(txc.DB); + + auto row1 = db.Table<Schema2::RegularTable1>().Key(1).Select(); + auto row2 = db.Table<Schema2::RegularTable2>().Key(2).Select(); + + auto row = db.Table<Schema2::TableRenamed>().Key(0xdead).Select(); + + if (!row1.IsReady() || !row2.IsReady() || !row.IsReady()) + return false; + + UNIT_ASSERT_VALUES_EQUAL(row1.GetValue<Schema2::RegularTable1::Value>(), 10); + UNIT_ASSERT_VALUES_EQUAL(row2.GetValue<Schema2::RegularTable2::Value>(), 20); + + // the main purpose of this test + UNIT_ASSERT_VALUES_EQUAL(row.GetValue<Schema2::TableRenamed::ValueRenamed>(), 0xbeaf); + + return true; + }; + + void Complete(const TActorContext &ctx) override { + ctx.Send(ctx.SelfID, new NFake::TEvReturn); + } +}; + +struct TEnv : public NFake::TRunner { + TEnv() + : Edge(Env.AllocateEdgeActor()) + { + FireDummyTablet(); + + SendSync(new NFake::TEvExecute{ new TTxInitSchema1(Edge) }); + + SendAsync(new NFake::TEvExecute{ new TTxStore(Edge) }); + WaitFor<NFake::TEvResult>(); + + SendSync(new NFake::TEvExecute{ new TTxSelect1(Edge) }, /* retry = */ true); + } + + void FireDummyTablet() + { + FireTablet(Edge, Tablet, [this](const TActorId &tablet, TTabletStorageInfo *info) { + return new NFake::TDummy(tablet, info, Edge); + }); + + WaitFor<NFake::TEvReady>(); + } + + void SendSync(IEventBase *event, bool retry = false, bool gone = false) + { + const auto wretry = PipeCfgRetries(); + const auto basic = NTabletPipe::TClientConfig(); + + Env.SendToPipe(Tablet, Edge, event, 0, retry ? wretry : basic); + + gone ? WaitForGone() : WaitForWakeUp(); + } + + void SendAsync(IEventBase *event) + { + Env.SendToPipe(Tablet, Edge, event); + } + + void RestartTablet() + { + SendSync(new TEvents::TEvPoison, false, true); + FireDummyTablet(); + } + + void WaitForWakeUp() { WaitFor<TEvents::TEvWakeup>(); } + void WaitForGone() { WaitFor<TEvents::TEvGone>(); } + + template<typename TEv> + typename TEv::TPtr GrabEdgeEvent() + { + return Env.GrabEdgeEventRethrow<TEv>(Edge); + } + + template<typename TEv> + void WaitFor(size_t num = 1) + { + for (; num > 0; num--) { + TAutoPtr<IEventHandle> handle; + Env.GrabEdgeEventRethrow<TEv>(handle); + } + } + + static NTabletPipe::TClientConfig PipeCfgRetries() + { + NTabletPipe::TClientConfig pipeConfig; + pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); + return pipeConfig; + } + + const ui32 Tablet = MakeTabletID(0, 0, 1); + const TActorId Edge; +}; + +Y_UNIT_TEST_SUITE(TFlatTableRenameTableAndColumn) { + + Y_UNIT_TEST(TestSchema1ToSchema2NoRestart) { + TEnv env; + + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }); + + env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); + }; + + Y_UNIT_TEST(TestSchema1ToSchema2) { + TEnv env; + + env.RestartTablet(); + + // Check initial data + env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); + + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }); + + env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // Check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); + } + + Y_UNIT_TEST(TestSchema1ToSchema2ToSchema1) { + TEnv env; + + env.RestartTablet(); + + // Update to Schema2 + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // Update back to Schema1 + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema1(env.Edge) }, /* retry = */ true); + + // Check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // Check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); + }; + + Y_UNIT_TEST(TestSchema1ToSchema2ToSchema1ToSchema2) { + TEnv env; + + env.RestartTablet(); + + // Update to Schema2 + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // Update back to Schema1 + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema1(env.Edge) }, /* retry = */ true); + + // Check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // Check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect1(env.Edge) }, /* retry = */ true); + + // Update to Schema2 + env.SendSync(new NFake::TEvExecute{ new TTxInitSchema2(env.Edge) }, /* retry = */ true); + env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); + + env.RestartTablet(); + + // finally check data + env.SendSync(new NFake::TEvExecute{ new TTxSelect2(env.Edge) }, /* retry = */ true); + }; +} + +} // namespace NTabletFlatExecutor } // namespace NKikimr diff --git a/ydb/core/tablet_flat/ut/ut_sausage.cpp b/ydb/core/tablet_flat/ut/ut_sausage.cpp index 6a7237cd404..9fed2caacc8 100644 --- a/ydb/core/tablet_flat/ut/ut_sausage.cpp +++ b/ydb/core/tablet_flat/ut/ut_sausage.cpp @@ -16,9 +16,9 @@ namespace NPageCollection { namespace { struct TMyPageCollection { - using TArrayRef = TArrayRef<const TGlobId>; + using TArrayRef = TArrayRef<const TGlobId>; - TMyPageCollection(TArrayRef globs) : Globs(globs) { } + TMyPageCollection(TArrayRef globs) : Globs(globs) { } inline TBorder Bounds(ui32 page) const noexcept { @@ -32,7 +32,7 @@ namespace { return at < Globs.size() ? Globs[at] : TGlobId{ }; } - const TArrayRef Globs; + const TArrayRef Globs; }; } diff --git a/ydb/core/tablet_flat/ut/ut_screen.cpp b/ydb/core/tablet_flat/ut/ut_screen.cpp index e92a41a6abc..b2d04bc6cf0 100644 --- a/ydb/core/tablet_flat/ut/ut_screen.cpp +++ b/ydb/core/tablet_flat/ut/ut_screen.cpp @@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TScreen) { using namespace NTable::NTest; using THole = TScreen::THole; - TIntrusiveConstPtr<TScreen> one(new TScreen({ { 3, 10 }, { 40, 70 }, { 80, 99 } })); + TIntrusiveConstPtr<TScreen> one(new TScreen({ { 3, 10 }, { 40, 70 }, { 80, 99 } })); auto cut = [=](THole hole) { return TScreen::Cut(one, hole); }; @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TScreen) { using namespace NTable::NTest; using THole = TScreen::THole; - TIntrusiveConstPtr<TScreen> whole(new TScreen({{ 3, 10 }, { 40, 70 }, { 80, 99 }})); + TIntrusiveConstPtr<TScreen> whole(new TScreen({{ 3, 10 }, { 40, 70 }, { 80, 99 }})); { /* Check simple split and merge w/o gliding edges */ diff --git a/ydb/core/tablet_flat/ut/ut_slice.cpp b/ydb/core/tablet_flat/ut/ut_slice.cpp index e60d947428d..5833066aadb 100644 --- a/ydb/core/tablet_flat/ut/ut_slice.cpp +++ b/ydb/core/tablet_flat/ut/ut_slice.cpp @@ -39,13 +39,13 @@ namespace { return std::move(*this); } - TIntrusiveConstPtr<TSlices> Build() && + TIntrusiveConstPtr<TSlices> Build() && { return std::move(Run); } private: - TIntrusivePtr<TSlices> Run; + TIntrusivePtr<TSlices> Run; }; bool EqualByRowId(const TSlice& a, const TSlice& b) @@ -70,12 +70,12 @@ namespace { return (ait == a.end()) == (bit == b.end()); } - bool EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) + bool EqualByRowId(const TIntrusiveConstPtr<TSlices>& a, const TIntrusiveConstPtr<TSlices>& b) { return EqualByRowId(*a, *b); } - void VerifyEqual(const TIntrusiveConstPtr<TSlices>& value, const TIntrusiveConstPtr<TSlices>& expected) + void VerifyEqual(const TIntrusiveConstPtr<TSlices>& value, const TIntrusiveConstPtr<TSlices>& expected) { UNIT_ASSERT_C( EqualByRowId(value, expected), @@ -83,17 +83,17 @@ namespace { } void VerifyMerge( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b, - const TIntrusiveConstPtr<TSlices>& expected) + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b, + const TIntrusiveConstPtr<TSlices>& expected) { VerifyEqual(TSlices::Merge(a, b), expected); VerifyEqual(TSlices::Merge(b, a), expected); } void VerifyEqualCall( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b, + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b, bool expected) { UNIT_ASSERT_C( @@ -104,8 +104,8 @@ namespace { } void VerifySupersetCall( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b, + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b, bool expected) { UNIT_ASSERT_C( @@ -115,10 +115,10 @@ namespace { << " a superset of " << NFmt::If(b.Get())); } - TIntrusiveConstPtr<TSlices> VerifySubtract( - const TIntrusiveConstPtr<TSlices>& a, - const TIntrusiveConstPtr<TSlices>& b, - const TIntrusiveConstPtr<TSlices>& expected) + TIntrusiveConstPtr<TSlices> VerifySubtract( + const TIntrusiveConstPtr<TSlices>& a, + const TIntrusiveConstPtr<TSlices>& b, + const TIntrusiveConstPtr<TSlices>& expected) { auto result = TSlices::Subtract(a, b); UNIT_ASSERT_C( @@ -368,7 +368,7 @@ Y_UNIT_TEST_SUITE(TPartSlice) { Y_UNIT_TEST(LookupFull) { // Build run with 16 slices, enough to test both slow and fast path - TIntrusivePtr<TSlices> x = new TSlices; + TIntrusivePtr<TSlices> x = new TSlices; for (int i = 0; i < 16; ++i) { x->emplace_back( TSerializedCellVec(), // key not important diff --git a/ydb/core/tablet_flat/ut/ut_slice_loader.cpp b/ydb/core/tablet_flat/ut/ut_slice_loader.cpp index f5133625f4a..822319b533a 100644 --- a/ydb/core/tablet_flat/ut/ut_slice_loader.cpp +++ b/ydb/core/tablet_flat/ut/ut_slice_loader.cpp @@ -87,7 +87,7 @@ namespace { Y_FAIL("Unexpected Glob(...) call"); } - bool Verify(ui32, TArrayRef<const char>) const noexcept override + bool Verify(ui32, TArrayRef<const char>) const noexcept override { Y_FAIL("Unexpected Verify(...) call"); } @@ -104,10 +104,10 @@ namespace { struct TCheckResult { size_t Pages; - TIntrusivePtr<TSlices> Run; + TIntrusivePtr<TSlices> Run; }; - void VerifyRunOrder(TIntrusiveConstPtr<TSlices> run, const TKeyNulls& keys) + void VerifyRunOrder(TIntrusiveConstPtr<TSlices> run, const TKeyNulls& keys) { const TSlice* prev = nullptr; for (auto& slice : *run) { @@ -127,7 +127,7 @@ namespace { { TCheckResult result; - TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection = new TTestPartPageCollection(part, 0); + TIntrusiveConstPtr<NPageCollection::IPageCollection> pageCollection = new TTestPartPageCollection(part, 0); TKeysEnv env(part.Get(), new TCache(pageCollection)); TKeysLoader loader(part.Get(), &env); @@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TPartSliceLoader) { } Y_UNIT_TEST(RestoreMissingSliceFullScreen) { - TIntrusiveConstPtr<TScreen> screen; + TIntrusiveConstPtr<TScreen> screen; { // Construct screen from every index page TVector<TScreen::THole> holes; @@ -199,7 +199,7 @@ Y_UNIT_TEST_SUITE(TPartSliceLoader) { } Y_UNIT_TEST(RestoreFromScreenIndexKeys) { - TIntrusiveConstPtr<TScreen> screen; + TIntrusiveConstPtr<TScreen> screen; { // Construct screen from every even index page TVector<TScreen::THole> holes; @@ -224,7 +224,7 @@ Y_UNIT_TEST_SUITE(TPartSliceLoader) { } Y_UNIT_TEST(RestoreFromScreenDataKeys) { - TIntrusiveConstPtr<TScreen> screen; + TIntrusiveConstPtr<TScreen> screen; { // Use every even index page, without first and last key TVector<TScreen::THole> holes; diff --git a/ydb/core/tablet_flat/ut/ut_versions.cpp b/ydb/core/tablet_flat/ut/ut_versions.cpp index 650e686aaa0..848fc747032 100644 --- a/ydb/core/tablet_flat/ut/ut_versions.cpp +++ b/ydb/core/tablet_flat/ut/ut_versions.cpp @@ -50,7 +50,7 @@ namespace { return mass; } - TSubset MakeSubset(TIntrusiveConstPtr<TRowScheme> scheme, TVector<const TPartEggs*> eggs) + TSubset MakeSubset(TIntrusiveConstPtr<TRowScheme> scheme, TVector<const TPartEggs*> eggs) { TVector<TPartView> partView; diff --git a/ydb/core/tablet_flat/ut/ya.make b/ydb/core/tablet_flat/ut/ya.make index 88c75b55bdb..fd66d042026 100644 --- a/ydb/core/tablet_flat/ut/ya.make +++ b/ydb/core/tablet_flat/ut/ya.make @@ -34,7 +34,7 @@ SRCS( ut_iterator.cpp ut_memtable.cpp ut_sausage.cpp - ut_comp_gen.cpp + ut_comp_gen.cpp ut_comp_shard.cpp ut_compaction.cpp ut_compaction_multi.cpp @@ -44,7 +44,7 @@ SRCS( ut_proto.cpp ut_pages.cpp ut_redo.cpp - ut_rename_table_column.cpp + ut_rename_table_column.cpp ut_other.cpp ut_forward.cpp ut_screen.cpp diff --git a/ydb/core/tablet_flat/util_basics.h b/ydb/core/tablet_flat/util_basics.h index 9e0adca2ed8..3da3f7dfccb 100644 --- a/ydb/core/tablet_flat/util_basics.h +++ b/ydb/core/tablet_flat/util_basics.h @@ -4,7 +4,7 @@ #include <util/generic/array_ref.h> namespace NKikimr { - struct IDestructable { - virtual ~IDestructable() = default; + struct IDestructable { + virtual ~IDestructable() = default; }; } diff --git a/ydb/core/testlib/actors/test_runtime.cpp b/ydb/core/testlib/actors/test_runtime.cpp index bd4ba6f9b0a..63f0436bff7 100644 --- a/ydb/core/testlib/actors/test_runtime.cpp +++ b/ydb/core/testlib/actors/test_runtime.cpp @@ -130,7 +130,7 @@ namespace NActors { nodeAppData->StaticBlobStorageConfig->CopyFrom(*app0->StaticBlobStorageConfig); nodeAppData->EnableKqpSpilling = app0->EnableKqpSpilling; nodeAppData->FeatureFlags = app0->FeatureFlags; - nodeAppData->CompactionConfig = app0->CompactionConfig; + nodeAppData->CompactionConfig = app0->CompactionConfig; nodeAppData->HiveConfig = app0->HiveConfig; nodeAppData->DataShardConfig = app0->DataShardConfig; nodeAppData->MeteringConfig = app0->MeteringConfig; @@ -192,9 +192,9 @@ namespace NActors { return true; case NKikimr::TEvBlobStorage::EvNotReadyRetryTimeout: case NKikimr::TEvTabletPipe::EvClientRetry: - case NKikimr::TEvTabletBase::EvFollowerRetry: - case NKikimr::TEvTabletBase::EvTryBuildFollowerGraph: - case NKikimr::TEvTabletBase::EvTrySyncFollower: + case NKikimr::TEvTabletBase::EvFollowerRetry: + case NKikimr::TEvTabletBase::EvTryBuildFollowerGraph: + case NKikimr::TEvTabletBase::EvTrySyncFollower: return false; case NKikimr::TEvents::TEvFlushLog::EventType: return false; diff --git a/ydb/core/testlib/actors/test_runtime.h b/ydb/core/testlib/actors/test_runtime.h index 3394513abc8..deb156876bf 100644 --- a/ydb/core/testlib/actors/test_runtime.h +++ b/ydb/core/testlib/actors/test_runtime.h @@ -15,7 +15,7 @@ namespace NKikimrProto { } namespace NActors { - struct IDestructable { virtual ~IDestructable() = default; }; + struct IDestructable { virtual ~IDestructable() = default; }; using TKeyConfigGenerator = std::function<NKikimrProto::TKeyConfig (ui32)>; @@ -41,7 +41,7 @@ namespace NActors { public: struct TEgg { TAutoPtr<NKikimr::TAppData> App0; - TAutoPtr<NActors::IDestructable> Opaque; + TAutoPtr<NActors::IDestructable> Opaque; TKeyConfigGenerator KeyConfigGenerator; }; @@ -85,7 +85,7 @@ namespace NActors { private: THolder<NKikimr::TAppData> App0; TKeyConfigGenerator KeyConfigGenerator; - THolder<IDestructable> Opaque; + THolder<IDestructable> Opaque; TVector<ui16> MonPorts; }; } // namespace NActors diff --git a/ydb/core/testlib/basics/appdata.h b/ydb/core/testlib/basics/appdata.h index ad753975dc1..409869161f5 100644 --- a/ydb/core/testlib/basics/appdata.h +++ b/ydb/core/testlib/basics/appdata.h @@ -35,7 +35,7 @@ namespace NKikimr { }; struct TAppPrepare : public TTestFeatureFlagsHolder<TAppPrepare> { - struct TMine : public NActors::IDestructable { + struct TMine : public NActors::IDestructable { TIntrusivePtr<NScheme::TTypeRegistry> Types; TIntrusivePtr<NMiniKQL::IFunctionRegistry> Funcs; TIntrusivePtr<TFormatFactory> Formats; @@ -74,7 +74,7 @@ namespace NKikimr { TIntrusivePtr<TDomainsInfo> Domains; TMap<ui32, NKikimrProto::TKeyConfig> Keys; bool EnableKqpSpilling = false; - NKikimrConfig::TCompactionConfig CompactionConfig; + NKikimrConfig::TCompactionConfig CompactionConfig; TString NetDataSourceUrl; NKikimrConfig::THiveConfig HiveConfig; NKikimrConfig::TDataShardConfig DataShardConfig; diff --git a/ydb/core/testlib/basics/helpers.cpp b/ydb/core/testlib/basics/helpers.cpp index f0dd2f63a11..259e4f9da94 100644 --- a/ydb/core/testlib/basics/helpers.cpp +++ b/ydb/core/testlib/basics/helpers.cpp @@ -4,7 +4,7 @@ namespace NKikimr { - TTabletStorageInfo* CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, + TTabletStorageInfo* CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure, ui32 groupId) { THolder<TTabletStorageInfo> x(new TTabletStorageInfo()); @@ -24,7 +24,7 @@ namespace NKikimr { return x.Release(); } - TActorId CreateTestBootstrapper(TTestActorRuntime &runtime, TTabletStorageInfo *info, + TActorId CreateTestBootstrapper(TTestActorRuntime &runtime, TTabletStorageInfo *info, std::function<IActor* (const TActorId &, TTabletStorageInfo*)> op, ui32 nodeIndex) { TIntrusivePtr<TBootstrapperInfo> bi(new TBootstrapperInfo(new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0))); @@ -67,7 +67,7 @@ namespace NKikimr { }; void TStrandedPDiskServiceFactory::Create(const TActorContext &ctx, ui32 pDiskID, - const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) + const TIntrusivePtr<TPDiskConfig> &cfg, const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) { Y_UNUSED(ctx); Y_VERIFY(!Runtime.IsRealThreads()); @@ -75,7 +75,7 @@ namespace NKikimr { ui32 nodeIndex = nodeId - Runtime.GetNodeId(0); Runtime.BlockOutputForActor(TActorId(nodeId, "actorsystem")); - TActorId actorId = Runtime.Register(CreatePDisk(cfg, mainKey, Runtime.GetAppData(0).Counters), nodeIndex, poolId, TMailboxType::Revolving); + TActorId actorId = Runtime.Register(CreatePDisk(cfg, mainKey, Runtime.GetAppData(0).Counters), nodeIndex, poolId, TMailboxType::Revolving); TActorId pDiskServiceId = MakeBlobStoragePDiskID(nodeId, pDiskID); Runtime.BlockOutputForActor(pDiskServiceId); diff --git a/ydb/core/testlib/basics/helpers.h b/ydb/core/testlib/basics/helpers.h index 7b30ca83682..7a70063f7a3 100644 --- a/ydb/core/testlib/basics/helpers.h +++ b/ydb/core/testlib/basics/helpers.h @@ -32,9 +32,9 @@ namespace NFake { const TBlobStorageGroupType::EErasureSpecies BootGroupErasure = TBlobStorageGroupType::ErasureNone; - TTabletStorageInfo* CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, + TTabletStorageInfo* CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure = BootGroupErasure, ui32 groupId = 0); - TActorId CreateTestBootstrapper(TTestActorRuntime &runtime, TTabletStorageInfo *info, + TActorId CreateTestBootstrapper(TTestActorRuntime &runtime, TTabletStorageInfo *info, std::function<IActor* (const TActorId &, TTabletStorageInfo*)> op, ui32 nodeIndex = 0); NTabletPipe::TClientConfig GetPipeConfigWithRetries(); @@ -66,7 +66,7 @@ namespace NFake { {} void Create(const TActorContext &ctx, ui32 pDiskID, const TIntrusivePtr<TPDiskConfig> &cfg, - const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) override; + const NPDisk::TKey &mainKey, ui32 poolId, ui32 nodeId) override; virtual ~TStrandedPDiskServiceFactory() {} diff --git a/ydb/core/testlib/basics/services.cpp b/ydb/core/testlib/basics/services.cpp index 6d88b65bf40..b4585ad96c6 100644 --- a/ydb/core/testlib/basics/services.cpp +++ b/ydb/core/testlib/basics/services.cpp @@ -48,7 +48,7 @@ namespace NPDisk { void SetupSchemeCache(TTestActorRuntime& runtime, ui32 nodeIndex, const TString& root) { auto cacheConfig = MakeIntrusive<NSchemeCache::TSchemeCacheConfig>(); - cacheConfig->Roots.emplace_back(1, TTestTxConfig::SchemeShard, root); + cacheConfig->Roots.emplace_back(1, TTestTxConfig::SchemeShard, root); cacheConfig->Counters = new NMonitoring::TDynamicCounters(); runtime.AddLocalService(MakeSchemeCacheID(), @@ -67,9 +67,9 @@ namespace NPDisk { void SetupTabletPipePeNodeCaches(TTestActorRuntime& runtime, ui32 nodeIndex) { - TIntrusivePtr<TPipePeNodeCacheConfig> leaderPipeConfig = new TPipePeNodeCacheConfig(); - leaderPipeConfig->PipeRefreshTime = TDuration::Zero(); - leaderPipeConfig->PipeConfig.RetryPolicy = {.RetryLimitCount = 3}; + TIntrusivePtr<TPipePeNodeCacheConfig> leaderPipeConfig = new TPipePeNodeCacheConfig(); + leaderPipeConfig->PipeRefreshTime = TDuration::Zero(); + leaderPipeConfig->PipeConfig.RetryPolicy = {.RetryLimitCount = 3}; TIntrusivePtr<TPipePeNodeCacheConfig> followerPipeConfig = new TPipePeNodeCacheConfig(); followerPipeConfig->PipeRefreshTime = TDuration::Seconds(30); @@ -77,7 +77,7 @@ namespace NPDisk { followerPipeConfig->PipeConfig.RetryPolicy = {.RetryLimitCount = 3}; runtime.AddLocalService(MakePipePeNodeCacheID(false), - TActorSetupCmd(CreatePipePeNodeCache(leaderPipeConfig), TMailboxType::Revolving, 0), nodeIndex); + TActorSetupCmd(CreatePipePeNodeCache(leaderPipeConfig), TMailboxType::Revolving, 0), nodeIndex); runtime.AddLocalService(MakePipePeNodeCacheID(true), TActorSetupCmd(CreatePipePeNodeCache(followerPipeConfig), TMailboxType::Revolving, 0), nodeIndex); } diff --git a/ydb/core/testlib/basics/storage.h b/ydb/core/testlib/basics/storage.h index b64460932e4..36cee178189 100644 --- a/ydb/core/testlib/basics/storage.h +++ b/ydb/core/testlib/basics/storage.h @@ -65,7 +65,7 @@ namespace NKikimr { if (!Mock) { FormatPDisk(PDiskPath, Conf.DiskSize, Conf.SectorSize, Conf.ChunkSize, PDiskGuid, - 0x123 + salt, 0x456 + salt, 0x789 + salt, mainKey, + 0x123 + salt, 0x456 + salt, 0x789 + salt, mainKey, "", false, false, SectorMap); } } diff --git a/ydb/core/testlib/fake_coordinator.cpp b/ydb/core/testlib/fake_coordinator.cpp index edb51ee707a..0be35b3bcfe 100644 --- a/ydb/core/testlib/fake_coordinator.cpp +++ b/ydb/core/testlib/fake_coordinator.cpp @@ -4,7 +4,7 @@ namespace NKikimr { void BootFakeCoordinator(TTestActorRuntime& runtime, ui64 coordinatorId, TFakeCoordinator::TState::TPtr state) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(coordinatorId, TTabletTypes::FLAT_TX_COORDINATOR), + CreateTestBootstrapper(runtime, CreateTestTabletInfo(coordinatorId, TTabletTypes::FLAT_TX_COORDINATOR), [=](const TActorId & tablet, TTabletStorageInfo* info) { return new TFakeCoordinator(tablet, info, state); }); diff --git a/ydb/core/testlib/fake_scheme_shard.h b/ydb/core/testlib/fake_scheme_shard.h index aca318c33c6..8c388d49dd0 100644 --- a/ydb/core/testlib/fake_scheme_shard.h +++ b/ydb/core/testlib/fake_scheme_shard.h @@ -108,7 +108,7 @@ private: }; void BootFakeSchemeShard(TTestActorRuntime& runtime, ui64 tabletId, TFakeSchemeShardState::TPtr state) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::SchemeShard), [=](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::SchemeShard), [=](const TActorId & tablet, TTabletStorageInfo* info) { return new TFakeSchemeShard(tablet, info, state); }); diff --git a/ydb/core/testlib/tablet_flat_dummy.cpp b/ydb/core/testlib/tablet_flat_dummy.cpp index a44674fba43..1a9dca04a52 100644 --- a/ydb/core/testlib/tablet_flat_dummy.cpp +++ b/ydb/core/testlib/tablet_flat_dummy.cpp @@ -8,8 +8,8 @@ namespace NKikimr { -namespace { - +namespace { + class TDummyFlatTablet : public TActor<TDummyFlatTablet>, public NTabletFlatExecutor::TTabletExecutedFlat { struct Schema : NIceDb::Schema { @@ -90,7 +90,7 @@ class TDummyFlatTablet : public TActor<TDummyFlatTablet>, public NTabletFlatExec void OnActivateExecutor(const TActorContext &ctx) override { Become(&TThis::StateWork); - if (Executor()->GetStats().IsFollower) + if (Executor()->GetStats().IsFollower) SignalTabletActive(ctx); else Execute(new TTxSchemeInit(this), ctx); @@ -139,8 +139,8 @@ public: } }; -} // namespace - +} // namespace + IActor* CreateFlatDummyTablet(const TActorId &tablet, TTabletStorageInfo *info) { return new TDummyFlatTablet(tablet, info); diff --git a/ydb/core/testlib/tablet_helpers.cpp b/ydb/core/testlib/tablet_helpers.cpp index ac27b6ba794..a853040b932 100644 --- a/ydb/core/testlib/tablet_helpers.cpp +++ b/ydb/core/testlib/tablet_helpers.cpp @@ -170,16 +170,16 @@ namespace NKikimr { auto info = static_cast<TEvStateStorage::TEvInfo*>(event->GetBase()); if (info->Status == NKikimrProto::OK && (Find(TabletIds.begin(), TabletIds.end(), info->TabletID) != TabletIds.end())) { if (ENABLE_REBOOT_DISPATCH_LOG) { - Cerr << "Leader for TabletID " << info->TabletID << " is " << info->CurrentLeaderTablet << " sender: " << event->Sender << " recipient: " << event->Recipient << Endl; + Cerr << "Leader for TabletID " << info->TabletID << " is " << info->CurrentLeaderTablet << " sender: " << event->Sender << " recipient: " << event->Recipient << Endl; } - if (info->CurrentLeaderTablet) { - TabletLeaders[info->TabletID] = info->CurrentLeaderTablet; + if (info->CurrentLeaderTablet) { + TabletLeaders[info->TabletID] = info->CurrentLeaderTablet; } else { if (ENABLE_REBOOT_DISPATCH_LOG) { - Cerr << "IGNORE Leader for TabletID " << info->TabletID << " is " << info->CurrentLeaderTablet << " sender: " << event->Sender << " recipient: " << event->Recipient << Endl; + Cerr << "IGNORE Leader for TabletID " << info->TabletID << " is " << info->CurrentLeaderTablet << " sender: " << event->Sender << " recipient: " << event->Recipient << Endl; } } - TabletRelatedActors[info->CurrentLeaderTablet] = info->TabletID; + TabletRelatedActors[info->CurrentLeaderTablet] = info->TabletID; } } else if (event->GetTypeRewrite() == TEvFakeHive::EvNotifyTabletDeleted) { @@ -199,12 +199,12 @@ namespace NKikimr { } } - const TMap<ui64, TActorId>& GetTabletLeaders() const { - return TabletLeaders; + const TMap<ui64, TActorId>& GetTabletLeaders() const { + return TabletLeaders; } bool IsTabletEvent(const TAutoPtr<IEventHandle>& event) const { - for (const auto& kv : TabletLeaders) { + for (const auto& kv : TabletLeaders) { if (event->GetRecipientRewrite() == kv.second) { return true; } @@ -217,8 +217,8 @@ namespace NKikimr { if (DeletedTablets.contains(tabletId)) return false; - auto it = TabletLeaders.find(tabletId); - if (it != TabletLeaders.end() && event->GetRecipientRewrite() == it->second) { + auto it = TabletLeaders.find(tabletId); + if (it != TabletLeaders.end() && event->GetRecipientRewrite() == it->second) { return true; } @@ -255,7 +255,7 @@ namespace NKikimr { } protected: - TMap<ui64, TActorId> TabletLeaders; + TMap<ui64, TActorId> TabletLeaders; TMap<TActorId, ui64> TabletRelatedActors; TSet<ui64> DeletedTablets; bool& TracingActive; @@ -313,7 +313,7 @@ namespace NKikimr { runtime.PushFront(event); } - TActorId targetActorId = TabletLeaders[TabletId]; + TActorId targetActorId = TabletLeaders[TabletId]; if (targetActorId == TActorId()) { if (ENABLE_REBOOT_DISPATCH_LOG) @@ -337,7 +337,7 @@ namespace NKikimr { if (ENABLE_REBOOT_DISPATCH_LOG) Cerr << "!Reboot " << TabletId << " (actor " << targetActorId << ") rebooted!\n"; - InvalidateTabletResolverCache(runtime, TabletId); + InvalidateTabletResolverCache(runtime, TabletId); TDispatchOptions invalidateOptions; invalidateOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvStateStorage::EvInfo)); runtime.DispatchEvents(invalidateOptions); @@ -568,8 +568,8 @@ namespace NKikimr { TTabletTracer& Tracer; }; - TActorId FollowerTablet(TTestActorRuntime &runtime, const TActorId &launcher, TTabletStorageInfo *info, std::function<IActor * (const TActorId &, TTabletStorageInfo *)> op) { - return runtime.Register(CreateTabletFollower(launcher, info, new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0), 0, new TResourceProfiles)); + TActorId FollowerTablet(TTestActorRuntime &runtime, const TActorId &launcher, TTabletStorageInfo *info, std::function<IActor * (const TActorId &, TTabletStorageInfo *)> op) { + return runtime.Register(CreateTabletFollower(launcher, info, new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0), 0, new TResourceProfiles)); } TActorId ResolveTablet(TTestActorRuntime &runtime, ui64 tabletId, ui32 nodeIndex, bool sysTablet) { @@ -585,34 +585,34 @@ namespace NKikimr { } } - void ForwardToTablet(TTestActorRuntime &runtime, ui64 tabletId, const TActorId& sender, IEventBase *ev, ui32 nodeIndex, bool sysTablet) { + void ForwardToTablet(TTestActorRuntime &runtime, ui64 tabletId, const TActorId& sender, IEventBase *ev, ui32 nodeIndex, bool sysTablet) { runtime.Send(new IEventHandle(MakeTabletResolverID(), sender, new TEvTabletResolver::TEvForward(tabletId, new IEventHandle(TActorId(), sender, ev), { }, sysTablet ? TEvTabletResolver::TEvForward::EActor::SysTablet : TEvTabletResolver::TEvForward::EActor::Tablet)), nodeIndex); } - void InvalidateTabletResolverCache(TTestActorRuntime &runtime, ui64 tabletId, ui32 nodeIndex) { + void InvalidateTabletResolverCache(TTestActorRuntime &runtime, ui64 tabletId, ui32 nodeIndex) { runtime.Send(new IEventHandle(MakeTabletResolverID(), TActorId(), new TEvTabletResolver::TEvTabletProblem(tabletId, TActorId())), nodeIndex); } - void RebootTablet(TTestActorRuntime &runtime, ui64 tabletId, const TActorId& sender, ui32 nodeIndex, bool sysTablet) { - ForwardToTablet(runtime, tabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex, sysTablet); + void RebootTablet(TTestActorRuntime &runtime, ui64 tabletId, const TActorId& sender, ui32 nodeIndex, bool sysTablet) { + ForwardToTablet(runtime, tabletId, sender, new TEvents::TEvPoisonPill(), nodeIndex, sysTablet); TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot, 1)); runtime.DispatchEvents(rebootOptions); - InvalidateTabletResolverCache(runtime, tabletId, nodeIndex); + InvalidateTabletResolverCache(runtime, tabletId, nodeIndex); WaitScheduledEvents(runtime, TDuration::Seconds(1), sender, nodeIndex); } void GracefulRestartTablet(TTestActorRuntime &runtime, ui64 tabletId, const TActorId &sender, ui32 nodeIndex) { - ForwardToTablet(runtime, tabletId, sender, new TEvTablet::TEvTabletStop(tabletId, TEvTablet::TEvTabletStop::ReasonStop), nodeIndex, /* sysTablet = */ true); + ForwardToTablet(runtime, tabletId, sender, new TEvTablet::TEvTabletStop(tabletId, TEvTablet::TEvTabletStop::ReasonStop), nodeIndex, /* sysTablet = */ true); TDispatchOptions rebootOptions; rebootOptions.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot, 1)); runtime.DispatchEvents(rebootOptions); - InvalidateTabletResolverCache(runtime, tabletId, nodeIndex); + InvalidateTabletResolverCache(runtime, tabletId, nodeIndex); WaitScheduledEvents(runtime, TDuration::Seconds(1), sender, nodeIndex); } @@ -1062,10 +1062,10 @@ namespace NKikimr { return totalFreeSize; }; - NTabletPipe::TClientConfig GetPipeConfigWithRetriesAndFollowers() { // with blackjack and hookers... (c) + NTabletPipe::TClientConfig GetPipeConfigWithRetriesAndFollowers() { // with blackjack and hookers... (c) NTabletPipe::TClientConfig pipeConfig; pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); - pipeConfig.AllowFollower = true; + pipeConfig.AllowFollower = true; return pipeConfig; } @@ -1379,7 +1379,7 @@ namespace NKikimr { auto it = State->Tablets.find(key); Y_VERIFY(it != State->Tablets.end()); - THolder<TTabletStorageInfo> tabletInfo(CreateTestTabletInfo(tabletId, it->second.Type)); + THolder<TTabletStorageInfo> tabletInfo(CreateTestTabletInfo(tabletId, it->second.Type)); ctx.Send(ev->Sender, new TEvLocal::TEvBootTablet(*tabletInfo.Get(), 0), 0, ev->Cookie); } @@ -1411,7 +1411,7 @@ namespace NKikimr { TIntrusivePtr<TBootstrapperInfo> bi(new TBootstrapperInfo(new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0))); return ctx.ExecutorThread.RegisterActor(CreateBootstrapper( - CreateTestTabletInfo(State->NextTabletId, tabletType, erasure), bi.Get())); + CreateTestTabletInfo(State->NextTabletId, tabletType, erasure), bi.Get())); } void FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabletId, const TFakeHiveTabletInfo *info) { @@ -1434,7 +1434,7 @@ namespace NKikimr { void BootFakeHive(TTestActorRuntime& runtime, ui64 tabletId, TFakeHiveState::TPtr state, TGetTabletCreationFunc getTabletCreationFunc) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::Hive), [=](const TActorId & tablet, TTabletStorageInfo* info) { + CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::Hive), [=](const TActorId & tablet, TTabletStorageInfo* info) { return new TFakeHive(tablet, info, state, (getTabletCreationFunc == nullptr) ? &TFakeHive::DefaultGetTabletCreationFunc : getTabletCreationFunc); }); diff --git a/ydb/core/testlib/tablet_helpers.h b/ydb/core/testlib/tablet_helpers.h index a0cc392bff2..81a7c614aaa 100644 --- a/ydb/core/testlib/tablet_helpers.h +++ b/ydb/core/testlib/tablet_helpers.h @@ -18,12 +18,12 @@ namespace NKikimr { const TBlobStorageGroupType::EErasureSpecies DataGroupErasure = TBlobStorageGroupType::ErasureNone; - TActorId FollowerTablet(TTestActorRuntime &runtime, const TActorId &launcher, TTabletStorageInfo *info, + TActorId FollowerTablet(TTestActorRuntime &runtime, const TActorId &launcher, TTabletStorageInfo *info, std::function<IActor* (const TActorId &, TTabletStorageInfo*)> op); TActorId ResolveTablet(TTestActorRuntime& runtime, ui64 tabletId, ui32 nodeIndex = 0, bool sysTablet = false); - void ForwardToTablet(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender, IEventBase *ev, ui32 nodeIndex = 0, bool sysTablet = false); - void InvalidateTabletResolverCache(TTestActorRuntime& runtime, ui64 tabletId, ui32 nodeIndex = 0); - void RebootTablet(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender, ui32 nodeIndex = 0, bool sysTablet = false); + void ForwardToTablet(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender, IEventBase *ev, ui32 nodeIndex = 0, bool sysTablet = false); + void InvalidateTabletResolverCache(TTestActorRuntime& runtime, ui64 tabletId, ui32 nodeIndex = 0); + void RebootTablet(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender, ui32 nodeIndex = 0, bool sysTablet = false); void GracefulRestartTablet(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender, ui32 nodeIndex = 0); void SetupTabletServices(TTestActorRuntime& runtime, TAppPrepare* app = nullptr, bool mockDisk = false, NFake::TStorage storage = {}, NFake::TCaches caches = {}); @@ -79,9 +79,9 @@ namespace NKikimr { ui64 GetFreePDiskSize(TTestActorRuntime& runtime, const TActorId& sender); void PrintTabletDb(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& sender); - NTabletPipe::TClientConfig GetPipeConfigWithRetriesAndFollowers(); + NTabletPipe::TClientConfig GetPipeConfigWithRetriesAndFollowers(); - IActor* CreateFlatDummyTablet(const TActorId &tablet, TTabletStorageInfo *info); + IActor* CreateFlatDummyTablet(const TActorId &tablet, TTabletStorageInfo *info); void WaitScheduledEvents(TTestActorRuntime &runtime, TDuration delay, const TActorId &sender, ui32 nodeIndex = 0); @@ -140,7 +140,7 @@ namespace NKikimr { typedef TIntrusivePtr<TFakeHiveState> TPtr; TFakeHiveState() - : NextTabletId(TTestTxConfig::FakeHiveTablets) + : NextTabletId(TTestTxConfig::FakeHiveTablets) , NextHiveNextTabletId(NextTabletId + TABLETS_PER_CHILD_HIVE) {} diff --git a/ydb/core/testlib/tenant_runtime.cpp b/ydb/core/testlib/tenant_runtime.cpp index 5d928453c62..974cc166d0d 100644 --- a/ydb/core/testlib/tenant_runtime.cpp +++ b/ydb/core/testlib/tenant_runtime.cpp @@ -378,7 +378,7 @@ class TFakeHive : public TActor<TFakeHive>, public TTabletExecutedFlat { { TIntrusivePtr<TBootstrapperInfo> bi(new TBootstrapperInfo(new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0))); - return ctx.ExecutorThread.RegisterActor(CreateBootstrapper(CreateTestTabletInfo(State.NextTabletId, tabletType, erasure), bi.Get())); + return ctx.ExecutorThread.RegisterActor(CreateBootstrapper(CreateTestTabletInfo(State.NextTabletId, tabletType, erasure), bi.Get())); } void SendDeletionNotification(ui64 tabletId, TActorId waiter, const TActorContext& ctx) @@ -737,7 +737,7 @@ void TTenantTestRuntime::CreateTenantPool(ui32 nodeIndex, const TTenantTestConfi NKikimrTabletBase::TMetrics limit; TLocalConfig::TPtr localConfig = new TLocalConfig; localConfig->TabletClassInfo[TTabletTypes::Dummy].SetupInfo - = new TTabletSetupInfo(&CreateFlatDummyTablet, + = new TTabletSetupInfo(&CreateFlatDummyTablet, TMailboxType::Simple, 0, TMailboxType::Simple, 0); @@ -853,15 +853,15 @@ void TTenantTestRuntime::Setup(bool createTenantPools) for (auto &pr : GetAppData().DomainsInfo->Domains) { auto &domain = pr.second; for (auto id : domain->TxAllocators) { - auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); EnableScheduleForActor(aid, true); } for (auto id : domain->Coordinators) { - auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::FLAT_TX_COORDINATOR), &CreateFlatTxCoordinator); + auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::FLAT_TX_COORDINATOR), &CreateFlatTxCoordinator); EnableScheduleForActor(aid, true); } for (auto id : domain->Mediators) { - auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::TX_MEDIATOR), &CreateTxMediator); + auto aid = CreateTestBootstrapper(*this, CreateTestTabletInfo(id, TTabletTypes::TX_MEDIATOR), &CreateTxMediator); EnableScheduleForActor(aid, true); } } @@ -880,14 +880,14 @@ void TTenantTestRuntime::Setup(bool createTenantPools) subdomains.push_back(std::make_pair(subDomain, key.GetPathId())); } - auto info = CreateTestTabletInfo(domain.SchemeShardId, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(*this, info, [sender=Sender, subdomains](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(domain.SchemeShardId, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(*this, info, [sender=Sender, subdomains](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { return new TFakeSchemeShard(tablet, info, sender, subdomains); }); EnableScheduleForActor(actorId, true); } else { - auto info = CreateTestTabletInfo(domain.SchemeShardId, TTabletTypes::FLAT_SCHEMESHARD, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(domain.SchemeShardId, TTabletTypes::FLAT_SCHEMESHARD, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { return CreateFlatTxSchemeShard(tablet, info); }); EnableScheduleForActor(actorId, true); @@ -953,8 +953,8 @@ void TTenantTestRuntime::Setup(bool createTenantPools) // Create Hive. { - auto info = CreateTestTabletInfo(Config.HiveId, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(*this, info, [this](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(Config.HiveId, TTabletTypes::TX_DUMMY, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(*this, info, [this](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { return new TFakeHive(tablet, info, Sender, Config.HiveId, SubDomainKeys); }); EnableScheduleForActor(actorId, true); @@ -962,8 +962,8 @@ void TTenantTestRuntime::Setup(bool createTenantPools) // Create BS Controller. { - auto info = CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER); - TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(MakeBSControllerID(0), TTabletTypes::FLAT_BS_CONTROLLER); + TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { //return new TFakeBSController(tablet, info); return CreateFlatBsController(tablet, info); }); @@ -1032,8 +1032,8 @@ void TTenantTestRuntime::Setup(bool createTenantPools) // Create Console { - auto info = CreateTestTabletInfo(MakeConsoleID(0), TTabletTypes::CONSOLE, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(MakeConsoleID(0), TTabletTypes::CONSOLE, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(*this, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { return CreateConsole(tablet, info); }); EnableScheduleForActor(actorId, true); @@ -1099,8 +1099,8 @@ void TTenantTestRuntime::Setup(bool createTenantPools) // Create Tenant Slot Broker { - auto info = CreateTestTabletInfo(MakeTenantSlotBrokerID(0), TTabletTypes::TENANT_SLOT_BROKER, TErasureType::ErasureNone); - TActorId actorId = CreateTestBootstrapper(*this, info, [&config=this->Config](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { + auto info = CreateTestTabletInfo(MakeTenantSlotBrokerID(0), TTabletTypes::TENANT_SLOT_BROKER, TErasureType::ErasureNone); + TActorId actorId = CreateTestBootstrapper(*this, info, [&config=this->Config](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* { if (config.FakeTenantSlotBroker) return new TFakeTenantSlotBroker(tablet, info); else diff --git a/ydb/core/testlib/test_client.cpp b/ydb/core/testlib/test_client.cpp index f7ae90aa4a1..d4907c26f1e 100644 --- a/ydb/core/testlib/test_client.cpp +++ b/ydb/core/testlib/test_client.cpp @@ -163,7 +163,7 @@ namespace Tests { app.SetKeepSnapshotTimeout(Settings->KeepSnapshotTimeout); app.SetChangesQueueItemsLimit(Settings->ChangesQueueItemsLimit); app.SetChangesQueueBytesLimit(Settings->ChangesQueueBytesLimit); - app.CompactionConfig = Settings->CompactionConfig; + app.CompactionConfig = Settings->CompactionConfig; app.FeatureFlags = Settings->FeatureFlags; Runtime = MakeHolder<TTestBasicRuntime>(StaticNodes() + DynamicNodes(), Settings->UseRealThreads); @@ -206,7 +206,7 @@ namespace Tests { SetupTabletServices(*Runtime, &app, (StaticNodes() + DynamicNodes()) == 1 && Settings->EnableMockOnSingleNode, Settings->CustomDiskParams); - CreateBootstrapTablets(); + CreateBootstrapTablets(); SetupStorage(); for (ui32 nodeIdx = 0; nodeIdx < StaticNodes() + DynamicNodes(); ++nodeIdx) { @@ -358,20 +358,20 @@ namespace Tests { app.AddDomain(domain.Release()); } - void TServer::CreateBootstrapTablets() { + void TServer::CreateBootstrapTablets() { const ui32 domainId = Settings->Domain; Y_VERIFY(TDomainsInfo::MakeTxAllocatorIDFixed(domainId, 1) == ChangeStateStorage(TxAllocator, domainId)); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(TxAllocator, domainId), TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(TxAllocator, domainId), TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); Y_VERIFY(TDomainsInfo::MakeTxCoordinatorIDFixed(domainId, 1) == ChangeStateStorage(Coordinator, domainId)); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Coordinator, domainId), TTabletTypes::FLAT_TX_COORDINATOR), &CreateFlatTxCoordinator); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Coordinator, domainId), TTabletTypes::FLAT_TX_COORDINATOR), &CreateFlatTxCoordinator); Y_VERIFY(TDomainsInfo::MakeTxMediatorIDFixed(domainId, 1) == ChangeStateStorage(Mediator, domainId)); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Mediator, domainId), TTabletTypes::TX_MEDIATOR), &CreateTxMediator); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(SchemeRoot, domainId), TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Hive, domainId), TTabletTypes::FLAT_HIVE), &CreateDefaultHive); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeBSControllerID(domainId), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeTenantSlotBrokerID(domainId), TTabletTypes::TENANT_SLOT_BROKER), &NTenantSlotBroker::CreateTenantSlotBroker); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Mediator, domainId), TTabletTypes::TX_MEDIATOR), &CreateTxMediator); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(SchemeRoot, domainId), TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(Hive, domainId), TTabletTypes::FLAT_HIVE), &CreateDefaultHive); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeBSControllerID(domainId), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeTenantSlotBrokerID(domainId), TTabletTypes::TENANT_SLOT_BROKER), &NTenantSlotBroker::CreateTenantSlotBroker); if (Settings->EnableConsole) - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeConsoleID(domainId), TTabletTypes::CONSOLE), &NConsole::CreateConsole); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(MakeConsoleID(domainId), TTabletTypes::CONSOLE), &NConsole::CreateConsole); } void TServer::SetupStorage() { @@ -495,7 +495,7 @@ namespace Tests { void TServer::SetupLocalConfig(TLocalConfig &localConfig, const NKikimr::TAppData &appData) { localConfig.TabletClassInfo[appData.DefaultTabletTypes.Dummy] = TLocalConfig::TTabletClassInfo(new TTabletSetupInfo( - &CreateFlatDummyTablet, TMailboxType::Revolving, appData.UserPoolId, + &CreateFlatDummyTablet, TMailboxType::Revolving, appData.UserPoolId, TMailboxType::Revolving, appData.SystemPoolId)); localConfig.TabletClassInfo[appData.DefaultTabletTypes.DataShard] = TLocalConfig::TTabletClassInfo(new TTabletSetupInfo( @@ -854,8 +854,8 @@ namespace Tests { if (!Runtime) ythrow TWithBackTrace<yexception>() << "Server is redirected"; - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(DummyTablet1, Settings->Domain), TTabletTypes::TX_DUMMY), &CreateFlatDummyTablet); - CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(DummyTablet2, Settings->Domain), TTabletTypes::TX_DUMMY), &CreateFlatDummyTablet); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(DummyTablet1, Settings->Domain), TTabletTypes::TX_DUMMY), &CreateFlatDummyTablet); + CreateTestBootstrapper(*Runtime, CreateTestTabletInfo(ChangeStateStorage(DummyTablet2, Settings->Domain), TTabletTypes::TX_DUMMY), &CreateFlatDummyTablet); } TTestActorRuntime* TServer::GetRuntime() const { @@ -1588,7 +1588,7 @@ namespace Tests { request->Record.SetPath(path); const ui64 schemeRoot = GetPatchedSchemeRoot(SchemeRoot, Domain, SupportsRedirect); TActorId sender = runtime->AllocateEdgeActor(0); - ForwardToTablet(*runtime, schemeRoot, sender, request.Release(), 0); + ForwardToTablet(*runtime, schemeRoot, sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult>(handle); @@ -1966,8 +1966,8 @@ namespace Tests { Cerr << "error: " << err.Str() << Endl; } } - if (response.HasHadFollowerReads() && response.GetHadFollowerReads()) { - Cerr << "had follower reads" << Endl; + if (response.HasHadFollowerReads() && response.GetHadFollowerReads()) { + Cerr << "had follower reads" << Endl; } if (expectedResponse.HasStatus()) { @@ -2007,7 +2007,7 @@ namespace Tests { TString TClient::SendTabletMonQuery(TTestActorRuntime* runtime, ui64 tabletId, TString query) { TActorId sender = runtime->AllocateEdgeActor(0); - ForwardToTablet(*runtime, tabletId, sender, new NActors::NMon::TEvRemoteHttpInfo(query), 0); + ForwardToTablet(*runtime, tabletId, sender, new NActors::NMon::TEvRemoteHttpInfo(query), 0); TAutoPtr<IEventHandle> handle; // Timeout for DEBUG purposes only runtime->GrabEdgeEvent<NMon::TEvRemoteJsonInfoRes>(handle); @@ -2038,11 +2038,11 @@ namespace Tests { return SendTabletMonQuery(runtime, hive, TString("/app?page=KickNode&node=") + ToString(nodeId)); } - bool TClient::WaitForTabletAlive(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout) { + bool TClient::WaitForTabletAlive(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout) { TActorId edge = runtime->AllocateEdgeActor(); NTabletPipe::TClientConfig clientConfig; - clientConfig.AllowFollower = !leader; - clientConfig.ForceFollower = !leader; + clientConfig.AllowFollower = !leader; + clientConfig.ForceFollower = !leader; clientConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); TActorId pipeClient = runtime->Register(NTabletPipe::CreateClient(edge, tabletId, clientConfig)); TAutoPtr<IEventHandle> handle; @@ -2066,11 +2066,11 @@ namespace Tests { return res; } - bool TClient::WaitForTabletDown(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout) { + bool TClient::WaitForTabletDown(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout) { TActorId edge = runtime->AllocateEdgeActor(); NTabletPipe::TClientConfig clientConfig; - clientConfig.AllowFollower = !leader; - clientConfig.ForceFollower = !leader; + clientConfig.AllowFollower = !leader; + clientConfig.ForceFollower = !leader; clientConfig.RetryPolicy = { .RetryLimitCount = 5, .MinRetryTime = TDuration::MilliSeconds(500), @@ -2111,10 +2111,10 @@ namespace Tests { return res; } - void TClient::GetTabletInfoFromHive(TTestActorRuntime* runtime, ui64 tabletId, bool returnFollowers, NKikimrHive::TEvResponseHiveInfo& res) { + void TClient::GetTabletInfoFromHive(TTestActorRuntime* runtime, ui64 tabletId, bool returnFollowers, NKikimrHive::TEvResponseHiveInfo& res) { TAutoPtr<TEvHive::TEvRequestHiveInfo> ev(new TEvHive::TEvRequestHiveInfo); ev->Record.SetTabletID(tabletId); - ev->Record.SetReturnFollowers(returnFollowers); + ev->Record.SetReturnFollowers(returnFollowers); ui64 hive = ChangeStateStorage(Tests::Hive, Domain); TActorId edge = runtime->AllocateEdgeActor(); @@ -2124,7 +2124,7 @@ namespace Tests { res.Swap(&response->Record); } - ui32 TClient::GetLeaderNode(TTestActorRuntime* runtime, ui64 tabletId) { + ui32 TClient::GetLeaderNode(TTestActorRuntime* runtime, ui64 tabletId) { NKikimrHive::TEvResponseHiveInfo res; GetTabletInfoFromHive(runtime, tabletId, false, res); // Cerr << res << Endl; @@ -2177,19 +2177,19 @@ namespace Tests { } } - TVector<ui32> TClient::GetFollowerNodes(TTestActorRuntime* runtime, ui64 tabletId) { + TVector<ui32> TClient::GetFollowerNodes(TTestActorRuntime* runtime, ui64 tabletId) { NKikimrHive::TEvResponseHiveInfo res; GetTabletInfoFromHive(runtime, tabletId, true, res); // Cerr << res << Endl; - TVector<ui32> followerNodes; + TVector<ui32> followerNodes; for (const NKikimrHive::TTabletInfo& tablet : res.GetTablets()) { - if (tablet.GetTabletID() == tabletId && tablet.HasFollowerID()) { - followerNodes.push_back(NodeIdToIndex(runtime, tablet.GetNodeID())); + if (tablet.GetTabletID() == tabletId && tablet.HasFollowerID()) { + followerNodes.push_back(NodeIdToIndex(runtime, tablet.GetNodeID())); } } - return followerNodes; + return followerNodes; } void TClient::S3Listing(const TString& table, const TString& prefixColumnsPb, @@ -2243,7 +2243,7 @@ namespace Tests { *request->Record.MutableResource()->MutableHierarhicalDRRResourceConfig() = props; TActorId sender = runtime->AllocateEdgeActor(0); - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvAddQuoterResourceResult>(handle); @@ -2255,7 +2255,7 @@ namespace Tests { THolder<NKesus::TEvKesus::TEvGetConfig> request = MakeHolder<NKesus::TEvKesus::TEvGetConfig>(); TActorId sender = runtime->AllocateEdgeActor(0); - ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); + ForwardToTablet(*runtime, GetKesusTabletId(kesusPath), sender, request.Release(), 0); TAutoPtr<IEventHandle> handle; runtime->GrabEdgeEvent<NKesus::TEvKesus::TEvGetConfigResult>(handle); diff --git a/ydb/core/testlib/test_client.h b/ydb/core/testlib/test_client.h index 4db08dc95fb..2064752ab45 100644 --- a/ydb/core/testlib/test_client.h +++ b/ydb/core/testlib/test_client.h @@ -117,7 +117,7 @@ namespace Tests { ui64 ChangesQueueItemsLimit = 0; ui64 ChangesQueueBytesLimit = 0; NKikimrConfig::TAppConfig AppConfig; - NKikimrConfig::TCompactionConfig CompactionConfig; + NKikimrConfig::TCompactionConfig CompactionConfig; TMap<ui32, TString> NodeKeys; ui64 DomainPlanResolution = 0; std::shared_ptr<NKikimr::NMsgBusProxy::IPersQueueGetReadSessionsInfoWorkerFactory> PersQueueGetReadSessionsInfoWorkerFactory; @@ -152,7 +152,7 @@ namespace Tests { TServerSettings& SetEnableKqpSpilling(bool value) { EnableKqpSpilling = value; return *this; } TServerSettings& SetDomainPlanResolution(ui64 resolution) { DomainPlanResolution = resolution; return *this; } TServerSettings& SetFeatureFlags(const NKikimrConfig::TFeatureFlags& value) { FeatureFlags = value; return *this; } - TServerSettings& SetCompactionConfig(const NKikimrConfig::TCompactionConfig& value) { CompactionConfig = value; return *this; } + TServerSettings& SetCompactionConfig(const NKikimrConfig::TCompactionConfig& value) { CompactionConfig = value; return *this; } TServerSettings& SetEnableDbCounters(bool value) { FeatureFlags.SetEnableDbCounters(value); return *this; } TServerSettings& SetEnableYq(bool value) { EnableYq = value; return *this; } TServerSettings& SetKeepSnapshotTimeout(TDuration value) { KeepSnapshotTimeout = value; return *this; } @@ -196,7 +196,7 @@ namespace Tests { void SetupMessageBus(ui16 port, const TString &tracePath); void SetupDomains(TAppPrepare&); - void CreateBootstrapTablets(); + void CreateBootstrapTablets(); void SetupLocalConfig(TLocalConfig &localConfig, const NKikimr::TAppData &appData); void SetupDomainLocalService(ui32 nodeIdx); void SetupLocalService(ui32 nodeIdx, const TString &domainName); @@ -418,17 +418,17 @@ namespace Tests { TString SendTabletMonQuery(TTestActorRuntime* runtime, ui64 tabletId, TString query); TString MarkNodeInHive(TTestActorRuntime* runtime, ui32 nodeIdx, bool up); TString KickNodeInHive(TTestActorRuntime* runtime, ui32 nodeIdx); - bool WaitForTabletAlive(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout); - bool WaitForTabletDown(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout); - ui32 GetLeaderNode(TTestActorRuntime* runtime, ui64 tabletId); + bool WaitForTabletAlive(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout); + bool WaitForTabletDown(TTestActorRuntime* runtime, ui64 tabletId, bool leader, TDuration timeout); + ui32 GetLeaderNode(TTestActorRuntime* runtime, ui64 tabletId); bool TabletExistsInHive(TTestActorRuntime* runtime, ui64 tabletId, bool evenInDeleting = false); - TVector<ui32> GetFollowerNodes(TTestActorRuntime *runtime, ui64 tabletId); + TVector<ui32> GetFollowerNodes(TTestActorRuntime *runtime, ui64 tabletId); void S3Listing(const TString& table, const TString& prefixColumnsPb, const TString &pathPrefix, const TString &pathDelimiter, const TString& startAfterSuffixColumnsPb, const TVector<TString>& columnsToReturn, ui32 maxKeys, ui32 timeoutMillisec, NKikimrClient::TS3ListingResponse &res); - void GetTabletInfoFromHive(TTestActorRuntime* runtime, ui64 tabletId, bool returnFollowers, NKikimrHive::TEvResponseHiveInfo& res); + void GetTabletInfoFromHive(TTestActorRuntime* runtime, ui64 tabletId, bool returnFollowers, NKikimrHive::TEvResponseHiveInfo& res); void GetTabletStorageInfoFromHive(TTestActorRuntime* runtime, ui64 tabletId, NKikimrHive::TEvGetTabletStorageInfoResult& res); static void RefreshPathCache(TTestActorRuntime* runtime, const TString& path, ui32 nodeIdx = 0); diff --git a/ydb/core/testlib/test_pq_client.h b/ydb/core/testlib/test_pq_client.h index adca0e94206..f0599232508 100644 --- a/ydb/core/testlib/test_pq_client.h +++ b/ydb/core/testlib/test_pq_client.h @@ -724,7 +724,7 @@ public: void RestartSchemeshard(TTestActorRuntime* runtime) { TActorId sender = runtime->AllocateEdgeActor(); const ui64 schemeRoot = GetPatchedSchemeRoot(Tests::SchemeRoot, Settings.Domain, Settings.SupportsRedirect); - ForwardToTablet(*runtime, schemeRoot, sender, new TEvents::TEvPoisonPill(), 0); + ForwardToTablet(*runtime, schemeRoot, sender, new TEvents::TEvPoisonPill(), 0); TDispatchOptions options; runtime->DispatchEvents(options); } @@ -775,7 +775,7 @@ public: Cerr << res->Record << "\n"; const ui64 tablet = res->Record.GetPathDescription().GetPersQueueGroup().GetBalancerTabletID(); TActorId sender = runtime->AllocateEdgeActor(); - ForwardToTablet(*runtime, tablet, sender, new TEvents::TEvPoisonPill(), 0); + ForwardToTablet(*runtime, tablet, sender, new TEvents::TEvPoisonPill(), 0); TDispatchOptions options; runtime->DispatchEvents(options); } @@ -791,7 +791,7 @@ public: } TActorId sender = runtime->AllocateEdgeActor(); for (auto & tablet : tablets) { - ForwardToTablet(*runtime, tablet, sender, new TEvents::TEvPoisonPill(), 0); + ForwardToTablet(*runtime, tablet, sender, new TEvents::TEvPoisonPill(), 0); TDispatchOptions options; try { runtime->DispatchEvents(options); diff --git a/ydb/core/tx/columnshard/blob_manager.cpp b/ydb/core/tx/columnshard/blob_manager.cpp index 32fd62ca6f7..2d390802d0f 100644 --- a/ydb/core/tx/columnshard/blob_manager.cpp +++ b/ydb/core/tx/columnshard/blob_manager.cpp @@ -19,7 +19,7 @@ TLogoBlobID ParseLogoBlobId(TString blobId) { struct TBlobBatch::TBatchInfo : TNonCopyable { TIntrusivePtr<TTabletStorageInfo> TabletInfo; - TAllocatedGenStepConstPtr GenStepRef; + TAllocatedGenStepConstPtr GenStepRef; const ui32 Gen; const ui32 Step; const ui32 Channel; @@ -30,7 +30,7 @@ struct TBlobBatch::TBatchInfo : TNonCopyable { ui64 TotalSizeBytes; TVector<TString> SmallBlobs; - TBatchInfo(TIntrusivePtr<TTabletStorageInfo> tabletInfo, TAllocatedGenStepConstPtr genStep, ui32 channel) + TBatchInfo(TIntrusivePtr<TTabletStorageInfo> tabletInfo, TAllocatedGenStepConstPtr genStep, ui32 channel) : TabletInfo(tabletInfo) , GenStepRef(genStep) , Gen(std::get<0>(GenStepRef->GenStep)) @@ -195,7 +195,7 @@ bool TBlobManager::LoadState(IBlobManagerDb& db) { } AllocatedGenSteps.push_back(new TAllocatedGenStep({CurrentGen, 0})); - Sort(AllocatedGenSteps.begin(), AllocatedGenSteps.end(), [](const TAllocatedGenStepConstPtr& a, const TAllocatedGenStepConstPtr& b) { + Sort(AllocatedGenSteps.begin(), AllocatedGenSteps.end(), [](const TAllocatedGenStepConstPtr& a, const TAllocatedGenStepConstPtr& b) { return a->GenStep < b->GenStep; }); @@ -390,7 +390,7 @@ TBlobBatch TBlobManager::StartBlobBatch(ui32 channel) { ++CountersUpdate.BatchesStarted; Y_VERIFY(channel == BLOB_CHANNEL, "Support for mutiple blob channels is not implemented yet"); ++CurrentStep; - TAllocatedGenStepConstPtr genStepRef = new TAllocatedGenStep({CurrentGen, CurrentStep}); + TAllocatedGenStepConstPtr genStepRef = new TAllocatedGenStep({CurrentGen, CurrentStep}); AllocatedGenSteps.push_back(genStepRef); auto batchInfo = std::make_unique<TBlobBatch::TBatchInfo>(TabletInfo, genStepRef, channel); return TBlobBatch(std::move(batchInfo)); diff --git a/ydb/core/tx/columnshard/blob_manager.h b/ydb/core/tx/columnshard/blob_manager.h index d878cd9094b..fb9814ceac7 100644 --- a/ydb/core/tx/columnshard/blob_manager.h +++ b/ydb/core/tx/columnshard/blob_manager.h @@ -96,8 +96,8 @@ struct TAllocatedGenStep : public TThrRefBase { } }; -using TAllocatedGenStepConstPtr = TIntrusiveConstPtr<TAllocatedGenStep>; - +using TAllocatedGenStepConstPtr = TIntrusiveConstPtr<TAllocatedGenStep>; + struct TBlobManagerCounters { ui64 BatchesStarted = 0; ui64 BatchesCommitted = 0; @@ -146,7 +146,7 @@ private: THashMap<TUnifiedBlobId, i64> BlobsUseCount; // Sorted queue of GenSteps that have in-flight BlobBatches - TDeque<TAllocatedGenStepConstPtr> AllocatedGenSteps; + TDeque<TAllocatedGenStepConstPtr> AllocatedGenSteps; // The Gen:Step that has been acknowledged by the Distributed Storage TGenStep LastCollectedGenStep = {0, 0}; diff --git a/ydb/core/tx/columnshard/columnshard_ut_common.cpp b/ydb/core/tx/columnshard/columnshard_ut_common.cpp index e7e8a980a28..fea0855cee2 100644 --- a/ydb/core/tx/columnshard/columnshard_ut_common.cpp +++ b/ydb/core/tx/columnshard/columnshard_ut_common.cpp @@ -42,7 +42,7 @@ bool ProposeSchemaTx(TTestBasicRuntime& runtime, TActorId& sender, const TString auto event = std::make_unique<TEvColumnShard::TEvProposeTransaction>( NKikimrTxColumnShard::TX_KIND_SCHEMA, 0, sender, snap.TxId, txBody); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, event.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, event.release()); auto ev = runtime.GrabEdgeEvent<TEvColumnShard::TEvProposeTransactionResult>(sender); const auto& res = ev->Get()->Record; UNIT_ASSERT_EQUAL(res.GetTxId(), snap.TxId); @@ -51,12 +51,12 @@ bool ProposeSchemaTx(TTestBasicRuntime& runtime, TActorId& sender, const TString } void PlanSchemaTx(TTestBasicRuntime& runtime, TActorId& sender, NOlap::TSnapshot snap) { - auto plan = std::make_unique<TEvTxProcessing::TEvPlanStep>(snap.PlanStep, 0, TTestTxConfig::TxTablet0); + auto plan = std::make_unique<TEvTxProcessing::TEvPlanStep>(snap.PlanStep, 0, TTestTxConfig::TxTablet0); auto tx = plan->Record.AddTransactions(); tx->SetTxId(snap.TxId); ActorIdToProto(sender, tx->MutableAckTo()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, plan.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, plan.release()); UNIT_ASSERT(runtime.GrabEdgeEvent<TEvTxProcessing::TEvPlanStepAck>(sender)); auto ev = runtime.GrabEdgeEvent<TEvColumnShard::TEvProposeTransactionResult>(sender); const auto& res = ev->Get()->Record; @@ -72,13 +72,13 @@ bool WriteData(TTestBasicRuntime& runtime, TActorId& sender, ui64 metaShard, ui6 if (schema) { write->SetArrowSchema(NArrow::SerializeSchema(*schema)); } - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, write.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, write.release()); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvWriteResult>(handle); UNIT_ASSERT(event); auto& resWrite = Proto(event); - UNIT_ASSERT_EQUAL(resWrite.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resWrite.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resWrite.GetTxInitiator(), metaShard); return (resWrite.GetStatus() == NKikimrTxColumnShard::EResultStatus::SUCCESS); } @@ -112,14 +112,14 @@ void ScanIndexStats(TTestBasicRuntime& runtime, TActorId& sender, const TVector< record.MutableSnapshot()->SetTxId(snap.TxId); record.SetDataFormat(NKikimrTxDataShard::EScanDataFormat::ARROW); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, scan.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, scan.release()); } void ProposeCommit(TTestBasicRuntime& runtime, TActorId& sender, ui64 metaShard, ui64 txId, const TVector<ui64>& writeIds) { NKikimrTxColumnShard::ETransactionKind txKind = NKikimrTxColumnShard::ETransactionKind::TX_KIND_COMMIT; TString txBody = TTestSchema::CommitTxBody(metaShard, writeIds); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvProposeTransaction(txKind, sender, txId, txBody)); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvProposeTransactionResult>(handle); @@ -132,12 +132,12 @@ void ProposeCommit(TTestBasicRuntime& runtime, TActorId& sender, ui64 metaShard, } void PlanCommit(TTestBasicRuntime& runtime, TActorId& sender, ui64 planStep, ui64 txId) { - auto plan = std::make_unique<TEvTxProcessing::TEvPlanStep>(planStep, 0, TTestTxConfig::TxTablet0); + auto plan = std::make_unique<TEvTxProcessing::TEvPlanStep>(planStep, 0, TTestTxConfig::TxTablet0); auto tx = plan->Record.AddTransactions(); tx->SetTxId(txId); ActorIdToProto(sender, tx->MutableAckTo()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, plan.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, plan.release()); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvProposeTransactionResult>(handle); UNIT_ASSERT(event); diff --git a/ydb/core/tx/columnshard/ut_columnshard_read_write.cpp b/ydb/core/tx/columnshard/ut_columnshard_read_write.cpp index 12144200761..00e3143fc61 100644 --- a/ydb/core/tx/columnshard/ut_columnshard_read_write.cpp +++ b/ydb/core/tx/columnshard/ut_columnshard_read_write.cpp @@ -140,7 +140,7 @@ void TestWriteImpl(const TVector<std::pair<TString, TTypeId>>& ydbSchema) { TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -148,7 +148,7 @@ void TestWriteImpl(const TVector<std::pair<TString, TTypeId>>& ydbSchema) { // - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; @@ -226,7 +226,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& runtime.SetLogPriority(NKikimrServices::BLOB_CACHE, NActors::NLog::PRI_DEBUG); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -236,7 +236,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& const TString& data) { bool ok = WriteData(runtime, sender, metaShard, writeId, tableId, data); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } return ok; }; @@ -245,20 +245,20 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& const TVector<ui64>& writeIds) { ProposeCommit(runtime, sender, metaShard, txId, writeIds); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } }; auto planCommit = [&](TTestBasicRuntime& runtime, TActorId& sender, ui64 planStep, ui64 txId) { PlanCommit(runtime, sender, planStep, txId); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } }; // - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; @@ -281,14 +281,14 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 0, 0, tableId)); TAutoPtr<IEventHandle> handle; auto event2 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event2); auto& resRead = Proto(event2); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -304,13 +304,13 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 2 (committed, old snapshot) - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 0, 0, tableId)); auto event5 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event5); auto& resRead2 = Proto(event5); - UNIT_ASSERT_EQUAL(resRead2.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead2.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead2.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead2.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead2.GetBatch(), 0); @@ -319,13 +319,13 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 3 (committed) - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, planStep, txId, tableId)); auto event6 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event6); auto& resRead3 = Proto(event6); - UNIT_ASSERT_EQUAL(resRead3.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead3.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead3.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead3.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead3.GetBatch(), 0); @@ -345,12 +345,12 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& auto read_col1 = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, txId, tableId); Proto(read_col1.get()).AddColumnIds(1); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read_col1.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read_col1.release()); auto event7 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event7); auto& resRead4 = Proto(event7); - UNIT_ASSERT_EQUAL(resRead4.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead4.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead4.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead4.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead4.GetBatch(), 0); @@ -366,12 +366,12 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& auto read_col2 = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, txId, tableId); Proto(read_col2.get()).AddColumnNames("timestamp"); Proto(read_col2.get()).AddColumnNames("message"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read_col2.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read_col2.release()); auto event8 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event8); auto& resRead5 = Proto(event8); - UNIT_ASSERT_EQUAL(resRead5.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead5.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead5.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead5.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead5.GetBatch(), 0); @@ -405,13 +405,13 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 6, planstep 0 - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 0, 0, tableId)); auto event9 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event9); auto& resRead6 = Proto(event9); - UNIT_ASSERT_EQUAL(resRead6.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead6.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead6.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead6.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead6.GetBatch(), 0); @@ -420,13 +420,13 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 7, planstep 21 (part of index) - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 21, txId, tableId)); auto event10 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event10); auto& resRead7 = Proto(event10); - UNIT_ASSERT_EQUAL(resRead7.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead7.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead7.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead7.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead7.GetBatch(), 0); @@ -445,13 +445,13 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 8, planstep 22 (full index) - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 22, txId, tableId)); auto event11 = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event11); auto& resRead8 = Proto(event11); - UNIT_ASSERT_EQUAL(resRead8.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead8.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead8.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead8.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead8.GetBatch(), 0); @@ -482,7 +482,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 9 (committed, indexed) - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 23, txId, tableId)); TVector<TString> readData; TString schema; @@ -492,7 +492,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -521,7 +521,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& // read 10 - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvColumnShard::TEvRead(sender, metaShard, 24, txId, tableId)); readData.clear(); schema.clear(); @@ -531,7 +531,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -589,7 +589,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& greater->SetInclusive(prGreater.Inclusive); less->SetInclusive(prLess.Inclusive); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, evRead.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, evRead.release()); } readData.clear(); schema.clear(); @@ -598,7 +598,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -634,7 +634,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& greater->SetInclusive(prGreater.Inclusive); less->SetInclusive(prLess.Inclusive); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, evRead.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, evRead.release()); } readData.clear(); schema.clear(); @@ -643,7 +643,7 @@ void TestWriteReadImpl(bool reboots, const TVector<std::pair<TString, TTypeId>>& UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -664,7 +664,7 @@ void TestCompactionInGranuleImpl(bool reboots) { TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -674,7 +674,7 @@ void TestCompactionInGranuleImpl(bool reboots) { const TString& data) { bool ok = WriteData(runtime, sender, metaShard, writeId, tableId, data); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } return ok; }; @@ -683,20 +683,20 @@ void TestCompactionInGranuleImpl(bool reboots) { const TVector<ui64>& writeIds) { ProposeCommit(runtime, sender, metaShard, txId, writeIds); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } }; auto planCommit = [&](TTestBasicRuntime& runtime, TActorId& sender, ui64 planStep, ui64 txId) { PlanCommit(runtime, sender, planStep, txId); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } }; // - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; ui64 planStep = 100; @@ -731,7 +731,7 @@ void TestCompactionInGranuleImpl(bool reboots) { } if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } proposeCommit(runtime, sender, metaShard, txId, ids); @@ -759,12 +759,12 @@ void TestCompactionInGranuleImpl(bool reboots) { Proto(read.get()).AddColumnNames("timestamp"); Proto(read.get()).AddColumnNames("message"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -792,7 +792,7 @@ void TestCompactionInGranuleImpl(bool reboots) { UNIT_ASSERT_VALUES_EQUAL(readStats.GetUsedColumns(), 7); // planStep, txId + 4 PK columns + "message" UNIT_ASSERT(readStats.GetIndexPortions() <= 2); // got compaction - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } } @@ -802,13 +802,13 @@ void TestReadWithProgramImpl() TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 tableId = 1; SetupSchema(runtime, sender, tableId); @@ -819,7 +819,7 @@ void TestReadWithProgramImpl() readProto.SetOlapProgramType(::NKikimrSchemeOp::EOlapProgramType::OLAP_PROGRAM_SSA_PROGRAM); readProto.SetOlapProgram("XXXYYYZZZ"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, readEvent); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, readEvent); TAutoPtr<IEventHandle> handle; auto result = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); @@ -827,7 +827,7 @@ void TestReadWithProgramImpl() auto& resRead = Proto(result); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::ERROR); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -842,14 +842,14 @@ void TestReadWithProgramImpl() readProto.SetOlapProgramType(::NKikimrSchemeOp::EOlapProgramType::OLAP_PROGRAM_SSA_PROGRAM_WITH_PARAMETERS); readProto.SetOlapProgram("XXXYYYZZZ"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, readEvent); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, readEvent); TAutoPtr<IEventHandle> handle; auto result = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(result); auto& resRead = Proto(result); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::ERROR); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -906,13 +906,13 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; ui64 planStep = 100; @@ -953,7 +953,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { Proto(read.get()).AddColumnNames("timestamp"); Proto(read.get()).AddColumnNames("message"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); } ui32 expected = 0; @@ -964,7 +964,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -1017,7 +1017,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { less->SetRow(NArrow::SerializeBatchNoCompression(prLess.Batch)); //less->SetInclusive(prLess.Inclusive); TODO - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); } { // one result expected @@ -1025,7 +1025,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -1069,7 +1069,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { greater->SetRow(NArrow::SerializeBatchNoCompression(prGreater.Batch)); //greater->SetInclusive(prGreater.Inclusive); TODO - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); } { // one result expected @@ -1077,7 +1077,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT(resRead.GetData().size() > 0); @@ -1104,7 +1104,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { // TODO: check data } - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } { // Get index stats @@ -1156,13 +1156,13 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; ui64 planStep = 1000000; @@ -1191,14 +1191,14 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { request->Record.AddColumnNames("timestamp"); request->Record.AddColumnNames("message"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, request.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, request.release()); } auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& response = event->Record; - UNIT_ASSERT_VALUES_EQUAL(response.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_VALUES_EQUAL(response.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_VALUES_EQUAL(response.GetTxInitiator(), metaShard); UNIT_ASSERT_VALUES_EQUAL(response.GetStatus(), (ui32)NKikimrTxColumnShard::EResultStatus::ERROR); } @@ -1214,7 +1214,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { request->Record.MutableSnapshot()->SetStep(planStep - staleness.MilliSeconds()); request->Record.MutableSnapshot()->SetTxId(Max<ui64>()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, request.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, request.release()); } auto event = runtime.GrabEdgeEvent<NKqp::TEvKqpCompute::TEvScanError>(handle); @@ -1245,13 +1245,13 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { runtime.SetLogPriority(NKikimrServices::BLOB_CACHE, NActors::NLog::PRI_DEBUG); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::COLUMNSHARD), &CreateColumnShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; @@ -1416,7 +1416,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { Proto(read.get()).AddColumnNames("timestamp"); Proto(read.get()).AddColumnNames("message"); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); ui32 expected = 0; ui32 num = 0; @@ -1425,7 +1425,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); @@ -1471,7 +1471,7 @@ Y_UNIT_TEST_SUITE(TColumnShardTestReadWrite) { UNIT_ASSERT_VALUES_EQUAL(inFlightReads.size(), 1); { auto read = std::make_unique<NColumnShard::TEvPrivate::TEvReadFinished>(*inFlightReads.begin()); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); } // Advance the time and trigger some more compactions and cleanups diff --git a/ydb/core/tx/columnshard/ut_columnshard_schema.cpp b/ydb/core/tx/columnshard/ut_columnshard_schema.cpp index 1c6b5fbb8e3..d2bb656e920 100644 --- a/ydb/core/tx/columnshard/ut_columnshard_schema.cpp +++ b/ydb/core/tx/columnshard/ut_columnshard_schema.cpp @@ -34,7 +34,7 @@ bool TriggerTTL(TTestBasicRuntime& runtime, TActorId& sender, NOlap::TSnapshot s auto event = std::make_unique<TEvColumnShard::TEvProposeTransaction>( NKikimrTxColumnShard::TX_KIND_TTL, sender, snap.TxId, txBody); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, event.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, event.release()); auto ev = runtime.GrabEdgeEvent<TEvColumnShard::TEvProposeTransactionResult>(sender); const auto& res = ev->Get()->Record; UNIT_ASSERT_EQUAL(res.GetTxId(), snap.TxId); @@ -82,7 +82,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) // - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; ui64 planStep = 1000000000; // greater then delays @@ -137,7 +137,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) // TODO: write into path 2 (no ttl) if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } if (internal) { @@ -149,7 +149,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) TAutoPtr<IEventHandle> handle; if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } { @@ -157,12 +157,12 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) auto read = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, Max<ui64>(), tableId); Proto(read.get()).AddColumnNames(TTestSchema::DefaultTtlColumn); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -197,12 +197,12 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) auto read = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, Max<ui64>(), tableId); Proto(read.get()).AddColumnNames(TTestSchema::DefaultTtlColumn); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -232,12 +232,12 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {}) auto read = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, Max<ui64>(), tableId); Proto(read.get()).AddColumnNames(TTestSchema::DefaultTtlColumn); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); @@ -264,7 +264,7 @@ void TestDrop(bool reboots) { // - ui64 metaShard = TTestTxConfig::TxTablet1; + ui64 metaShard = TTestTxConfig::TxTablet1; ui64 writeId = 0; ui64 tableId = 1; ui64 planStep = 1000000000; // greater then delays @@ -297,7 +297,7 @@ void TestDrop(bool reboots) { PlanCommit(runtime, sender, ++planStep, txId); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } // Drop table @@ -306,7 +306,7 @@ void TestDrop(bool reboots) { PlanSchemaTx(runtime, sender, {planStep, txId}); if (reboots) { - RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); + RebootTablet(runtime, TTestTxConfig::TxTablet0, sender); } TAutoPtr<IEventHandle> handle; @@ -315,12 +315,12 @@ void TestDrop(bool reboots) { auto read = std::make_unique<TEvColumnShard::TEvRead>(sender, metaShard, planStep, Max<ui64>(), tableId); Proto(read.get()).AddColumnNames(TTestSchema::DefaultTtlColumn); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, read.release()); auto event = runtime.GrabEdgeEvent<TEvColumnShard::TEvReadResult>(handle); UNIT_ASSERT(event); auto& resRead = Proto(event); - UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(resRead.GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(resRead.GetTxInitiator(), metaShard); UNIT_ASSERT_EQUAL(resRead.GetStatus(), NKikimrTxColumnShard::EResultStatus::SUCCESS); UNIT_ASSERT_EQUAL(resRead.GetBatch(), 0); diff --git a/ydb/core/tx/datashard/change_sender_async_index.cpp b/ydb/core/tx/datashard/change_sender_async_index.cpp index 3451ea4ccfa..1bc6796dbf6 100644 --- a/ydb/core/tx/datashard/change_sender_async_index.cpp +++ b/ydb/core/tx/datashard/change_sender_async_index.cpp @@ -51,7 +51,7 @@ class TAsyncIndexChangeSenderShard: public TActorBootstrapped<TAsyncIndexChangeS void Handle(TEvTxUserProxy::TEvGetProxyServicesResponse::TPtr& ev) { LOG_D("Handle " << ev->Get()->ToString()); - LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; + LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; Handshake(); } @@ -62,7 +62,7 @@ class TAsyncIndexChangeSenderShard: public TActorBootstrapped<TAsyncIndexChangeS ev->Record.SetOrigin(DataShard.TabletId); ev->Record.SetGeneration(DataShard.Generation); - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), ShardId, true)); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(ev.Release(), ShardId, true)); Become(&TThis::StateHandshake); } @@ -126,7 +126,7 @@ class TAsyncIndexChangeSenderShard: public TActorBootstrapped<TAsyncIndexChangeS return Ready(); } - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(records.Release(), ShardId, false)); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(records.Release(), ShardId, false)); Become(&TThis::StateWaitingStatus); } @@ -236,7 +236,7 @@ private: const TMap<TTag, TTag> TagMap; // from main to index mutable TMaybe<TString> LogPrefix; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; ui64 LastRecordOrder; }; // TAsyncIndexChangeSenderShard diff --git a/ydb/core/tx/datashard/check_scheme_tx_unit.cpp b/ydb/core/tx/datashard/check_scheme_tx_unit.cpp index 2539efe549f..bbba1c6d95d 100644 --- a/ydb/core/tx/datashard/check_scheme_tx_unit.cpp +++ b/ydb/core/tx/datashard/check_scheme_tx_unit.cpp @@ -442,9 +442,9 @@ bool TCheckSchemeTxUnit::CheckAlter(TActiveTransaction *activeTx) return false; } - if (DataShard.IsFollower()) { + if (DataShard.IsFollower()) { LOG_DEBUG_S(TActivationContext::AsActorContext(), NKikimrServices::TX_DATASHARD, - "Ignoring alter, attempt to freeze follower, tablet " << DataShard.TabletID() + "Ignoring alter, attempt to freeze follower, tablet " << DataShard.TabletID() << " txId " << activeTx->GetTxId() << " currentTxId " << Pipeline.CurrentSchemaTxId()); BuildResult(activeTx, NKikimrTxDataShard::TEvProposeTransactionResult::BAD_REQUEST); diff --git a/ydb/core/tx/datashard/datashard.cpp b/ydb/core/tx/datashard/datashard.cpp index 6c24cb8bc85..d86568b4a15 100644 --- a/ydb/core/tx/datashard/datashard.cpp +++ b/ydb/core/tx/datashard/datashard.cpp @@ -8,8 +8,8 @@ #include <library/cpp/monlib/service/pages/templates.h> -#include <contrib/libs/apache/arrow/cpp/src/arrow/api.h> - +#include <contrib/libs/apache/arrow/cpp/src/arrow/api.h> + namespace NKikimr { IActor* CreateDataShard(const TActorId &tablet, TTabletStorageInfo *info) { @@ -176,7 +176,7 @@ void TDataShard::OnTabletStop(TEvTablet::TEvTabletStop::TPtr &ev, const TActorCo LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "OnTabletStop: " << TabletID() << " reason = " << msg->GetReason()); - if (!IsFollower() && GetState() == TShardState::Ready) { + if (!IsFollower() && GetState() == TShardState::Ready) { if (!Stopping) { Stopping = true; OnStopGuardStarting(ctx); @@ -301,7 +301,7 @@ void TDataShard::OnActivateExecutor(const TActorContext& ctx) { AppData(ctx)->Icb->RegisterSharedControl(BackupReadAheadLo, "DataShardControls.BackupReadAheadLo"); AppData(ctx)->Icb->RegisterSharedControl(BackupReadAheadHi, "DataShardControls.BackupReadAheadHi"); - // OnActivateExecutor might be called multiple times for a follower + // OnActivateExecutor might be called multiple times for a follower // but the counters should be initialized only once if (TabletCountersPtr) { Executor()->RegisterExternalTabletCounters(TabletCountersPtr); @@ -310,16 +310,16 @@ void TDataShard::OnActivateExecutor(const TActorContext& ctx) { AllocCounters = TAlignedPagePoolCounters(AppData(ctx)->Counters, "datashard"); - if (!Executor()->GetStats().IsFollower) { + if (!Executor()->GetStats().IsFollower) { Execute(CreateTxInitSchema(), ctx); Become(&TThis::StateInactive); } else { SyncConfig(); State = TShardState::Readonly; - FollowerState = { }; - Become(&TThis::StateWorkAsFollower); + FollowerState = { }; + Become(&TThis::StateWorkAsFollower); SignalTabletActive(ctx); - LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "Follower switched to work state: " << TabletID()); + LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "Follower switched to work state: " << TabletID()); } } @@ -697,18 +697,18 @@ void TDataShard::PersistUserTable(NIceDb::TNiceDb& db, ui64 tableId, const TUser NIceDb::TUpdate<Schema::UserTables::Schema>(tableInfo.GetSchema())); } -void TDataShard::PersistUserTableFullCompactionTs(NIceDb::TNiceDb& db, ui64 tableId, ui64 ts) { - db.Table<Schema::UserTablesStats>().Key(tableId).Update<Schema::UserTablesStats::FullCompactionTs>(ts); -} - +void TDataShard::PersistUserTableFullCompactionTs(NIceDb::TNiceDb& db, ui64 tableId, ui64 ts) { + db.Table<Schema::UserTablesStats>().Key(tableId).Update<Schema::UserTablesStats::FullCompactionTs>(ts); +} + void TDataShard::PersistMoveUserTable(NIceDb::TNiceDb& db, ui64 prevTableId, ui64 tableId, const TUserTable& tableInfo) { db.Table<Schema::UserTables>().Key(prevTableId).Delete(); PersistUserTable(db, tableId, tableInfo); - - db.Table<Schema::UserTablesStats>().Key(prevTableId).Delete(); - if (tableInfo.Stats.LastFullCompaction) { - PersistUserTableFullCompactionTs(db, tableId, tableInfo.Stats.LastFullCompaction.Seconds()); - } + + db.Table<Schema::UserTablesStats>().Key(prevTableId).Delete(); + if (tableInfo.Stats.LastFullCompaction) { + PersistUserTableFullCompactionTs(db, tableId, tableInfo.Stats.LastFullCompaction.Seconds()); + } } TUserTable::TPtr TDataShard::AlterTableSchemaVersion( @@ -979,7 +979,7 @@ void TDataShard::DropUserTable(TTransactionContext& txc, ui64 tableId) { txc.DB.Alter().DropTable(ti->second->ShadowTid); } db.Table<Schema::UserTables>().Key(ti->first).Delete(); - db.Table<Schema::UserTablesStats>().Key(ti->first).Delete(); + db.Table<Schema::UserTablesStats>().Key(ti->first).Delete(); TableInfos.erase(ti); } @@ -1000,7 +1000,7 @@ void TDataShard::DropAllUserTables(TTransactionContext& txc) { SnapshotManager.PersistRemoveAllSnapshots(db); for (const auto& ti : TableInfos) { db.Table<Schema::UserTables>().Key(ti.first).Delete(); - db.Table<Schema::UserTablesStats>().Key(ti.first).Delete(); + db.Table<Schema::UserTablesStats>().Key(ti.first).Delete(); } TableInfos.clear(); @@ -1294,37 +1294,37 @@ NKikimrTxDataShard::TError::EKind ConvertErrCode(NMiniKQL::IEngineFlat::EResult } } -Ydb::StatusIds::StatusCode ConvertToYdbStatusCode(NKikimrTxDataShard::TError::EKind code) { - switch (code) { - case NKikimrTxDataShard::TError::OK: - return Ydb::StatusIds::SUCCESS; - case NKikimrTxDataShard::TError::BAD_TX_KIND: - case NKikimrTxDataShard::TError::SCHEME_ERROR: - case NKikimrTxDataShard::TError::WRONG_PAYLOAD_TYPE: - case NKikimrTxDataShard::TError::LEAF_REQUIRED: - case NKikimrTxDataShard::TError::WRONG_SHARD_STATE: - case NKikimrTxDataShard::TError::PROGRAM_ERROR: - case NKikimrTxDataShard::TError::OUT_OF_SPACE: - case NKikimrTxDataShard::TError::READ_SIZE_EXECEEDED: - case NKikimrTxDataShard::TError::SHARD_IS_BLOCKED: - case NKikimrTxDataShard::TError::UNKNOWN: - case NKikimrTxDataShard::TError::REPLY_SIZE_EXECEEDED: - case NKikimrTxDataShard::TError::EXECUTION_CANCELLED: - return Ydb::StatusIds::INTERNAL_ERROR; - case NKikimrTxDataShard::TError::BAD_ARGUMENT: - case NKikimrTxDataShard::TError::READONLY: - case NKikimrTxDataShard::TError::SNAPSHOT_NOT_READY_YET: - case NKikimrTxDataShard::TError::SCHEME_CHANGED: - case NKikimrTxDataShard::TError::DUPLICATED_SNAPSHOT_POLICY: - case NKikimrTxDataShard::TError::MISSING_SNAPSHOT_POLICY: - return Ydb::StatusIds::BAD_REQUEST; - case NKikimrTxDataShard::TError::SNAPSHOT_NOT_EXIST: - return Ydb::StatusIds::NOT_FOUND; - default: - return Ydb::StatusIds::GENERIC_ERROR; - } -} - +Ydb::StatusIds::StatusCode ConvertToYdbStatusCode(NKikimrTxDataShard::TError::EKind code) { + switch (code) { + case NKikimrTxDataShard::TError::OK: + return Ydb::StatusIds::SUCCESS; + case NKikimrTxDataShard::TError::BAD_TX_KIND: + case NKikimrTxDataShard::TError::SCHEME_ERROR: + case NKikimrTxDataShard::TError::WRONG_PAYLOAD_TYPE: + case NKikimrTxDataShard::TError::LEAF_REQUIRED: + case NKikimrTxDataShard::TError::WRONG_SHARD_STATE: + case NKikimrTxDataShard::TError::PROGRAM_ERROR: + case NKikimrTxDataShard::TError::OUT_OF_SPACE: + case NKikimrTxDataShard::TError::READ_SIZE_EXECEEDED: + case NKikimrTxDataShard::TError::SHARD_IS_BLOCKED: + case NKikimrTxDataShard::TError::UNKNOWN: + case NKikimrTxDataShard::TError::REPLY_SIZE_EXECEEDED: + case NKikimrTxDataShard::TError::EXECUTION_CANCELLED: + return Ydb::StatusIds::INTERNAL_ERROR; + case NKikimrTxDataShard::TError::BAD_ARGUMENT: + case NKikimrTxDataShard::TError::READONLY: + case NKikimrTxDataShard::TError::SNAPSHOT_NOT_READY_YET: + case NKikimrTxDataShard::TError::SCHEME_CHANGED: + case NKikimrTxDataShard::TError::DUPLICATED_SNAPSHOT_POLICY: + case NKikimrTxDataShard::TError::MISSING_SNAPSHOT_POLICY: + return Ydb::StatusIds::BAD_REQUEST; + case NKikimrTxDataShard::TError::SNAPSHOT_NOT_EXIST: + return Ydb::StatusIds::NOT_FOUND; + default: + return Ydb::StatusIds::GENERIC_ERROR; + } +} + void TDataShard::Handle(TEvents::TEvGone::TPtr &ev) { Actors.erase(ev->Sender); } @@ -1738,7 +1738,7 @@ void TDataShard::Handle(TEvPrivate::TEvPersistScanState::TPtr& ev, const TActorC } void TDataShard::Handle(TEvTabletPipe::TEvClientConnected::TPtr &ev, const TActorContext &ctx) { - Y_VERIFY(ev->Get()->Leader, "Unexpectedly connected to follower of tablet %" PRIu64, ev->Get()->TabletId); + Y_VERIFY(ev->Get()->Leader, "Unexpectedly connected to follower of tablet %" PRIu64, ev->Get()->TabletId); if (ev->Get()->ClientId == SchemeShardPipe) { if (!TransQueue.HasNotAckedSchemaTx()) { @@ -1887,7 +1887,7 @@ void TDataShard::AckRSToDeletedTablet(ui64 tabletId, const TActorContext& ctx) { void TDataShard::Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev, const TActorContext &ctx) { Y_UNUSED(ev); Y_UNUSED(ctx); LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, "Server connected at tablet %s %" PRIu64 , - Executor()->GetStats().IsFollower ? "follower" : "leader", ev->Get()->TabletId); + Executor()->GetStats().IsFollower ? "follower" : "leader", ev->Get()->TabletId); } void TDataShard::Handle(TEvTabletPipe::TEvServerDisconnected::TPtr &ev, const TActorContext &ctx) { @@ -2510,7 +2510,7 @@ void TDataShard::Handle(TEvDataShard::TEvUnsafeUploadRowsRequest::TPtr& ev, cons } void TDataShard::ScanComplete(NTable::EAbort, - TAutoPtr<IDestructable> prod, + TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx) { @@ -2626,112 +2626,112 @@ void TDataShard::Handle(TEvDataShard::TEvGetRemovedRowVersions::TPtr& ev, const Execute(new TTxGetRemovedRowVersions(this, std::move(ev)), ctx); } -} // NDataShard - -TString TEvDataShard::TEvRead::ToString() const { - TStringStream ss; - ss << TBase::ToString(); - if (!Keys.empty()) { - ss << " KeysSize: " << Keys.size(); - } - if (!Ranges.empty()) { - ss << " RangesSize: " << Ranges.size(); - } - return ss.Str(); -} - -NActors::IEventBase* TEvDataShard::TEvRead::Load(TEventSerializedData* data) { - auto* base = TBase::Load(data); - auto* event = static_cast<TEvRead*>(base); - auto& record = event->Record; - - event->Keys.reserve(record.KeysSize()); - for (const auto& key: record.GetKeys()) { - event->Keys.emplace_back(key); - } - - event->Ranges.reserve(record.RangesSize()); - for (const auto& range: record.GetRanges()) { - event->Ranges.emplace_back(range); - } - - return base; -} - -// really ugly hacky, because Record is not mutable and calling members are const -void TEvDataShard::TEvRead::FillRecord() { - if (!Keys.empty()) { - Record.MutableKeys()->Reserve(Keys.size()); - for (auto& key: Keys) { - Record.AddKeys(key.ReleaseBuffer()); - } - Keys.clear(); - } - - if (!Ranges.empty()) { - Record.MutableRanges()->Reserve(Ranges.size()); - for (auto& range: Ranges) { - auto* pbRange = Record.AddRanges(); - range.Serialize(*pbRange); - } - Ranges.clear(); - } -} - -TString TEvDataShard::TEvReadResult::ToString() const { - TStringStream ss; - ss << TBase::ToString(); - - if (ArrowBatch) { - ss << " ArrowRows: " << ArrowBatch->num_rows() - << " ArrowCols: " << ArrowBatch->num_columns(); - } - - if (!Rows.empty()) { - ss << " RowsSize: " << Rows.size(); - } - - return ss.Str(); -} - -NActors::IEventBase* TEvDataShard::TEvReadResult::Load(TEventSerializedData* data) { - auto* base = TBase::Load(data); - auto* event = static_cast<TEvReadResult*>(base); - auto& record = event->Record; - - if (record.HasArrowBatch()) { - const auto& batch = record.GetArrowBatch(); - auto schema = NArrow::DeserializeSchema(batch.GetSchema()); - event->ArrowBatch = NArrow::DeserializeBatch(batch.GetBatch(), schema); - record.ClearArrowBatch(); - } else if (record.HasCellVec()) { - auto& batch = *record.MutableCellVec(); - event->RowsSerialized.reserve(batch.RowsSize()); - for (auto& row: *batch.MutableRows()) { - event->RowsSerialized.emplace_back(std::move(row)); - } - record.ClearCellVec(); - } - - return base; -} - -void TEvDataShard::TEvReadResult::FillRecord() { - if (ArrowBatch) { - auto* protoBatch = Record.MutableArrowBatch(); - protoBatch->SetSchema(NArrow::SerializeSchema(*ArrowBatch->schema())); - protoBatch->SetBatch(NArrow::SerializeBatchNoCompression(ArrowBatch)); - ArrowBatch.reset(); - return; - } else if (!Rows.empty()) { - auto* protoBatch = Record.MutableCellVec(); - protoBatch->MutableRows()->Reserve(Rows.size()); - for (const auto& row: Rows) { - protoBatch->AddRows(TSerializedCellVec::Serialize(row)); - } - Rows.clear(); - return; - } -} - -} // NKikimr +} // NDataShard + +TString TEvDataShard::TEvRead::ToString() const { + TStringStream ss; + ss << TBase::ToString(); + if (!Keys.empty()) { + ss << " KeysSize: " << Keys.size(); + } + if (!Ranges.empty()) { + ss << " RangesSize: " << Ranges.size(); + } + return ss.Str(); +} + +NActors::IEventBase* TEvDataShard::TEvRead::Load(TEventSerializedData* data) { + auto* base = TBase::Load(data); + auto* event = static_cast<TEvRead*>(base); + auto& record = event->Record; + + event->Keys.reserve(record.KeysSize()); + for (const auto& key: record.GetKeys()) { + event->Keys.emplace_back(key); + } + + event->Ranges.reserve(record.RangesSize()); + for (const auto& range: record.GetRanges()) { + event->Ranges.emplace_back(range); + } + + return base; +} + +// really ugly hacky, because Record is not mutable and calling members are const +void TEvDataShard::TEvRead::FillRecord() { + if (!Keys.empty()) { + Record.MutableKeys()->Reserve(Keys.size()); + for (auto& key: Keys) { + Record.AddKeys(key.ReleaseBuffer()); + } + Keys.clear(); + } + + if (!Ranges.empty()) { + Record.MutableRanges()->Reserve(Ranges.size()); + for (auto& range: Ranges) { + auto* pbRange = Record.AddRanges(); + range.Serialize(*pbRange); + } + Ranges.clear(); + } +} + +TString TEvDataShard::TEvReadResult::ToString() const { + TStringStream ss; + ss << TBase::ToString(); + + if (ArrowBatch) { + ss << " ArrowRows: " << ArrowBatch->num_rows() + << " ArrowCols: " << ArrowBatch->num_columns(); + } + + if (!Rows.empty()) { + ss << " RowsSize: " << Rows.size(); + } + + return ss.Str(); +} + +NActors::IEventBase* TEvDataShard::TEvReadResult::Load(TEventSerializedData* data) { + auto* base = TBase::Load(data); + auto* event = static_cast<TEvReadResult*>(base); + auto& record = event->Record; + + if (record.HasArrowBatch()) { + const auto& batch = record.GetArrowBatch(); + auto schema = NArrow::DeserializeSchema(batch.GetSchema()); + event->ArrowBatch = NArrow::DeserializeBatch(batch.GetBatch(), schema); + record.ClearArrowBatch(); + } else if (record.HasCellVec()) { + auto& batch = *record.MutableCellVec(); + event->RowsSerialized.reserve(batch.RowsSize()); + for (auto& row: *batch.MutableRows()) { + event->RowsSerialized.emplace_back(std::move(row)); + } + record.ClearCellVec(); + } + + return base; +} + +void TEvDataShard::TEvReadResult::FillRecord() { + if (ArrowBatch) { + auto* protoBatch = Record.MutableArrowBatch(); + protoBatch->SetSchema(NArrow::SerializeSchema(*ArrowBatch->schema())); + protoBatch->SetBatch(NArrow::SerializeBatchNoCompression(ArrowBatch)); + ArrowBatch.reset(); + return; + } else if (!Rows.empty()) { + auto* protoBatch = Record.MutableCellVec(); + protoBatch->MutableRows()->Reserve(Rows.size()); + for (const auto& row: Rows) { + protoBatch->AddRows(TSerializedCellVec::Serialize(row)); + } + Rows.clear(); + return; + } +} + +} // NKikimr diff --git a/ydb/core/tx/datashard/datashard.h b/ydb/core/tx/datashard/datashard.h index e7eb76ac5f8..5a93c035026 100644 --- a/ydb/core/tx/datashard/datashard.h +++ b/ydb/core/tx/datashard/datashard.h @@ -6,20 +6,20 @@ #include <ydb/core/tx/message_seqno.h> #include <ydb/core/base/domain.h> #include <ydb/core/base/row_version.h> -#include <ydb/core/scheme/scheme_tabledefs.h> -#include <ydb/core/scheme/scheme_tablecell.h> +#include <ydb/core/scheme/scheme_tabledefs.h> +#include <ydb/core/scheme/scheme_tablecell.h> #include <ydb/core/scheme/scheme_type_registry.h> #include <ydb/core/protos/tx_datashard.pb.h> #include <ydb/core/tablet_flat/flat_row_versions.h> - + #include <library/cpp/time_provider/time_provider.h> -namespace arrow { - -class RecordBatch; - -} - +namespace arrow { + +class RecordBatch; + +} + namespace NKikimr { namespace NDataShard { @@ -284,20 +284,20 @@ struct TEvDataShard { EvGetRemovedRowVersions, /* for tests */ EvGetRemovedRowVersionsResult, /* for tests */ - EvCompactTable, - EvCompactTableResult, - + EvCompactTable, + EvCompactTableResult, + EvCompactBorrowed, /* +60 */ - EvGetCompactTableStats, /* for tests */ - EvGetCompactTableStatsResult, /* for tests */ - - EvRead, - EvReadResult, - EvReadContinue, - EvReadAck, - EvReadCancel, - + EvGetCompactTableStats, /* for tests */ + EvGetCompactTableStatsResult, /* for tests */ + + EvRead, + EvReadResult, + EvReadContinue, + EvReadAck, + EvReadCancel, + EvEnd }; @@ -875,134 +875,134 @@ struct TEvDataShard { } }; - // In most cases this event is local, thus users must - // use Keys, Ranges and Program struct members instead of corresponding - // protobuf members. In case of remote event these struct members will - // be serialized and deserialized. - struct TEvRead : public TEventPB<TEvRead, - NKikimrTxDataShard::TEvRead, - TEvDataShard::EvRead> { - using TBase = TEventPB<TEvRead, - NKikimrTxDataShard::TEvRead, - TEvDataShard::EvRead>; - - TEvRead() = default; - - TString ToString() const override; - - ui32 CalculateSerializedSize() const override { - const_cast<TEvRead*>(this)->FillRecord(); - return TBase::CalculateSerializedSize(); - } - - bool SerializeToArcadiaStream(NActors::TChunkSerializer* chunker) const override { - const_cast<TEvRead*>(this)->FillRecord(); - return TBase::SerializeToArcadiaStream(chunker); - } - - static NActors::IEventBase* Load(TEventSerializedData* data); - - private: - void FillRecord(); - - public: - // Either one of Keys, Ranges or Record.Program is allowed - - // TODO: consider TOwnedCellVec depending on kqp - TVector<TSerializedCellVec> Keys; - - // In current kqp impl ranges are already in TSerializedTableRange - // format, thus same format here - TVector<TSerializedTableRange> Ranges; - }; - - struct TEvReadResult : public TEventPB<TEvReadResult, - NKikimrTxDataShard::TEvReadResult, - TEvDataShard::EvReadResult> { - using TBase = TEventPB<TEvReadResult, - NKikimrTxDataShard::TEvReadResult, - TEvDataShard::EvReadResult>; - - TEvReadResult() = default; - - TString ToString() const override; - - ui32 CalculateSerializedSize() const override { - const_cast<TEvReadResult*>(this)->FillRecord(); - return TBase::CalculateSerializedSize(); - } - - bool SerializeToArcadiaStream(NActors::TChunkSerializer* chunker) const override { - const_cast<TEvReadResult*>(this)->FillRecord(); - return TBase::SerializeToArcadiaStream(chunker); - } - - static NActors::IEventBase* Load(TEventSerializedData* data); - - private: - void FillRecord(); - - public: - // CellVec (TODO: add schema?) - - size_t GetRowsCount() const { - return Rows.size() + RowsSerialized.size(); - } - - TConstArrayRef<TCell> GetCells(size_t row) const { - if (!Rows.empty()) { - return Rows[row]; - } - return RowsSerialized[row].GetCells(); - } - - void SetRows(TVector<TOwnedCellVec>&& rows) { - Rows = std::move(rows); - } - - // Arrow - - std::shared_ptr<arrow::RecordBatch> ArrowBatch; - - private: - // for local events - TVector<TOwnedCellVec> Rows; - - // for remote events to avoid extra copying - TVector<TSerializedCellVec> RowsSerialized; - }; - - struct TEvReadContinue : public TEventLocal<TEvReadContinue, TEvDataShard::EvReadContinue> { - TActorId Reader; - ui64 ReadId; - - TEvReadContinue(TActorId reader, ui64 readId) - : Reader(reader) - , ReadId(readId) - {} - }; - - struct TEvReadAck : public TEventPB<TEvReadAck, - NKikimrTxDataShard::TEvReadAck, - TEvDataShard::EvReadAck> { - TEvReadAck() = default; - }; - - struct TEvReadCancel : public TEventPB<TEvReadCancel, - NKikimrTxDataShard::TEvReadCancel, - TEvDataShard::EvReadCancel> { - TEvReadCancel() = default; - }; - + // In most cases this event is local, thus users must + // use Keys, Ranges and Program struct members instead of corresponding + // protobuf members. In case of remote event these struct members will + // be serialized and deserialized. + struct TEvRead : public TEventPB<TEvRead, + NKikimrTxDataShard::TEvRead, + TEvDataShard::EvRead> { + using TBase = TEventPB<TEvRead, + NKikimrTxDataShard::TEvRead, + TEvDataShard::EvRead>; + + TEvRead() = default; + + TString ToString() const override; + + ui32 CalculateSerializedSize() const override { + const_cast<TEvRead*>(this)->FillRecord(); + return TBase::CalculateSerializedSize(); + } + + bool SerializeToArcadiaStream(NActors::TChunkSerializer* chunker) const override { + const_cast<TEvRead*>(this)->FillRecord(); + return TBase::SerializeToArcadiaStream(chunker); + } + + static NActors::IEventBase* Load(TEventSerializedData* data); + + private: + void FillRecord(); + + public: + // Either one of Keys, Ranges or Record.Program is allowed + + // TODO: consider TOwnedCellVec depending on kqp + TVector<TSerializedCellVec> Keys; + + // In current kqp impl ranges are already in TSerializedTableRange + // format, thus same format here + TVector<TSerializedTableRange> Ranges; + }; + + struct TEvReadResult : public TEventPB<TEvReadResult, + NKikimrTxDataShard::TEvReadResult, + TEvDataShard::EvReadResult> { + using TBase = TEventPB<TEvReadResult, + NKikimrTxDataShard::TEvReadResult, + TEvDataShard::EvReadResult>; + + TEvReadResult() = default; + + TString ToString() const override; + + ui32 CalculateSerializedSize() const override { + const_cast<TEvReadResult*>(this)->FillRecord(); + return TBase::CalculateSerializedSize(); + } + + bool SerializeToArcadiaStream(NActors::TChunkSerializer* chunker) const override { + const_cast<TEvReadResult*>(this)->FillRecord(); + return TBase::SerializeToArcadiaStream(chunker); + } + + static NActors::IEventBase* Load(TEventSerializedData* data); + + private: + void FillRecord(); + + public: + // CellVec (TODO: add schema?) + + size_t GetRowsCount() const { + return Rows.size() + RowsSerialized.size(); + } + + TConstArrayRef<TCell> GetCells(size_t row) const { + if (!Rows.empty()) { + return Rows[row]; + } + return RowsSerialized[row].GetCells(); + } + + void SetRows(TVector<TOwnedCellVec>&& rows) { + Rows = std::move(rows); + } + + // Arrow + + std::shared_ptr<arrow::RecordBatch> ArrowBatch; + + private: + // for local events + TVector<TOwnedCellVec> Rows; + + // for remote events to avoid extra copying + TVector<TSerializedCellVec> RowsSerialized; + }; + + struct TEvReadContinue : public TEventLocal<TEvReadContinue, TEvDataShard::EvReadContinue> { + TActorId Reader; + ui64 ReadId; + + TEvReadContinue(TActorId reader, ui64 readId) + : Reader(reader) + , ReadId(readId) + {} + }; + + struct TEvReadAck : public TEventPB<TEvReadAck, + NKikimrTxDataShard::TEvReadAck, + TEvDataShard::EvReadAck> { + TEvReadAck() = default; + }; + + struct TEvReadCancel : public TEventPB<TEvReadCancel, + NKikimrTxDataShard::TEvReadCancel, + TEvDataShard::EvReadCancel> { + TEvReadCancel() = default; + }; + struct TEvReadColumnsRequest : public TEventPB<TEvReadColumnsRequest, - NKikimrTxDataShard::TEvReadColumnsRequest, - TEvDataShard::EvReadColumnsRequest> { + NKikimrTxDataShard::TEvReadColumnsRequest, + TEvDataShard::EvReadColumnsRequest> { TEvReadColumnsRequest() = default; }; struct TEvReadColumnsResponse : public TEventPB<TEvReadColumnsResponse, - NKikimrTxDataShard::TEvReadColumnsResponse, - TEvDataShard::EvReadColumnsResponse> { + NKikimrTxDataShard::TEvReadColumnsResponse, + TEvDataShard::EvReadColumnsResponse> { TEvReadColumnsResponse() = default; explicit TEvReadColumnsResponse(ui64 tabletId, ui32 status = NKikimrTxDataShard::TError::OK) { @@ -1369,31 +1369,31 @@ struct TEvDataShard { : RemovedRowVersions(removedRowVersions) { } }; - - struct TEvCompactTable : public TEventPB<TEvCompactTable, NKikimrTxDataShard::TEvCompactTable, - TEvDataShard::EvCompactTable> { - TEvCompactTable() = default; - TEvCompactTable(ui64 ownerId, ui64 localId) { - Record.MutablePathId()->SetOwnerId(ownerId); - Record.MutablePathId()->SetLocalId(localId); - } - }; - - struct TEvCompactTableResult : public TEventPB<TEvCompactTableResult, NKikimrTxDataShard::TEvCompactTableResult, - TEvDataShard::EvCompactTableResult> { - TEvCompactTableResult() = default; - - TEvCompactTableResult(ui64 tabletId, const TPathId& pathId, NKikimrTxDataShard::TEvCompactTableResult::EStatus status) - : TEvCompactTableResult(tabletId, pathId.OwnerId, pathId.LocalPathId, status) - { } - - TEvCompactTableResult(ui64 tabletId, ui64 ownerId, ui64 localId, NKikimrTxDataShard::TEvCompactTableResult::EStatus status) { - Record.SetTabletId(tabletId); - Record.MutablePathId()->SetOwnerId(ownerId); - Record.MutablePathId()->SetLocalId(localId); - Record.SetStatus(status); - } - }; + + struct TEvCompactTable : public TEventPB<TEvCompactTable, NKikimrTxDataShard::TEvCompactTable, + TEvDataShard::EvCompactTable> { + TEvCompactTable() = default; + TEvCompactTable(ui64 ownerId, ui64 localId) { + Record.MutablePathId()->SetOwnerId(ownerId); + Record.MutablePathId()->SetLocalId(localId); + } + }; + + struct TEvCompactTableResult : public TEventPB<TEvCompactTableResult, NKikimrTxDataShard::TEvCompactTableResult, + TEvDataShard::EvCompactTableResult> { + TEvCompactTableResult() = default; + + TEvCompactTableResult(ui64 tabletId, const TPathId& pathId, NKikimrTxDataShard::TEvCompactTableResult::EStatus status) + : TEvCompactTableResult(tabletId, pathId.OwnerId, pathId.LocalPathId, status) + { } + + TEvCompactTableResult(ui64 tabletId, ui64 ownerId, ui64 localId, NKikimrTxDataShard::TEvCompactTableResult::EStatus status) { + Record.SetTabletId(tabletId); + Record.MutablePathId()->SetOwnerId(ownerId); + Record.MutablePathId()->SetLocalId(localId); + Record.SetStatus(status); + } + }; /** * This message is used to ask datashard to compact any borrowed parts it has @@ -1414,20 +1414,20 @@ struct TEvDataShard { "EvCompactBorrowed event has an unexpected value"); }; - struct TEvGetCompactTableStats : public TEventPB<TEvGetCompactTableStats, NKikimrTxDataShard::TEvGetCompactTableStats, - TEvDataShard::EvGetCompactTableStats> { - TEvGetCompactTableStats() = default; - TEvGetCompactTableStats(ui64 ownerId, ui64 localId) { - Record.MutablePathId()->SetOwnerId(ownerId); - Record.MutablePathId()->SetLocalId(localId); - } - }; - - struct TEvGetCompactTableStatsResult : public TEventPB<TEvGetCompactTableStatsResult, NKikimrTxDataShard::TEvGetCompactTableStatsResult, - TEvDataShard::EvGetCompactTableStatsResult> { - TEvGetCompactTableStatsResult() = default; - }; - + struct TEvGetCompactTableStats : public TEventPB<TEvGetCompactTableStats, NKikimrTxDataShard::TEvGetCompactTableStats, + TEvDataShard::EvGetCompactTableStats> { + TEvGetCompactTableStats() = default; + TEvGetCompactTableStats(ui64 ownerId, ui64 localId) { + Record.MutablePathId()->SetOwnerId(ownerId); + Record.MutablePathId()->SetLocalId(localId); + } + }; + + struct TEvGetCompactTableStatsResult : public TEventPB<TEvGetCompactTableStatsResult, NKikimrTxDataShard::TEvGetCompactTableStatsResult, + TEvDataShard::EvGetCompactTableStatsResult> { + TEvGetCompactTableStatsResult() = default; + }; + struct TEvApplyReplicationChanges : public TEventPB<TEvApplyReplicationChanges, NKikimrTxDataShard::TEvApplyReplicationChanges, diff --git a/ydb/core/tx/datashard/datashard__build_index.cpp b/ydb/core/tx/datashard/datashard__build_index.cpp index 456b9e5741f..5aebf94dc51 100644 --- a/ydb/core/tx/datashard/datashard__build_index.cpp +++ b/ydb/core/tx/datashard/datashard__build_index.cpp @@ -254,7 +254,7 @@ public: ~TBuildIndexScan() override = default; - THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme>) noexcept override { + THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme>) noexcept override { auto selfActorId = TActivationContext::AsActorContext().RegisterWithSameMailbox(this); auto ctx = TActivationContext::AsActorContext().MakeFor(selfActorId); @@ -332,7 +332,7 @@ public: return EScan::Feed; } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { auto ctx = TActivationContext::AsActorContext().MakeFor(SelfId()); if (Uploader) { @@ -527,7 +527,7 @@ private: } }; -TAutoPtr<NTable::IScan> CreateBuildIndexScan( +TAutoPtr<NTable::IScan> CreateBuildIndexScan( ui64 buildIndexId, TString target, const TBuildIndexRecord::TSeqNo& seqNo, diff --git a/ydb/core/tx/datashard/datashard__cancel_tx_proposal.cpp b/ydb/core/tx/datashard/datashard__cancel_tx_proposal.cpp index f428d55d56d..ff950f6a597 100644 --- a/ydb/core/tx/datashard/datashard__cancel_tx_proposal.cpp +++ b/ydb/core/tx/datashard/datashard__cancel_tx_proposal.cpp @@ -13,9 +13,9 @@ TDataShard::TTxCancelTransactionProposal::TTxCancelTransactionProposal(TDataShar bool TDataShard::TTxCancelTransactionProposal::Execute(TTransactionContext &txc, const TActorContext &ctx) { - if (Self->IsFollower()) { + if (Self->IsFollower()) { LOG_ERROR_S(ctx, NKikimrServices::TX_DATASHARD, - "Unexpected TTxCancelTransactionProposal at tablet follower " + "Unexpected TTxCancelTransactionProposal at tablet follower " << Self->TabletID() << " txId " << TxId); return true; } diff --git a/ydb/core/tx/datashard/datashard__compaction.cpp b/ydb/core/tx/datashard/datashard__compaction.cpp index 1ccb7c14935..7ab0bfeca57 100644 --- a/ydb/core/tx/datashard/datashard__compaction.cpp +++ b/ydb/core/tx/datashard/datashard__compaction.cpp @@ -1,103 +1,103 @@ -#include "datashard_impl.h" - -namespace NKikimr { +#include "datashard_impl.h" + +namespace NKikimr { namespace NDataShard { - + class TDataShard::TTxCompactTable : public NTabletFlatExecutor::TTransactionBase<TDataShard> { -private: - TEvDataShard::TEvCompactTable::TPtr Ev; - -public: +private: + TEvDataShard::TEvCompactTable::TPtr Ev; + +public: TTxCompactTable(TDataShard* ds, TEvDataShard::TEvCompactTable::TPtr ev) - : TBase(ds) - , Ev(ev) - {} - - TTxType GetTxType() const override { return TXTYPE_COMPACT_TABLE; } - - bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { - auto& record = Ev->Get()->Record; - - if (!Self->IsStateActive()) { - LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, - "Background compaction tx at non-ready tablet " << Self->TabletID() - << " state " << Self->State - << ", requested from " << Ev->Sender); - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - Self->TabletID(), - record.GetPathId().GetOwnerId(), - record.GetPathId().GetLocalId(), - NKikimrTxDataShard::TEvCompactTableResult::FAILED); - ctx.Send(Ev->Sender, std::move(response)); - return true; - } - - auto pathId = TPathId( - record.GetPathId().GetOwnerId(), - record.GetPathId().GetLocalId()); - - if (Self->GetPathOwnerId() != pathId.OwnerId) { - LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, - "Background compaction " << Self->TabletID() - << " of not owned " << pathId - << ", self path owner id# " << Self->GetPathOwnerId()); - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - Self->TabletID(), - pathId, - NKikimrTxDataShard::TEvCompactTableResult::FAILED); - ctx.Send(Ev->Sender, std::move(response)); - return true; - } - - const auto& tableId = pathId.LocalPathId; - auto it = Self->TableInfos.find(tableId); - if (it == Self->TableInfos.end()) { - LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, - "Background compaction " << Self->TabletID() - << " of unknown " << pathId - << ", requested from " << Ev->Sender); - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - Self->TabletID(), - pathId, - NKikimrTxDataShard::TEvCompactTableResult::FAILED); - ctx.Send(Ev->Sender, std::move(response)); - return true; - } - const TUserTable& tableInfo = *it->second; - const auto localTid = tableInfo.LocalTid; - - // TODO: consider using metrics instead - ++tableInfo.Stats.BackgroundCompactionRequests; - - auto stats = txc.DB.GetCompactionStats(localTid); - - bool hasBorrowed = false; - if (stats.PartOwners.size() > 1) { - hasBorrowed = true; - } else if (stats.PartOwners.size() == 1) { - if (*stats.PartOwners.begin() != Self->TabletID()) { - hasBorrowed = true; - } - } - + : TBase(ds) + , Ev(ev) + {} + + TTxType GetTxType() const override { return TXTYPE_COMPACT_TABLE; } + + bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { + auto& record = Ev->Get()->Record; + + if (!Self->IsStateActive()) { + LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, + "Background compaction tx at non-ready tablet " << Self->TabletID() + << " state " << Self->State + << ", requested from " << Ev->Sender); + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + Self->TabletID(), + record.GetPathId().GetOwnerId(), + record.GetPathId().GetLocalId(), + NKikimrTxDataShard::TEvCompactTableResult::FAILED); + ctx.Send(Ev->Sender, std::move(response)); + return true; + } + + auto pathId = TPathId( + record.GetPathId().GetOwnerId(), + record.GetPathId().GetLocalId()); + + if (Self->GetPathOwnerId() != pathId.OwnerId) { + LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, + "Background compaction " << Self->TabletID() + << " of not owned " << pathId + << ", self path owner id# " << Self->GetPathOwnerId()); + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + Self->TabletID(), + pathId, + NKikimrTxDataShard::TEvCompactTableResult::FAILED); + ctx.Send(Ev->Sender, std::move(response)); + return true; + } + + const auto& tableId = pathId.LocalPathId; + auto it = Self->TableInfos.find(tableId); + if (it == Self->TableInfos.end()) { + LOG_WARN_S(ctx, NKikimrServices::TX_DATASHARD, + "Background compaction " << Self->TabletID() + << " of unknown " << pathId + << ", requested from " << Ev->Sender); + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + Self->TabletID(), + pathId, + NKikimrTxDataShard::TEvCompactTableResult::FAILED); + ctx.Send(Ev->Sender, std::move(response)); + return true; + } + const TUserTable& tableInfo = *it->second; + const auto localTid = tableInfo.LocalTid; + + // TODO: consider using metrics instead + ++tableInfo.Stats.BackgroundCompactionRequests; + + auto stats = txc.DB.GetCompactionStats(localTid); + + bool hasBorrowed = false; + if (stats.PartOwners.size() > 1) { + hasBorrowed = true; + } else if (stats.PartOwners.size() == 1) { + if (*stats.PartOwners.begin() != Self->TabletID()) { + hasBorrowed = true; + } + } + if (hasBorrowed && !record.GetCompactBorrowed()) { - // normally we should not receive requests to compact in this case - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, - "Background compaction of tablet# " << Self->TabletID() - << " of path# " << pathId - << ", requested from# " << Ev->Sender - << " contains borrowed data, failed"); - - Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION_FAILED_BORROWED); - - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - Self->TabletID(), - pathId, - NKikimrTxDataShard::TEvCompactTableResult::FAILED); - ctx.Send(Ev->Sender, std::move(response)); - return true; - } - + // normally we should not receive requests to compact in this case + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, + "Background compaction of tablet# " << Self->TabletID() + << " of path# " << pathId + << ", requested from# " << Ev->Sender + << " contains borrowed data, failed"); + + Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION_FAILED_BORROWED); + + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + Self->TabletID(), + pathId, + NKikimrTxDataShard::TEvCompactTableResult::FAILED); + ctx.Send(Ev->Sender, std::move(response)); + return true; + } + if (stats.PartCount <= 1 && stats.MemDataSize == 0 && !hasBorrowed) { // nothing to compact LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, @@ -116,144 +116,144 @@ public: return true; } - auto compactionId = Self->Executor()->CompactTable(tableInfo.LocalTid); - if (compactionId) { - LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, - "Started background compaction# " << compactionId - << " of " << Self->TabletID() - << " tableId# " << tableId - << " localTid# " << localTid - << ", requested from " << Ev->Sender - << ", partsCount# " << stats.PartCount - << ", memtableSize# " << stats.MemDataSize - << ", memtableWaste# " << stats.MemDataWaste - << ", memtableRows# " << stats.MemRowCount); - - Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION); - Self->CompactionWaiters[tableInfo.LocalTid].emplace_back(std::make_tuple(compactionId, pathId, Ev->Sender)); - } else { - // compaction failed, for now we don't care - Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION_FAILED_START); - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - Self->TabletID(), - pathId, - NKikimrTxDataShard::TEvCompactTableResult::FAILED); - ctx.Send(Ev->Sender, std::move(response)); - } - - return true; - } - - void Complete(const TActorContext& ctx) override { - Y_UNUSED(ctx); - } -}; - -class TDataShard::TTxPersistFullCompactionTs : public NTabletFlatExecutor::TTransactionBase<TDataShard> { - ui64 TableId; - TInstant Ts; - -public: - TTxPersistFullCompactionTs(TDataShard* ds, ui64 tableId, TInstant ts) - : TBase(ds) - , TableId(tableId) - , Ts(ts) - {} - - // note, that type is the same as in TTxCompactTable - TTxType GetTxType() const override { return TXTYPE_COMPACT_TABLE; } - - bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { - Y_UNUSED(ctx); - NIceDb::TNiceDb db(txc.DB); - Self->PersistUserTableFullCompactionTs(db, TableId, Ts.Seconds()); - return true; - } + auto compactionId = Self->Executor()->CompactTable(tableInfo.LocalTid); + if (compactionId) { + LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, + "Started background compaction# " << compactionId + << " of " << Self->TabletID() + << " tableId# " << tableId + << " localTid# " << localTid + << ", requested from " << Ev->Sender + << ", partsCount# " << stats.PartCount + << ", memtableSize# " << stats.MemDataSize + << ", memtableWaste# " << stats.MemDataWaste + << ", memtableRows# " << stats.MemRowCount); + + Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION); + Self->CompactionWaiters[tableInfo.LocalTid].emplace_back(std::make_tuple(compactionId, pathId, Ev->Sender)); + } else { + // compaction failed, for now we don't care + Self->IncCounter(COUNTER_TX_BACKGROUND_COMPACTION_FAILED_START); + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + Self->TabletID(), + pathId, + NKikimrTxDataShard::TEvCompactTableResult::FAILED); + ctx.Send(Ev->Sender, std::move(response)); + } + + return true; + } + + void Complete(const TActorContext& ctx) override { + Y_UNUSED(ctx); + } +}; + +class TDataShard::TTxPersistFullCompactionTs : public NTabletFlatExecutor::TTransactionBase<TDataShard> { + ui64 TableId; + TInstant Ts; + +public: + TTxPersistFullCompactionTs(TDataShard* ds, ui64 tableId, TInstant ts) + : TBase(ds) + , TableId(tableId) + , Ts(ts) + {} + + // note, that type is the same as in TTxCompactTable + TTxType GetTxType() const override { return TXTYPE_COMPACT_TABLE; } + + bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { + Y_UNUSED(ctx); + NIceDb::TNiceDb db(txc.DB); + Self->PersistUserTableFullCompactionTs(db, TableId, Ts.Seconds()); + return true; + } + + void Complete(const TActorContext& ctx) override { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, + "Updated last full compaction of tablet# "<< Self->TabletID() + << ", tableId# " << TableId + << ", last full compaction# " << Ts); + } +}; - void Complete(const TActorContext& ctx) override { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, - "Updated last full compaction of tablet# "<< Self->TabletID() - << ", tableId# " << TableId - << ", last full compaction# " << Ts); - } -}; - void TDataShard::Handle(TEvDataShard::TEvCompactTable::TPtr& ev, const TActorContext& ctx) { - Executor()->Execute(new TTxCompactTable(this, ev), ctx); -} - -void TDataShard::CompactionComplete(ui32 tableId, const TActorContext &ctx) { - auto finishedInfo = Executor()->GetFinishedCompactionInfo(tableId); - - if (tableId >= Schema::MinLocalTid) { - for (auto& ti : TableInfos) { - if (ti.second->LocalTid != tableId && ti.second->ShadowTid != tableId) - continue; - if (ti.second->Stats.LastFullCompaction < finishedInfo.FullCompactionTs) { - ti.second->Stats.LastFullCompaction = finishedInfo.FullCompactionTs; - Executor()->Execute( - new TTxPersistFullCompactionTs( - this, - ti.first, - finishedInfo.FullCompactionTs), - ctx); - } - - ti.second->StatsNeedUpdate = true; - UpdateTableStats(ctx); - break; - } - } - - ReplyCompactionWaiters(tableId, finishedInfo.Edge, ctx); -} - -void TDataShard::ReplyCompactionWaiters(ui32 tableId, ui64 edge, const TActorContext &ctx) { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, - "CompactionComplete of tablet# "<< TabletID() - << ", table# " << tableId - << ", finished edge# " << edge - << ", front# " << (CompactionWaiters[tableId].empty() ? 0UL : std::get<0>(CompactionWaiters[tableId].front()))); - - while (!CompactionWaiters[tableId].empty()) { - const auto& waiter = CompactionWaiters[tableId].front(); - if (std::get<0>(waiter) > edge) - break; - - const auto& pathId = std::get<1>(waiter); - const auto& sender = std::get<2>(waiter); - auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( - TabletID(), - pathId.OwnerId, - pathId.LocalPathId, - NKikimrTxDataShard::TEvCompactTableResult::OK); - ctx.Send(sender, std::move(response)); - - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, - "Sending TEvCompactTableResult to# " << sender - << "pathId# " << pathId); - - CompactionWaiters[tableId].pop_front(); - } -} - + Executor()->Execute(new TTxCompactTable(this, ev), ctx); +} + +void TDataShard::CompactionComplete(ui32 tableId, const TActorContext &ctx) { + auto finishedInfo = Executor()->GetFinishedCompactionInfo(tableId); + + if (tableId >= Schema::MinLocalTid) { + for (auto& ti : TableInfos) { + if (ti.second->LocalTid != tableId && ti.second->ShadowTid != tableId) + continue; + if (ti.second->Stats.LastFullCompaction < finishedInfo.FullCompactionTs) { + ti.second->Stats.LastFullCompaction = finishedInfo.FullCompactionTs; + Executor()->Execute( + new TTxPersistFullCompactionTs( + this, + ti.first, + finishedInfo.FullCompactionTs), + ctx); + } + + ti.second->StatsNeedUpdate = true; + UpdateTableStats(ctx); + break; + } + } + + ReplyCompactionWaiters(tableId, finishedInfo.Edge, ctx); +} + +void TDataShard::ReplyCompactionWaiters(ui32 tableId, ui64 edge, const TActorContext &ctx) { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, + "CompactionComplete of tablet# "<< TabletID() + << ", table# " << tableId + << ", finished edge# " << edge + << ", front# " << (CompactionWaiters[tableId].empty() ? 0UL : std::get<0>(CompactionWaiters[tableId].front()))); + + while (!CompactionWaiters[tableId].empty()) { + const auto& waiter = CompactionWaiters[tableId].front(); + if (std::get<0>(waiter) > edge) + break; + + const auto& pathId = std::get<1>(waiter); + const auto& sender = std::get<2>(waiter); + auto response = MakeHolder<TEvDataShard::TEvCompactTableResult>( + TabletID(), + pathId.OwnerId, + pathId.LocalPathId, + NKikimrTxDataShard::TEvCompactTableResult::OK); + ctx.Send(sender, std::move(response)); + + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, + "Sending TEvCompactTableResult to# " << sender + << "pathId# " << pathId); + + CompactionWaiters[tableId].pop_front(); + } +} + void TDataShard::Handle(TEvDataShard::TEvGetCompactTableStats::TPtr& ev, const TActorContext& ctx) { - auto &record = ev->Get()->Record; - auto response = MakeHolder<TEvDataShard::TEvGetCompactTableStatsResult>(); - - auto pathId = TPathId( - record.GetPathId().GetOwnerId(), - record.GetPathId().GetLocalId()); - - const auto& tableId = pathId.LocalPathId; - auto it = TableInfos.find(tableId); - if (it != TableInfos.end()) { - const TUserTable& tableInfo = *it->second; - response->Record.SetBackgroundCompactionRequests(tableInfo.Stats.BackgroundCompactionRequests); - } - - ctx.Send(ev->Sender, std::move(response)); -} - + auto &record = ev->Get()->Record; + auto response = MakeHolder<TEvDataShard::TEvGetCompactTableStatsResult>(); + + auto pathId = TPathId( + record.GetPathId().GetOwnerId(), + record.GetPathId().GetLocalId()); + + const auto& tableId = pathId.LocalPathId; + auto it = TableInfos.find(tableId); + if (it != TableInfos.end()) { + const TUserTable& tableInfo = *it->second; + response->Record.SetBackgroundCompactionRequests(tableInfo.Stats.BackgroundCompactionRequests); + } + + ctx.Send(ev->Sender, std::move(response)); +} + } // NDataShard -} // NKikimr +} // NKikimr diff --git a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp index 9cf11108bdc..026b14e461f 100644 --- a/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp +++ b/ydb/core/tx/datashard/datashard__conditional_erase_rows.cpp @@ -27,7 +27,7 @@ protected: TPos Pos = Max<TPos>(); }; - virtual TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const = 0; + virtual TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const = 0; virtual TActorId CreateEraser() = 0; virtual void CloseEraser() = 0; }; @@ -235,7 +235,7 @@ public: << " }"; } - IScan::THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { + IScan::THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { TlsActivationContext->AsActorContext().RegisterWithSameMailbox(this); Driver = driver; @@ -303,7 +303,7 @@ public: return EScan::Sleep; } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { Reply(abort != EAbort::None); PassAway(); @@ -323,7 +323,7 @@ public: } protected: - TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const override { + TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const override { TVector<TKey> keyOrder; for (const auto& col : scheme->Cols) { @@ -359,7 +359,7 @@ private: THolder<IEraseRowsCondition> Condition; IDriver* Driver; - TIntrusiveConstPtr<TScheme> Scheme; + TIntrusiveConstPtr<TScheme> Scheme; TVector<TKey> KeyOrder; TVector<TTag> ScanTags; TSerializedKeys SerializedKeys; @@ -383,7 +383,7 @@ public: protected: // Enrich key with indexed columns - TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const override { + TVector<TKey> MakeKeyOrder(TIntrusiveConstPtr<IScan::TScheme> scheme) const override { auto keyOrder = TCondEraseScan::MakeKeyOrder(scheme); THashSet<TTag> keys; diff --git a/ydb/core/tx/datashard/datashard__init.cpp b/ydb/core/tx/datashard/datashard__init.cpp index b96f0deb771..dc12c49959b 100644 --- a/ydb/core/tx/datashard/datashard__init.cpp +++ b/ydb/core/tx/datashard/datashard__init.cpp @@ -162,7 +162,7 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { PRECHARGE_SYS_TABLE(Schema::ReplicationSources); PRECHARGE_SYS_TABLE(Schema::ReplicationSourceOffsets); PRECHARGE_SYS_TABLE(Schema::DstReplicationSourceOffsetsReceived); - PRECHARGE_SYS_TABLE(Schema::UserTablesStats); + PRECHARGE_SYS_TABLE(Schema::UserTablesStats); PRECHARGE_SYS_TABLE(Schema::SchemaSnapshots); if (!ready) @@ -227,25 +227,25 @@ bool TDataShard::TTxInit::ReadEverything(TTransactionContext &txc) { } } - if (Self->State != TShardState::Offline && txc.DB.GetScheme().GetTableInfo(Schema::UserTablesStats::TableId)) { - // Reads user tables persistent stats - auto rowset = db.Table<Schema::UserTablesStats>().GreaterOrEqual(0).Select(); - if (!rowset.IsReady()) - return false; - while (!rowset.EndOfSet()) { - ui64 tableId = rowset.GetValue<Schema::UserTablesStats::Tid>(); - ui64 ts = rowset.GetValueOrDefault<Schema::UserTablesStats::FullCompactionTs>(); - if (ts != 0) { - auto it = Self->TableInfos.find(tableId); - if (it != Self->TableInfos.end()) { - it->second->Stats.LastFullCompaction = TInstant::Seconds(ts); - } - } - if (!rowset.Next()) - return false; - } - } - + if (Self->State != TShardState::Offline && txc.DB.GetScheme().GetTableInfo(Schema::UserTablesStats::TableId)) { + // Reads user tables persistent stats + auto rowset = db.Table<Schema::UserTablesStats>().GreaterOrEqual(0).Select(); + if (!rowset.IsReady()) + return false; + while (!rowset.EndOfSet()) { + ui64 tableId = rowset.GetValue<Schema::UserTablesStats::Tid>(); + ui64 ts = rowset.GetValueOrDefault<Schema::UserTablesStats::FullCompactionTs>(); + if (ts != 0) { + auto it = Self->TableInfos.find(tableId); + if (it != Self->TableInfos.end()) { + it->second->Stats.LastFullCompaction = TInstant::Seconds(ts); + } + } + if (!rowset.Next()) + return false; + } + } + { // Read split snapshots on src tablet auto rowset = db.Table<Schema::SplitSrcSnapshots>().GreaterOrEqual(0).Select(); if (!rowset.IsReady()) @@ -619,12 +619,12 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont const auto& scheme = txc.DB.GetScheme(); - // Check that TxInit from leader has been already replicated to the follower + // Check that TxInit from leader has been already replicated to the follower // and all internal tables have already been created bool isInitialized = scheme.GetTableInfo(Schema::Sys::TableId); if (!isInitialized) { status = NKikimrTxDataShard::TError::WRONG_SHARD_STATE; - errMessage = Sprintf("Follower has not been initialized yet: tablet id: %" PRIu64, TabletID()); + errMessage = Sprintf("Follower has not been initialized yet: tablet id: %" PRIu64, TabletID()); return true; } @@ -633,14 +633,14 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont // Check if user tables schema has changed since last time we synchronized it ui64 lastSchemeUpdate = txc.DB.Head(Schema::UserTables::TableId).Serial; - if (lastSchemeUpdate > FollowerState.LastSchemeUpdate) { + if (lastSchemeUpdate > FollowerState.LastSchemeUpdate) { NIceDb::TNiceDb db(txc.DB); { LOG_DEBUG(ctx, NKikimrServices::TX_DATASHARD, - "Updating tables metadata on follower, tabletId %" PRIu64 + "Updating tables metadata on follower, tabletId %" PRIu64 " prevGen %" PRIu64 " prevStep %" PRIu64 " newGen %" PRIu64 " newStep %" PRIu64, - TabletID(), FollowerState.LastSchemeUpdate >> 32, - FollowerState.LastSchemeUpdate & (ui32)-1, + TabletID(), FollowerState.LastSchemeUpdate >> 32, + FollowerState.LastSchemeUpdate & (ui32)-1, lastSchemeUpdate >> 32, lastSchemeUpdate & (ui32)-1); // Reload user tables metadata @@ -689,17 +689,17 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont } } } - FollowerState.LastSchemeUpdate = lastSchemeUpdate; + FollowerState.LastSchemeUpdate = lastSchemeUpdate; } - // N.B. follower with snapshots support may be loaded in datashard without a snapshots table + // N.B. follower with snapshots support may be loaded in datashard without a snapshots table if (scheme.GetTableInfo(Schema::Snapshots::TableId)) { ui64 lastSnapshotsUpdate = txc.DB.Head(Schema::Snapshots::TableId).Serial; - if (lastSnapshotsUpdate > FollowerState.LastSnapshotsUpdate) { + if (lastSnapshotsUpdate > FollowerState.LastSnapshotsUpdate) { LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, - "Updating snapshots metadata on follower, tabletId " << TabletID() - << " prevGen " << (FollowerState.LastSnapshotsUpdate >> 32) - << " prevStep " << (FollowerState.LastSnapshotsUpdate & (ui32)-1) + "Updating snapshots metadata on follower, tabletId " << TabletID() + << " prevGen " << (FollowerState.LastSnapshotsUpdate >> 32) + << " prevStep " << (FollowerState.LastSnapshotsUpdate & (ui32)-1) << " newGen " << (lastSnapshotsUpdate >> 32) << " newStep " << (lastSnapshotsUpdate & (ui32)-1)); @@ -708,7 +708,7 @@ bool TDataShard::SyncSchemeOnFollower(TTransactionContext &txc, const TActorCont return false; } - FollowerState.LastSnapshotsUpdate = lastSnapshotsUpdate; + FollowerState.LastSnapshotsUpdate = lastSnapshotsUpdate; } // Initialize PathOwnerId (required for snapshot keys) diff --git a/ydb/core/tx/datashard/datashard__kqp_scan.cpp b/ydb/core/tx/datashard/datashard__kqp_scan.cpp index 4a14ade9e9b..b6b6b7e337d 100644 --- a/ydb/core/tx/datashard/datashard__kqp_scan.cpp +++ b/ydb/core/tx/datashard/datashard__kqp_scan.cpp @@ -25,7 +25,7 @@ constexpr ui64 READAHEAD_HI = 512_KB; constexpr TDuration SCAN_HARD_TIMEOUT = TDuration::Minutes(10); constexpr TDuration SCAN_HARD_TIMEOUT_GAP = TDuration::Seconds(5); -class TKqpScanResult : public IDestructable {}; +class TKqpScanResult : public IDestructable {}; class TKqpScan : public TActor<TKqpScan>, public NTable::IScan { public: @@ -180,7 +180,7 @@ private: } private: - THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept final { + THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept final { Y_VERIFY(scheme); Y_VERIFY(driver); @@ -329,7 +329,7 @@ private: } private: - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept final { + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept final { auto prio = abort == EAbort::None ? NActors::NLog::PRI_DEBUG : NActors::NLog::PRI_ERROR; LOG_LOG_S(*TlsActivationContext, prio, NKikimrServices::TX_DATASHARD, "Finish scan" << ", at: " << ScanActorId << ", scanId: " << ScanId diff --git a/ydb/core/tx/datashard/datashard__monitoring.cpp b/ydb/core/tx/datashard/datashard__monitoring.cpp index 4effeb88069..644f9a74199 100644 --- a/ydb/core/tx/datashard/datashard__monitoring.cpp +++ b/ydb/core/tx/datashard/datashard__monitoring.cpp @@ -101,7 +101,7 @@ public: info.SetSchemeShard(Self->PathOwnerId); info.SetMediator(Self->LastKnownMediator); info.SetGeneration(Self->Generation()); - info.SetIsFollower(Self->IsFollower()); + info.SetIsFollower(Self->IsFollower()); info.SetState(DatashardStateName(Self->State)); info.SetIsActive(Self->IsStateActive()); info.SetHasSharedBlobs(Self->HasSharedBlobs()); diff --git a/ydb/core/tx/datashard/datashard__op_rows.cpp b/ydb/core/tx/datashard/datashard__op_rows.cpp index 5a149ecd6eb..3b3c9d9d6f9 100644 --- a/ydb/core/tx/datashard/datashard__op_rows.cpp +++ b/ydb/core/tx/datashard/datashard__op_rows.cpp @@ -24,7 +24,7 @@ public: LOG_INFO_S(ctx, NKikimrServices::TX_DATASHARD, "TTxDirectBase(" << GetTxType() << ") Execute" << ": at tablet# " << Self->TabletID()); - if (Self->IsFollower()) { + if (Self->IsFollower()) { return true; // TODO: report error } diff --git a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp index c7d8402ee00..7dfb1a294e6 100644 --- a/ydb/core/tx/datashard/datashard__propose_tx_base.cpp +++ b/ydb/core/tx/datashard/datashard__propose_tx_base.cpp @@ -35,13 +35,13 @@ bool TDataShard::TTxProposeTransactionBase::Execute(NTabletFlatExecutor::TTransa try { TOutputOpData::TResultPtr result = nullptr; - // If tablet is in follower mode then we should sync scheme + // If tablet is in follower mode then we should sync scheme // before we build and check operation. - if (Self->IsFollower()) { + if (Self->IsFollower()) { NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; TString errMessage; - if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) + if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) return false; if (status != NKikimrTxDataShard::TError::OK) { diff --git a/ydb/core/tx/datashard/datashard__read_columns.cpp b/ydb/core/tx/datashard/datashard__read_columns.cpp index c05f9dd28ab..2b56a192d10 100644 --- a/ydb/core/tx/datashard/datashard__read_columns.cpp +++ b/ydb/core/tx/datashard/datashard__read_columns.cpp @@ -56,7 +56,7 @@ class TReadColumnsScan : public INoTxScan { TAutoPtr<TEvDataShard::TEvReadColumnsResponse> Result; IDriver *Driver = nullptr; - TIntrusiveConstPtr<TScheme> Scheme; + TIntrusiveConstPtr<TScheme> Scheme; public: TReadColumnsScan(const TKeyBoundary& keyFrom, @@ -86,7 +86,7 @@ public: , BlockBuilder(std::move(blockBuilder)) {} - THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { + THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { Driver = driver; Scheme = std::move(scheme); @@ -127,7 +127,7 @@ public: return EScan::Feed; } - TAutoPtr<IDestructable> Finish(EAbort reason) noexcept override { + TAutoPtr<IDestructable> Finish(EAbort reason) noexcept override { Result = new TEvDataShard::TEvReadColumnsResponse(TabletId); if (reason == EAbort::None) { @@ -216,11 +216,11 @@ public: bool useScan = Self->ReadColumnsScanEnabled; - if (Self->IsFollower()) { + if (Self->IsFollower()) { NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; TString errMessage; - if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) + if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) return false; if (status != NKikimrTxDataShard::TError::OK) { @@ -279,7 +279,7 @@ public: if (!Self->GetSnapshotManager().FindAvailable(*snapshotKey)) { SetError(NKikimrTxDataShard::TError::SNAPSHOT_NOT_EXIST, TStringBuilder() << "Table id " << tableId << " has no snapshot at " << ReadVersion - << " shard " << Self->TabletID() << (Self->IsFollower() ? " RO replica" : "")); + << " shard " << Self->TabletID() << (Self->IsFollower() ? " RO replica" : "")); return true; } } @@ -380,7 +380,7 @@ public: if (!Self->GetSnapshotManager().AcquireReference(*snapshotKey)) { SetError(NKikimrTxDataShard::TError::SNAPSHOT_NOT_EXIST, TStringBuilder() << "Table id " << tableId << " has no snapshot at " << ReadVersion - << " shard " << Self->TabletID() << (Self->IsFollower() ? " RO replica" : "")); + << " shard " << Self->TabletID() << (Self->IsFollower() ? " RO replica" : "")); return true; } } diff --git a/ydb/core/tx/datashard/datashard__read_iterator.cpp b/ydb/core/tx/datashard/datashard__read_iterator.cpp index 1b43cd6bc65..bfc05ece6e9 100644 --- a/ydb/core/tx/datashard/datashard__read_iterator.cpp +++ b/ydb/core/tx/datashard/datashard__read_iterator.cpp @@ -1,1164 +1,1164 @@ -#include "datashard_impl.h" - -#include <ydb/core/formats/arrow_batch_builder.h> - -#include <util/system/hp_timer.h> - -#include <utility> - -namespace NKikimr::NDataShard { - -using namespace NTabletFlatExecutor; - -namespace { - -constexpr ui64 MinRowsPerCheck = 1000; - -class TCellBlockBuilder : public IBlockBuilder { -public: - bool Start( - const TVector<std::pair<TString, NScheme::TTypeId>>& columns, - ui64 maxRowsInBlock, - ui64 maxBytesInBlock, - TString& err) override - { - Columns = columns; - Y_UNUSED(maxRowsInBlock); - Y_UNUSED(maxBytesInBlock); - Y_UNUSED(err); - return true; - } - - void AddRow(const TDbTupleRef& key, const TDbTupleRef& value) override { - Y_UNUSED(key); - - Rows.emplace_back(value.Cells()); - BytesCount += Rows.back().DataSize(); - } - - TString Finish() override { - return TString(); - } - - size_t Bytes() const override { return BytesCount; } - -public: - TVector<TOwnedCellVec> FlushBatch() { return std::move(Rows); } - -private: - TVector<std::pair<TString, NScheme::TTypeId>> Columns; - - TVector<TOwnedCellVec> Rows; - ui64 BytesCount = 0; - - std::unique_ptr<IBlockBuilder> Clone() const override { - return nullptr; - } -}; - -struct TShortColumnInfo { - NTable::TTag Tag; - NScheme::TTypeId Type; - TString Name; - - TShortColumnInfo(NTable::TTag tag, NScheme::TTypeId type, const TString& name) - : Tag(tag) - , Type(type) - , Name(name) - {} - - TString Dump() const { - TStringStream ss; - ss << "{Tag: " << Tag << ", Type: " << Type << ", Name: " << Name << "}"; - return ss.Str(); - } -}; - -struct TShortTableInfo { - TShortTableInfo() = default; - TShortTableInfo(TShortTableInfo&& other) = default; - - TShortTableInfo(TUserTable::TCPtr& tableInfo) { - LocalTid = tableInfo->LocalTid; - SchemaVersion = tableInfo->GetTableSchemaVersion(); - KeyColumnTypes = tableInfo->KeyColumnTypes; - KeyColumnCount = tableInfo->KeyColumnIds.size(); - - for (const auto& it: tableInfo->Columns) { - const auto& column = it.second; - Columns.emplace(it.first, TShortColumnInfo(it.first, column.Type, column.Name)); - } - } - - TShortTableInfo(ui32 localTid, const NTable::TRowScheme& schema) { - LocalTid = localTid; - KeyColumnCount = schema.Keys->Types.size(); - KeyColumnTypes.reserve(KeyColumnCount); - for (auto type: schema.Keys->Types) { - KeyColumnTypes.push_back(type.GetTypeId()); - } - - // note that we don't have column names here, but - // for cellvec we will not need them at all - for (const auto& col: schema.Cols) { - Columns.emplace(col.Tag, TShortColumnInfo(col.Tag, col.TypeId, "")); - } - } - - TShortTableInfo& operator =(TShortTableInfo&& other) = default; - - TString Dump() const { - TStringStream ss; - ss << "{LocalTid: " << LocalTid << ", SchemaVerstion: " << SchemaVersion << ", Columns: {"; - for (const auto& it: Columns) { - ss << it.second.Dump(); - } - ss << "}"; - return ss.Str(); - } - - ui32 LocalTid = 0; - ui64 SchemaVersion = 0; - size_t KeyColumnCount = 0; - TVector<NScheme::TTypeId> KeyColumnTypes; - TMap<NTable::TTag, TShortColumnInfo> Columns; -}; - -TVector<std::pair<TString, NScheme::TTypeId>> GetNameTypeColumns( - const std::vector<NTable::TTag>& tags, - const TShortTableInfo& tableInfo) -{ - TVector<std::pair<TString, NScheme::TTypeId>> result; - for (auto tag: tags) { - auto it = tableInfo.Columns.find(tag); - if (it == tableInfo.Columns.end()) { - result.clear(); - return result; - } - const auto& userColumn = it->second; - result.emplace_back(userColumn.Name, userColumn.Type); - } - return result; -} - -std::pair<std::unique_ptr<IBlockBuilder>, TString> CreateBlockBuilder( - const TReadIteratorState& state, - const TShortTableInfo& tableInfo) -{ - std::unique_ptr<IBlockBuilder> blockBuilder; - TString error; - - auto nameTypeCols = GetNameTypeColumns(state.Columns, tableInfo); - if (nameTypeCols.empty()) { - error = "Wrong columns requested"; - return std::make_pair(nullptr, error); - } - - switch (state.Format) { - case NKikimrTxDataShard::EScanDataFormat::ARROW: - blockBuilder.reset(new NArrow::TArrowBatchBuilder()); - break; - case NKikimrTxDataShard::EScanDataFormat::CELLVEC: - blockBuilder.reset(new TCellBlockBuilder()); - break; - default: - error = TStringBuilder() << "Unknown format: " << (int)state.Format; - return std::make_pair(nullptr, error); - } - - TString err; - if (!blockBuilder->Start(nameTypeCols, state.Quota.Rows, state.Quota.Bytes, err)) { - error = TStringBuilder() << "Failed to start block builder: " << err; - return std::make_pair(nullptr, error); - } - - return std::make_pair(std::move(blockBuilder), error); -} - -std::vector<TRawTypeValue> ToRawTypeValue( - const TSerializedCellVec& keyCells, - const TShortTableInfo& tableInfo, - bool addNulls) -{ - std::vector<TRawTypeValue> result; - result.reserve(keyCells.GetCells().size()); - - for (ui32 i = 0; i < keyCells.GetCells().size(); ++i) { - result.push_back(TRawTypeValue(keyCells.GetCells()[i].AsRef(), tableInfo.KeyColumnTypes[i])); - } - - // note that currently without nulls it is [prefix, +inf, +inf], - // and with nulls it is [prefix, null, null] - if (addNulls) - result.resize(tableInfo.KeyColumnTypes.size()); - - return result; -} - -ui64 ResetRowStats(NTable::TIteratorStats& stats) -{ - return std::exchange(stats.DeletedRowSkips, 0UL) + - std::exchange(stats.InvisibleRowSkips, 0UL); -} - -// nota that reader captures state reference and must be used only -// after checking that state is still alife, i.e. read can be aborted -// between Execute() and Complete() -class TReader { - const TReadIteratorState& State; - IBlockBuilder& BlockBuilder; - const TShortTableInfo& TableInfo; - - std::vector<NKikimr::NScheme::TTypeId> ColumnTypes; - - ui32 FirstUnprocessedQuery; - TString LastProcessedKey; - - ui64 RowsRead = 0; - ui64 RowsSinceLastCheck = 0; - - ui64 BytesInResult = 0; - - NHPTimer::STime StartTime; - NHPTimer::STime EndTime; - - static const NHPTimer::STime MaxCyclesPerIteration; - - enum class EReadStatus { - Done = 0, - NeedData, - StoppedByLimit, - }; - -public: - TReader(TReadIteratorState& state, - IBlockBuilder& blockBuilder, - const TShortTableInfo& tableInfo) - : State(state) - , BlockBuilder(blockBuilder) - , TableInfo(tableInfo) - , FirstUnprocessedQuery(State.FirstUnprocessedQuery) - { - GetTimeFast(&StartTime); - EndTime = StartTime; - } - - EReadStatus ReadRange(TTransactionContext& txc, const TActorContext& ctx, const TSerializedTableRange& range) { - bool fromInclusive; - TSerializedCellVec keyFromCells; - if (Y_UNLIKELY(FirstUnprocessedQuery == State.FirstUnprocessedQuery && State.LastProcessedKey)) { - fromInclusive = false; - keyFromCells = TSerializedCellVec(State.LastProcessedKey); - } else { - fromInclusive = range.FromInclusive; - keyFromCells = TSerializedCellVec(range.From); - } - const auto keyFrom = ToRawTypeValue(keyFromCells, TableInfo, fromInclusive); - - const TSerializedCellVec keyToCells(range.To); - const auto keyTo = ToRawTypeValue(keyToCells, TableInfo, !range.ToInclusive); - - // TODO: split range into parts like in read_columns - - NTable::TKeyRange iterRange; - iterRange.MinKey = keyFrom; - iterRange.MaxKey = keyTo; - iterRange.MinInclusive = fromInclusive; - iterRange.MaxInclusive = range.ToInclusive; - bool reverse = State.Reverse; - - EReadStatus result; - if (!reverse) { - auto iter = txc.DB.IterateRange(TableInfo.LocalTid, iterRange, State.Columns, State.ReadVersion); - result = Iterate(iter.Get(), true, ctx); - } else { - auto iter = txc.DB.IterateRangeReverse(TableInfo.LocalTid, iterRange, State.Columns, State.ReadVersion); - result = Iterate(iter.Get(), true, ctx); - } - - if (result == EReadStatus::NeedData) { - if (LastProcessedKey) { - keyFromCells = TSerializedCellVec(LastProcessedKey); - const auto keyFrom = ToRawTypeValue(keyFromCells, TableInfo, false); - Precharge(txc.DB, keyFrom, iterRange.MaxKey, reverse); - } else { - Precharge(txc.DB, iterRange.MinKey, iterRange.MaxKey, reverse); - } - return EReadStatus::NeedData; - } - - return result; - } - - EReadStatus ReadKey(TTransactionContext& txc, const TActorContext& ctx, const TSerializedCellVec& keyCells) { - if (keyCells.GetCells().size() != TableInfo.KeyColumnCount) { - // key prefix, treat it as range [prefix, 0, 0] - [prefix, +inf, +inf] - TSerializedTableRange range; - range.From = keyCells; - range.To = keyCells; - range.ToInclusive = true; - range.FromInclusive = true; - return ReadRange(txc, ctx, range); - } - - if (ColumnTypes.empty()) { - for (auto tag: State.Columns) { - auto it = TableInfo.Columns.find(tag); - Y_ASSERT(it != TableInfo.Columns.end()); - ColumnTypes.emplace_back(it->second.Type); - } - } - - const auto key = ToRawTypeValue(keyCells, TableInfo, true); - - NTable::TRowState rowState; - rowState.Init(State.Columns.size()); - NTable::TSelectStats stats; - auto ready = txc.DB.Select(TableInfo.LocalTid, key, State.Columns, rowState, stats, 0, State.ReadVersion); - RowsSinceLastCheck += 1 + stats.Invisible; - if (ready == NTable::EReady::Page) { - return EReadStatus::NeedData; - } - if (ready == NTable::EReady::Gone) { - return EReadStatus::Done; - } - - // TODO: looks kind of ugly: we assume that cells in rowState are stored in array - TDbTupleRef value(&ColumnTypes[0], &rowState.Get(0), ColumnTypes.size()); - - // note that if user requests key columns then they will be in - // rowValues and we don't have to add rowKey columns - BlockBuilder.AddRow(TDbTupleRef(), value); - ++RowsRead; - - return EReadStatus::Done; - } - - // TODO: merge ReadRanges and ReadKeys to single template Read? - - bool ReadRanges(TTransactionContext& txc, const TActorContext& ctx) { - for (; FirstUnprocessedQuery < State.Request->Ranges.size(); ++FirstUnprocessedQuery) { - if (OutOfQuota() || ShouldStopByElapsedTime()) - return true; - - const auto& range = State.Request->Ranges[FirstUnprocessedQuery]; - auto status = ReadRange(txc, ctx, range); - switch (status) { - case EReadStatus::Done: - continue; - case EReadStatus::StoppedByLimit: - return true; - case EReadStatus::NeedData: - return false; - } - } - - return true; - } - - bool ReadKeys(TTransactionContext& txc, const TActorContext& ctx) { - for (; FirstUnprocessedQuery < State.Request->Keys.size(); ++FirstUnprocessedQuery) { - if (OutOfQuota() || ShouldStopByElapsedTime()) - return true; - - const auto& key = State.Request->Keys[FirstUnprocessedQuery]; - auto status = ReadKey(txc, ctx, key); - switch (status) { - case EReadStatus::Done: - continue; - case EReadStatus::StoppedByLimit: - return true; - case EReadStatus::NeedData: - return false; - } - } - - return true; - } - - // return semantics the same as in the Execute() - bool Read(TTransactionContext& txc, const TActorContext& ctx) { - // TODO: consider trying to precharge multiple records at once in case - // when first precharge fails? - - if (!State.Request->Keys.empty()) { - return ReadKeys(txc, ctx); - } - - // since no keys, then we must have ranges (has been checked initially) - return ReadRanges(txc, ctx); - } - - bool HasUnreadQueries() const { - return FirstUnprocessedQuery < State.Request->Keys.size() - || FirstUnprocessedQuery < State.Request->Ranges.size(); - } - - void UpdateCycles() { - GetTimeFast(&EndTime); - } - - NHPTimer::STime ElapsedCycles() const { - return EndTime - StartTime; - } - - bool ShouldStopByElapsedTime() { - // TODO: should we also check bytes for the case - // when rows are very heavy? - if (RowsSinceLastCheck >= MinRowsPerCheck) { - RowsSinceLastCheck = 0; - UpdateCycles(); - - return ElapsedCycles() >= MaxCyclesPerIteration; - } - - return false; - } - - void FillResult(TEvDataShard::TEvReadResult& result) { - auto& record = result.Record; - record.MutableStatus()->SetCode(Ydb::StatusIds::SUCCESS); - - if (HasUnreadQueries()) { - if (OutOfQuota()) { - record.SetLimitReached(true); - } - } else { - record.SetFinished(true); - } - - BytesInResult = BlockBuilder.Bytes(); - - if (BytesInResult = BlockBuilder.Bytes()) { - switch (State.Format) { - case NKikimrTxDataShard::ARROW: { - auto& arrowBuilder = static_cast<NArrow::TArrowBatchBuilder&>(BlockBuilder); - result.ArrowBatch = arrowBuilder.FlushBatch(false); - break; - } - case NKikimrTxDataShard::CELLVEC: { - auto& cellBuilder = static_cast<TCellBlockBuilder&>(BlockBuilder); - result.SetRows(cellBuilder.FlushBatch()); - break; - } - default: { - // never happens - } - } - } - - record.SetResultFormat(State.Format); - - record.SetReadId(State.ReadId); - record.SetSeqNo(State.SeqNo + 1); - - NKikimrTxDataShard::TReadContinuationToken continuationToken; - continuationToken.SetFirstUnprocessedQuery(FirstUnprocessedQuery); - - // note that when LastProcessedKey set then - // FirstUnprocessedQuery is definitely partially read range - if (LastProcessedKey) - continuationToken.SetLastProcessedKey(LastProcessedKey); - - bool res = continuationToken.SerializeToString(record.MutableContinuationToken()); - Y_ASSERT(res); - } - - void UpdateState(TReadIteratorState& state) { - state.FirstUnprocessedQuery = FirstUnprocessedQuery; - state.LastProcessedKey = LastProcessedKey; - state.ConsumeSeqNo(RowsRead, BytesInResult); - } - - ui64 GetRowsRead() const { return RowsRead; } - -private: - bool OutOfQuota() const { - return RowsRead >= State.Quota.Rows || - RowsRead >= State.MaxRowsInResult || - BlockBuilder.Bytes() >= State.Quota.Bytes|| - BytesInResult >= State.Quota.Bytes; - } - - bool Precharge( - NTable::TDatabase& db, - NTable::TRawVals keyFrom, - NTable::TRawVals keyTo, - bool reverse) - { - Y_ASSERT(RowsRead < State.Quota.Rows); - Y_ASSERT(BlockBuilder.Bytes() < State.Quota.Bytes); - - ui64 rowsLeft = State.Quota.Rows - RowsRead; - ui64 bytesLeft = State.Quota.Bytes - BlockBuilder.Bytes(); - - auto direction = reverse ? NTable::EDirection::Reverse : NTable::EDirection::Forward; - return db.Precharge(TableInfo.LocalTid, - keyFrom, - keyTo, - State.Columns, - 0, - rowsLeft, - bytesLeft, - direction, - State.ReadVersion); - } - - template <typename TIterator> - EReadStatus Iterate(TIterator* iter, bool isRange, const TActorContext& ctx) { - Y_UNUSED(ctx); - while (iter->Next(NTable::ENext::Data) == NTable::EReady::Data) { - TDbTupleRef rowKey = iter->GetKey(); - - if (isRange) { - LastProcessedKey = TSerializedCellVec::Serialize(rowKey.Cells()); - } - - TDbTupleRef rowValues = iter->GetValues(); - - // note that if user requests key columns then they will be in - // rowValues and we don't have to add rowKey columns - BlockBuilder.AddRow(TDbTupleRef(), rowValues); - - ++RowsRead; - RowsSinceLastCheck += 1 + ResetRowStats(iter->Stats); - if (OutOfQuota() || ShouldStopByElapsedTime()) { - return EReadStatus::StoppedByLimit; - } - } - - // last iteration to Page or Gone also might have deleted or invisible rows - RowsSinceLastCheck += ResetRowStats(iter->Stats); - - // TODO: consider restart when Page and too few data read - // (how much is too few, less than user's limit?) - if (iter->Last() == NTable::EReady::Page && RowsRead == 0) { - return EReadStatus::NeedData; - } - - // range fully read, no reason to keep LastProcessedKey - if (isRange && iter->Last() == NTable::EReady::Gone) - LastProcessedKey.clear(); - - return EReadStatus::Done; - } -}; - -const NHPTimer::STime TReader::MaxCyclesPerIteration = - /* 10ms */ (NHPTimer::GetCyclesPerSecond() + 99) / 100; - -} // namespace - -class TDataShard::TTxRead : public NTabletFlatExecutor::TTransactionBase<TDataShard> { - TActorId Sender; - std::shared_ptr<TEvDataShard::TEvRead> Request; - - std::unique_ptr<TEvDataShard::TEvReadResult> Result; - - // on each Execute() set by CheckRequestAndInit - std::unique_ptr<IBlockBuilder> BlockBuilder; - TShortTableInfo TableInfo; - std::unique_ptr<TReader> Reader; - -public: - TTxRead(TDataShard* ds, TEvDataShard::TEvRead::TPtr ev) - : TBase(ds) - , Sender(ev->Sender) - , Request(ev->Release().Release()) - {} - - TTxType GetTxType() const override { return TXTYPE_READ; } - - bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { - TReadIteratorId readId(Sender, Request->Record.GetReadId()); - auto it = Self->ReadIterators.find(readId); - if (it == Self->ReadIterators.end()) { - // iterator has been aborted - return true; - } - - Y_ASSERT(it->second); - auto& state = *it->second; - state.State = TReadIteratorState::EState::Init; - - Result.reset(new TEvDataShard::TEvReadResult()); - - if (Self->State != TShardState::Ready && - Self->State != TShardState::Readonly) - { - // TODO: do we need more state checks here? - SetStatusError( - Result->Record, - Ydb::StatusIds::INTERNAL_ERROR, - TStringBuilder() << "Wrong shard state: " << DatashardStateName(Self->State) - << ", tablet id: " << Self->TabletID()); - return true; - } - - // TODO: in case of restart we recheck request and rebuild state, - // I believe it is needed because between restart schema can change, - // table can be deleted, version can gone, etc - bool finished = finished; - CheckRequestAndInit(txc, ctx, state, finished); - if (state.State != TReadIteratorState::EState::Executing) { - return finished; - } - - Y_ASSERT(Reader); - - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() << " Read: " << Request->Record); - - return Reader->Read(txc, ctx); - } - - void Complete(const TActorContext& ctx) override { - TReadIteratorId readId(Sender, Request->Record.GetReadId()); - auto it = Self->ReadIterators.find(readId); - if (it == Self->ReadIterators.end()) { - // iterator has been aborted - return; - } - - // normally will not happen, just for extra sanity check - if (!Result) { - Self->ReadIterators.erase(it); - return; - } - - // error happened and status set - auto& record = Result->Record; - if (record.HasStatus()) { - ctx.Send(Sender, Result.release()); - Self->ReadIterators.erase(it); - return; - } - - Y_ASSERT(Reader); - Y_ASSERT(BlockBuilder); - - Reader->FillResult(*Result); - ctx.Send(Sender, Result.release()); - - // note that we save the state only when there're unread queries - if (Reader->HasUnreadQueries()) { - Y_ASSERT(it->second); - auto& state = *it->second; - Reader->UpdateState(state); - if (!state.IsExhausted()) { - ctx.Send( - Self->SelfId(), - new TEvDataShard::TEvReadContinue(Sender, Request->Record.GetReadId())); - } - } else { - Self->ReadIterators.erase(it); - } - } - -private: - void CheckRequestAndInit(TTransactionContext& txc, const TActorContext& ctx, TReadIteratorState& state, bool& finished) { - const auto& record = Request->Record; - - if (!Request->Keys.empty() && !Request->Ranges.empty()) { - SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Both keys and ranges are forbidden"); - finished = true; - return; - } - - if (Request->Keys.empty() && Request->Ranges.empty()) { - SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Neither keys nor ranges"); - finished = true; - return; - } - - if (record.HasProgram()) { - SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "PushDown is not supported"); - finished = true; - return; - } - - if (record.ColumnsSize() == 0) { - SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Missing Columns"); - finished = true; - return; - } - - state.ReadId = record.GetReadId(); - state.PathId = TPathId( - record.GetTableId().GetOwnerId(), - record.GetTableId().GetTableId()); - - if (record.HasMaxRows()) - state.Quota.Rows = record.GetMaxRows(); - - if (record.HasMaxBytes()) - state.Quota.Bytes = record.GetMaxBytes(); - - if (record.HasResultFormat()) - state.Format = record.GetResultFormat(); - - if (record.HasMaxRowsInResult()) - state.MaxRowsInResult = record.GetMaxRowsInResult(); - - if (record.HasSnapshot()) { - state.ReadVersion.Step = record.GetSnapshot().GetStep(); - state.ReadVersion.TxId = record.GetSnapshot().GetTxId(); - } - - state.Reverse = record.GetReverse(); - - if (state.PathId.OwnerId != Self->TabletID()) { - if (state.PathId.OwnerId != Self->GetPathOwnerId()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Requesting ownerId: " << state.PathId.OwnerId - << ", tableId: " << state.PathId.LocalPathId - << ", from wrong owner: " << Self->GetPathOwnerId()); - finished = true; - return; - } - - auto tableId = state.PathId.LocalPathId; - auto it = Self->TableInfos.find(tableId); - if (it == Self->TableInfos.end()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Unknown table id: " << state.PathId.LocalPathId); - finished = true; - return; - } - - auto& userTableInfo = it->second; - TableInfo = TShortTableInfo(userTableInfo); - - if (userTableInfo->IsBackup) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - "Can't read from a backup table"); - finished = true; - return; - } - - if (state.ReadVersion.IsMax()) { - // TODO: currently not supported - SetStatusError(Result->Record, Ydb::StatusIds::UNSUPPORTED, "HEAD version is unsupported"); - finished = true; - return; - } else { - ui64 ownerId = state.PathId.OwnerId; - TSnapshotKey snapshotKey( - ownerId, - tableId, - state.ReadVersion.Step, - state.ReadVersion.TxId); - - if (!Self->GetSnapshotManager().FindAvailable(snapshotKey)) { - SetStatusError( - Result->Record, - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Table id " << tableId << " has no snapshot at " - << state.ReadVersion << " shard " << Self->TabletID() - << (Self->IsFollower() ? " RO replica" : "")); - finished = true; - return; - } - } - - state.SchemaVersion = userTableInfo->GetTableSchemaVersion(); - if (record.GetTableId().HasSchemaVersion()) { - if (state.SchemaVersion != record.GetTableId().GetSchemaVersion()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::SCHEME_ERROR, - TStringBuilder() << "Wrong schemaversion " << record.GetTableId().GetSchemaVersion() - << " requested, table schemaversion " << state.SchemaVersion); - finished = true; - return; - } - } - - userTableInfo->Stats.AccessTime = TAppData::TimeProvider->Now(); - } else { - if (state.PathId.LocalPathId >= TDataShard::Schema::MinLocalTid) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Only sys tables can be read by localTid, table " - << state.PathId.LocalPathId); - finished = true; - return; - } - - if (!state.ReadVersion.IsMax()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Only HEAD read from sys tables is allowed"); - finished = true; - return; - } - - if (state.Format != NKikimrTxDataShard::CELLVEC) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Sys tables can be read only in cellvec format, but requested " - << (int)NKikimrTxDataShard::CELLVEC); - finished = true; - return; - } - - if (record.GetTableId().HasSchemaVersion()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - TStringBuilder() << "Requesting system stable owned " << state.PathId.OwnerId - << ", localTid: " << state.PathId.LocalPathId - << ", with schema: " << record.GetTableId().GetSchemaVersion()); - finished = true; - return; - } - - auto schema = txc.DB.GetRowScheme(state.PathId.LocalPathId); - if (!schema) { - SetStatusError( - Result->Record, - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Failed to get scheme for table local id: " - << state.PathId.LocalPathId); - finished = true; - return; - } - TableInfo = TShortTableInfo(state.PathId.LocalPathId, *schema); - } - - if (Self->IsFollower()) { - NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; - TString errMessage; - - if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) { - finished = false; - return; - } - - if (status != NKikimrTxDataShard::TError::OK) { - SetStatusError( - Result->Record, - Ydb::StatusIds::INTERNAL_ERROR, - "Follower not ready"); - finished = true; - return; - } - - if (!state.ReadVersion.IsMax()) { - // check that follower has this version - NIceDb::TNiceDb db(txc.DB); - TRowVersion lastCompleteTx; - if (!TDataShard::SysGetUi64(db, Schema::Sys_LastCompleteStep, lastCompleteTx.Step)) { - finished = false; - return; - } - if (!TDataShard::SysGetUi64(db, Schema::Sys_LastCompleteTx, lastCompleteTx.TxId)) { - finished = false; - return; - } - - if (state.ReadVersion > lastCompleteTx) { - // it would be better to have something like retry later - SetStatusError( - Result->Record, - Ydb::StatusIds::INTERNAL_ERROR, - TStringBuilder() << "Version " << state.ReadVersion - << " is not available on follower yet"); - finished = true; - return; - } - } else { - SetStatusError( - Result->Record, - Ydb::StatusIds::UNSUPPORTED, - "HEAD version on followers is unsupported"); - finished = true; - return; - } - - // TODO: check that no lock requested - } - - state.Columns.reserve(record.ColumnsSize()); - for (auto col: record.GetColumns()) { - auto it = TableInfo.Columns.find(col); - if (it == TableInfo.Columns.end()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::SCHEME_ERROR, - TStringBuilder() << "Unknown column: " << col); - finished = true; - return; - } - - state.Columns.push_back(col); - } - - { - auto p = CreateBlockBuilder(state, TableInfo); - if (!p.first) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - p.second); - finished = true; - return; - } - std::swap(BlockBuilder, p.first); - } - - state.Request = Request; - - Y_ASSERT(Result); - - state.State = TReadIteratorState::EState::Executing; - Reader.reset(new TReader(state, *BlockBuilder, TableInfo)); - - finished = false; - } -}; - -class TDataShard::TTxReadContinue : public NTabletFlatExecutor::TTransactionBase<TDataShard> { - TEvDataShard::TEvReadContinue::TPtr Ev; - - std::unique_ptr<TEvDataShard::TEvReadResult> Result; - std::unique_ptr<IBlockBuilder> BlockBuilder; - TShortTableInfo TableInfo; - std::unique_ptr<TReader> Reader; - -public: - TTxReadContinue(TDataShard* ds, TEvDataShard::TEvReadContinue::TPtr ev) - : TBase(ds) - , Ev(ev) - {} - - // note that intentionally the same as TEvRead - TTxType GetTxType() const override { return TXTYPE_READ; } - - bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { - TReadIteratorId readId(Ev->Get()->Reader, Ev->Get()->ReadId); - auto it = Self->ReadIterators.find(readId); - if (it == Self->ReadIterators.end()) { - // read has been aborted - return true; - } - - Y_ASSERT(it->second); - auto& state = *it->second; - - Result.reset(new TEvDataShard::TEvReadResult()); - - if (state.PathId.OwnerId == Self->GetPathOwnerId()) { - const auto& tableId = state.PathId.LocalPathId; - auto it = Self->TableInfos.find(tableId); - if (it == Self->TableInfos.end()) { - SetStatusError( - Result->Record, - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Unknown table id: " << state.PathId.LocalPathId); - return true; - } - auto userTableInfo = it->second; - TableInfo = TShortTableInfo(userTableInfo); - auto currentSchemaVersion = TableInfo.SchemaVersion; - if (state.SchemaVersion != currentSchemaVersion) { - SetStatusError( - Result->Record, - Ydb::StatusIds::SCHEME_ERROR, - TStringBuilder() << "Schema changed, current " << currentSchemaVersion - << ", requested table schemaversion " << state.SchemaVersion); - return true; - } - - userTableInfo->Stats.AccessTime = TAppData::TimeProvider->Now(); - } else { - auto schema = txc.DB.GetRowScheme(state.PathId.LocalPathId); - if (!schema) { - SetStatusError( - Result->Record, - Ydb::StatusIds::NOT_FOUND, - TStringBuilder() << "Failed to get scheme for table local id: " - << state.PathId.LocalPathId); - return true; - } - TableInfo = TShortTableInfo(state.PathId.LocalPathId, *schema); - } - - { - auto p = CreateBlockBuilder(state, TableInfo); - if (!p.first) { - SetStatusError( - Result->Record, - Ydb::StatusIds::BAD_REQUEST, - p.second); - return true; - } - std::swap(BlockBuilder, p.first); - } - - Y_ASSERT(Result); - - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() - << " ReadContinue: " << Ev->Get()->Reader << "," << Ev->Get()->ReadId); - - Reader.reset(new TReader(state, *BlockBuilder, TableInfo)); - return Reader->Read(txc, ctx); - } - - void Complete(const TActorContext& ctx) override { - // TODO: it is complete copypaste from TEvRead::Complete() - - const auto* request = Ev->Get(); - TReadIteratorId readId(request->Reader, request->ReadId); - auto it = Self->ReadIterators.find(readId); - if (it == Self->ReadIterators.end()) { - // iterator has been aborted - return; - } - - // normally will not happen, just for extra sanity check - if (!Result) { - Self->ReadIterators.erase(it); - return; - } - - // error happened and status set - auto& record = Result->Record; - if (record.HasStatus()) { - ctx.Send(request->Reader, Result.release()); - Self->ReadIterators.erase(it); - return; - } - - Y_ASSERT(Reader); - Y_ASSERT(BlockBuilder); - - Reader->FillResult(*Result); - ctx.Send(request->Reader, Result.release()); - - if (Reader->HasUnreadQueries()) { - Y_ASSERT(it->second); - auto& state = *it->second; - Reader->UpdateState(state); - if (!state.IsExhausted()) { - ctx.Send( - Self->SelfId(), - new TEvDataShard::TEvReadContinue(request->Reader, request->ReadId)); - } else { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() - << " Read quota exhausted for " << request->Reader << "," << request->ReadId); - } - } else { - Self->ReadIterators.erase(it); - } - } -}; - -void TDataShard::Handle(TEvDataShard::TEvRead::TPtr& ev, const TActorContext& ctx) { - const auto& record = ev->Get()->Record; - if (Y_UNLIKELY(!record.HasReadId())) { - std::unique_ptr<TEvDataShard::TEvReadResult> result(new TEvDataShard::TEvReadResult()); - SetStatusError(result->Record, Ydb::StatusIds::BAD_REQUEST, "Missing ReadId"); - ctx.Send(ev->Sender, result.release()); - return; - } - - TReadIteratorId readId(ev->Sender, record.GetReadId()); - if (Y_UNLIKELY(ReadIterators.contains(readId))) { - std::unique_ptr<TEvDataShard::TEvReadResult> result(new TEvDataShard::TEvReadResult()); - SetStatusError( - result->Record, - Ydb::StatusIds::ALREADY_EXISTS, - TStringBuilder() << "Request " << readId.ReadId << " already executing"); - ctx.Send(ev->Sender, result.release()); - return; - } - - ReadIterators.emplace(readId, new TReadIteratorState()); - Executor()->Execute(new TTxRead(this, ev), ctx); -} - -void TDataShard::Handle(TEvDataShard::TEvReadContinue::TPtr& ev, const TActorContext& ctx) { - TReadIteratorId readId(ev->Get()->Reader, ev->Get()->ReadId); - if (Y_UNLIKELY(!ReadIterators.contains(readId))) { - // was aborted - return; - } - - Executor()->Execute(new TTxReadContinue(this, ev), ctx); -} - -void TDataShard::Handle(TEvDataShard::TEvReadAck::TPtr& ev, const TActorContext& ctx) { - // two possible cases: - // 1. read exhausted and we need to start its execution (if bytes available again), - // can start transaction right from here. - // 2. read is in progress, we need just to update quota. - - const auto& record = ev->Get()->Record; - if (Y_UNLIKELY(!record.HasReadId() || !record.HasSeqNo() || - !record.HasMaxRows() || !record.HasMaxBytes())) - { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadAck: " << record); - return; - } - - TReadIteratorId readId(ev->Sender, record.GetReadId()); - - auto it = ReadIterators.find(readId); - if (it == ReadIterators.end()) { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() - << " ReadAck on missing iterator: " << record); - return; - } - - Y_ASSERT(it->second); - auto& state = *it->second; - if (state.State == NDataShard::TReadIteratorState::EState::Init) { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() - << " ReadAck on not inialized iterator: " << record); - return; - } - - if (state.SeqNo < record.GetSeqNo()) { - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " out of order ReadAck: " - << record << ", current seqNo# " << state.SeqNo); - return; - } - - bool wasExhausted = state.IsExhausted(); - state.UpQuota( - record.GetSeqNo(), - record.GetMaxRows(), - record.GetMaxBytes()); - - if (wasExhausted && !state.IsExhausted()) { - ctx.Send( - SelfId(), - new TEvDataShard::TEvReadContinue(ev->Sender, record.GetReadId())); - } - - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadAck: " << record - << ", " << (wasExhausted ? "read continued" : "quota updated") - << ", bytesLeft# " << state.Quota.Bytes << ", rowsLeft# " << state.Quota.Rows); -} - -void TDataShard::Handle(TEvDataShard::TEvReadCancel::TPtr& ev, const TActorContext& ctx) { - const auto& record = ev->Get()->Record; - if (!record.HasReadId()) - return; - - LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadCancel: " << record); - - TReadIteratorId readId(ev->Sender, record.GetReadId()); - ReadIterators.erase(readId); -} - -} // NKikimr::NDataShard +#include "datashard_impl.h" + +#include <ydb/core/formats/arrow_batch_builder.h> + +#include <util/system/hp_timer.h> + +#include <utility> + +namespace NKikimr::NDataShard { + +using namespace NTabletFlatExecutor; + +namespace { + +constexpr ui64 MinRowsPerCheck = 1000; + +class TCellBlockBuilder : public IBlockBuilder { +public: + bool Start( + const TVector<std::pair<TString, NScheme::TTypeId>>& columns, + ui64 maxRowsInBlock, + ui64 maxBytesInBlock, + TString& err) override + { + Columns = columns; + Y_UNUSED(maxRowsInBlock); + Y_UNUSED(maxBytesInBlock); + Y_UNUSED(err); + return true; + } + + void AddRow(const TDbTupleRef& key, const TDbTupleRef& value) override { + Y_UNUSED(key); + + Rows.emplace_back(value.Cells()); + BytesCount += Rows.back().DataSize(); + } + + TString Finish() override { + return TString(); + } + + size_t Bytes() const override { return BytesCount; } + +public: + TVector<TOwnedCellVec> FlushBatch() { return std::move(Rows); } + +private: + TVector<std::pair<TString, NScheme::TTypeId>> Columns; + + TVector<TOwnedCellVec> Rows; + ui64 BytesCount = 0; + + std::unique_ptr<IBlockBuilder> Clone() const override { + return nullptr; + } +}; + +struct TShortColumnInfo { + NTable::TTag Tag; + NScheme::TTypeId Type; + TString Name; + + TShortColumnInfo(NTable::TTag tag, NScheme::TTypeId type, const TString& name) + : Tag(tag) + , Type(type) + , Name(name) + {} + + TString Dump() const { + TStringStream ss; + ss << "{Tag: " << Tag << ", Type: " << Type << ", Name: " << Name << "}"; + return ss.Str(); + } +}; + +struct TShortTableInfo { + TShortTableInfo() = default; + TShortTableInfo(TShortTableInfo&& other) = default; + + TShortTableInfo(TUserTable::TCPtr& tableInfo) { + LocalTid = tableInfo->LocalTid; + SchemaVersion = tableInfo->GetTableSchemaVersion(); + KeyColumnTypes = tableInfo->KeyColumnTypes; + KeyColumnCount = tableInfo->KeyColumnIds.size(); + + for (const auto& it: tableInfo->Columns) { + const auto& column = it.second; + Columns.emplace(it.first, TShortColumnInfo(it.first, column.Type, column.Name)); + } + } + + TShortTableInfo(ui32 localTid, const NTable::TRowScheme& schema) { + LocalTid = localTid; + KeyColumnCount = schema.Keys->Types.size(); + KeyColumnTypes.reserve(KeyColumnCount); + for (auto type: schema.Keys->Types) { + KeyColumnTypes.push_back(type.GetTypeId()); + } + + // note that we don't have column names here, but + // for cellvec we will not need them at all + for (const auto& col: schema.Cols) { + Columns.emplace(col.Tag, TShortColumnInfo(col.Tag, col.TypeId, "")); + } + } + + TShortTableInfo& operator =(TShortTableInfo&& other) = default; + + TString Dump() const { + TStringStream ss; + ss << "{LocalTid: " << LocalTid << ", SchemaVerstion: " << SchemaVersion << ", Columns: {"; + for (const auto& it: Columns) { + ss << it.second.Dump(); + } + ss << "}"; + return ss.Str(); + } + + ui32 LocalTid = 0; + ui64 SchemaVersion = 0; + size_t KeyColumnCount = 0; + TVector<NScheme::TTypeId> KeyColumnTypes; + TMap<NTable::TTag, TShortColumnInfo> Columns; +}; + +TVector<std::pair<TString, NScheme::TTypeId>> GetNameTypeColumns( + const std::vector<NTable::TTag>& tags, + const TShortTableInfo& tableInfo) +{ + TVector<std::pair<TString, NScheme::TTypeId>> result; + for (auto tag: tags) { + auto it = tableInfo.Columns.find(tag); + if (it == tableInfo.Columns.end()) { + result.clear(); + return result; + } + const auto& userColumn = it->second; + result.emplace_back(userColumn.Name, userColumn.Type); + } + return result; +} + +std::pair<std::unique_ptr<IBlockBuilder>, TString> CreateBlockBuilder( + const TReadIteratorState& state, + const TShortTableInfo& tableInfo) +{ + std::unique_ptr<IBlockBuilder> blockBuilder; + TString error; + + auto nameTypeCols = GetNameTypeColumns(state.Columns, tableInfo); + if (nameTypeCols.empty()) { + error = "Wrong columns requested"; + return std::make_pair(nullptr, error); + } + + switch (state.Format) { + case NKikimrTxDataShard::EScanDataFormat::ARROW: + blockBuilder.reset(new NArrow::TArrowBatchBuilder()); + break; + case NKikimrTxDataShard::EScanDataFormat::CELLVEC: + blockBuilder.reset(new TCellBlockBuilder()); + break; + default: + error = TStringBuilder() << "Unknown format: " << (int)state.Format; + return std::make_pair(nullptr, error); + } + + TString err; + if (!blockBuilder->Start(nameTypeCols, state.Quota.Rows, state.Quota.Bytes, err)) { + error = TStringBuilder() << "Failed to start block builder: " << err; + return std::make_pair(nullptr, error); + } + + return std::make_pair(std::move(blockBuilder), error); +} + +std::vector<TRawTypeValue> ToRawTypeValue( + const TSerializedCellVec& keyCells, + const TShortTableInfo& tableInfo, + bool addNulls) +{ + std::vector<TRawTypeValue> result; + result.reserve(keyCells.GetCells().size()); + + for (ui32 i = 0; i < keyCells.GetCells().size(); ++i) { + result.push_back(TRawTypeValue(keyCells.GetCells()[i].AsRef(), tableInfo.KeyColumnTypes[i])); + } + + // note that currently without nulls it is [prefix, +inf, +inf], + // and with nulls it is [prefix, null, null] + if (addNulls) + result.resize(tableInfo.KeyColumnTypes.size()); + + return result; +} + +ui64 ResetRowStats(NTable::TIteratorStats& stats) +{ + return std::exchange(stats.DeletedRowSkips, 0UL) + + std::exchange(stats.InvisibleRowSkips, 0UL); +} + +// nota that reader captures state reference and must be used only +// after checking that state is still alife, i.e. read can be aborted +// between Execute() and Complete() +class TReader { + const TReadIteratorState& State; + IBlockBuilder& BlockBuilder; + const TShortTableInfo& TableInfo; + + std::vector<NKikimr::NScheme::TTypeId> ColumnTypes; + + ui32 FirstUnprocessedQuery; + TString LastProcessedKey; + + ui64 RowsRead = 0; + ui64 RowsSinceLastCheck = 0; + + ui64 BytesInResult = 0; + + NHPTimer::STime StartTime; + NHPTimer::STime EndTime; + + static const NHPTimer::STime MaxCyclesPerIteration; + + enum class EReadStatus { + Done = 0, + NeedData, + StoppedByLimit, + }; + +public: + TReader(TReadIteratorState& state, + IBlockBuilder& blockBuilder, + const TShortTableInfo& tableInfo) + : State(state) + , BlockBuilder(blockBuilder) + , TableInfo(tableInfo) + , FirstUnprocessedQuery(State.FirstUnprocessedQuery) + { + GetTimeFast(&StartTime); + EndTime = StartTime; + } + + EReadStatus ReadRange(TTransactionContext& txc, const TActorContext& ctx, const TSerializedTableRange& range) { + bool fromInclusive; + TSerializedCellVec keyFromCells; + if (Y_UNLIKELY(FirstUnprocessedQuery == State.FirstUnprocessedQuery && State.LastProcessedKey)) { + fromInclusive = false; + keyFromCells = TSerializedCellVec(State.LastProcessedKey); + } else { + fromInclusive = range.FromInclusive; + keyFromCells = TSerializedCellVec(range.From); + } + const auto keyFrom = ToRawTypeValue(keyFromCells, TableInfo, fromInclusive); + + const TSerializedCellVec keyToCells(range.To); + const auto keyTo = ToRawTypeValue(keyToCells, TableInfo, !range.ToInclusive); + + // TODO: split range into parts like in read_columns + + NTable::TKeyRange iterRange; + iterRange.MinKey = keyFrom; + iterRange.MaxKey = keyTo; + iterRange.MinInclusive = fromInclusive; + iterRange.MaxInclusive = range.ToInclusive; + bool reverse = State.Reverse; + + EReadStatus result; + if (!reverse) { + auto iter = txc.DB.IterateRange(TableInfo.LocalTid, iterRange, State.Columns, State.ReadVersion); + result = Iterate(iter.Get(), true, ctx); + } else { + auto iter = txc.DB.IterateRangeReverse(TableInfo.LocalTid, iterRange, State.Columns, State.ReadVersion); + result = Iterate(iter.Get(), true, ctx); + } + + if (result == EReadStatus::NeedData) { + if (LastProcessedKey) { + keyFromCells = TSerializedCellVec(LastProcessedKey); + const auto keyFrom = ToRawTypeValue(keyFromCells, TableInfo, false); + Precharge(txc.DB, keyFrom, iterRange.MaxKey, reverse); + } else { + Precharge(txc.DB, iterRange.MinKey, iterRange.MaxKey, reverse); + } + return EReadStatus::NeedData; + } + + return result; + } + + EReadStatus ReadKey(TTransactionContext& txc, const TActorContext& ctx, const TSerializedCellVec& keyCells) { + if (keyCells.GetCells().size() != TableInfo.KeyColumnCount) { + // key prefix, treat it as range [prefix, 0, 0] - [prefix, +inf, +inf] + TSerializedTableRange range; + range.From = keyCells; + range.To = keyCells; + range.ToInclusive = true; + range.FromInclusive = true; + return ReadRange(txc, ctx, range); + } + + if (ColumnTypes.empty()) { + for (auto tag: State.Columns) { + auto it = TableInfo.Columns.find(tag); + Y_ASSERT(it != TableInfo.Columns.end()); + ColumnTypes.emplace_back(it->second.Type); + } + } + + const auto key = ToRawTypeValue(keyCells, TableInfo, true); + + NTable::TRowState rowState; + rowState.Init(State.Columns.size()); + NTable::TSelectStats stats; + auto ready = txc.DB.Select(TableInfo.LocalTid, key, State.Columns, rowState, stats, 0, State.ReadVersion); + RowsSinceLastCheck += 1 + stats.Invisible; + if (ready == NTable::EReady::Page) { + return EReadStatus::NeedData; + } + if (ready == NTable::EReady::Gone) { + return EReadStatus::Done; + } + + // TODO: looks kind of ugly: we assume that cells in rowState are stored in array + TDbTupleRef value(&ColumnTypes[0], &rowState.Get(0), ColumnTypes.size()); + + // note that if user requests key columns then they will be in + // rowValues and we don't have to add rowKey columns + BlockBuilder.AddRow(TDbTupleRef(), value); + ++RowsRead; + + return EReadStatus::Done; + } + + // TODO: merge ReadRanges and ReadKeys to single template Read? + + bool ReadRanges(TTransactionContext& txc, const TActorContext& ctx) { + for (; FirstUnprocessedQuery < State.Request->Ranges.size(); ++FirstUnprocessedQuery) { + if (OutOfQuota() || ShouldStopByElapsedTime()) + return true; + + const auto& range = State.Request->Ranges[FirstUnprocessedQuery]; + auto status = ReadRange(txc, ctx, range); + switch (status) { + case EReadStatus::Done: + continue; + case EReadStatus::StoppedByLimit: + return true; + case EReadStatus::NeedData: + return false; + } + } + + return true; + } + + bool ReadKeys(TTransactionContext& txc, const TActorContext& ctx) { + for (; FirstUnprocessedQuery < State.Request->Keys.size(); ++FirstUnprocessedQuery) { + if (OutOfQuota() || ShouldStopByElapsedTime()) + return true; + + const auto& key = State.Request->Keys[FirstUnprocessedQuery]; + auto status = ReadKey(txc, ctx, key); + switch (status) { + case EReadStatus::Done: + continue; + case EReadStatus::StoppedByLimit: + return true; + case EReadStatus::NeedData: + return false; + } + } + + return true; + } + + // return semantics the same as in the Execute() + bool Read(TTransactionContext& txc, const TActorContext& ctx) { + // TODO: consider trying to precharge multiple records at once in case + // when first precharge fails? + + if (!State.Request->Keys.empty()) { + return ReadKeys(txc, ctx); + } + + // since no keys, then we must have ranges (has been checked initially) + return ReadRanges(txc, ctx); + } + + bool HasUnreadQueries() const { + return FirstUnprocessedQuery < State.Request->Keys.size() + || FirstUnprocessedQuery < State.Request->Ranges.size(); + } + + void UpdateCycles() { + GetTimeFast(&EndTime); + } + + NHPTimer::STime ElapsedCycles() const { + return EndTime - StartTime; + } + + bool ShouldStopByElapsedTime() { + // TODO: should we also check bytes for the case + // when rows are very heavy? + if (RowsSinceLastCheck >= MinRowsPerCheck) { + RowsSinceLastCheck = 0; + UpdateCycles(); + + return ElapsedCycles() >= MaxCyclesPerIteration; + } + + return false; + } + + void FillResult(TEvDataShard::TEvReadResult& result) { + auto& record = result.Record; + record.MutableStatus()->SetCode(Ydb::StatusIds::SUCCESS); + + if (HasUnreadQueries()) { + if (OutOfQuota()) { + record.SetLimitReached(true); + } + } else { + record.SetFinished(true); + } + + BytesInResult = BlockBuilder.Bytes(); + + if (BytesInResult = BlockBuilder.Bytes()) { + switch (State.Format) { + case NKikimrTxDataShard::ARROW: { + auto& arrowBuilder = static_cast<NArrow::TArrowBatchBuilder&>(BlockBuilder); + result.ArrowBatch = arrowBuilder.FlushBatch(false); + break; + } + case NKikimrTxDataShard::CELLVEC: { + auto& cellBuilder = static_cast<TCellBlockBuilder&>(BlockBuilder); + result.SetRows(cellBuilder.FlushBatch()); + break; + } + default: { + // never happens + } + } + } + + record.SetResultFormat(State.Format); + + record.SetReadId(State.ReadId); + record.SetSeqNo(State.SeqNo + 1); + + NKikimrTxDataShard::TReadContinuationToken continuationToken; + continuationToken.SetFirstUnprocessedQuery(FirstUnprocessedQuery); + + // note that when LastProcessedKey set then + // FirstUnprocessedQuery is definitely partially read range + if (LastProcessedKey) + continuationToken.SetLastProcessedKey(LastProcessedKey); + + bool res = continuationToken.SerializeToString(record.MutableContinuationToken()); + Y_ASSERT(res); + } + + void UpdateState(TReadIteratorState& state) { + state.FirstUnprocessedQuery = FirstUnprocessedQuery; + state.LastProcessedKey = LastProcessedKey; + state.ConsumeSeqNo(RowsRead, BytesInResult); + } + + ui64 GetRowsRead() const { return RowsRead; } + +private: + bool OutOfQuota() const { + return RowsRead >= State.Quota.Rows || + RowsRead >= State.MaxRowsInResult || + BlockBuilder.Bytes() >= State.Quota.Bytes|| + BytesInResult >= State.Quota.Bytes; + } + + bool Precharge( + NTable::TDatabase& db, + NTable::TRawVals keyFrom, + NTable::TRawVals keyTo, + bool reverse) + { + Y_ASSERT(RowsRead < State.Quota.Rows); + Y_ASSERT(BlockBuilder.Bytes() < State.Quota.Bytes); + + ui64 rowsLeft = State.Quota.Rows - RowsRead; + ui64 bytesLeft = State.Quota.Bytes - BlockBuilder.Bytes(); + + auto direction = reverse ? NTable::EDirection::Reverse : NTable::EDirection::Forward; + return db.Precharge(TableInfo.LocalTid, + keyFrom, + keyTo, + State.Columns, + 0, + rowsLeft, + bytesLeft, + direction, + State.ReadVersion); + } + + template <typename TIterator> + EReadStatus Iterate(TIterator* iter, bool isRange, const TActorContext& ctx) { + Y_UNUSED(ctx); + while (iter->Next(NTable::ENext::Data) == NTable::EReady::Data) { + TDbTupleRef rowKey = iter->GetKey(); + + if (isRange) { + LastProcessedKey = TSerializedCellVec::Serialize(rowKey.Cells()); + } + + TDbTupleRef rowValues = iter->GetValues(); + + // note that if user requests key columns then they will be in + // rowValues and we don't have to add rowKey columns + BlockBuilder.AddRow(TDbTupleRef(), rowValues); + + ++RowsRead; + RowsSinceLastCheck += 1 + ResetRowStats(iter->Stats); + if (OutOfQuota() || ShouldStopByElapsedTime()) { + return EReadStatus::StoppedByLimit; + } + } + + // last iteration to Page or Gone also might have deleted or invisible rows + RowsSinceLastCheck += ResetRowStats(iter->Stats); + + // TODO: consider restart when Page and too few data read + // (how much is too few, less than user's limit?) + if (iter->Last() == NTable::EReady::Page && RowsRead == 0) { + return EReadStatus::NeedData; + } + + // range fully read, no reason to keep LastProcessedKey + if (isRange && iter->Last() == NTable::EReady::Gone) + LastProcessedKey.clear(); + + return EReadStatus::Done; + } +}; + +const NHPTimer::STime TReader::MaxCyclesPerIteration = + /* 10ms */ (NHPTimer::GetCyclesPerSecond() + 99) / 100; + +} // namespace + +class TDataShard::TTxRead : public NTabletFlatExecutor::TTransactionBase<TDataShard> { + TActorId Sender; + std::shared_ptr<TEvDataShard::TEvRead> Request; + + std::unique_ptr<TEvDataShard::TEvReadResult> Result; + + // on each Execute() set by CheckRequestAndInit + std::unique_ptr<IBlockBuilder> BlockBuilder; + TShortTableInfo TableInfo; + std::unique_ptr<TReader> Reader; + +public: + TTxRead(TDataShard* ds, TEvDataShard::TEvRead::TPtr ev) + : TBase(ds) + , Sender(ev->Sender) + , Request(ev->Release().Release()) + {} + + TTxType GetTxType() const override { return TXTYPE_READ; } + + bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { + TReadIteratorId readId(Sender, Request->Record.GetReadId()); + auto it = Self->ReadIterators.find(readId); + if (it == Self->ReadIterators.end()) { + // iterator has been aborted + return true; + } + + Y_ASSERT(it->second); + auto& state = *it->second; + state.State = TReadIteratorState::EState::Init; + + Result.reset(new TEvDataShard::TEvReadResult()); + + if (Self->State != TShardState::Ready && + Self->State != TShardState::Readonly) + { + // TODO: do we need more state checks here? + SetStatusError( + Result->Record, + Ydb::StatusIds::INTERNAL_ERROR, + TStringBuilder() << "Wrong shard state: " << DatashardStateName(Self->State) + << ", tablet id: " << Self->TabletID()); + return true; + } + + // TODO: in case of restart we recheck request and rebuild state, + // I believe it is needed because between restart schema can change, + // table can be deleted, version can gone, etc + bool finished = finished; + CheckRequestAndInit(txc, ctx, state, finished); + if (state.State != TReadIteratorState::EState::Executing) { + return finished; + } + + Y_ASSERT(Reader); + + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() << " Read: " << Request->Record); + + return Reader->Read(txc, ctx); + } + + void Complete(const TActorContext& ctx) override { + TReadIteratorId readId(Sender, Request->Record.GetReadId()); + auto it = Self->ReadIterators.find(readId); + if (it == Self->ReadIterators.end()) { + // iterator has been aborted + return; + } + + // normally will not happen, just for extra sanity check + if (!Result) { + Self->ReadIterators.erase(it); + return; + } + + // error happened and status set + auto& record = Result->Record; + if (record.HasStatus()) { + ctx.Send(Sender, Result.release()); + Self->ReadIterators.erase(it); + return; + } + + Y_ASSERT(Reader); + Y_ASSERT(BlockBuilder); + + Reader->FillResult(*Result); + ctx.Send(Sender, Result.release()); + + // note that we save the state only when there're unread queries + if (Reader->HasUnreadQueries()) { + Y_ASSERT(it->second); + auto& state = *it->second; + Reader->UpdateState(state); + if (!state.IsExhausted()) { + ctx.Send( + Self->SelfId(), + new TEvDataShard::TEvReadContinue(Sender, Request->Record.GetReadId())); + } + } else { + Self->ReadIterators.erase(it); + } + } + +private: + void CheckRequestAndInit(TTransactionContext& txc, const TActorContext& ctx, TReadIteratorState& state, bool& finished) { + const auto& record = Request->Record; + + if (!Request->Keys.empty() && !Request->Ranges.empty()) { + SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Both keys and ranges are forbidden"); + finished = true; + return; + } + + if (Request->Keys.empty() && Request->Ranges.empty()) { + SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Neither keys nor ranges"); + finished = true; + return; + } + + if (record.HasProgram()) { + SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "PushDown is not supported"); + finished = true; + return; + } + + if (record.ColumnsSize() == 0) { + SetStatusError(Result->Record, Ydb::StatusIds::BAD_REQUEST, "Missing Columns"); + finished = true; + return; + } + + state.ReadId = record.GetReadId(); + state.PathId = TPathId( + record.GetTableId().GetOwnerId(), + record.GetTableId().GetTableId()); + + if (record.HasMaxRows()) + state.Quota.Rows = record.GetMaxRows(); + + if (record.HasMaxBytes()) + state.Quota.Bytes = record.GetMaxBytes(); + + if (record.HasResultFormat()) + state.Format = record.GetResultFormat(); + + if (record.HasMaxRowsInResult()) + state.MaxRowsInResult = record.GetMaxRowsInResult(); + + if (record.HasSnapshot()) { + state.ReadVersion.Step = record.GetSnapshot().GetStep(); + state.ReadVersion.TxId = record.GetSnapshot().GetTxId(); + } + + state.Reverse = record.GetReverse(); + + if (state.PathId.OwnerId != Self->TabletID()) { + if (state.PathId.OwnerId != Self->GetPathOwnerId()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Requesting ownerId: " << state.PathId.OwnerId + << ", tableId: " << state.PathId.LocalPathId + << ", from wrong owner: " << Self->GetPathOwnerId()); + finished = true; + return; + } + + auto tableId = state.PathId.LocalPathId; + auto it = Self->TableInfos.find(tableId); + if (it == Self->TableInfos.end()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Unknown table id: " << state.PathId.LocalPathId); + finished = true; + return; + } + + auto& userTableInfo = it->second; + TableInfo = TShortTableInfo(userTableInfo); + + if (userTableInfo->IsBackup) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + "Can't read from a backup table"); + finished = true; + return; + } + + if (state.ReadVersion.IsMax()) { + // TODO: currently not supported + SetStatusError(Result->Record, Ydb::StatusIds::UNSUPPORTED, "HEAD version is unsupported"); + finished = true; + return; + } else { + ui64 ownerId = state.PathId.OwnerId; + TSnapshotKey snapshotKey( + ownerId, + tableId, + state.ReadVersion.Step, + state.ReadVersion.TxId); + + if (!Self->GetSnapshotManager().FindAvailable(snapshotKey)) { + SetStatusError( + Result->Record, + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Table id " << tableId << " has no snapshot at " + << state.ReadVersion << " shard " << Self->TabletID() + << (Self->IsFollower() ? " RO replica" : "")); + finished = true; + return; + } + } + + state.SchemaVersion = userTableInfo->GetTableSchemaVersion(); + if (record.GetTableId().HasSchemaVersion()) { + if (state.SchemaVersion != record.GetTableId().GetSchemaVersion()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::SCHEME_ERROR, + TStringBuilder() << "Wrong schemaversion " << record.GetTableId().GetSchemaVersion() + << " requested, table schemaversion " << state.SchemaVersion); + finished = true; + return; + } + } + + userTableInfo->Stats.AccessTime = TAppData::TimeProvider->Now(); + } else { + if (state.PathId.LocalPathId >= TDataShard::Schema::MinLocalTid) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Only sys tables can be read by localTid, table " + << state.PathId.LocalPathId); + finished = true; + return; + } + + if (!state.ReadVersion.IsMax()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Only HEAD read from sys tables is allowed"); + finished = true; + return; + } + + if (state.Format != NKikimrTxDataShard::CELLVEC) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Sys tables can be read only in cellvec format, but requested " + << (int)NKikimrTxDataShard::CELLVEC); + finished = true; + return; + } + + if (record.GetTableId().HasSchemaVersion()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + TStringBuilder() << "Requesting system stable owned " << state.PathId.OwnerId + << ", localTid: " << state.PathId.LocalPathId + << ", with schema: " << record.GetTableId().GetSchemaVersion()); + finished = true; + return; + } + + auto schema = txc.DB.GetRowScheme(state.PathId.LocalPathId); + if (!schema) { + SetStatusError( + Result->Record, + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Failed to get scheme for table local id: " + << state.PathId.LocalPathId); + finished = true; + return; + } + TableInfo = TShortTableInfo(state.PathId.LocalPathId, *schema); + } + + if (Self->IsFollower()) { + NKikimrTxDataShard::TError::EKind status = NKikimrTxDataShard::TError::OK; + TString errMessage; + + if (!Self->SyncSchemeOnFollower(txc, ctx, status, errMessage)) { + finished = false; + return; + } + + if (status != NKikimrTxDataShard::TError::OK) { + SetStatusError( + Result->Record, + Ydb::StatusIds::INTERNAL_ERROR, + "Follower not ready"); + finished = true; + return; + } + + if (!state.ReadVersion.IsMax()) { + // check that follower has this version + NIceDb::TNiceDb db(txc.DB); + TRowVersion lastCompleteTx; + if (!TDataShard::SysGetUi64(db, Schema::Sys_LastCompleteStep, lastCompleteTx.Step)) { + finished = false; + return; + } + if (!TDataShard::SysGetUi64(db, Schema::Sys_LastCompleteTx, lastCompleteTx.TxId)) { + finished = false; + return; + } + + if (state.ReadVersion > lastCompleteTx) { + // it would be better to have something like retry later + SetStatusError( + Result->Record, + Ydb::StatusIds::INTERNAL_ERROR, + TStringBuilder() << "Version " << state.ReadVersion + << " is not available on follower yet"); + finished = true; + return; + } + } else { + SetStatusError( + Result->Record, + Ydb::StatusIds::UNSUPPORTED, + "HEAD version on followers is unsupported"); + finished = true; + return; + } + + // TODO: check that no lock requested + } + + state.Columns.reserve(record.ColumnsSize()); + for (auto col: record.GetColumns()) { + auto it = TableInfo.Columns.find(col); + if (it == TableInfo.Columns.end()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::SCHEME_ERROR, + TStringBuilder() << "Unknown column: " << col); + finished = true; + return; + } + + state.Columns.push_back(col); + } + + { + auto p = CreateBlockBuilder(state, TableInfo); + if (!p.first) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + p.second); + finished = true; + return; + } + std::swap(BlockBuilder, p.first); + } + + state.Request = Request; + + Y_ASSERT(Result); + + state.State = TReadIteratorState::EState::Executing; + Reader.reset(new TReader(state, *BlockBuilder, TableInfo)); + + finished = false; + } +}; + +class TDataShard::TTxReadContinue : public NTabletFlatExecutor::TTransactionBase<TDataShard> { + TEvDataShard::TEvReadContinue::TPtr Ev; + + std::unique_ptr<TEvDataShard::TEvReadResult> Result; + std::unique_ptr<IBlockBuilder> BlockBuilder; + TShortTableInfo TableInfo; + std::unique_ptr<TReader> Reader; + +public: + TTxReadContinue(TDataShard* ds, TEvDataShard::TEvReadContinue::TPtr ev) + : TBase(ds) + , Ev(ev) + {} + + // note that intentionally the same as TEvRead + TTxType GetTxType() const override { return TXTYPE_READ; } + + bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { + TReadIteratorId readId(Ev->Get()->Reader, Ev->Get()->ReadId); + auto it = Self->ReadIterators.find(readId); + if (it == Self->ReadIterators.end()) { + // read has been aborted + return true; + } + + Y_ASSERT(it->second); + auto& state = *it->second; + + Result.reset(new TEvDataShard::TEvReadResult()); + + if (state.PathId.OwnerId == Self->GetPathOwnerId()) { + const auto& tableId = state.PathId.LocalPathId; + auto it = Self->TableInfos.find(tableId); + if (it == Self->TableInfos.end()) { + SetStatusError( + Result->Record, + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Unknown table id: " << state.PathId.LocalPathId); + return true; + } + auto userTableInfo = it->second; + TableInfo = TShortTableInfo(userTableInfo); + auto currentSchemaVersion = TableInfo.SchemaVersion; + if (state.SchemaVersion != currentSchemaVersion) { + SetStatusError( + Result->Record, + Ydb::StatusIds::SCHEME_ERROR, + TStringBuilder() << "Schema changed, current " << currentSchemaVersion + << ", requested table schemaversion " << state.SchemaVersion); + return true; + } + + userTableInfo->Stats.AccessTime = TAppData::TimeProvider->Now(); + } else { + auto schema = txc.DB.GetRowScheme(state.PathId.LocalPathId); + if (!schema) { + SetStatusError( + Result->Record, + Ydb::StatusIds::NOT_FOUND, + TStringBuilder() << "Failed to get scheme for table local id: " + << state.PathId.LocalPathId); + return true; + } + TableInfo = TShortTableInfo(state.PathId.LocalPathId, *schema); + } + + { + auto p = CreateBlockBuilder(state, TableInfo); + if (!p.first) { + SetStatusError( + Result->Record, + Ydb::StatusIds::BAD_REQUEST, + p.second); + return true; + } + std::swap(BlockBuilder, p.first); + } + + Y_ASSERT(Result); + + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() + << " ReadContinue: " << Ev->Get()->Reader << "," << Ev->Get()->ReadId); + + Reader.reset(new TReader(state, *BlockBuilder, TableInfo)); + return Reader->Read(txc, ctx); + } + + void Complete(const TActorContext& ctx) override { + // TODO: it is complete copypaste from TEvRead::Complete() + + const auto* request = Ev->Get(); + TReadIteratorId readId(request->Reader, request->ReadId); + auto it = Self->ReadIterators.find(readId); + if (it == Self->ReadIterators.end()) { + // iterator has been aborted + return; + } + + // normally will not happen, just for extra sanity check + if (!Result) { + Self->ReadIterators.erase(it); + return; + } + + // error happened and status set + auto& record = Result->Record; + if (record.HasStatus()) { + ctx.Send(request->Reader, Result.release()); + Self->ReadIterators.erase(it); + return; + } + + Y_ASSERT(Reader); + Y_ASSERT(BlockBuilder); + + Reader->FillResult(*Result); + ctx.Send(request->Reader, Result.release()); + + if (Reader->HasUnreadQueries()) { + Y_ASSERT(it->second); + auto& state = *it->second; + Reader->UpdateState(state); + if (!state.IsExhausted()) { + ctx.Send( + Self->SelfId(), + new TEvDataShard::TEvReadContinue(request->Reader, request->ReadId)); + } else { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() + << " Read quota exhausted for " << request->Reader << "," << request->ReadId); + } + } else { + Self->ReadIterators.erase(it); + } + } +}; + +void TDataShard::Handle(TEvDataShard::TEvRead::TPtr& ev, const TActorContext& ctx) { + const auto& record = ev->Get()->Record; + if (Y_UNLIKELY(!record.HasReadId())) { + std::unique_ptr<TEvDataShard::TEvReadResult> result(new TEvDataShard::TEvReadResult()); + SetStatusError(result->Record, Ydb::StatusIds::BAD_REQUEST, "Missing ReadId"); + ctx.Send(ev->Sender, result.release()); + return; + } + + TReadIteratorId readId(ev->Sender, record.GetReadId()); + if (Y_UNLIKELY(ReadIterators.contains(readId))) { + std::unique_ptr<TEvDataShard::TEvReadResult> result(new TEvDataShard::TEvReadResult()); + SetStatusError( + result->Record, + Ydb::StatusIds::ALREADY_EXISTS, + TStringBuilder() << "Request " << readId.ReadId << " already executing"); + ctx.Send(ev->Sender, result.release()); + return; + } + + ReadIterators.emplace(readId, new TReadIteratorState()); + Executor()->Execute(new TTxRead(this, ev), ctx); +} + +void TDataShard::Handle(TEvDataShard::TEvReadContinue::TPtr& ev, const TActorContext& ctx) { + TReadIteratorId readId(ev->Get()->Reader, ev->Get()->ReadId); + if (Y_UNLIKELY(!ReadIterators.contains(readId))) { + // was aborted + return; + } + + Executor()->Execute(new TTxReadContinue(this, ev), ctx); +} + +void TDataShard::Handle(TEvDataShard::TEvReadAck::TPtr& ev, const TActorContext& ctx) { + // two possible cases: + // 1. read exhausted and we need to start its execution (if bytes available again), + // can start transaction right from here. + // 2. read is in progress, we need just to update quota. + + const auto& record = ev->Get()->Record; + if (Y_UNLIKELY(!record.HasReadId() || !record.HasSeqNo() || + !record.HasMaxRows() || !record.HasMaxBytes())) + { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadAck: " << record); + return; + } + + TReadIteratorId readId(ev->Sender, record.GetReadId()); + + auto it = ReadIterators.find(readId); + if (it == ReadIterators.end()) { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() + << " ReadAck on missing iterator: " << record); + return; + } + + Y_ASSERT(it->second); + auto& state = *it->second; + if (state.State == NDataShard::TReadIteratorState::EState::Init) { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() + << " ReadAck on not inialized iterator: " << record); + return; + } + + if (state.SeqNo < record.GetSeqNo()) { + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " out of order ReadAck: " + << record << ", current seqNo# " << state.SeqNo); + return; + } + + bool wasExhausted = state.IsExhausted(); + state.UpQuota( + record.GetSeqNo(), + record.GetMaxRows(), + record.GetMaxBytes()); + + if (wasExhausted && !state.IsExhausted()) { + ctx.Send( + SelfId(), + new TEvDataShard::TEvReadContinue(ev->Sender, record.GetReadId())); + } + + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadAck: " << record + << ", " << (wasExhausted ? "read continued" : "quota updated") + << ", bytesLeft# " << state.Quota.Bytes << ", rowsLeft# " << state.Quota.Rows); +} + +void TDataShard::Handle(TEvDataShard::TEvReadCancel::TPtr& ev, const TActorContext& ctx) { + const auto& record = ev->Get()->Record; + if (!record.HasReadId()) + return; + + LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD, TabletID() << " ReadCancel: " << record); + + TReadIteratorId readId(ev->Sender, record.GetReadId()); + ReadIterators.erase(readId); +} + +} // NKikimr::NDataShard diff --git a/ydb/core/tx/datashard/datashard__s3.cpp b/ydb/core/tx/datashard/datashard__s3.cpp index f2a6a45e3c6..2f7a74bbab6 100644 --- a/ydb/core/tx/datashard/datashard__s3.cpp +++ b/ydb/core/tx/datashard/datashard__s3.cpp @@ -142,7 +142,7 @@ public: keyRange.MinInclusive = false; } - TAutoPtr<NTable::TTableIt> iter = txc.DB.IterateRange(localTableId, keyRange, columnsToReturn); + TAutoPtr<NTable::TTableIt> iter = txc.DB.IterateRange(localTableId, keyRange, columnsToReturn); ui64 foundKeys = Result->Record.ContentsRowsSize() + Result->Record.CommonPrefixesRowsSize(); while (iter->Next(NTable::ENext::All) == NTable::EReady::Data) { diff --git a/ydb/core/tx/datashard/datashard__stats.cpp b/ydb/core/tx/datashard/datashard__stats.cpp index 36a6e57f3b3..129a14dca5f 100644 --- a/ydb/core/tx/datashard/datashard__stats.cpp +++ b/ydb/core/tx/datashard/datashard__stats.cpp @@ -8,9 +8,9 @@ namespace NDataShard { class TAsyncTableStatsBuilder : public TActorBootstrapped<TAsyncTableStatsBuilder> { public: - TAsyncTableStatsBuilder(TActorId replyTo, ui64 tableId, ui64 indexSize, const TAutoPtr<NTable::TSubset> subset, + TAsyncTableStatsBuilder(TActorId replyTo, ui64 tableId, ui64 indexSize, const TAutoPtr<NTable::TSubset> subset, ui64 memRowCount, ui64 memDataSize, - ui64 rowCountResolution, ui64 dataSizeResolution, ui64 searchHeight, TInstant statsUpdateTime) + ui64 rowCountResolution, ui64 dataSizeResolution, ui64 searchHeight, TInstant statsUpdateTime) : ReplyTo(replyTo) , TableId(tableId) , IndexSize(indexSize) @@ -20,7 +20,7 @@ public: , MemDataSize(memDataSize) , RowCountResolution(rowCountResolution) , DataSizeResolution(dataSizeResolution) - , SearchHeight(searchHeight) + , SearchHeight(searchHeight) {} static constexpr auto ActorActivityType() { @@ -35,7 +35,7 @@ public: ev->PartCount = Subset->Flatten.size() + Subset->ColdParts.size(); ev->MemRowCount = MemRowCount; ev->MemDataSize = MemDataSize; - ev->SearchHeight = SearchHeight; + ev->SearchHeight = SearchHeight; NTable::GetPartOwners(*Subset, ev->PartOwners); @@ -53,12 +53,12 @@ private: ui64 TableId; ui64 IndexSize; TInstant StatsUpdateTime; - TAutoPtr<NTable::TSubset> Subset; + TAutoPtr<NTable::TSubset> Subset; ui64 MemRowCount; ui64 MemDataSize; ui64 RowCountResolution; ui64 DataSizeResolution; - ui64 SearchHeight; + ui64 SearchHeight; }; @@ -124,8 +124,8 @@ public: } Result->Record.MutableTableStats()->SetPartCount(tableInfo.Stats.PartCount); - Result->Record.MutableTableStats()->SetSearchHeight(tableInfo.Stats.SearchHeight); - Result->Record.MutableTableStats()->SetLastFullCompactionTs(tableInfo.Stats.LastFullCompaction.Seconds()); + Result->Record.MutableTableStats()->SetSearchHeight(tableInfo.Stats.SearchHeight); + Result->Record.MutableTableStats()->SetLastFullCompactionTs(tableInfo.Stats.LastFullCompaction.Seconds()); Result->Record.SetShardState(Self->State); for (const auto& pi : tableInfo.Stats.PartOwners) { @@ -193,11 +193,11 @@ void TDataShard::Handle(TEvPrivate::TEvAsyncTableStats::TPtr& ev, const TActorCo ev->Get()->StatsUpdateTime); tableInfo.Stats.MemRowCount = ev->Get()->MemRowCount; tableInfo.Stats.MemDataSize = ev->Get()->MemDataSize; - + dataSize += tableInfo.Stats.DataStats.DataSize; - UpdateSearchHeightStats(tableInfo.Stats, ev->Get()->SearchHeight); - + UpdateSearchHeightStats(tableInfo.Stats, ev->Get()->SearchHeight); + tableInfo.StatsUpdateInProgress = false; SendPeriodicTableStats(ctx); @@ -251,19 +251,19 @@ public: ui64 memRowCount = txc.DB.GetTableMemRowCount(localTableId); ui64 memDataSize = txc.DB.GetTableMemSize(localTableId); - ui64 searchHeight = txc.DB.GetTableSearchHeight(localTableId); + ui64 searchHeight = txc.DB.GetTableSearchHeight(localTableId); if (shadowTableId) { memRowCount += txc.DB.GetTableMemRowCount(shadowTableId); memDataSize += txc.DB.GetTableMemSize(shadowTableId); - searchHeight = 0; + searchHeight = 0; } - Self->UpdateFullCompactionTsMetric(ti.second->Stats); - + Self->UpdateFullCompactionTsMetric(ti.second->Stats); + if (!ti.second->StatsNeedUpdate) { ti.second->Stats.MemRowCount = memRowCount; ti.second->Stats.MemDataSize = memDataSize; - Self->UpdateSearchHeightStats(ti.second->Stats, searchHeight); + Self->UpdateSearchHeightStats(ti.second->Stats, searchHeight); continue; } @@ -293,7 +293,7 @@ public: indexSize += txc.DB.GetTableIndexSize(shadowTableId); } - TAutoPtr<NTable::TSubset> subsetForStats = txc.DB.Subset(localTableId, NTable::TEpoch::Max(), NTable::TRawVals(), NTable::TRawVals()); + TAutoPtr<NTable::TSubset> subsetForStats = txc.DB.Subset(localTableId, NTable::TEpoch::Max(), NTable::TRawVals(), NTable::TRawVals()); // Remove memtables from the subset as we only want to look at indexes for parts subsetForStats->Frozen.clear(); @@ -321,7 +321,7 @@ public: memDataSize, rowCountResolution, dataSizeResolution, - searchHeight, + searchHeight, AppData(ctx)->TimeProvider->Now()); ctx.Register(builder, TMailboxType::HTSwap, AppData(ctx)->BatchPoolId); @@ -361,38 +361,38 @@ void TDataShard::UpdateTableStats(const TActorContext &ctx) { Executor()->Execute(new TTxInitiateStatsUpdate(this), ctx); } -void TDataShard::UpdateSearchHeightStats(TUserTable::TStats& stats, ui64 newSearchHeight) { - if (TabletCounters) { - if (stats.LastSearchHeightMetricSet) - TabletCounters->Percentile()[COUNTER_SHARDS_WITH_SEARCH_HEIGHT].DecrementFor(stats.SearchHeight); - - TabletCounters->Percentile()[COUNTER_SHARDS_WITH_SEARCH_HEIGHT].IncrementFor(newSearchHeight); - stats.LastSearchHeightMetricSet = true; - } - stats.SearchHeight = newSearchHeight; -} - -void TDataShard::UpdateFullCompactionTsMetric(TUserTable::TStats& stats) { - if (!TabletCounters) - return; - - auto now = AppData()->TimeProvider->Now(); - if (now < stats.LastFullCompaction) { - // extra sanity check - return; - } - - auto newHours = (now - stats.LastFullCompaction).Hours(); - if (stats.HoursSinceFullCompaction && newHours == *stats.HoursSinceFullCompaction) - return; - - if (stats.HoursSinceFullCompaction) - TabletCounters->Percentile()[COUNTER_SHARDS_WITH_FULL_COMPACTION].DecrementFor(*stats.HoursSinceFullCompaction); - - TabletCounters->Percentile()[COUNTER_SHARDS_WITH_FULL_COMPACTION].IncrementFor(newHours); - stats.HoursSinceFullCompaction = newHours; -} - +void TDataShard::UpdateSearchHeightStats(TUserTable::TStats& stats, ui64 newSearchHeight) { + if (TabletCounters) { + if (stats.LastSearchHeightMetricSet) + TabletCounters->Percentile()[COUNTER_SHARDS_WITH_SEARCH_HEIGHT].DecrementFor(stats.SearchHeight); + + TabletCounters->Percentile()[COUNTER_SHARDS_WITH_SEARCH_HEIGHT].IncrementFor(newSearchHeight); + stats.LastSearchHeightMetricSet = true; + } + stats.SearchHeight = newSearchHeight; +} + +void TDataShard::UpdateFullCompactionTsMetric(TUserTable::TStats& stats) { + if (!TabletCounters) + return; + + auto now = AppData()->TimeProvider->Now(); + if (now < stats.LastFullCompaction) { + // extra sanity check + return; + } + + auto newHours = (now - stats.LastFullCompaction).Hours(); + if (stats.HoursSinceFullCompaction && newHours == *stats.HoursSinceFullCompaction) + return; + + if (stats.HoursSinceFullCompaction) + TabletCounters->Percentile()[COUNTER_SHARDS_WITH_FULL_COMPACTION].DecrementFor(*stats.HoursSinceFullCompaction); + + TabletCounters->Percentile()[COUNTER_SHARDS_WITH_FULL_COMPACTION].IncrementFor(newHours); + stats.HoursSinceFullCompaction = newHours; +} + void TDataShard::CollectCpuUsage(const TActorContext &ctx) { auto* metrics = Executor()->GetResourceMetrics(); TInstant now = AppData(ctx)->TimeProvider->Now(); diff --git a/ydb/core/tx/datashard/datashard_distributed_erase.cpp b/ydb/core/tx/datashard/datashard_distributed_erase.cpp index 99daf437775..fae7d2edeb3 100644 --- a/ydb/core/tx/datashard/datashard_distributed_erase.cpp +++ b/ydb/core/tx/datashard/datashard_distributed_erase.cpp @@ -301,7 +301,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { << ", shard# " << shardId); auto cancel = MakeHolder<TEvDataShard::TEvCancelTransactionProposal>(TxId); - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(cancel.Release(), shardId, false)); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(cancel.Release(), shardId, false)); } } @@ -326,7 +326,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { LOG_D("Handle TEvTxUserProxy::TEvAllocateTxIdResult"); TxId = ev->Get()->TxId; - LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; + LeaderPipeCache = ev->Get()->Services.LeaderPipeCache; Mon = ev->Get()->TxProxyMon; ResolveTables(); @@ -745,7 +745,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { NKikimrTxDataShard::TX_KIND_DISTRIBUTED_ERASE, SelfId(), TxId, tx.SerializeAsString() ); - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(propose.Release(), shardId, true)); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(propose.Release(), shardId, true)); Y_VERIFY_DEBUG(!Shards.contains(shardId)); Shards.insert(shardId); @@ -915,7 +915,7 @@ class TDistEraser: public TActorBootstrapped<TDistEraser> { PendingResult.insert(shardId); } - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(propose.Release(), SelectedCoordinator, true)); + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(propose.Release(), SelectedCoordinator, true)); Become(&TThis::StatePlan); } @@ -1093,7 +1093,7 @@ private: bool ResolvingKeys; ui64 TxId; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; TIntrusivePtr<NTxProxy::TTxProxyMon> Mon; THashMap<TTableId, TTableInfo> TableInfos; diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h index d41e07ded26..11313474f80 100644 --- a/ydb/core/tx/datashard/datashard_impl.h +++ b/ydb/core/tx/datashard/datashard_impl.h @@ -17,7 +17,7 @@ #include "change_exchange.h" #include "change_record.h" #include "progress_queue.h" -#include "read_iterator.h" +#include "read_iterator.h" #include <ydb/core/tx/time_cast/time_cast.h> #include <ydb/core/tx/tx_processing.h> @@ -177,8 +177,8 @@ class TDataShard class TTxInitiateStatsUpdate; class TTxCheckInReadSets; class TTxRemoveOldInReadSets; - class TTxRead; - class TTxReadContinue; + class TTxRead; + class TTxReadContinue; class TTxReadColumns; class TTxGetInfo; class TTxListOperations; @@ -197,8 +197,8 @@ class TDataShard class TTxExecuteMvccStateChange; class TTxGetRemovedRowVersions; class TTxCompactBorrowed; - class TTxCompactTable; - class TTxPersistFullCompactionTs; + class TTxCompactTable; + class TTxPersistFullCompactionTs; template <typename T> friend class TTxDirectBase; class TTxUploadRows; @@ -330,7 +330,7 @@ class TDataShard ui64 PartCount = 0; ui64 MemRowCount = 0; ui64 MemDataSize = 0; - ui64 SearchHeight = 0; + ui64 SearchHeight = 0; }; struct TEvRemoveOldInReadSets : public TEventLocal<TEvRemoveOldInReadSets, EvRemoveOldInReadSets> {}; @@ -397,12 +397,12 @@ class TDataShard }; struct TEvAsyncJobComplete : public TEventLocal<TEvAsyncJobComplete, EvAsyncJobComplete> { - explicit TEvAsyncJobComplete(TAutoPtr<IDestructable> prod) + explicit TEvAsyncJobComplete(TAutoPtr<IDestructable> prod) : Prod(prod) { } - TAutoPtr<IDestructable> Prod; + TAutoPtr<IDestructable> Prod; }; struct TEvSubDomainPathIdFound : public TEventLocal<TEvSubDomainPathIdFound, EvSubDomainPathIdFound> { @@ -448,7 +448,7 @@ class TDataShard using TColumns = TableColumns<Id, Bytes, Uint64>; }; - // Note that table UserTablesStats must be always updated with this one + // Note that table UserTablesStats must be always updated with this one struct UserTables : Table<2> { struct Tid : Column<1, NScheme::NTypeIds::Uint64> {}; struct LocalTid : Column<2, NScheme::NTypeIds::Uint32> {}; @@ -726,16 +726,16 @@ class TDataShard using TColumns = TableColumns<SrcTabletId, PathOwnerId, TablePathId>; }; - struct UserTablesStats : Table<27> { - struct Tid : Column<1, NScheme::NTypeIds::Uint64> {}; - - // seconds since epoch - struct FullCompactionTs : Column<2, NScheme::NTypeIds::Uint64> { static constexpr ui64 Default = 0; }; - - using TKey = TableKey<Tid>; - using TColumns = TableColumns<Tid, FullCompactionTs>; - }; - + struct UserTablesStats : Table<27> { + struct Tid : Column<1, NScheme::NTypeIds::Uint64> {}; + + // seconds since epoch + struct FullCompactionTs : Column<2, NScheme::NTypeIds::Uint64> { static constexpr ui64 Default = 0; }; + + using TKey = TableKey<Tid>; + using TColumns = TableColumns<Tid, FullCompactionTs>; + }; + struct SchemaSnapshots : Table<28> { struct PathOwnerId : Column<1, NScheme::NTypeIds::Uint64> {}; struct LocalPathId : Column<2, NScheme::NTypeIds::Uint64> {}; @@ -752,7 +752,7 @@ class TDataShard DeadlineQueue, SchemaOperations, SplitSrcSnapshots, SplitDstReceivedSnapshots, TxArtifacts, ScanProgress, Snapshots, S3Uploads, S3Downloads, ChangeRecords, ChangeRecordDetails, ChangeSenders, S3UploadedParts, SrcChangeSenderActivations, DstChangeSenderActivations, - ReplicationSourceOffsets, ReplicationSources, DstReplicationSourceOffsetsReceived, + ReplicationSourceOffsets, ReplicationSources, DstReplicationSourceOffsetsReceived, UserTablesStats, SchemaSnapshots>; // These settings are persisted on each Init. So we use empty settings in order not to overwrite what @@ -886,7 +886,7 @@ class TDataShard void Handle(TEvDataShard::TEvStateChangedResult::TPtr &ev, const TActorContext &ctx); void Handle(TEvDataShard::TEvProposeTransaction::TPtr &ev, const TActorContext &ctx); void Handle(TEvDataShard::TEvProposeTransactionAttach::TPtr &ev, const TActorContext &ctx); - void HandleAsFollower(TEvDataShard::TEvProposeTransaction::TPtr &ev, const TActorContext &ctx); + void HandleAsFollower(TEvDataShard::TEvProposeTransaction::TPtr &ev, const TActorContext &ctx); void ProposeTransaction(TEvDataShard::TEvProposeTransaction::TPtr &&ev, const TActorContext &ctx); void Handle(TEvTxProcessing::TEvPlanStep::TPtr &ev, const TActorContext &ctx); void Handle(TEvTxProcessing::TEvReadSet::TPtr &ev, const TActorContext &ctx); @@ -922,10 +922,10 @@ class TDataShard void Handle(TEvDataShard::TEvEraseRowsRequest::TPtr& ev, const TActorContext& ctx); void Handle(TEvDataShard::TEvConditionalEraseRowsRequest::TPtr& ev, const TActorContext& ctx); void Handle(TEvPrivate::TEvConditionalEraseRowsRegistered::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvRead::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvReadContinue::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvReadAck::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvReadCancel::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvRead::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvReadContinue::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvReadAck::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvReadCancel::TPtr& ev, const TActorContext& ctx); void Handle(TEvDataShard::TEvReadColumnsRequest::TPtr& ev, const TActorContext& ctx); void Handle(TEvDataShard::TEvGetInfoRequest::TPtr& ev, const TActorContext& ctx); void Handle(TEvDataShard::TEvListOperationsRequest::TPtr& ev, const TActorContext& ctx); @@ -987,9 +987,9 @@ class TDataShard void Handle(TEvDataShard::TEvCompactBorrowed::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvCompactTable::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvGetCompactTableStats::TPtr& ev, const TActorContext& ctx); - + void Handle(TEvDataShard::TEvCompactTable::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvGetCompactTableStats::TPtr& ev, const TActorContext& ctx); + void Handle(TEvDataShard::TEvApplyReplicationChanges::TPtr& ev, const TActorContext& ctx); void HandleByReplicationSourceOffsetsServer(STATEFN_SIG); @@ -1036,7 +1036,7 @@ class TDataShard void PersistSys(NIceDb::TNiceDb& db, ui64 key, ui32 value) const; void PersistSys(NIceDb::TNiceDb& db, ui64 key, bool value) const; void PersistUserTable(NIceDb::TNiceDb& db, ui64 tableId, const TUserTable& tableInfo); - void PersistUserTableFullCompactionTs(NIceDb::TNiceDb& db, ui64 tableId, ui64 ts); + void PersistUserTableFullCompactionTs(NIceDb::TNiceDb& db, ui64 tableId, ui64 ts); void PersistMoveUserTable(NIceDb::TNiceDb& db, ui64 prevTableId, ui64 tableId, const TUserTable& tableInfo); void DropAllUserTables(TTransactionContext& txc); @@ -1125,8 +1125,8 @@ public: ui32 Generation() const { return Executor()->Generation(); } - bool IsFollower() const { return Executor()->GetStats().IsFollower; } - bool SyncSchemeOnFollower(NTabletFlatExecutor::TTransactionContext &txc, const TActorContext &ctx, + bool IsFollower() const { return Executor()->GetStats().IsFollower; } + bool SyncSchemeOnFollower(NTabletFlatExecutor::TTransactionContext &txc, const TActorContext &ctx, NKikimrTxDataShard::TError::EKind & status, TString& errMessage); ui64 GetMaxTxInFly() { return MaxTxInFly; } @@ -1235,7 +1235,7 @@ public: } ui64 MakeScanSnapshot(ui32 tableId) { return Executor()->MakeScanSnapshot(tableId); } - ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options = TScanOptions()) + ui64 QueueScan(ui32 tableId, TAutoPtr<NTable::IScan> scan, ui64 cookie, const TScanOptions& options = TScanOptions()) { return Executor()->QueueScan(tableId, scan, cookie, options); } @@ -1254,8 +1254,8 @@ public: void CompactionComplete(ui32 tableId, const TActorContext &ctx) override; void CompletedLoansChanged(const TActorContext &ctx) override; - void ReplyCompactionWaiters(ui32 tableId, ui64 edge, const TActorContext &ctx); - + void ReplyCompactionWaiters(ui32 tableId, ui64 edge, const TActorContext &ctx); + TUserTable::TSpecialUpdate SpecialUpdates(const NTable::TDatabase& db, const TTableId& tableId) const; void SetTableAccessTime(const TTableId& tableId, TInstant ts); @@ -1264,11 +1264,11 @@ public: NMiniKQL::IKeyAccessSampler::TPtr GetKeyAccessSampler(); void EnableKeyAccessSampling(const TActorContext &ctx, TInstant until); void UpdateTableStats(const TActorContext& ctx); - void UpdateSearchHeightStats(TUserTable::TStats& stats, ui64 newSearchHeight); - void UpdateFullCompactionTsMetric(TUserTable::TStats& stats); + void UpdateSearchHeightStats(TUserTable::TStats& stats, ui64 newSearchHeight); + void UpdateFullCompactionTsMetric(TUserTable::TStats& stats); void CollectCpuUsage(const TActorContext& ctx); - void ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx) override; + void ScanComplete(NTable::EAbort status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx) override; bool ReassignChannelsEnabled() const override; ui64 GetMemoryUsage() const override; @@ -1776,8 +1776,8 @@ private: bool Acked = false; }; - // For follower only - struct TFollowerState { + // For follower only + struct TFollowerState { ui64 LastSchemeUpdate = 0; ui64 LastSnapshotsUpdate = 0; }; @@ -1914,7 +1914,7 @@ private: THashSet<TActorId> Actors; TLoanReturnTracker LoanReturnTracker; - TFollowerState FollowerState; + TFollowerState FollowerState; TSwitchState MvccSwitchState; bool SplitSnapshotStarted; // Non-persistent flag that is used to restart snapshot in case of datashard restart @@ -2064,16 +2064,16 @@ private: // in THashMap<ui64, TInChangeSender> InChangeSenders; // ui64 is shard id - // compactionId, tableId/ownerId, actorId - using TCompactionWaiter = std::tuple<ui64, TPathId, TActorId>; - using TCompactionWaiterList = TList<TCompactionWaiter>; - - // tableLocalTid -> waiters, note that compactionId is monotonically - // increasing and compactions for same table finish in order: - // thus we always add waiters to the end of the list and remove - // from the front - THashMap<ui32, TCompactionWaiterList> CompactionWaiters; - + // compactionId, tableId/ownerId, actorId + using TCompactionWaiter = std::tuple<ui64, TPathId, TActorId>; + using TCompactionWaiterList = TList<TCompactionWaiter>; + + // tableLocalTid -> waiters, note that compactionId is monotonically + // increasing and compactions for same table finish in order: + // thus we always add waiters to the end of the list and remove + // from the front + THashMap<ui32, TCompactionWaiterList> CompactionWaiters; + struct TReplicationSourceOffsetsReceiveState { // A set of tables for which we already received offsets THashSet<TPathId> Received; @@ -2093,8 +2093,8 @@ private: TReplicatedTableState* FindReplicatedTable(const TPathId& pathId); TReplicatedTableState* EnsureReplicatedTable(const TPathId& pathId); - TReadIteratorsMap ReadIterators; - + TReadIteratorsMap ReadIterators; + protected: // Redundant init state required by flat executor implementation void StateInit(TAutoPtr<NActors::IEventHandle> &ev, const NActors::TActorContext &ctx) { @@ -2184,10 +2184,10 @@ protected: HFunc(TEvDataShard::TEvEraseRowsRequest, Handle); HFunc(TEvDataShard::TEvConditionalEraseRowsRequest, Handle); HFunc(TEvPrivate::TEvConditionalEraseRowsRegistered, Handle); - HFunc(TEvDataShard::TEvRead, Handle); - HFunc(TEvDataShard::TEvReadContinue, Handle); - HFunc(TEvDataShard::TEvReadAck, Handle); - HFunc(TEvDataShard::TEvReadCancel, Handle); + HFunc(TEvDataShard::TEvRead, Handle); + HFunc(TEvDataShard::TEvReadContinue, Handle); + HFunc(TEvDataShard::TEvReadAck, Handle); + HFunc(TEvDataShard::TEvReadCancel, Handle); HFunc(TEvDataShard::TEvReadColumnsRequest, Handle); HFunc(TEvDataShard::TEvGetInfoRequest, Handle); HFunc(TEvDataShard::TEvListOperationsRequest, Handle); @@ -2221,8 +2221,8 @@ protected: HFunc(TEvChangeExchange::TEvSplitAck, Handle); HFunc(TEvDataShard::TEvGetRemovedRowVersions, Handle); HFunc(TEvDataShard::TEvCompactBorrowed, Handle); - HFunc(TEvDataShard::TEvCompactTable, Handle); - HFunc(TEvDataShard::TEvGetCompactTableStats, Handle); + HFunc(TEvDataShard::TEvCompactTable, Handle); + HFunc(TEvDataShard::TEvGetCompactTableStats, Handle); HFunc(TEvDataShard::TEvApplyReplicationChanges, Handle); fFunc(TEvDataShard::EvGetReplicationSourceOffsets, HandleByReplicationSourceOffsetsServer); fFunc(TEvDataShard::EvReplicationSourceOffsetsAck, HandleByReplicationSourceOffsetsServer); @@ -2238,12 +2238,12 @@ protected: } // This is the main state - void StateWorkAsFollower(TAutoPtr<NActors::IEventHandle> &ev, const NActors::TActorContext &ctx) { + void StateWorkAsFollower(TAutoPtr<NActors::IEventHandle> &ev, const NActors::TActorContext &ctx) { TRACE_EVENT(NKikimrServices::TX_DATASHARD); switch (ev->GetTypeRewrite()) { hFunc(TEvents::TEvGone, Handle); HFuncTraced(TEvents::TEvPoisonPill, Handle); - HFuncTraced(TEvDataShard::TEvProposeTransaction, HandleAsFollower); + HFuncTraced(TEvDataShard::TEvProposeTransaction, HandleAsFollower); HFuncTraced(TEvPrivate::TEvDelayedProposeTransaction, Handle); HFuncTraced(TEvDataShard::TEvReadColumnsRequest, Handle); HFuncTraced(TEvTabletPipe::TEvServerConnected, Handle); @@ -2385,8 +2385,8 @@ protected: } ev->Record.MutableTableStats()->SetPartCount(ti.Stats.PartCount); - ev->Record.MutableTableStats()->SetSearchHeight(ti.Stats.SearchHeight); - ev->Record.MutableTableStats()->SetLastFullCompactionTs(ti.Stats.LastFullCompaction.Seconds()); + ev->Record.MutableTableStats()->SetSearchHeight(ti.Stats.SearchHeight); + ev->Record.MutableTableStats()->SetLastFullCompactionTs(ti.Stats.LastFullCompaction.Seconds()); if (!ti.Stats.PartOwners.contains(TabletID())) { ev->Record.AddUserTablePartOwners(TabletID()); @@ -2425,8 +2425,8 @@ protected: NKikimrTxDataShard::TError::EKind ConvertErrCode(NMiniKQL::IEngineFlat::EResult code); -Ydb::StatusIds::StatusCode ConvertToYdbStatusCode(NKikimrTxDataShard::TError::EKind); - +Ydb::StatusIds::StatusCode ConvertToYdbStatusCode(NKikimrTxDataShard::TError::EKind); + template <class T> void SetStatusError(T &rec, Ydb::StatusIds::StatusCode status, diff --git a/ydb/core/tx/datashard/datashard_loans.cpp b/ydb/core/tx/datashard/datashard_loans.cpp index c55ca3faf64..adbfc4769db 100644 --- a/ydb/core/tx/datashard/datashard_loans.cpp +++ b/ydb/core/tx/datashard/datashard_loans.cpp @@ -143,7 +143,7 @@ void TDataShard::Handle(TEvDataShard::TEvReturnBorrowedPartAck::TPtr& ev, const bool TDataShard::HasSharedBlobs() const { const bool* hasSharedBlobsPtr = Executor()->GetStats().HasSharedBlobs; if (!hasSharedBlobsPtr) { - Y_VERIFY(Executor()->GetStats().IsFollower); + Y_VERIFY(Executor()->GetStats().IsFollower); return false; } return *hasSharedBlobsPtr; diff --git a/ydb/core/tx/datashard/datashard_pipeline.cpp b/ydb/core/tx/datashard/datashard_pipeline.cpp index 20a3c68ede3..3498162c17e 100644 --- a/ydb/core/tx/datashard/datashard_pipeline.cpp +++ b/ydb/core/tx/datashard/datashard_pipeline.cpp @@ -594,7 +594,7 @@ bool TPipeline::SaveInReadSet(const TEvTxProcessing::TEvReadSet &rs, } // If there is no required tx then we cannot assume it is finished. - // There are cases when tablet is not leader any more but is not dead + // There are cases when tablet is not leader any more but is not dead // yet and can receive RS for tx executed in another generation of this // tablet. In this case this tablet should be dead soon and source will // connect to the correct tablet and resend RS. diff --git a/ydb/core/tx/datashard/datashard_snapshots.cpp b/ydb/core/tx/datashard/datashard_snapshots.cpp index e67bfde4884..da1219bb9e6 100644 --- a/ydb/core/tx/datashard/datashard_snapshots.cpp +++ b/ydb/core/tx/datashard/datashard_snapshots.cpp @@ -595,7 +595,7 @@ bool TSnapshotManager::RemoveExpiredSnapshots(NTable::TDatabase& db, TInstant no TRowVersion leastAcquired = TRowVersion::Max(); for (auto &it : Self->Pipeline.GetImmediateOps()) { if (it.second->IsMvccSnapshotRead()) - leastAcquired = Min(leastAcquired, it.second->GetMvccSnapshot()); + leastAcquired = Min(leastAcquired, it.second->GetMvccSnapshot()); } removed |= AdvanceWatermark(db, Min(proposed, leastPlanned, leastAcquired, CompleteEdge)); diff --git a/ydb/core/tx/datashard/datashard_switch_mvcc_state.cpp b/ydb/core/tx/datashard/datashard_switch_mvcc_state.cpp index 47f4fa420a8..04c09cf74bf 100644 --- a/ydb/core/tx/datashard/datashard_switch_mvcc_state.cpp +++ b/ydb/core/tx/datashard/datashard_switch_mvcc_state.cpp @@ -32,7 +32,7 @@ void TDataShard::CheckMvccStateChangeCanStart(const TActorContext& ctx) { [[fallthrough]]; case TShardState::Readonly: - // Don't switch the state on follower + // Don't switch the state on follower [[fallthrough]]; case TShardState::Offline: diff --git a/ydb/core/tx/datashard/datashard_txs.h b/ydb/core/tx/datashard/datashard_txs.h index 51aba7b4dbb..4a9ab008789 100644 --- a/ydb/core/tx/datashard/datashard_txs.h +++ b/ydb/core/tx/datashard/datashard_txs.h @@ -91,7 +91,7 @@ public: TTxType GetTxType() const override { return TXTYPE_PROPOSE; } private: - bool SyncSchemeOnFollower(TOutputOpData::TResultPtr &result, + bool SyncSchemeOnFollower(TOutputOpData::TResultPtr &result, TTransactionContext &txc, const TActorContext &ctx); diff --git a/ydb/core/tx/datashard/datashard_user_table.h b/ydb/core/tx/datashard/datashard_user_table.h index fad38a36884..0dab30cb84f 100644 --- a/ydb/core/tx/datashard/datashard_user_table.h +++ b/ydb/core/tx/datashard/datashard_user_table.h @@ -307,20 +307,20 @@ struct TUserTable : public TThrRefBase { ui64 MemDataSize = 0; TInstant AccessTime; TInstant UpdateTime; - TInstant LastFullCompaction; + TInstant LastFullCompaction; THashSet<ui64> PartOwners; ui64 PartCount = 0; - ui64 SearchHeight = 0; + ui64 SearchHeight = 0; TInstant StatsUpdateTime; ui64 DataSizeResolution = 0; ui64 RowCountResolution = 0; - ui64 BackgroundCompactionRequests = 0; + ui64 BackgroundCompactionRequests = 0; NTable::TKeyAccessSample AccessStats; - bool LastSearchHeightMetricSet = false; - - std::optional<ui32> HoursSinceFullCompaction; - + bool LastSearchHeightMetricSet = false; + + std::optional<ui32> HoursSinceFullCompaction; + void Update(NTable::TStats&& dataStats, ui64 indexSize, THashSet<ui64>&& partOwners, ui64 partCount, TInstant statsUpdateTime) { DataStats = dataStats; IndexSize = indexSize; diff --git a/ydb/core/tx/datashard/datashard_ut_background_compaction.cpp b/ydb/core/tx/datashard/datashard_ut_background_compaction.cpp index 2c5575ffd70..4872979bdf6 100644 --- a/ydb/core/tx/datashard/datashard_ut_background_compaction.cpp +++ b/ydb/core/tx/datashard/datashard_ut_background_compaction.cpp @@ -1,149 +1,149 @@ -#include "datashard_ut_common.h" -#include "datashard_active_transaction.h" - +#include "datashard_ut_common.h" +#include "datashard_active_transaction.h" + #include <ydb/core/tx/tx_proxy/proxy.h> #include <ydb/core/tx/tx_proxy/read_table.h> - + #include <ydb/public/sdk/cpp/client/ydb_result/result.h> - -namespace NKikimr { - -using namespace NKikimr::NDataShard; + +namespace NKikimr { + +using namespace NKikimr::NDataShard; using namespace NSchemeShard; -using namespace Tests; - -namespace { - -NKikimrTxDataShard::TEvCompactTableResult CompactTable( - Tests::TServer::TPtr server, - NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - ui64 tabletId, - ui64 ownerId) -{ - auto &runtime = *server->GetRuntime(); - - auto sender = runtime.AllocateEdgeActor(); - auto request = MakeHolder<TEvDataShard::TEvCompactTable>(ownerId, userTable.GetPathId()); - runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); - - TAutoPtr<IEventHandle> handle; - auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvCompactTableResult>(handle); - return response->Record; -} - -} // namespace - -Y_UNIT_TEST_SUITE(DataShardBackgroundCompaction) { - Y_UNIT_TEST(ShouldCompact) { - TPortManager pm; - TServerSettings serverSettings(pm.GetPort(2134)); - serverSettings.SetDomainName("Root") - .SetUseRealThreads(false); - - Tests::TServer::TPtr server = new TServer(serverSettings); - auto &runtime = *server->GetRuntime(); - auto sender = runtime.AllocateEdgeActor(); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - - InitRoot(server, sender); - - CreateShardedTable(server, sender, "/Root", "table-1", 1); - ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); - - auto shards = GetTableShards(server, sender, "/Root/table-1"); - - auto [tables, ownerId] = GetTables(server, shards.at(0)); - auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); - UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::OK); - } - - Y_UNIT_TEST(ShouldNotCompactWhenBorrowed) { - TPortManager pm; - TServerSettings serverSettings(pm.GetPort(2134)); - serverSettings.SetDomainName("Root") - .SetUseRealThreads(false); - - Tests::TServer::TPtr server = new TServer(serverSettings); - auto &runtime = *server->GetRuntime(); - auto sender = runtime.AllocateEdgeActor(); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - - InitRoot(server, sender); - - CreateShardedTable(server, sender, "/Root", "table-1", 1); - ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); - - auto shards = GetTableShards(server, sender, "/Root/table-1"); - - SetSplitMergePartCountLimit(&runtime, -1); - ui64 txId = AsyncSplitTable(server, sender, "/Root/table-1", shards.at(0), 3); - WaitTxNotification(server, sender, txId); - - auto [tables, ownerId] = GetTables(server, shards.at(0)); - - shards = GetTableShards(server, sender, "/Root/table-1"); - UNIT_ASSERT(shards.size() > 1); - - for (auto shard: shards) { - auto compactionResult = CompactTable(server, tables["table-1"], shard, ownerId); - UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::FAILED); - } - } - - Y_UNIT_TEST(ShouldNotCompactEmptyTable) { - TPortManager pm; - TServerSettings serverSettings(pm.GetPort(2134)); - serverSettings.SetDomainName("Root") - .SetUseRealThreads(false); - - Tests::TServer::TPtr server = new TServer(serverSettings); - auto &runtime = *server->GetRuntime(); - auto sender = runtime.AllocateEdgeActor(); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - - InitRoot(server, sender); - - CreateShardedTable(server, sender, "/Root", "table-1", 1); - auto shards = GetTableShards(server, sender, "/Root/table-1"); - - auto [tables, ownerId] = GetTables(server, shards.at(0)); - auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); - UNIT_ASSERT(compactionResult.GetStatus() == NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED); - } - - Y_UNIT_TEST(ShouldNotCompactSecondTime) { - TPortManager pm; - TServerSettings serverSettings(pm.GetPort(2134)); - serverSettings.SetDomainName("Root") - .SetUseRealThreads(false); - - Tests::TServer::TPtr server = new TServer(serverSettings); - auto &runtime = *server->GetRuntime(); - auto sender = runtime.AllocateEdgeActor(); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - - InitRoot(server, sender); - - CreateShardedTable(server, sender, "/Root", "table-1", 1); - ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); - - auto shards = GetTableShards(server, sender, "/Root/table-1"); - - auto [tables, ownerId] = GetTables(server, shards.at(0)); - auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); - UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::OK); - - compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); - UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED); - } -} - -} // namespace NKikimr +using namespace Tests; + +namespace { + +NKikimrTxDataShard::TEvCompactTableResult CompactTable( + Tests::TServer::TPtr server, + NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + ui64 tabletId, + ui64 ownerId) +{ + auto &runtime = *server->GetRuntime(); + + auto sender = runtime.AllocateEdgeActor(); + auto request = MakeHolder<TEvDataShard::TEvCompactTable>(ownerId, userTable.GetPathId()); + runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); + + TAutoPtr<IEventHandle> handle; + auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvCompactTableResult>(handle); + return response->Record; +} + +} // namespace + +Y_UNIT_TEST_SUITE(DataShardBackgroundCompaction) { + Y_UNIT_TEST(ShouldCompact) { + TPortManager pm; + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false); + + Tests::TServer::TPtr server = new TServer(serverSettings); + auto &runtime = *server->GetRuntime(); + auto sender = runtime.AllocateEdgeActor(); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + + InitRoot(server, sender); + + CreateShardedTable(server, sender, "/Root", "table-1", 1); + ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); + + auto shards = GetTableShards(server, sender, "/Root/table-1"); + + auto [tables, ownerId] = GetTables(server, shards.at(0)); + auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); + UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::OK); + } + + Y_UNIT_TEST(ShouldNotCompactWhenBorrowed) { + TPortManager pm; + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false); + + Tests::TServer::TPtr server = new TServer(serverSettings); + auto &runtime = *server->GetRuntime(); + auto sender = runtime.AllocateEdgeActor(); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + + InitRoot(server, sender); + + CreateShardedTable(server, sender, "/Root", "table-1", 1); + ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); + + auto shards = GetTableShards(server, sender, "/Root/table-1"); + + SetSplitMergePartCountLimit(&runtime, -1); + ui64 txId = AsyncSplitTable(server, sender, "/Root/table-1", shards.at(0), 3); + WaitTxNotification(server, sender, txId); + + auto [tables, ownerId] = GetTables(server, shards.at(0)); + + shards = GetTableShards(server, sender, "/Root/table-1"); + UNIT_ASSERT(shards.size() > 1); + + for (auto shard: shards) { + auto compactionResult = CompactTable(server, tables["table-1"], shard, ownerId); + UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::FAILED); + } + } + + Y_UNIT_TEST(ShouldNotCompactEmptyTable) { + TPortManager pm; + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false); + + Tests::TServer::TPtr server = new TServer(serverSettings); + auto &runtime = *server->GetRuntime(); + auto sender = runtime.AllocateEdgeActor(); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + + InitRoot(server, sender); + + CreateShardedTable(server, sender, "/Root", "table-1", 1); + auto shards = GetTableShards(server, sender, "/Root/table-1"); + + auto [tables, ownerId] = GetTables(server, shards.at(0)); + auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); + UNIT_ASSERT(compactionResult.GetStatus() == NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED); + } + + Y_UNIT_TEST(ShouldNotCompactSecondTime) { + TPortManager pm; + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false); + + Tests::TServer::TPtr server = new TServer(serverSettings); + auto &runtime = *server->GetRuntime(); + auto sender = runtime.AllocateEdgeActor(); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + + InitRoot(server, sender); + + CreateShardedTable(server, sender, "/Root", "table-1", 1); + ExecSQL(server, sender, "UPSERT INTO [/Root/table-1] (key, value) VALUES (1, 100), (3, 300), (5, 500);"); + + auto shards = GetTableShards(server, sender, "/Root/table-1"); + + auto [tables, ownerId] = GetTables(server, shards.at(0)); + auto compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); + UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::OK); + + compactionResult = CompactTable(server, tables["table-1"], shards.at(0), ownerId); + UNIT_ASSERT_VALUES_EQUAL(compactionResult.GetStatus(), NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED); + } +} + +} // namespace NKikimr diff --git a/ydb/core/tx/datashard/datashard_ut_common.cpp b/ydb/core/tx/datashard/datashard_ut_common.cpp index e7156a320f9..d754f7ad0e2 100644 --- a/ydb/core/tx/datashard/datashard_ut_common.cpp +++ b/ydb/core/tx/datashard/datashard_ut_common.cpp @@ -67,8 +67,8 @@ TTester::TTester(ESchema schema, const TOptions& opts) Sender = Runtime.AllocateEdgeActor(); // Schemeshard is only used to receive notifications - CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_SCHEMESHARD_TABLET_ID, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); - CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_TX_ALLOCATOR_TABLET_ID, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_SCHEMESHARD_TABLET_ID, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_TX_ALLOCATOR_TABLET_ID, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); CreateSchema(schema, opts); } @@ -86,8 +86,8 @@ TTester::TTester(ESchema schema, const TString& dispatchName, std::function<void DispatchName = dispatchName; // Schemeshard is only used to receive notifications - CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_SCHEMESHARD_TABLET_ID, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); - CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_TX_ALLOCATOR_TABLET_ID, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_SCHEMESHARD_TABLET_ID, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(Runtime, CreateTestTabletInfo(FAKE_TX_ALLOCATOR_TABLET_ID, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); CreateSchema(schema, opts); } @@ -98,7 +98,7 @@ void TTester::EmptyShardKeyResolver(TKeyDesc& key) { void TTester::SingleShardKeyResolver(TKeyDesc& key) { key.Status = TKeyDesc::EStatus::Ok; - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); } void TTester::ThreeShardPointKeyResolver(TKeyDesc& key) { @@ -109,11 +109,11 @@ void TTester::ThreeShardPointKeyResolver(TKeyDesc& key) { if (key.Range.Point) { ui32 key0 = *(ui32*)key.Range.From[0].Data(); if (key0 < ShardBorder1) { - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); } else if (key0 < ShardBorder2) { - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet1)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet1)); } else { - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet2)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet2)); } } else { UNIT_ASSERT(key.Range.From.size() > 0); @@ -126,11 +126,11 @@ void TTester::ThreeShardPointKeyResolver(TKeyDesc& key) { UNIT_ASSERT(from <= to); if (from < ShardBorder1) - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); if (from < ShardBorder2 && to >= ShardBorder1) - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet1)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet1)); if (to >= ShardBorder2) - key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet2)); + key.Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet2)); } } @@ -148,7 +148,7 @@ TTester::TKeyResolver TTester::GetKeyResolver() const { } void TTester::CreateDataShard(TFakeMiniKQLProxy& proxy, ui64 tabletId, const TString& schemeText, bool withRegister) { - TActorId actorId = CreateTestBootstrapper(Runtime, CreateTestTabletInfo(tabletId, TTabletTypes::FLAT_DATASHARD), + TActorId actorId = CreateTestBootstrapper(Runtime, CreateTestTabletInfo(tabletId, TTabletTypes::FLAT_DATASHARD), &::NKikimr::CreateDataShard); Y_UNUSED(actorId); @@ -158,7 +158,7 @@ void TTester::CreateDataShard(TFakeMiniKQLProxy& proxy, ui64 tabletId, const TSt UNIT_ASSERT_EQUAL(proxy.ExecSchemeCreateTable(schemeText, {tabletId}), IEngineFlat::EStatus::Complete); - RebootTablet(Runtime, tabletId, Sender); + RebootTablet(Runtime, tabletId, Sender); //Runtime.EnableScheduleForActor(actorId, true); @@ -254,21 +254,21 @@ void TTester::CreateSchema(ESchema schema, const TOptions& opts) { TFakeMiniKQLProxy proxy(*this); switch (schema) { case ESchema_KV: - CreateDataShard(proxy, TTestTxConfig::TxTablet0, keyValueSchemeText, true); + CreateDataShard(proxy, TTestTxConfig::TxTablet0, keyValueSchemeText, true); break; case ESchema_DoubleKV: - CreateDataShard(proxy, TTestTxConfig::TxTablet0, doubleKeyValueSchemeText, true); + CreateDataShard(proxy, TTestTxConfig::TxTablet0, doubleKeyValueSchemeText, true); break; case ESchema_DoubleKVExternal: - CreateDataShard(proxy, TTestTxConfig::TxTablet0, doubleKeyValueExternalSchemeText, true); + CreateDataShard(proxy, TTestTxConfig::TxTablet0, doubleKeyValueExternalSchemeText, true); break; case ESchema_SpecialKV: - CreateDataShard(proxy, TTestTxConfig::TxTablet0, specialKeyValueSchemeText, true); + CreateDataShard(proxy, TTestTxConfig::TxTablet0, specialKeyValueSchemeText, true); break; case ESchema_MultiShardKV: - CreateDataShard(proxy, TTestTxConfig::TxTablet0, keyValueSchemeText, true); - CreateDataShard(proxy, TTestTxConfig::TxTablet1, keyValueSchemeText); - CreateDataShard(proxy, TTestTxConfig::TxTablet2, keyValueSchemeText); + CreateDataShard(proxy, TTestTxConfig::TxTablet0, keyValueSchemeText, true); + CreateDataShard(proxy, TTestTxConfig::TxTablet1, keyValueSchemeText); + CreateDataShard(proxy, TTestTxConfig::TxTablet2, keyValueSchemeText); break; } } @@ -668,7 +668,7 @@ void TFakeMiniKQLProxy::Propose(TFakeProxyTx& tx, bool holdImmediate) { void TFakeMiniKQLProxy::ResolveShards(const TSet<ui64>& shards) { for (ui64 shard : shards) { auto event = new TEvDataShard::TEvGetShardState(Tester.Sender); - ForwardToTablet(Tester.Runtime, shard, Tester.Sender, event); + ForwardToTablet(Tester.Runtime, shard, Tester.Sender, event); } for (ui32 results = 0; results < shards.size(); ++results) { @@ -870,7 +870,7 @@ ui64 TFakeMiniKQLProxy::Plan(ui64 stepId, const TMap<ui64, TFakeProxyTx::TPtr>& TExpectedReadSet::TWaitFor waitFor = DelayedReadSets.front().Freedom; if (shard == waitFor.Shard && tx->TxId() == waitFor.TxId) { if (RebootOnDelay) { - RebootTablet(Tester.Runtime, TTestTxConfig::TxTablet0, Tester.Sender); + RebootTablet(Tester.Runtime, TTestTxConfig::TxTablet0, Tester.Sender); } Y_VERIFY(delayedEvent); @@ -997,7 +997,7 @@ TKeyExtractor::TKeyExtractor(TTester& tester, TString programText) { for (auto& key : Engine->GetDbKeys()) { key->Status = TKeyDesc::EStatus::Ok; - key->Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); + key->Partitions.push_back(TKeyDesc::TPartitionInfo((ui64)TTestTxConfig::TxTablet0)); } } @@ -1199,9 +1199,9 @@ void CreateShardedTable(Tests::TServer::TPtr server, CreateShardedTable(server, sender, root, name, opts); } -NKikimrScheme::TEvDescribeSchemeResult DescribeTable(Tests::TServer::TPtr server, - TActorId sender, - const TString &path) +NKikimrScheme::TEvDescribeSchemeResult DescribeTable(Tests::TServer::TPtr server, + TActorId sender, + const TString &path) { auto &runtime = *server->GetRuntime(); TAutoPtr<IEventHandle> handle; @@ -1212,45 +1212,45 @@ NKikimrScheme::TEvDescribeSchemeResult DescribeTable(Tests::TServer::TPtr server request->Record.MutableDescribePath()->MutableOptions()->SetShowPrivateTable(true); runtime.Send(new IEventHandle(MakeTxProxyID(), sender, request.Release())); auto reply = runtime.GrabEdgeEventRethrow<TEvSchemeShard::TEvDescribeSchemeResult>(handle); - - return *reply->MutableRecord(); -} - -TVector<ui64> GetTableShards(Tests::TServer::TPtr server, - TActorId sender, - const TString &path) -{ - TVector<ui64> shards; - auto lsResult = DescribeTable(server, sender, path); - for (auto &part : lsResult.GetPathDescription().GetTablePartitions()) + + return *reply->MutableRecord(); +} + +TVector<ui64> GetTableShards(Tests::TServer::TPtr server, + TActorId sender, + const TString &path) +{ + TVector<ui64> shards; + auto lsResult = DescribeTable(server, sender, path); + for (auto &part : lsResult.GetPathDescription().GetTablePartitions()) shards.push_back(part.GetDatashardId()); return shards; } -std::pair<TTableInfoMap, ui64> GetTables( - Tests::TServer::TPtr server, - ui64 tabletId) -{ - auto &runtime = *server->GetRuntime(); - - auto sender = runtime.AllocateEdgeActor(); - auto request = MakeHolder<TEvDataShard::TEvGetInfoRequest>(); - runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); - - TTableInfoMap result; - - TAutoPtr<IEventHandle> handle; - auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetInfoResponse>(handle); - for (auto& table: response->Record.GetUserTables()) { - result[table.GetName()] = table; - } - - auto ownerId = response->Record.GetTabletInfo().GetSchemeShard(); - - return std::make_pair(result, ownerId); -} - +std::pair<TTableInfoMap, ui64> GetTables( + Tests::TServer::TPtr server, + ui64 tabletId) +{ + auto &runtime = *server->GetRuntime(); + + auto sender = runtime.AllocateEdgeActor(); + auto request = MakeHolder<TEvDataShard::TEvGetInfoRequest>(); + runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); + + TTableInfoMap result; + + TAutoPtr<IEventHandle> handle; + auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetInfoResponse>(handle); + for (auto& table: response->Record.GetUserTables()) { + result[table.GetName()] = table; + } + + auto ownerId = response->Record.GetTabletInfo().GetSchemeShard(); + + return std::make_pair(result, ownerId); +} + TTableId ResolveTableId( Tests::TServer::TPtr server, TActorId sender, @@ -1284,7 +1284,7 @@ NTable::TRowVersionRanges GetRemovedRowVersions( { auto request = MakeHolder<TEvDataShard::TEvGetRemovedRowVersions>(TPathId{}); - ForwardToTablet(runtime, shardId, sender, request.Release()); + ForwardToTablet(runtime, shardId, sender, request.Release()); } auto ev = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetRemovedRowVersionsResult>(sender); diff --git a/ydb/core/tx/datashard/datashard_ut_common.h b/ydb/core/tx/datashard/datashard_ut_common.h index 0c36dfab84a..4b5d7fe4ea0 100644 --- a/ydb/core/tx/datashard/datashard_ut_common.h +++ b/ydb/core/tx/datashard/datashard_ut_common.h @@ -117,8 +117,8 @@ private: void RegisterTableInResolver(const TString& schemeText); static void EmptyShardKeyResolver(TKeyDesc& key); - static void SingleShardKeyResolver(TKeyDesc& key); // uses TTestTxConfig::TxTablet0 - static void ThreeShardPointKeyResolver(TKeyDesc& key); // uses TTestTxConfig::TxTablet0,1,2 + static void SingleShardKeyResolver(TKeyDesc& key); // uses TTestTxConfig::TxTablet0 + static void ThreeShardPointKeyResolver(TKeyDesc& key); // uses TTestTxConfig::TxTablet0,1,2 }; /// @@ -134,8 +134,8 @@ struct TExpectedReadSet { TWaitFor Freedom; TExpectedReadSet(ui64 txId, TWaitFor freedom) - : SrcTablet(TTestTxConfig::TxTablet1) - , DstTablet(TTestTxConfig::TxTablet0) + : SrcTablet(TTestTxConfig::TxTablet1) + , DstTablet(TTestTxConfig::TxTablet0) , TxId(txId) , Freedom(freedom) {} @@ -333,9 +333,9 @@ public: static TDatashardInitialEventsFilter CreateDefault() { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); return TDatashardInitialEventsFilter(tabletIds); } @@ -470,11 +470,11 @@ TVector<ui64> GetTableShards(Tests::TServer::TPtr server, TActorId sender, const TString &path); -using TTableInfoMap = THashMap<TString, NKikimrTxDataShard::TEvGetInfoResponse::TUserTable>; - -std::pair<TTableInfoMap, ui64> GetTables(Tests::TServer::TPtr server, - ui64 tabletId); - +using TTableInfoMap = THashMap<TString, NKikimrTxDataShard::TEvGetInfoResponse::TUserTable>; + +std::pair<TTableInfoMap, ui64> GetTables(Tests::TServer::TPtr server, + ui64 tabletId); + TTableId ResolveTableId( Tests::TServer::TPtr server, TActorId sender, diff --git a/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp b/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp index 4baa52cbc3a..87a51ef80ab 100644 --- a/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp +++ b/ydb/core/tx/datashard/datashard_ut_erase_rows.cpp @@ -1556,7 +1556,7 @@ tkey = 100, key = 4 auto tabletIds = GetTableShards(server, sender, "/Root/table-1/by_skey/indexImplTable"); UNIT_ASSERT_VALUES_EQUAL(tabletIds.size(), 1); - RebootTablet(runtime, tabletIds[0], sender); + RebootTablet(runtime, tabletIds[0], sender); for (auto& ev : delayed) { runtime.Send(ev.Release(), 0, true); diff --git a/ydb/core/tx/datashard/datashard_ut_init.cpp b/ydb/core/tx/datashard/datashard_ut_init.cpp index 2d9f55b56d2..818e30ab0cb 100644 --- a/ydb/core/tx/datashard/datashard_ut_init.cpp +++ b/ydb/core/tx/datashard/datashard_ut_init.cpp @@ -99,18 +99,18 @@ Y_UNIT_TEST_SUITE(TTxDataShardTestInit) { TTester::Setup(runtime); TActorId sender = runtime.AllocateEdgeActor(); - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::FLAT_DATASHARD), &CreateDataShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TTestTxConfig::TxTablet0, TTabletTypes::FLAT_DATASHARD), &CreateDataShard); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); runtime.DispatchEvents(options); Y_UNUSED(sender); - ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvDataShard::TEvGetShardState(sender)); + ForwardToTablet(runtime, TTestTxConfig::TxTablet0, sender, new TEvDataShard::TEvGetShardState(sender)); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvDataShard::TEvGetShardStateResult>(handle); UNIT_ASSERT(event); - UNIT_ASSERT_EQUAL(event->GetOrigin(), TTestTxConfig::TxTablet0); + UNIT_ASSERT_EQUAL(event->GetOrigin(), TTestTxConfig::TxTablet0); UNIT_ASSERT_EQUAL(event->GetState(), NDataShard::TShardState::WaitScheme); } diff --git a/ydb/core/tx/datashard/datashard_ut_minikql.cpp b/ydb/core/tx/datashard/datashard_ut_minikql.cpp index b10135ad1fe..7974e474861 100644 --- a/ydb/core/tx/datashard/datashard_ut_minikql.cpp +++ b/ydb/core/tx/datashard/datashard_ut_minikql.cpp @@ -734,7 +734,7 @@ Y_UNIT_TEST(TableStats) { TFakeMiniKQLProxy proxy(t); ui64 tableId = 13; - ui64 ds1 = TTestTxConfig::TxTablet0; + ui64 ds1 = TTestTxConfig::TxTablet0; { auto programText = R"___(( @@ -816,7 +816,7 @@ Y_UNIT_TEST(TableStatsHistograms) { TFakeMiniKQLProxy proxy(t); ui64 tableId = 13; - ui64 ds1 = TTestTxConfig::TxTablet0; + ui64 ds1 = TTestTxConfig::TxTablet0; for (int i = 0; i < 1000; ++i) { auto programText = R"___(( @@ -934,9 +934,9 @@ void CrossShard_1_Cycle_Impl(const TString& dispatchName, std::function<void (TT Y_UNIT_TEST(CrossShard_1_Cycle) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1011,9 +1011,9 @@ void CrossShard_2_SwapAndCopy_Impl(const TString& dispatchName, std::function<vo Y_UNIT_TEST(CrossShard_2_SwapAndCopy) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1089,9 +1089,9 @@ void CrossShard_3_AllToOne_Impl(const TString& dispatchName, std::function<void Y_UNIT_TEST(CrossShard_3_AllToOne) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1165,9 +1165,9 @@ void CrossShard_4_OneToAll_Impl(const TString& dispatchName, std::function<void Y_UNIT_TEST(CrossShard_4_OneToAll) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1277,9 +1277,9 @@ void CrossShard_5_AllToAll_Impl(const TString& dispatchName, std::function<void Y_UNIT_TEST(CrossShard_5_AllToAll) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1353,9 +1353,9 @@ void CrossShard_6_Local_Impl(const TString& dispatchName, std::function<void (TT Y_UNIT_TEST(CrossShard_6_Local) { TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); - tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet0); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet1); + tabletIds.push_back((ui64)TTestTxConfig::TxTablet2); TDatashardInitialEventsFilter initialEventsFilter(tabletIds); RunTestWithReboots(tabletIds, [&]() { return initialEventsFilter.Prepare(); @@ -1543,7 +1543,7 @@ Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { }, activeZone); TFakeMiniKQLProxy proxy(t); - auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); auto programText = R"___(( (let row '('('key (Uint32 '42)))) @@ -1558,7 +1558,7 @@ Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { auto text = Sprintf(programText, TString(1024, 'v').data()); UNIT_ASSERT_EQUAL(proxy.Execute(text), IEngineFlat::EStatus::Complete); - auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); // Expect one allocation on prepare. CheckCounters(counters2, counters1, 1, 0, 0); @@ -1578,7 +1578,7 @@ Y_UNIT_TEST(MemoryUsageImmediateSmallTx) { UNIT_ASSERT_EQUAL(proxy.Execute(programText, res), IEngineFlat::EStatus::Complete); } - auto counters3 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters3 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); // Expect one allocation on prepare. CheckCounters(counters3, counters2, 1, 0, 0); } @@ -1590,7 +1590,7 @@ Y_UNIT_TEST(MemoryUsageImmediateMediumTx) { }, activeZone); TFakeMiniKQLProxy proxy(t); - auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); { auto programText = R"___(( @@ -1609,7 +1609,7 @@ Y_UNIT_TEST(MemoryUsageImmediateMediumTx) { UNIT_ASSERT_EQUAL(proxy.Execute(programText, res), IEngineFlat::EStatus::Complete); } - auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); // Expect one allocation on prepare and one or two // allocations during execution. CheckCounters(counters2, counters1, TCounterRange{2, 3}, 0, 0); @@ -1622,7 +1622,7 @@ Y_UNIT_TEST(MemoryUsageImmediateHugeTx) { }, activeZone); TFakeMiniKQLProxy proxy(t); - auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters1 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); { auto programText = R"___(( @@ -1641,7 +1641,7 @@ Y_UNIT_TEST(MemoryUsageImmediateHugeTx) { UNIT_ASSERT_EQUAL(proxy.Execute(programText, res), IEngineFlat::EStatus::Complete); } - auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); + auto counters2 = ReadTxMemoryCounters(t, TTestTxConfig::TxTablet0); // Expect one allocation on prepare and three // allocations during execution. CheckCounters(counters2, counters1, 4, 0, 0); diff --git a/ydb/core/tx/datashard/datashard_ut_minstep.cpp b/ydb/core/tx/datashard/datashard_ut_minstep.cpp index 68ddda20ec3..99d72b2e457 100644 --- a/ydb/core/tx/datashard/datashard_ut_minstep.cpp +++ b/ydb/core/tx/datashard/datashard_ut_minstep.cpp @@ -255,11 +255,11 @@ Y_UNIT_TEST_SUITE(TDataShardMinStepTest) { switch (rebootOnPropose) { case ERebootOnPropose::DataShard: Cerr << "Rebooting datashard and waiting for new propose..." << Endl; - RebootTablet(runtime, table1shard, sender); + RebootTablet(runtime, table1shard, sender); break; case ERebootOnPropose::SchemeShard: Cerr << "Rebooting schemeshard and waiting for datashard propose..." << Endl; - RebootTablet(runtime, schemeShard, sender); + RebootTablet(runtime, schemeShard, sender); break; } if (proposes.size() < 1) { diff --git a/ydb/core/tx/datashard/datashard_ut_order.cpp b/ydb/core/tx/datashard/datashard_ut_order.cpp index ad7f1d673f1..32472dce59e 100644 --- a/ydb/core/tx/datashard/datashard_ut_order.cpp +++ b/ydb/core/tx/datashard/datashard_ut_order.cpp @@ -390,7 +390,7 @@ Y_UNIT_TEST_WITH_MVCC(DelayData) { EvictShardCache(proxy, 500); ui64 indepTxId = proxy.LastTxId() + 2; - proxy.DelayData({TTestTxConfig::TxTablet0, indepTxId}); + proxy.DelayData({TTestTxConfig::TxTablet0, indepTxId}); const char * programRead = R"(( (let key_ '('('key (Uint32 '0)))) @@ -524,7 +524,7 @@ Y_UNIT_TEST_WITH_MVCC(ReadWriteReorder) { auto txWriteLast = proxy.LastTxId(); // Delay first shard readsets until last write succeeds - proxy.DelayReadSet(TExpectedReadSet(txMoveKey, { TTestTxConfig::TxTablet0, txWriteLast })); + proxy.DelayReadSet(TExpectedReadSet(txMoveKey, { TTestTxConfig::TxTablet0, txWriteLast })); proxy.ExecQueue(); // Sanity check: read must go first, otherwise the whole machinery would hang @@ -678,13 +678,13 @@ static void RandomTxDeps(const TTester::TOptions& opts, ui32 numTxs, ui32 maxKey indepPos = 7; indepTxId = proxy.LastTxId() + 8; ui64 delayedRS = proxy.LastTxId() + 2; // 2 cause of o-o-o disabled till first complete (LastCompleteTx) - proxy.DelayReadSet(TExpectedReadSet(delayedRS, {TTestTxConfig::TxTablet0, indepTxId}), opts.RebootOnDelay); + proxy.DelayReadSet(TExpectedReadSet(delayedRS, {TTestTxConfig::TxTablet0, indepTxId}), opts.RebootOnDelay); } else if (opts.DelayData) { UNIT_ASSERT(numTxs >= 8); indepPos = 7; EvictShardCache(proxy, 500); indepTxId = proxy.LastTxId() + 8; - proxy.DelayData({TTestTxConfig::TxTablet0, indepTxId}); + proxy.DelayData({TTestTxConfig::TxTablet0, indepTxId}); } TVector<ui32> expected(32, Max<ui32>()); @@ -1902,7 +1902,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestOutOfOrderRestartLocksSingleWithoutBarrier) { TPortManager pm; TServerSettings serverSettings(pm.GetPort(2134)); serverSettings.SetDomainName("Root") - .SetEnableMvcc(false) // intentionally, because we test non-mvcc locks logic + .SetEnableMvcc(false) // intentionally, because we test non-mvcc locks logic .SetUseRealThreads(false); Tests::TServer::TPtr server = new TServer(serverSettings); @@ -1971,7 +1971,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestOutOfOrderRestartLocksSingleWithoutBarrier) { // Reboot table-1 tablet readSets.clear(); - RebootTablet(runtime, table1shards[0], sender); + RebootTablet(runtime, table1shards[0], sender); // Wait until we captured both readsets again if (readSets.size() < 2) { @@ -2116,7 +2116,7 @@ Y_UNIT_TEST_NEW_ENGINE(MvccTestOutOfOrderRestartLocksSingleWithoutBarrier) { // Reboot table-1 tablet readSets.clear(); - RebootTablet(runtime, table1shards[0], sender); + RebootTablet(runtime, table1shards[0], sender); // Wait until we captured both readsets again if (readSets.size() < 2) { @@ -2275,7 +2275,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderRestartLocksReorderedWithoutBarrier, UseMvcc, Use // Reboot table-1 tablet UNIT_ASSERT_VALUES_EQUAL(readSets.size(), 2u); readSets.clear(); - RebootTablet(runtime, table1shards[0], sender); + RebootTablet(runtime, table1shards[0], sender); // Wait until we captured both readsets again if (readSets.size() < 2) { @@ -2461,7 +2461,7 @@ Y_UNIT_TEST_QUAD(TestOutOfOrderNoBarrierRestartImmediateLongTail, UseMvcc, UseNe blockProgressEvents = true; bypassProgressEvents = 1; Cerr << "... rebooting tablet" << Endl; - RebootTablet(runtime, table1shards[0], sender); + RebootTablet(runtime, table1shards[0], sender); Cerr << "... tablet rebooted" << Endl; // Wait until we captured both readsets again @@ -3957,7 +3957,7 @@ Y_UNIT_TEST_NEW_ENGINE(TestSecondaryClearanceAfterShardRestartRace) { seenStreamClearanceRequests = 0; seenStreamClearanceResponses = 0; - RebootTablet(runtime, shards[0], sender); + RebootTablet(runtime, shards[0], sender); waitFor([&]{ return capturedDeliveryProblem.size() >= 1; }, "intercepted TEvDeliveryProblem"); waitFor([&]{ return seenStreamClearanceRequests >= 1; }, "observed TEvStreamClearanceRequest"); diff --git a/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp b/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp index 8bf8708060c..a605a029fc3 100644 --- a/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp +++ b/ydb/core/tx/datashard/datashard_ut_read_iterator.cpp @@ -1,1346 +1,1346 @@ -#include "datashard_ut_common.h" -#include "datashard_active_transaction.h" -#include "read_iterator.h" - -#include <ydb/core/formats/arrow_helpers.h> -#include <ydb/core/tx/tx_proxy/proxy.h> -#include <ydb/core/tx/tx_proxy/read_table.h> - +#include "datashard_ut_common.h" +#include "datashard_active_transaction.h" +#include "read_iterator.h" + +#include <ydb/core/formats/arrow_helpers.h> +#include <ydb/core/tx/tx_proxy/proxy.h> +#include <ydb/core/tx/tx_proxy/read_table.h> + #include <ydb/public/sdk/cpp/client/ydb_result/result.h> - -#include <algorithm> -#include <map> - -namespace NKikimr { - -using namespace NKikimr::NDataShard; -using namespace NSchemeShard; -using namespace Tests; - -namespace { - -using TCellVec = std::vector<TCell>; - -void CreateTable(Tests::TServer::TPtr server, - TActorId sender, - const TString &root, - const TString &name) -{ - TVector<TShardedTableOptions::TColumn> columns = { - {"key1", "Uint32", true, false}, - {"key2", "Uint32", true, false}, - {"key3", "Uint32", true, false}, - {"value", "Uint32", false, false} - }; - - auto opts = TShardedTableOptions() - .Shards(1) - .Columns(columns); - - CreateShardedTable(server, sender, root, name, opts); -} - -void CreateMoviesTable(Tests::TServer::TPtr server, - TActorId sender, - const TString &root, - const TString &name) -{ - TVector<TShardedTableOptions::TColumn> columns = { - {"id", "Uint32", true, false}, - {"title", "String", false, false}, - {"rating", "Uint32", false, false} - }; - - auto opts = TShardedTableOptions() - .Shards(1) - .Columns(columns); - - CreateShardedTable(server, sender, root, name, opts); -} - -struct TRowWriter : public NArrow::IRowWriter { - std::vector<TOwnedCellVec> Rows; - - TRowWriter() = default; - - void AddRow(const TConstArrayRef<TCell> &cells) override { - Rows.emplace_back(cells); - } -}; - -std::vector<TOwnedCellVec> GetRows( - const TVector<std::pair<TString, NScheme::TTypeId>>& batchSchema, - const TEvDataShard::TEvReadResult& result) -{ - UNIT_ASSERT(result.ArrowBatch); - - // TODO: use schema from ArrowBatch - TRowWriter writer; - NArrow::TArrowToYdbConverter converter(batchSchema, writer); - - TString error; - UNIT_ASSERT(converter.Process(*result.ArrowBatch, error)); - - return std::move(writer.Rows); -} - -void CheckRow( - const TConstArrayRef<TCell>& row, - const TCellVec& gold, - const std::vector<NScheme::TTypeIdOrder>& goldTypes) -{ - UNIT_ASSERT_VALUES_EQUAL(row.size(), gold.size()); - for (size_t i: xrange(row.size())) { - int cmp = CompareTypedCells(row[i], gold[i], goldTypes[i]); - UNIT_ASSERT_VALUES_EQUAL(cmp, 0); - } -} - -template <typename TCellVecType> -void CheckRows( - const std::vector<TCellVecType>& rows, - const std::vector<TCellVec>& gold, - const std::vector<NScheme::TTypeIdOrder>& goldTypes) -{ - UNIT_ASSERT_VALUES_EQUAL(rows.size(), gold.size()); - for (size_t i: xrange(rows.size())) { - CheckRow(rows[i], gold[i], goldTypes); - } -} - -void CheckResultCellVec( - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - const TEvDataShard::TEvReadResult& result, - const std::vector<TCellVec>& gold, - const std::vector<NScheme::TTypeIdOrder>& goldTypes, - std::vector<NTable::TTag> columns = {}) -{ - Y_UNUSED(userTable); - Y_UNUSED(columns); - - UNIT_ASSERT(!gold.empty()); - - auto nrows = result.GetRowsCount(); - TVector<TConstArrayRef<TCell>> rows; - rows.reserve(nrows); - for (size_t i = 0; i < nrows; ++i) { - rows.emplace_back(result.GetCells(i)); - } - - UNIT_ASSERT(!rows.empty()); - CheckRows(rows, gold, goldTypes); -} - -void CheckResultArrow( - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - const TEvDataShard::TEvReadResult& result, - const std::vector<TCellVec>& gold, - const std::vector<NScheme::TTypeIdOrder>& goldTypes, - std::vector<NTable::TTag> columns = {}) -{ - UNIT_ASSERT(!gold.empty()); - UNIT_ASSERT(result.ArrowBatch); - - TVector<std::pair<TString, NScheme::TTypeId>> batchSchema; - const auto& description = userTable.GetDescription(); - if (columns.empty()) { - batchSchema.reserve(description.ColumnsSize()); - for (const auto& column: description.GetColumns()) { - batchSchema.emplace_back(column.GetName(), column.GetTypeId()); - } - } else { - std::map<NTable::TTag, std::pair<TString, ui32>> colsMap; - for (const auto& column: description.GetColumns()) { - colsMap[column.GetId()] = std::make_pair(column.GetName(), column.GetTypeId()); - } - batchSchema.reserve(columns.size()); - for (auto tag: columns) { - const auto& col = colsMap[tag]; - batchSchema.emplace_back(col.first, col.second); - } - } - - auto rows = GetRows(batchSchema, result); - CheckRows(rows, gold, goldTypes); -} - -void CheckResult( - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - const TEvDataShard::TEvReadResult& result, - const std::vector<TCellVec>& gold, - const std::vector<NScheme::TTypeIdOrder>& goldTypes, - std::vector<NTable::TTag> columns = {}) -{ - const auto& record = result.Record; - - if (record.GetStatus().IssuesSize()) { - TStringStream ss; - for (const auto& issue: record.GetStatus().GetIssues()) { - ss << "issue: " << issue; - } - Cerr << "Request with issues: " << ss.Str() << Endl; - } - - UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::SUCCESS); - if (gold.size()) { - switch (record.GetResultFormat()) { - case NKikimrTxDataShard::ARROW: - CheckResultArrow(userTable, result, gold, goldTypes, columns); - break; - case NKikimrTxDataShard::CELLVEC: - CheckResultCellVec(userTable, result, gold, goldTypes, columns); - break; - default: - UNIT_ASSERT(false); - } - } else { - UNIT_ASSERT(!result.ArrowBatch && result.GetRowsCount() == 0); - } -} - -void CheckResult( - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - const TEvDataShard::TEvReadResult& result, - const std::vector<std::vector<ui32>>& gold, - std::vector<NTable::TTag> columns = {}) -{ - std::vector<NScheme::TTypeIdOrder> types; - if (!gold.empty() && !gold[0].empty()) { - types.reserve(gold[0].size()); - for (auto i: xrange(gold[0].size())) { - Y_UNUSED(i); - types.emplace_back(NScheme::NTypeIds::Uint32); - } - } - - std::vector<TCellVec> goldCells; - goldCells.reserve(gold.size()); - for (const auto& row: gold) { - TCellVec cells; - cells.reserve(row.size()); - for (auto item: row) { - cells.push_back(TCell::Make(item)); - } - goldCells.emplace_back(std::move(cells)); - } - - CheckResult(userTable, result, goldCells, types, columns); -} - -template <typename TKeyType> -TVector<TCell> ToCells(const std::vector<TKeyType>& keys) { - TVector<TCell> cells; - for (auto& key: keys) { - cells.emplace_back(TCell::Make(key)); - } - return cells; -} - -void AddKeyQuery( - TEvDataShard::TEvRead& request, - const std::vector<ui32>& keys) -{ - // convertion is ugly, but for tests is OK - auto cells = ToCells(keys); - auto buf = TSerializedCellVec::Serialize(cells); - request.Keys.emplace_back(buf); -} - -template <typename TCellType> -void AddRangeQuery( - TEvDataShard::TEvRead& request, - std::vector<TCellType> from, - bool fromInclusive, - std::vector<TCellType> to, - bool toInclusive) -{ - auto fromCells = ToCells(from); - auto toCells = ToCells(to); - - // convertion is ugly, but for tests is OK - auto fromBuf = TSerializedCellVec::Serialize(fromCells); - auto toBuf = TSerializedCellVec::Serialize(toCells); - - request.Ranges.emplace_back(fromBuf, toBuf, fromInclusive, toInclusive); -} - -struct TTableInfo { - TString Name; - - ui64 TabletId; - ui64 OwnerId; - NKikimrTxDataShard::TEvGetInfoResponse::TUserTable UserTable; - - TActorId ClientId; -}; - -struct TTestHelper { - TTestHelper() { - TPortManager pm; - TServerSettings serverSettings(pm.GetPort(2134)); - serverSettings.SetDomainName("Root") - .SetUseRealThreads(false); - - Server = new TServer(serverSettings); - - auto &runtime = *Server->GetRuntime(); - Sender = runtime.AllocateEdgeActor(); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - - InitRoot(Server, Sender); - - auto& table1 = Tables["table-1"]; - table1.Name = "table-1"; - { - CreateTable(Server, Sender, "/Root", "table-1"); - ExecSQL(Server, Sender, R"( - UPSERT INTO [/Root/table-1] - (key1, key2, key3, value) - VALUES - (1, 1, 1, 100), - (3, 3, 3, 300), - (5, 5, 5, 500), - (8, 0, 0, 800), - (8, 0, 1, 801), - (8, 1, 0, 802), - (8, 1, 1, 803), - (11, 11, 11, 1111); - )"); - - auto shards = GetTableShards(Server, Sender, "/Root/table-1"); - table1.TabletId = shards.at(0); - - auto [tables, ownerId] = GetTables(Server, table1.TabletId); - table1.OwnerId = ownerId; - table1.UserTable = tables["table-1"]; - - table1.ClientId = runtime.ConnectToPipe(table1.TabletId, Sender, 0, GetPipeConfigWithRetries()); - } - - auto& table2 = Tables["movies"]; - table2.Name = "movies"; - { - CreateMoviesTable(Server, Sender, "/Root", "movies"); - ExecSQL(Server, Sender, R"( - UPSERT INTO [/Root/movies] - (id, title, rating) - VALUES - (1, "I Robot", 10), - (2, "I Am Legend", 9), - (3, "Hard die", 8); - )"); - - auto shards = GetTableShards(Server, Sender, "/Root/movies"); - table2.TabletId = shards.at(0); - - auto [tables, ownerId] = GetTables(Server, table2.TabletId); - table2.OwnerId = ownerId; - table2.UserTable = tables["movies"]; - - table2.ClientId = runtime.ConnectToPipe(table2.TabletId, Sender, 0, GetPipeConfigWithRetries()); - } - } - - std::unique_ptr<TEvDataShard::TEvRead> GetBaseReadRequest( - const TString& tableName, - ui64 readId, - NKikimrTxDataShard::EScanDataFormat format = NKikimrTxDataShard::ARROW) - { - const auto& table = Tables[tableName]; - - std::unique_ptr<TEvDataShard::TEvRead> request(new TEvDataShard::TEvRead()); - auto& record = request->Record; - - record.SetReadId(readId); - record.MutableTableId()->SetOwnerId(table.OwnerId); - record.MutableTableId()->SetTableId(table.UserTable.GetPathId()); - - const auto& description = table.UserTable.GetDescription(); - std::vector<ui32> keyColumns( - description.GetKeyColumnIds().begin(), - description.GetKeyColumnIds().end()); - - for (const auto& column: description.GetColumns()) { - record.AddColumns(column.GetId()); - } - - record.MutableTableId()->SetSchemaVersion(description.GetTableSchemaVersion()); - - auto readVersion = CreateVolatileSnapshot( - Server, - {"/Root/movies", "/Root/table-1"}, - TDuration::Hours(1)); - - record.MutableSnapshot()->SetStep(readVersion.Step); - record.MutableSnapshot()->SetTxId(readVersion.TxId); - - record.SetResultFormat(format); - - return request; - } - - std::unique_ptr<TEvDataShard::TEvRead> GetUserTablesRequest( - const TString& tableName, - ui64 localTid, - ui64 readId) - { - const auto& table = Tables[tableName]; - - std::unique_ptr<TEvDataShard::TEvRead> request(new TEvDataShard::TEvRead()); - auto& record = request->Record; - - record.SetReadId(readId); - - record.MutableTableId()->SetOwnerId(table.TabletId); - record.MutableTableId()->SetTableId(localTid); - - record.AddColumns(1); - record.AddColumns(2); - - record.SetResultFormat(NKikimrTxDataShard::CELLVEC); - - return request; - } - - std::unique_ptr<TEvDataShard::TEvReadResult> WaitReadResult(TDuration timeout = TDuration::Max()) { - auto &runtime = *Server->GetRuntime(); - TAutoPtr<IEventHandle> handle; - runtime.GrabEdgeEventRethrow<TEvDataShard::TEvReadResult>(handle, timeout); - if (!handle) { - return nullptr; - } - auto event = handle->Release<TEvDataShard::TEvReadResult>(); - return std::unique_ptr<TEvDataShard::TEvReadResult>(event.Release()); - } - - std::unique_ptr<TEvDataShard::TEvReadResult> SendRead( - const TString& tableName, - TEvDataShard::TEvRead* request) - { - const auto& table = Tables[tableName]; - auto &runtime = *Server->GetRuntime(); - runtime.SendToPipe( - table.TabletId, - Sender, - request, - 0, - GetPipeConfigWithRetries(), - table.ClientId); - - return WaitReadResult(); - } - - void SendReadAck( - const TString& tableName, - const NKikimrTxDataShard::TEvReadResult& readResult, - ui64 rows, - ui64 bytes) - { - const auto& table = Tables[tableName]; - auto* request = new TEvDataShard::TEvReadAck(); - request->Record.SetReadId(readResult.GetReadId()); - request->Record.SetSeqNo(readResult.GetSeqNo()); - request->Record.SetMaxRows(rows); - request->Record.SetMaxBytes(bytes); - - auto &runtime = *Server->GetRuntime(); - runtime.SendToPipe( - table.TabletId, - Sender, request, - 0, - GetPipeConfigWithRetries(), - table.ClientId); - } - - void SendCancel(const TString& tableName, ui64 readId) { - const auto& table = Tables[tableName]; - auto* request = new TEvDataShard::TEvReadCancel(); - request->Record.SetReadId(readId); - - auto &runtime = *Server->GetRuntime(); - runtime.SendToPipe( - table.TabletId, - Sender, - request, - 0, - GetPipeConfigWithRetries(), - table.ClientId); - } - -public: - Tests::TServer::TPtr Server; - TActorId Sender; - - THashMap<TString, TTableInfo> Tables; -}; - -void TestReadKey(NKikimrTxDataShard::EScanDataFormat format) { - TTestHelper helper; - - for (ui32 k: {1, 3, 5}) { - auto request = helper.GetBaseReadRequest("table-1", 1, format); - AddKeyQuery(*request, {k, k, k}); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k, k, k, k * 100}}); - } -} - -void TestReadRangeInclusiveEnds(NKikimrTxDataShard::EScanDataFormat format) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1, format); - AddRangeQuery<ui32>( - *request, - {1, 1, 1}, - true, - {5, 5, 5}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {1, 1, 1, 100}, - {3, 3, 3, 300}, - {5, 5, 5, 500}, - }); -} - -void TestReadRangeMovies(NKikimrTxDataShard::EScanDataFormat format) { - // test just to check if non-trivial type like string is properly replied - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("movies", 1, format); - AddRangeQuery<ui32>( - *request, - {1}, - true, - {100}, - true - ); - - TString s1 = "I Robot"; - TString s2 = "I Am Legend"; - TString s3 = "Hard die"; - - auto readResult = helper.SendRead("movies", request.release()); - CheckResult(helper.Tables["movies"].UserTable, *readResult, - { - {TCell::Make(1u), TCell(s1.data(), s1.size()), TCell::Make(10u)}, - {TCell::Make(2u), TCell(s2.data(), s2.size()), TCell::Make(9u)}, - {TCell::Make(3u), TCell(s3.data(), s3.size()), TCell::Make(8u)} - }, - { - NScheme::TTypeIdOrder(NScheme::NTypeIds::Uint32), - NScheme::TTypeIdOrder(NScheme::NTypeIds::String), - NScheme::TTypeIdOrder(NScheme::NTypeIds::Uint32) - }); -} - -} // namespace - -Y_UNIT_TEST_SUITE(DataShardReadIterator) { - Y_UNIT_TEST(ShouldReadKeyCellVec) { - TestReadKey(NKikimrTxDataShard::CELLVEC); - } - - Y_UNIT_TEST(ShouldReadKeyArrow) { - TestReadKey(NKikimrTxDataShard::ARROW); - } - - Y_UNIT_TEST(ShouldReadRangeCellVec) { - TestReadRangeMovies(NKikimrTxDataShard::CELLVEC); - } - - Y_UNIT_TEST(ShouldReadRangeArrow) { - TestReadRangeMovies(NKikimrTxDataShard::ARROW); - } - - Y_UNIT_TEST(ShouldReadKeyOnlyValueColumn) { - TTestHelper helper; - - for (ui32 k: {1, 3, 5}) { - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {k, k, k}); - request->Record.ClearColumns(); - - const auto& description = helper.Tables["table-1"].UserTable.GetDescription(); - std::vector<ui32> keyColumns( - description.GetKeyColumnIds().begin(), - description.GetKeyColumnIds().end()); - - for (const auto& column: description.GetColumns()) { - auto it = std::find(keyColumns.begin(), keyColumns.end(), column.GetId()); - if (it != keyColumns.end()) - continue; - request->Record.AddColumns(column.GetId()); - } - - std::vector<NTable::TTag> columns( - request->Record.GetColumns().begin(), - request->Record.GetColumns().end()); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k * 100}}, columns); - } - } - - Y_UNIT_TEST(ShouldReadKeyValueColumnAndSomeKeyColumn) { - TTestHelper helper; - - for (ui32 k: {1, 3, 5}) { - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {k, k, k}); - request->Record.ClearColumns(); - - const auto& description = helper.Tables["table-1"].UserTable.GetDescription(); - std::vector<ui32> keyColumns( - description.GetKeyColumnIds().begin(), - description.GetKeyColumnIds().end()); - - for (const auto& column: description.GetColumns()) { - auto it = std::find(keyColumns.begin(), keyColumns.end(), column.GetId()); - if (it != keyColumns.end()) - continue; - request->Record.AddColumns(column.GetId()); - } - - request->Record.AddColumns(keyColumns[0]); - - std::vector<ui32> columns( - request->Record.GetColumns().begin(), - request->Record.GetColumns().end()); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k * 100, k}}, columns); - } - } - - Y_UNIT_TEST(ShouldReadNonExistingKey) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {2, 2, 2}); - - auto readResult = helper.SendRead("table-1", request.release()); - - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - }); - } - - Y_UNIT_TEST(ShouldReadMultipleKeys) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {3, 3, 3}); - AddKeyQuery(*request, {1, 1, 1}); - AddKeyQuery(*request, {5, 5, 5}); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {3, 3, 3, 300}, - {1, 1, 1, 100}, - {5, 5, 5, 500}, - }); - } - - Y_UNIT_TEST(ShouldReadMultipleKeysOneByOne) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request1, {3, 3, 3}); - AddKeyQuery(*request1, {1, 1, 1}); - AddKeyQuery(*request1, {5, 5, 5}); - request1->Record.SetMaxRowsInResult(1); - - ui32 continueCounter = 0; - helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { - if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { - ++continueCounter; - } - - return TTestActorRuntime::EEventAction::PROCESS; - }); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { - {3, 3, 3, 300} - }); - - const auto& record1 = readResult1->Record; - UNIT_ASSERT(record1.GetLimitReached()); - UNIT_ASSERT(record1.HasSeqNo()); - UNIT_ASSERT(!record1.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record1.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record1.GetSeqNo(), 1UL); - // TODO: check continuation token - - auto readResult2 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { - {1, 1, 1, 100} - }); - - const auto& record2 = readResult2->Record; - UNIT_ASSERT(record2.GetLimitReached()); - UNIT_ASSERT(!record2.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record2.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record2.GetSeqNo(), 2UL); - // TODO: check continuation token - - auto readResult3 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { - {5, 5, 5, 500} - }); - - UNIT_ASSERT_VALUES_EQUAL(continueCounter, 2); - - const auto& record3 = readResult3->Record; - UNIT_ASSERT(!record3.GetLimitReached()); - UNIT_ASSERT(record3.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); - // TODO: check continuation token - } - - Y_UNIT_TEST(ShouldHandleReadAck) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - for (size_t i = 0; i < 8; ++i) { - AddKeyQuery(*request1, {1, 1, 1}); - } - - // limit quota - request1->Record.SetMaxRows(1); - - ui32 continueCounter = 0; - helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { - if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { - ++continueCounter; - } - - return TTestActorRuntime::EEventAction::PROCESS; - }); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { - {1, 1, 1, 100} - }); - - UNIT_ASSERT_VALUES_EQUAL(continueCounter, 0); - - helper.SendReadAck("table-1", readResult1->Record, 3, 10000); - - auto readResult2 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { - {1, 1, 1, 100}, - {1, 1, 1, 100}, - {1, 1, 1, 100} - }); - - UNIT_ASSERT_VALUES_EQUAL(continueCounter, 1); - - helper.SendReadAck("table-1", readResult2->Record, 100, 10000); - - auto readResult3 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { - {1, 1, 1, 100}, - {1, 1, 1, 100}, - {1, 1, 1, 100}, - {1, 1, 1, 100} - }); - - const auto& record3 = readResult3->Record; - UNIT_ASSERT(record3.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); - - UNIT_ASSERT_VALUES_EQUAL(continueCounter, 2); - } - - Y_UNIT_TEST(ShouldNotReadAfterCancel) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - for (size_t i = 0; i < 8; ++i) { - AddKeyQuery(*request1, {1, 1, 1}); - } - - // limit quota - request1->Record.SetMaxRows(1); - - ui32 continueCounter = 0; - helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { - if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { - ++continueCounter; - } - - return TTestActorRuntime::EEventAction::PROCESS; - }); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { - {1, 1, 1, 100} - }); - - helper.SendCancel("table-1", 1); - helper.SendReadAck("table-1", readResult1->Record, 3, 10000); - - auto readResult2 = helper.WaitReadResult(TDuration::MilliSeconds(10)); - UNIT_ASSERT(!readResult2); - UNIT_ASSERT_VALUES_EQUAL(continueCounter, 0); - } - - Y_UNIT_TEST(ShouldForbidDuplicatedReadId) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request1, {3, 3, 3}); - AddKeyQuery(*request1, {1, 1, 1}); - AddKeyQuery(*request1, {5, 5, 5}); - request1->Record.SetMaxRows(1); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - - auto request2 = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request2, {3, 3, 3}); - auto readResult2 = helper.SendRead("table-1", request2.release()); - UNIT_ASSERT_VALUES_EQUAL(readResult2->Record.GetStatus().GetCode(), Ydb::StatusIds::ALREADY_EXISTS); - } - - Y_UNIT_TEST(ShouldReadRangeInclusiveEndsCellVec) { - TestReadRangeInclusiveEnds(NKikimrTxDataShard::CELLVEC); - } - - Y_UNIT_TEST(ShouldReadRangeInclusiveEndsArrow) { - TestReadRangeInclusiveEnds(NKikimrTxDataShard::ARROW); - } - - Y_UNIT_TEST(ShouldReadRangeReverse) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - request->Record.SetReverse(true); - AddRangeQuery<ui32>( - *request, - {1, 1, 1}, - true, - {5, 5, 5}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {5, 5, 5, 500}, - {3, 3, 3, 300}, - {1, 1, 1, 100}, - }); - } - - Y_UNIT_TEST(ShouldReadRangeInclusiveEndsMissingLeftRight) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request, - {2, 2, 2}, - true, - {7, 7, 7}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {3, 3, 3, 300}, - {5, 5, 5, 500}, - }); - } - - Y_UNIT_TEST(ShouldReadRangeNonInclusiveEnds) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request, - {1, 1, 1}, - false, - {5, 5, 5}, - false - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {3, 3, 3, 300}, - }); - } - - Y_UNIT_TEST(ShouldReadRangeLeftInclusive) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request, - {1, 1, 1}, - true, - {5, 5, 5}, - false - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {1, 1, 1, 100}, - {3, 3, 3, 300}, - }); - } - - Y_UNIT_TEST(ShouldReadRangeRightInclusive) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request, - {1, 1, 1}, - false, - {5, 5, 5}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {3, 3, 3, 300}, - {5, 5, 5, 500}, - }); - } - - Y_UNIT_TEST(ShouldReadNotExistingRange) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request, - {100, 1, 1}, - true, - {200, 5, 5}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - }); - } - - Y_UNIT_TEST(ShouldReadRangeOneByOne) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - AddRangeQuery<ui32>( - *request1, - {1, 1, 1}, - true, - {5, 5, 5}, - true - ); - AddRangeQuery<ui32>( - *request1, - {1, 1, 1}, - true, - {1, 1, 1}, - true - ); - - request1->Record.SetMaxRowsInResult(1); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { - {1, 1, 1, 100}, - }); - - const auto& record1 = readResult1->Record; - UNIT_ASSERT(record1.GetLimitReached()); - UNIT_ASSERT(record1.HasSeqNo()); - UNIT_ASSERT(!record1.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record1.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record1.GetSeqNo(), 1UL); - - // TODO: check continuation token - #if 0 - UNIT_ASSERT_VALUES_EQUAL(readResult1.GetFirstUnprocessedQuery(), 0UL); - - UNIT_ASSERT(readResult1.HasLastProcessedKey()); - TOwnedCellVec lastKey1( - TSerializedCellVec(readResult1.GetLastProcessedKey()).GetCells()); - CheckRow(lastKey1, {1, 1, 1}); -#endif - - auto readResult2 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { - {3, 3, 3, 300}, - }); - - const auto& record2 = readResult2->Record; - UNIT_ASSERT(record2.GetLimitReached()); - UNIT_ASSERT(!record2.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record2.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record2.GetSeqNo(), 2UL); - - // TODO: check continuation token -#if 0 - UNIT_ASSERT_VALUES_EQUAL(readResult2.GetFirstUnprocessedQuery(), 0UL); - - UNIT_ASSERT(readResult2.HasLastProcessedKey()); - TOwnedCellVec lastKey2( - TSerializedCellVec(readResult2.GetLastProcessedKey()).GetCells()); - CheckRow(lastKey2, {3, 3, 3}); -#endif - - auto readResult3 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { - {5, 5, 5, 500} - }); - - const auto& record3 = readResult3->Record; - UNIT_ASSERT(record3.GetLimitReached()); - UNIT_ASSERT(!record3.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); - - // TODO: check continuation token -#if 0 - UNIT_ASSERT_VALUES_EQUAL(readResult3.GetFirstUnprocessedQuery(), 1UL); - UNIT_ASSERT(!readResult3.HasLastProcessedKey()); -#endif - - auto readResult4 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult4, { - {1, 1, 1, 100} - }); - - const auto& record4 = readResult4->Record; - UNIT_ASSERT(record4.GetLimitReached()); - UNIT_ASSERT(!record4.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record4.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record4.GetSeqNo(), 4UL); - // TODO: check continuation token - - auto readResult5 = helper.WaitReadResult(); - CheckResult(helper.Tables["table-1"].UserTable, *readResult5, { - }); - - const auto& record5 = readResult5->Record; - UNIT_ASSERT(!record5.GetLimitReached()); - UNIT_ASSERT(record5.HasFinished()); - UNIT_ASSERT_VALUES_EQUAL(record5.GetReadId(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(record5.GetSeqNo(), 5UL); - // TODO: check no continuation token - } - - Y_UNIT_TEST(ShouldReadKeyPrefix1) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddKeyQuery(*request, {8}); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 0, 0, 800}, - {8, 0, 1, 801}, - {8, 1, 0, 802}, - {8, 1, 1, 803} - }); - } - - Y_UNIT_TEST(ShouldReadKeyPrefix2) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddKeyQuery(*request, {8, 0}); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 0, 0, 800}, - {8, 0, 1, 801}, - }); - } - - Y_UNIT_TEST(ShouldReadKeyPrefix3) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddKeyQuery(*request, {8, 1, 0}); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 1, 0, 802}, - }); - } - - Y_UNIT_TEST(ShouldReadRangePrefix1) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddRangeQuery<ui32>( - *request, - {8}, - true, - {9}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 0, 0, 800}, - {8, 0, 1, 801}, - {8, 1, 0, 802}, - {8, 1, 1, 803} - }); - } - - Y_UNIT_TEST(ShouldReadRangePrefix2) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddRangeQuery<ui32>( - *request, - {8}, - true, - {9}, - false - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 0, 0, 800}, - {8, 0, 1, 801}, - {8, 1, 0, 802}, - {8, 1, 1, 803} - }); - } - - Y_UNIT_TEST(ShouldReadRangePrefix3) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddRangeQuery<ui32>( - *request, - {8}, - true, - {8}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 0, 0, 800}, - {8, 0, 1, 801}, - {8, 1, 0, 802}, - {8, 1, 1, 803} - }); - } - - Y_UNIT_TEST(ShouldReadRangePrefix4) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddRangeQuery<ui32>( - *request, - {8}, - true, - {8}, - false - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, {}); - } - - Y_UNIT_TEST(ShouldReadRangePrefix5) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - - AddRangeQuery<ui32>( - *request, - {8, 1}, - true, - {9}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - CheckResult(helper.Tables["table-1"].UserTable, *readResult, { - {8, 1, 0, 802}, - {8, 1, 1, 803} - }); - } - - Y_UNIT_TEST(ShouldFailUknownColumns) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {1, 1, 1}); - - request->Record.AddColumns(0xDEADBEAF); - - auto readResult = helper.SendRead("table-1", request.release()); - UNIT_ASSERT_VALUES_EQUAL(readResult->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); - } - - Y_UNIT_TEST(ShouldFailWrongSchema) { - TTestHelper helper; - - auto request = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request, {1, 1, 1}); - - request->Record.MutableTableId()->SetSchemaVersion(0xDEADBEAF); - - auto readResult = helper.SendRead("table-1", request.release()); - UNIT_ASSERT_VALUES_EQUAL(readResult->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); - } - - Y_UNIT_TEST(ShouldFailReadNextAfterSchemeChange) { - TTestHelper helper; - - auto request1 = helper.GetBaseReadRequest("table-1", 1); - AddKeyQuery(*request1, {3, 3, 3}); - AddKeyQuery(*request1, {1, 1, 1}); - request1->Record.SetMaxRows(1); - - auto readResult1 = helper.SendRead("table-1", request1.release()); - - auto txId = AsyncAlterAddExtraColumn(helper.Server, "/Root", "table-1"); - WaitTxNotification(helper.Server, helper.Sender, txId); - - helper.SendReadAck("table-1", readResult1->Record, 3, 10000); - - auto readResult2 = helper.WaitReadResult(); - UNIT_ASSERT_VALUES_EQUAL(readResult2->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); - } -}; - -Y_UNIT_TEST_SUITE(DataShardReadIteratorSysTables) { - Y_UNIT_TEST(ShouldRead) { - TTestHelper helper; - - auto request = helper.GetUserTablesRequest("table-1", 2, 1); - AddRangeQuery<ui64>( - *request, - {Min<ui64>(),}, - true, - {Max<ui64>(),}, - true - ); - - auto readResult = helper.SendRead("table-1", request.release()); - const auto& record = readResult->Record; - - UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::SUCCESS); - UNIT_ASSERT_VALUES_EQUAL(readResult->GetRowsCount(), 1UL); - - const auto& cells = readResult->GetCells(0); - UNIT_ASSERT_VALUES_EQUAL(cells[0].AsValue<ui64>(), helper.Tables["table-1"].UserTable.GetPathId()); - } - - Y_UNIT_TEST(ShouldNotReadUserTableUsingLocalTid) { - TTestHelper helper; - - auto request = helper.GetUserTablesRequest("table-1", 2, 1); - AddRangeQuery<ui64>( - *request, - {Min<ui64>(),}, - true, - {Max<ui64>(),}, - true - ); - - auto localId = helper.Tables["table-1"].UserTable.GetLocalId(); - UNIT_ASSERT(localId >= 1000); - request->Record.MutableTableId()->SetTableId(localId); - - auto readResult = helper.SendRead("table-1", request.release()); - const auto& record = readResult->Record; - UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); - } - - Y_UNIT_TEST(ShouldForbidSchemaVersion) { - TTestHelper helper; - - auto request = helper.GetUserTablesRequest("table-1", 2, 1); - AddRangeQuery<ui64>( - *request, - {Min<ui64>(),}, - true, - {Max<ui64>(),}, - true - ); - - request->Record.MutableTableId()->SetSchemaVersion(1111); - - auto readResult = helper.SendRead("table-1", request.release()); - const auto& record = readResult->Record; - UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); - } - - Y_UNIT_TEST(ShouldNotAllowArrow) { - TTestHelper helper; - - auto request = helper.GetUserTablesRequest("table-1", 2, 1); - AddRangeQuery<ui64>( - *request, - {Min<ui64>(),}, - true, - {Max<ui64>(),}, - true - ); - - request->Record.SetResultFormat(NKikimrTxDataShard::ARROW); - - auto readResult = helper.SendRead("table-1", request.release()); - const auto& record = readResult->Record; - - UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); - } -}; - -Y_UNIT_TEST_SUITE(DataShardReadIteratorState) { - Y_UNIT_TEST(ShouldCalculateQuota) { - NDataShard::TReadIteratorState state; - state.Quota.Rows = 100; - state.Quota.Bytes = 1000; - state.ConsumeSeqNo(10, 100); // seqno1 - state.ConsumeSeqNo(30, 200); // seqno2 - state.ConsumeSeqNo(40, 300); // seqno3 - - UNIT_ASSERT_VALUES_EQUAL(state.SeqNo, 3UL); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 20UL); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 400UL); - - state.UpQuota(2, 200, 1000); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 160UL); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 700UL); - - state.ConsumeSeqNo(10, 100); // seqno4 - state.ConsumeSeqNo(20, 200); // seqno5 - state.ConsumeSeqNo(10, 50); // seqno6 - state.ConsumeSeqNo(2000, 2000); // seqno7 - - state.UpQuota(4, 5000, 5000); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 2970UL); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 2750); - - state.UpQuota(5, 100, 100); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 0UL); - UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 0UL); - UNIT_ASSERT(state.State == NDataShard::TReadIteratorState::EState::Exhausted); - } -}; - -} // namespace NKikimr + +#include <algorithm> +#include <map> + +namespace NKikimr { + +using namespace NKikimr::NDataShard; +using namespace NSchemeShard; +using namespace Tests; + +namespace { + +using TCellVec = std::vector<TCell>; + +void CreateTable(Tests::TServer::TPtr server, + TActorId sender, + const TString &root, + const TString &name) +{ + TVector<TShardedTableOptions::TColumn> columns = { + {"key1", "Uint32", true, false}, + {"key2", "Uint32", true, false}, + {"key3", "Uint32", true, false}, + {"value", "Uint32", false, false} + }; + + auto opts = TShardedTableOptions() + .Shards(1) + .Columns(columns); + + CreateShardedTable(server, sender, root, name, opts); +} + +void CreateMoviesTable(Tests::TServer::TPtr server, + TActorId sender, + const TString &root, + const TString &name) +{ + TVector<TShardedTableOptions::TColumn> columns = { + {"id", "Uint32", true, false}, + {"title", "String", false, false}, + {"rating", "Uint32", false, false} + }; + + auto opts = TShardedTableOptions() + .Shards(1) + .Columns(columns); + + CreateShardedTable(server, sender, root, name, opts); +} + +struct TRowWriter : public NArrow::IRowWriter { + std::vector<TOwnedCellVec> Rows; + + TRowWriter() = default; + + void AddRow(const TConstArrayRef<TCell> &cells) override { + Rows.emplace_back(cells); + } +}; + +std::vector<TOwnedCellVec> GetRows( + const TVector<std::pair<TString, NScheme::TTypeId>>& batchSchema, + const TEvDataShard::TEvReadResult& result) +{ + UNIT_ASSERT(result.ArrowBatch); + + // TODO: use schema from ArrowBatch + TRowWriter writer; + NArrow::TArrowToYdbConverter converter(batchSchema, writer); + + TString error; + UNIT_ASSERT(converter.Process(*result.ArrowBatch, error)); + + return std::move(writer.Rows); +} + +void CheckRow( + const TConstArrayRef<TCell>& row, + const TCellVec& gold, + const std::vector<NScheme::TTypeIdOrder>& goldTypes) +{ + UNIT_ASSERT_VALUES_EQUAL(row.size(), gold.size()); + for (size_t i: xrange(row.size())) { + int cmp = CompareTypedCells(row[i], gold[i], goldTypes[i]); + UNIT_ASSERT_VALUES_EQUAL(cmp, 0); + } +} + +template <typename TCellVecType> +void CheckRows( + const std::vector<TCellVecType>& rows, + const std::vector<TCellVec>& gold, + const std::vector<NScheme::TTypeIdOrder>& goldTypes) +{ + UNIT_ASSERT_VALUES_EQUAL(rows.size(), gold.size()); + for (size_t i: xrange(rows.size())) { + CheckRow(rows[i], gold[i], goldTypes); + } +} + +void CheckResultCellVec( + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + const TEvDataShard::TEvReadResult& result, + const std::vector<TCellVec>& gold, + const std::vector<NScheme::TTypeIdOrder>& goldTypes, + std::vector<NTable::TTag> columns = {}) +{ + Y_UNUSED(userTable); + Y_UNUSED(columns); + + UNIT_ASSERT(!gold.empty()); + + auto nrows = result.GetRowsCount(); + TVector<TConstArrayRef<TCell>> rows; + rows.reserve(nrows); + for (size_t i = 0; i < nrows; ++i) { + rows.emplace_back(result.GetCells(i)); + } + + UNIT_ASSERT(!rows.empty()); + CheckRows(rows, gold, goldTypes); +} + +void CheckResultArrow( + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + const TEvDataShard::TEvReadResult& result, + const std::vector<TCellVec>& gold, + const std::vector<NScheme::TTypeIdOrder>& goldTypes, + std::vector<NTable::TTag> columns = {}) +{ + UNIT_ASSERT(!gold.empty()); + UNIT_ASSERT(result.ArrowBatch); + + TVector<std::pair<TString, NScheme::TTypeId>> batchSchema; + const auto& description = userTable.GetDescription(); + if (columns.empty()) { + batchSchema.reserve(description.ColumnsSize()); + for (const auto& column: description.GetColumns()) { + batchSchema.emplace_back(column.GetName(), column.GetTypeId()); + } + } else { + std::map<NTable::TTag, std::pair<TString, ui32>> colsMap; + for (const auto& column: description.GetColumns()) { + colsMap[column.GetId()] = std::make_pair(column.GetName(), column.GetTypeId()); + } + batchSchema.reserve(columns.size()); + for (auto tag: columns) { + const auto& col = colsMap[tag]; + batchSchema.emplace_back(col.first, col.second); + } + } + + auto rows = GetRows(batchSchema, result); + CheckRows(rows, gold, goldTypes); +} + +void CheckResult( + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + const TEvDataShard::TEvReadResult& result, + const std::vector<TCellVec>& gold, + const std::vector<NScheme::TTypeIdOrder>& goldTypes, + std::vector<NTable::TTag> columns = {}) +{ + const auto& record = result.Record; + + if (record.GetStatus().IssuesSize()) { + TStringStream ss; + for (const auto& issue: record.GetStatus().GetIssues()) { + ss << "issue: " << issue; + } + Cerr << "Request with issues: " << ss.Str() << Endl; + } + + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::SUCCESS); + if (gold.size()) { + switch (record.GetResultFormat()) { + case NKikimrTxDataShard::ARROW: + CheckResultArrow(userTable, result, gold, goldTypes, columns); + break; + case NKikimrTxDataShard::CELLVEC: + CheckResultCellVec(userTable, result, gold, goldTypes, columns); + break; + default: + UNIT_ASSERT(false); + } + } else { + UNIT_ASSERT(!result.ArrowBatch && result.GetRowsCount() == 0); + } +} + +void CheckResult( + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + const TEvDataShard::TEvReadResult& result, + const std::vector<std::vector<ui32>>& gold, + std::vector<NTable::TTag> columns = {}) +{ + std::vector<NScheme::TTypeIdOrder> types; + if (!gold.empty() && !gold[0].empty()) { + types.reserve(gold[0].size()); + for (auto i: xrange(gold[0].size())) { + Y_UNUSED(i); + types.emplace_back(NScheme::NTypeIds::Uint32); + } + } + + std::vector<TCellVec> goldCells; + goldCells.reserve(gold.size()); + for (const auto& row: gold) { + TCellVec cells; + cells.reserve(row.size()); + for (auto item: row) { + cells.push_back(TCell::Make(item)); + } + goldCells.emplace_back(std::move(cells)); + } + + CheckResult(userTable, result, goldCells, types, columns); +} + +template <typename TKeyType> +TVector<TCell> ToCells(const std::vector<TKeyType>& keys) { + TVector<TCell> cells; + for (auto& key: keys) { + cells.emplace_back(TCell::Make(key)); + } + return cells; +} + +void AddKeyQuery( + TEvDataShard::TEvRead& request, + const std::vector<ui32>& keys) +{ + // convertion is ugly, but for tests is OK + auto cells = ToCells(keys); + auto buf = TSerializedCellVec::Serialize(cells); + request.Keys.emplace_back(buf); +} + +template <typename TCellType> +void AddRangeQuery( + TEvDataShard::TEvRead& request, + std::vector<TCellType> from, + bool fromInclusive, + std::vector<TCellType> to, + bool toInclusive) +{ + auto fromCells = ToCells(from); + auto toCells = ToCells(to); + + // convertion is ugly, but for tests is OK + auto fromBuf = TSerializedCellVec::Serialize(fromCells); + auto toBuf = TSerializedCellVec::Serialize(toCells); + + request.Ranges.emplace_back(fromBuf, toBuf, fromInclusive, toInclusive); +} + +struct TTableInfo { + TString Name; + + ui64 TabletId; + ui64 OwnerId; + NKikimrTxDataShard::TEvGetInfoResponse::TUserTable UserTable; + + TActorId ClientId; +}; + +struct TTestHelper { + TTestHelper() { + TPortManager pm; + TServerSettings serverSettings(pm.GetPort(2134)); + serverSettings.SetDomainName("Root") + .SetUseRealThreads(false); + + Server = new TServer(serverSettings); + + auto &runtime = *Server->GetRuntime(); + Sender = runtime.AllocateEdgeActor(); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + + InitRoot(Server, Sender); + + auto& table1 = Tables["table-1"]; + table1.Name = "table-1"; + { + CreateTable(Server, Sender, "/Root", "table-1"); + ExecSQL(Server, Sender, R"( + UPSERT INTO [/Root/table-1] + (key1, key2, key3, value) + VALUES + (1, 1, 1, 100), + (3, 3, 3, 300), + (5, 5, 5, 500), + (8, 0, 0, 800), + (8, 0, 1, 801), + (8, 1, 0, 802), + (8, 1, 1, 803), + (11, 11, 11, 1111); + )"); + + auto shards = GetTableShards(Server, Sender, "/Root/table-1"); + table1.TabletId = shards.at(0); + + auto [tables, ownerId] = GetTables(Server, table1.TabletId); + table1.OwnerId = ownerId; + table1.UserTable = tables["table-1"]; + + table1.ClientId = runtime.ConnectToPipe(table1.TabletId, Sender, 0, GetPipeConfigWithRetries()); + } + + auto& table2 = Tables["movies"]; + table2.Name = "movies"; + { + CreateMoviesTable(Server, Sender, "/Root", "movies"); + ExecSQL(Server, Sender, R"( + UPSERT INTO [/Root/movies] + (id, title, rating) + VALUES + (1, "I Robot", 10), + (2, "I Am Legend", 9), + (3, "Hard die", 8); + )"); + + auto shards = GetTableShards(Server, Sender, "/Root/movies"); + table2.TabletId = shards.at(0); + + auto [tables, ownerId] = GetTables(Server, table2.TabletId); + table2.OwnerId = ownerId; + table2.UserTable = tables["movies"]; + + table2.ClientId = runtime.ConnectToPipe(table2.TabletId, Sender, 0, GetPipeConfigWithRetries()); + } + } + + std::unique_ptr<TEvDataShard::TEvRead> GetBaseReadRequest( + const TString& tableName, + ui64 readId, + NKikimrTxDataShard::EScanDataFormat format = NKikimrTxDataShard::ARROW) + { + const auto& table = Tables[tableName]; + + std::unique_ptr<TEvDataShard::TEvRead> request(new TEvDataShard::TEvRead()); + auto& record = request->Record; + + record.SetReadId(readId); + record.MutableTableId()->SetOwnerId(table.OwnerId); + record.MutableTableId()->SetTableId(table.UserTable.GetPathId()); + + const auto& description = table.UserTable.GetDescription(); + std::vector<ui32> keyColumns( + description.GetKeyColumnIds().begin(), + description.GetKeyColumnIds().end()); + + for (const auto& column: description.GetColumns()) { + record.AddColumns(column.GetId()); + } + + record.MutableTableId()->SetSchemaVersion(description.GetTableSchemaVersion()); + + auto readVersion = CreateVolatileSnapshot( + Server, + {"/Root/movies", "/Root/table-1"}, + TDuration::Hours(1)); + + record.MutableSnapshot()->SetStep(readVersion.Step); + record.MutableSnapshot()->SetTxId(readVersion.TxId); + + record.SetResultFormat(format); + + return request; + } + + std::unique_ptr<TEvDataShard::TEvRead> GetUserTablesRequest( + const TString& tableName, + ui64 localTid, + ui64 readId) + { + const auto& table = Tables[tableName]; + + std::unique_ptr<TEvDataShard::TEvRead> request(new TEvDataShard::TEvRead()); + auto& record = request->Record; + + record.SetReadId(readId); + + record.MutableTableId()->SetOwnerId(table.TabletId); + record.MutableTableId()->SetTableId(localTid); + + record.AddColumns(1); + record.AddColumns(2); + + record.SetResultFormat(NKikimrTxDataShard::CELLVEC); + + return request; + } + + std::unique_ptr<TEvDataShard::TEvReadResult> WaitReadResult(TDuration timeout = TDuration::Max()) { + auto &runtime = *Server->GetRuntime(); + TAutoPtr<IEventHandle> handle; + runtime.GrabEdgeEventRethrow<TEvDataShard::TEvReadResult>(handle, timeout); + if (!handle) { + return nullptr; + } + auto event = handle->Release<TEvDataShard::TEvReadResult>(); + return std::unique_ptr<TEvDataShard::TEvReadResult>(event.Release()); + } + + std::unique_ptr<TEvDataShard::TEvReadResult> SendRead( + const TString& tableName, + TEvDataShard::TEvRead* request) + { + const auto& table = Tables[tableName]; + auto &runtime = *Server->GetRuntime(); + runtime.SendToPipe( + table.TabletId, + Sender, + request, + 0, + GetPipeConfigWithRetries(), + table.ClientId); + + return WaitReadResult(); + } + + void SendReadAck( + const TString& tableName, + const NKikimrTxDataShard::TEvReadResult& readResult, + ui64 rows, + ui64 bytes) + { + const auto& table = Tables[tableName]; + auto* request = new TEvDataShard::TEvReadAck(); + request->Record.SetReadId(readResult.GetReadId()); + request->Record.SetSeqNo(readResult.GetSeqNo()); + request->Record.SetMaxRows(rows); + request->Record.SetMaxBytes(bytes); + + auto &runtime = *Server->GetRuntime(); + runtime.SendToPipe( + table.TabletId, + Sender, request, + 0, + GetPipeConfigWithRetries(), + table.ClientId); + } + + void SendCancel(const TString& tableName, ui64 readId) { + const auto& table = Tables[tableName]; + auto* request = new TEvDataShard::TEvReadCancel(); + request->Record.SetReadId(readId); + + auto &runtime = *Server->GetRuntime(); + runtime.SendToPipe( + table.TabletId, + Sender, + request, + 0, + GetPipeConfigWithRetries(), + table.ClientId); + } + +public: + Tests::TServer::TPtr Server; + TActorId Sender; + + THashMap<TString, TTableInfo> Tables; +}; + +void TestReadKey(NKikimrTxDataShard::EScanDataFormat format) { + TTestHelper helper; + + for (ui32 k: {1, 3, 5}) { + auto request = helper.GetBaseReadRequest("table-1", 1, format); + AddKeyQuery(*request, {k, k, k}); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k, k, k, k * 100}}); + } +} + +void TestReadRangeInclusiveEnds(NKikimrTxDataShard::EScanDataFormat format) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1, format); + AddRangeQuery<ui32>( + *request, + {1, 1, 1}, + true, + {5, 5, 5}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {1, 1, 1, 100}, + {3, 3, 3, 300}, + {5, 5, 5, 500}, + }); +} + +void TestReadRangeMovies(NKikimrTxDataShard::EScanDataFormat format) { + // test just to check if non-trivial type like string is properly replied + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("movies", 1, format); + AddRangeQuery<ui32>( + *request, + {1}, + true, + {100}, + true + ); + + TString s1 = "I Robot"; + TString s2 = "I Am Legend"; + TString s3 = "Hard die"; + + auto readResult = helper.SendRead("movies", request.release()); + CheckResult(helper.Tables["movies"].UserTable, *readResult, + { + {TCell::Make(1u), TCell(s1.data(), s1.size()), TCell::Make(10u)}, + {TCell::Make(2u), TCell(s2.data(), s2.size()), TCell::Make(9u)}, + {TCell::Make(3u), TCell(s3.data(), s3.size()), TCell::Make(8u)} + }, + { + NScheme::TTypeIdOrder(NScheme::NTypeIds::Uint32), + NScheme::TTypeIdOrder(NScheme::NTypeIds::String), + NScheme::TTypeIdOrder(NScheme::NTypeIds::Uint32) + }); +} + +} // namespace + +Y_UNIT_TEST_SUITE(DataShardReadIterator) { + Y_UNIT_TEST(ShouldReadKeyCellVec) { + TestReadKey(NKikimrTxDataShard::CELLVEC); + } + + Y_UNIT_TEST(ShouldReadKeyArrow) { + TestReadKey(NKikimrTxDataShard::ARROW); + } + + Y_UNIT_TEST(ShouldReadRangeCellVec) { + TestReadRangeMovies(NKikimrTxDataShard::CELLVEC); + } + + Y_UNIT_TEST(ShouldReadRangeArrow) { + TestReadRangeMovies(NKikimrTxDataShard::ARROW); + } + + Y_UNIT_TEST(ShouldReadKeyOnlyValueColumn) { + TTestHelper helper; + + for (ui32 k: {1, 3, 5}) { + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {k, k, k}); + request->Record.ClearColumns(); + + const auto& description = helper.Tables["table-1"].UserTable.GetDescription(); + std::vector<ui32> keyColumns( + description.GetKeyColumnIds().begin(), + description.GetKeyColumnIds().end()); + + for (const auto& column: description.GetColumns()) { + auto it = std::find(keyColumns.begin(), keyColumns.end(), column.GetId()); + if (it != keyColumns.end()) + continue; + request->Record.AddColumns(column.GetId()); + } + + std::vector<NTable::TTag> columns( + request->Record.GetColumns().begin(), + request->Record.GetColumns().end()); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k * 100}}, columns); + } + } + + Y_UNIT_TEST(ShouldReadKeyValueColumnAndSomeKeyColumn) { + TTestHelper helper; + + for (ui32 k: {1, 3, 5}) { + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {k, k, k}); + request->Record.ClearColumns(); + + const auto& description = helper.Tables["table-1"].UserTable.GetDescription(); + std::vector<ui32> keyColumns( + description.GetKeyColumnIds().begin(), + description.GetKeyColumnIds().end()); + + for (const auto& column: description.GetColumns()) { + auto it = std::find(keyColumns.begin(), keyColumns.end(), column.GetId()); + if (it != keyColumns.end()) + continue; + request->Record.AddColumns(column.GetId()); + } + + request->Record.AddColumns(keyColumns[0]); + + std::vector<ui32> columns( + request->Record.GetColumns().begin(), + request->Record.GetColumns().end()); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, {{k * 100, k}}, columns); + } + } + + Y_UNIT_TEST(ShouldReadNonExistingKey) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {2, 2, 2}); + + auto readResult = helper.SendRead("table-1", request.release()); + + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + }); + } + + Y_UNIT_TEST(ShouldReadMultipleKeys) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {3, 3, 3}); + AddKeyQuery(*request, {1, 1, 1}); + AddKeyQuery(*request, {5, 5, 5}); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {3, 3, 3, 300}, + {1, 1, 1, 100}, + {5, 5, 5, 500}, + }); + } + + Y_UNIT_TEST(ShouldReadMultipleKeysOneByOne) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request1, {3, 3, 3}); + AddKeyQuery(*request1, {1, 1, 1}); + AddKeyQuery(*request1, {5, 5, 5}); + request1->Record.SetMaxRowsInResult(1); + + ui32 continueCounter = 0; + helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { + if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { + ++continueCounter; + } + + return TTestActorRuntime::EEventAction::PROCESS; + }); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { + {3, 3, 3, 300} + }); + + const auto& record1 = readResult1->Record; + UNIT_ASSERT(record1.GetLimitReached()); + UNIT_ASSERT(record1.HasSeqNo()); + UNIT_ASSERT(!record1.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record1.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record1.GetSeqNo(), 1UL); + // TODO: check continuation token + + auto readResult2 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { + {1, 1, 1, 100} + }); + + const auto& record2 = readResult2->Record; + UNIT_ASSERT(record2.GetLimitReached()); + UNIT_ASSERT(!record2.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record2.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record2.GetSeqNo(), 2UL); + // TODO: check continuation token + + auto readResult3 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { + {5, 5, 5, 500} + }); + + UNIT_ASSERT_VALUES_EQUAL(continueCounter, 2); + + const auto& record3 = readResult3->Record; + UNIT_ASSERT(!record3.GetLimitReached()); + UNIT_ASSERT(record3.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); + // TODO: check continuation token + } + + Y_UNIT_TEST(ShouldHandleReadAck) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + for (size_t i = 0; i < 8; ++i) { + AddKeyQuery(*request1, {1, 1, 1}); + } + + // limit quota + request1->Record.SetMaxRows(1); + + ui32 continueCounter = 0; + helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { + if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { + ++continueCounter; + } + + return TTestActorRuntime::EEventAction::PROCESS; + }); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { + {1, 1, 1, 100} + }); + + UNIT_ASSERT_VALUES_EQUAL(continueCounter, 0); + + helper.SendReadAck("table-1", readResult1->Record, 3, 10000); + + auto readResult2 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { + {1, 1, 1, 100}, + {1, 1, 1, 100}, + {1, 1, 1, 100} + }); + + UNIT_ASSERT_VALUES_EQUAL(continueCounter, 1); + + helper.SendReadAck("table-1", readResult2->Record, 100, 10000); + + auto readResult3 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { + {1, 1, 1, 100}, + {1, 1, 1, 100}, + {1, 1, 1, 100}, + {1, 1, 1, 100} + }); + + const auto& record3 = readResult3->Record; + UNIT_ASSERT(record3.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); + + UNIT_ASSERT_VALUES_EQUAL(continueCounter, 2); + } + + Y_UNIT_TEST(ShouldNotReadAfterCancel) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + for (size_t i = 0; i < 8; ++i) { + AddKeyQuery(*request1, {1, 1, 1}); + } + + // limit quota + request1->Record.SetMaxRows(1); + + ui32 continueCounter = 0; + helper.Server->GetRuntime()->SetObserverFunc([&continueCounter](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) { + if (ev->GetTypeRewrite() == TEvDataShard::EvReadContinue) { + ++continueCounter; + } + + return TTestActorRuntime::EEventAction::PROCESS; + }); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { + {1, 1, 1, 100} + }); + + helper.SendCancel("table-1", 1); + helper.SendReadAck("table-1", readResult1->Record, 3, 10000); + + auto readResult2 = helper.WaitReadResult(TDuration::MilliSeconds(10)); + UNIT_ASSERT(!readResult2); + UNIT_ASSERT_VALUES_EQUAL(continueCounter, 0); + } + + Y_UNIT_TEST(ShouldForbidDuplicatedReadId) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request1, {3, 3, 3}); + AddKeyQuery(*request1, {1, 1, 1}); + AddKeyQuery(*request1, {5, 5, 5}); + request1->Record.SetMaxRows(1); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + + auto request2 = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request2, {3, 3, 3}); + auto readResult2 = helper.SendRead("table-1", request2.release()); + UNIT_ASSERT_VALUES_EQUAL(readResult2->Record.GetStatus().GetCode(), Ydb::StatusIds::ALREADY_EXISTS); + } + + Y_UNIT_TEST(ShouldReadRangeInclusiveEndsCellVec) { + TestReadRangeInclusiveEnds(NKikimrTxDataShard::CELLVEC); + } + + Y_UNIT_TEST(ShouldReadRangeInclusiveEndsArrow) { + TestReadRangeInclusiveEnds(NKikimrTxDataShard::ARROW); + } + + Y_UNIT_TEST(ShouldReadRangeReverse) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + request->Record.SetReverse(true); + AddRangeQuery<ui32>( + *request, + {1, 1, 1}, + true, + {5, 5, 5}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {5, 5, 5, 500}, + {3, 3, 3, 300}, + {1, 1, 1, 100}, + }); + } + + Y_UNIT_TEST(ShouldReadRangeInclusiveEndsMissingLeftRight) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request, + {2, 2, 2}, + true, + {7, 7, 7}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {3, 3, 3, 300}, + {5, 5, 5, 500}, + }); + } + + Y_UNIT_TEST(ShouldReadRangeNonInclusiveEnds) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request, + {1, 1, 1}, + false, + {5, 5, 5}, + false + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {3, 3, 3, 300}, + }); + } + + Y_UNIT_TEST(ShouldReadRangeLeftInclusive) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request, + {1, 1, 1}, + true, + {5, 5, 5}, + false + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {1, 1, 1, 100}, + {3, 3, 3, 300}, + }); + } + + Y_UNIT_TEST(ShouldReadRangeRightInclusive) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request, + {1, 1, 1}, + false, + {5, 5, 5}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {3, 3, 3, 300}, + {5, 5, 5, 500}, + }); + } + + Y_UNIT_TEST(ShouldReadNotExistingRange) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request, + {100, 1, 1}, + true, + {200, 5, 5}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + }); + } + + Y_UNIT_TEST(ShouldReadRangeOneByOne) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + AddRangeQuery<ui32>( + *request1, + {1, 1, 1}, + true, + {5, 5, 5}, + true + ); + AddRangeQuery<ui32>( + *request1, + {1, 1, 1}, + true, + {1, 1, 1}, + true + ); + + request1->Record.SetMaxRowsInResult(1); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult1, { + {1, 1, 1, 100}, + }); + + const auto& record1 = readResult1->Record; + UNIT_ASSERT(record1.GetLimitReached()); + UNIT_ASSERT(record1.HasSeqNo()); + UNIT_ASSERT(!record1.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record1.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record1.GetSeqNo(), 1UL); + + // TODO: check continuation token + #if 0 + UNIT_ASSERT_VALUES_EQUAL(readResult1.GetFirstUnprocessedQuery(), 0UL); + + UNIT_ASSERT(readResult1.HasLastProcessedKey()); + TOwnedCellVec lastKey1( + TSerializedCellVec(readResult1.GetLastProcessedKey()).GetCells()); + CheckRow(lastKey1, {1, 1, 1}); +#endif + + auto readResult2 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult2, { + {3, 3, 3, 300}, + }); + + const auto& record2 = readResult2->Record; + UNIT_ASSERT(record2.GetLimitReached()); + UNIT_ASSERT(!record2.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record2.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record2.GetSeqNo(), 2UL); + + // TODO: check continuation token +#if 0 + UNIT_ASSERT_VALUES_EQUAL(readResult2.GetFirstUnprocessedQuery(), 0UL); + + UNIT_ASSERT(readResult2.HasLastProcessedKey()); + TOwnedCellVec lastKey2( + TSerializedCellVec(readResult2.GetLastProcessedKey()).GetCells()); + CheckRow(lastKey2, {3, 3, 3}); +#endif + + auto readResult3 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult3, { + {5, 5, 5, 500} + }); + + const auto& record3 = readResult3->Record; + UNIT_ASSERT(record3.GetLimitReached()); + UNIT_ASSERT(!record3.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record3.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record3.GetSeqNo(), 3UL); + + // TODO: check continuation token +#if 0 + UNIT_ASSERT_VALUES_EQUAL(readResult3.GetFirstUnprocessedQuery(), 1UL); + UNIT_ASSERT(!readResult3.HasLastProcessedKey()); +#endif + + auto readResult4 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult4, { + {1, 1, 1, 100} + }); + + const auto& record4 = readResult4->Record; + UNIT_ASSERT(record4.GetLimitReached()); + UNIT_ASSERT(!record4.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record4.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record4.GetSeqNo(), 4UL); + // TODO: check continuation token + + auto readResult5 = helper.WaitReadResult(); + CheckResult(helper.Tables["table-1"].UserTable, *readResult5, { + }); + + const auto& record5 = readResult5->Record; + UNIT_ASSERT(!record5.GetLimitReached()); + UNIT_ASSERT(record5.HasFinished()); + UNIT_ASSERT_VALUES_EQUAL(record5.GetReadId(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(record5.GetSeqNo(), 5UL); + // TODO: check no continuation token + } + + Y_UNIT_TEST(ShouldReadKeyPrefix1) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddKeyQuery(*request, {8}); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 0, 0, 800}, + {8, 0, 1, 801}, + {8, 1, 0, 802}, + {8, 1, 1, 803} + }); + } + + Y_UNIT_TEST(ShouldReadKeyPrefix2) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddKeyQuery(*request, {8, 0}); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 0, 0, 800}, + {8, 0, 1, 801}, + }); + } + + Y_UNIT_TEST(ShouldReadKeyPrefix3) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddKeyQuery(*request, {8, 1, 0}); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 1, 0, 802}, + }); + } + + Y_UNIT_TEST(ShouldReadRangePrefix1) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddRangeQuery<ui32>( + *request, + {8}, + true, + {9}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 0, 0, 800}, + {8, 0, 1, 801}, + {8, 1, 0, 802}, + {8, 1, 1, 803} + }); + } + + Y_UNIT_TEST(ShouldReadRangePrefix2) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddRangeQuery<ui32>( + *request, + {8}, + true, + {9}, + false + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 0, 0, 800}, + {8, 0, 1, 801}, + {8, 1, 0, 802}, + {8, 1, 1, 803} + }); + } + + Y_UNIT_TEST(ShouldReadRangePrefix3) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddRangeQuery<ui32>( + *request, + {8}, + true, + {8}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 0, 0, 800}, + {8, 0, 1, 801}, + {8, 1, 0, 802}, + {8, 1, 1, 803} + }); + } + + Y_UNIT_TEST(ShouldReadRangePrefix4) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddRangeQuery<ui32>( + *request, + {8}, + true, + {8}, + false + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, {}); + } + + Y_UNIT_TEST(ShouldReadRangePrefix5) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + + AddRangeQuery<ui32>( + *request, + {8, 1}, + true, + {9}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + CheckResult(helper.Tables["table-1"].UserTable, *readResult, { + {8, 1, 0, 802}, + {8, 1, 1, 803} + }); + } + + Y_UNIT_TEST(ShouldFailUknownColumns) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {1, 1, 1}); + + request->Record.AddColumns(0xDEADBEAF); + + auto readResult = helper.SendRead("table-1", request.release()); + UNIT_ASSERT_VALUES_EQUAL(readResult->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); + } + + Y_UNIT_TEST(ShouldFailWrongSchema) { + TTestHelper helper; + + auto request = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request, {1, 1, 1}); + + request->Record.MutableTableId()->SetSchemaVersion(0xDEADBEAF); + + auto readResult = helper.SendRead("table-1", request.release()); + UNIT_ASSERT_VALUES_EQUAL(readResult->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); + } + + Y_UNIT_TEST(ShouldFailReadNextAfterSchemeChange) { + TTestHelper helper; + + auto request1 = helper.GetBaseReadRequest("table-1", 1); + AddKeyQuery(*request1, {3, 3, 3}); + AddKeyQuery(*request1, {1, 1, 1}); + request1->Record.SetMaxRows(1); + + auto readResult1 = helper.SendRead("table-1", request1.release()); + + auto txId = AsyncAlterAddExtraColumn(helper.Server, "/Root", "table-1"); + WaitTxNotification(helper.Server, helper.Sender, txId); + + helper.SendReadAck("table-1", readResult1->Record, 3, 10000); + + auto readResult2 = helper.WaitReadResult(); + UNIT_ASSERT_VALUES_EQUAL(readResult2->Record.GetStatus().GetCode(), Ydb::StatusIds::SCHEME_ERROR); + } +}; + +Y_UNIT_TEST_SUITE(DataShardReadIteratorSysTables) { + Y_UNIT_TEST(ShouldRead) { + TTestHelper helper; + + auto request = helper.GetUserTablesRequest("table-1", 2, 1); + AddRangeQuery<ui64>( + *request, + {Min<ui64>(),}, + true, + {Max<ui64>(),}, + true + ); + + auto readResult = helper.SendRead("table-1", request.release()); + const auto& record = readResult->Record; + + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::SUCCESS); + UNIT_ASSERT_VALUES_EQUAL(readResult->GetRowsCount(), 1UL); + + const auto& cells = readResult->GetCells(0); + UNIT_ASSERT_VALUES_EQUAL(cells[0].AsValue<ui64>(), helper.Tables["table-1"].UserTable.GetPathId()); + } + + Y_UNIT_TEST(ShouldNotReadUserTableUsingLocalTid) { + TTestHelper helper; + + auto request = helper.GetUserTablesRequest("table-1", 2, 1); + AddRangeQuery<ui64>( + *request, + {Min<ui64>(),}, + true, + {Max<ui64>(),}, + true + ); + + auto localId = helper.Tables["table-1"].UserTable.GetLocalId(); + UNIT_ASSERT(localId >= 1000); + request->Record.MutableTableId()->SetTableId(localId); + + auto readResult = helper.SendRead("table-1", request.release()); + const auto& record = readResult->Record; + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); + } + + Y_UNIT_TEST(ShouldForbidSchemaVersion) { + TTestHelper helper; + + auto request = helper.GetUserTablesRequest("table-1", 2, 1); + AddRangeQuery<ui64>( + *request, + {Min<ui64>(),}, + true, + {Max<ui64>(),}, + true + ); + + request->Record.MutableTableId()->SetSchemaVersion(1111); + + auto readResult = helper.SendRead("table-1", request.release()); + const auto& record = readResult->Record; + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); + } + + Y_UNIT_TEST(ShouldNotAllowArrow) { + TTestHelper helper; + + auto request = helper.GetUserTablesRequest("table-1", 2, 1); + AddRangeQuery<ui64>( + *request, + {Min<ui64>(),}, + true, + {Max<ui64>(),}, + true + ); + + request->Record.SetResultFormat(NKikimrTxDataShard::ARROW); + + auto readResult = helper.SendRead("table-1", request.release()); + const auto& record = readResult->Record; + + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus().GetCode(), Ydb::StatusIds::BAD_REQUEST); + } +}; + +Y_UNIT_TEST_SUITE(DataShardReadIteratorState) { + Y_UNIT_TEST(ShouldCalculateQuota) { + NDataShard::TReadIteratorState state; + state.Quota.Rows = 100; + state.Quota.Bytes = 1000; + state.ConsumeSeqNo(10, 100); // seqno1 + state.ConsumeSeqNo(30, 200); // seqno2 + state.ConsumeSeqNo(40, 300); // seqno3 + + UNIT_ASSERT_VALUES_EQUAL(state.SeqNo, 3UL); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 20UL); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 400UL); + + state.UpQuota(2, 200, 1000); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 160UL); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 700UL); + + state.ConsumeSeqNo(10, 100); // seqno4 + state.ConsumeSeqNo(20, 200); // seqno5 + state.ConsumeSeqNo(10, 50); // seqno6 + state.ConsumeSeqNo(2000, 2000); // seqno7 + + state.UpQuota(4, 5000, 5000); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 2970UL); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 2750); + + state.UpQuota(5, 100, 100); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Rows, 0UL); + UNIT_ASSERT_VALUES_EQUAL(state.Quota.Bytes, 0UL); + UNIT_ASSERT(state.State == NDataShard::TReadIteratorState::EState::Exhausted); + } +}; + +} // namespace NKikimr diff --git a/ydb/core/tx/datashard/datashard_ut_read_table.cpp b/ydb/core/tx/datashard/datashard_ut_read_table.cpp index 60f0affa276..c11e21f2f2c 100644 --- a/ydb/core/tx/datashard/datashard_ut_read_table.cpp +++ b/ydb/core/tx/datashard/datashard_ut_read_table.cpp @@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(DataShardReadTableSnapshots) { "key = 4, value = 44\n"); Cerr << "---Rebooting tablet---" << Endl; - RebootTablet(runtime, shards[0], sender); + RebootTablet(runtime, shards[0], sender); // We must be able to finish reading from the acquired snapshot auto table1snapshot = table1state.All(); diff --git a/ydb/core/tx/datashard/datashard_ut_snapshot.cpp b/ydb/core/tx/datashard/datashard_ut_snapshot.cpp index 57a6d208c2c..ca3bc867fa6 100644 --- a/ydb/core/tx/datashard/datashard_ut_snapshot.cpp +++ b/ydb/core/tx/datashard/datashard_ut_snapshot.cpp @@ -651,7 +651,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { // Snapshots table must still have snapshot (used by paused ReadTable) UNIT_ASSERT_VALUES_EQUAL(GetSnapshotCount(runtime, shards1[0]), 1u); - RebootTablet(runtime, shards1[0], sender); + RebootTablet(runtime, shards1[0], sender); // Snapshots table should be cleaned up on reboot UNIT_ASSERT_VALUES_EQUAL(GetSnapshotCount(runtime, shards1[0]), 0u); @@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { TServerSettings serverSettings(pm.GetPort(2134)); serverSettings.SetDomainName("Root") .SetUseRealThreads(false) - .SetEnableMvcc(false) + .SetEnableMvcc(false) .SetDomainPlanResolution(1000); Tests::TServer::TPtr server = new TServer(serverSettings); @@ -788,7 +788,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { UNIT_ASSERT_VALUES_EQUAL(ranges.begin()->Upper, snapshot); } - RebootTablet(runtime, shards1[0], sender); + RebootTablet(runtime, shards1[0], sender); // Snapshots table should be cleaned up on reboot UNIT_ASSERT_VALUES_EQUAL(GetSnapshotCount(runtime, shards1[0]), 0u); @@ -809,7 +809,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) { TServerSettings serverSettings(pm.GetPort(2134)); serverSettings.SetDomainName("Root") .SetUseRealThreads(false) - .SetEnableMvcc(false) + .SetEnableMvcc(false) .SetDomainPlanResolution(1000); Tests::TServer::TPtr server = new TServer(serverSettings); diff --git a/ydb/core/tx/datashard/erase_rows_condition.cpp b/ydb/core/tx/datashard/erase_rows_condition.cpp index 98e7c3bb0f7..d6960773513 100644 --- a/ydb/core/tx/datashard/erase_rows_condition.cpp +++ b/ydb/core/tx/datashard/erase_rows_condition.cpp @@ -124,7 +124,7 @@ public: proto.SetColumnUnit(Unit); } - void Prepare(TIntrusiveConstPtr<NTable::TRowScheme> scheme, TMaybe<NTable::TPos> remapPos) override { + void Prepare(TIntrusiveConstPtr<NTable::TRowScheme> scheme, TMaybe<NTable::TPos> remapPos) override { const auto* columnInfo = scheme->ColInfo(ColumnId); Y_VERIFY(columnInfo); diff --git a/ydb/core/tx/datashard/erase_rows_condition.h b/ydb/core/tx/datashard/erase_rows_condition.h index b6d82642d36..df902660bad 100644 --- a/ydb/core/tx/datashard/erase_rows_condition.h +++ b/ydb/core/tx/datashard/erase_rows_condition.h @@ -16,7 +16,7 @@ class IEraseRowsCondition { public: virtual ~IEraseRowsCondition() = default; virtual void AddToRequest(NKikimrTxDataShard::TEvEraseRowsRequest& request) const = 0; - virtual void Prepare(TIntrusiveConstPtr<NTable::TRowScheme> scheme, TMaybe<NTable::TPos> remapPos = Nothing()) = 0; + virtual void Prepare(TIntrusiveConstPtr<NTable::TRowScheme> scheme, TMaybe<NTable::TPos> remapPos = Nothing()) = 0; virtual bool Check(const NTable::TRowState& row) const = 0; virtual TVector<NTable::TTag> Tags() const = 0; diff --git a/ydb/core/tx/datashard/export_scan.cpp b/ydb/core/tx/datashard/export_scan.cpp index 7773f7bcb4c..2cda75fdd07 100644 --- a/ydb/core/tx/datashard/export_scan.cpp +++ b/ydb/core/tx/datashard/export_scan.cpp @@ -169,7 +169,7 @@ public: << " }"; } - IScan::THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { + IScan::THello Prepare(IDriver* driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { TlsActivationContext->AsActorContext().RegisterWithSameMailbox(this); Driver = driver; @@ -208,7 +208,7 @@ public: return MaybeSendBuffer(); } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { const bool success = (abort == EAbort::None) && Success; if (abort != EAbort::None) { @@ -236,8 +236,8 @@ private: THolder<TStats> Stats; IDriver* Driver; - TIntrusiveConstPtr<TScheme> Scheme; - TAutoPtr<TSpent> Spent; + TIntrusiveConstPtr<TScheme> Scheme; + TAutoPtr<TSpent> Spent; TBitMap<EStateBits::ES_COUNT> State; bool Success; diff --git a/ydb/core/tx/datashard/export_scan.h b/ydb/core/tx/datashard/export_scan.h index e679322f9e9..d077576a607 100644 --- a/ydb/core/tx/datashard/export_scan.h +++ b/ydb/core/tx/datashard/export_scan.h @@ -70,7 +70,7 @@ struct TEvExportScan { }; // TEvExportScan -struct TExportScanProduct: public IDestructable { +struct TExportScanProduct: public IDestructable { bool Success; TString Error; ui64 BytesRead; diff --git a/ydb/core/tx/datashard/finish_propose_unit.cpp b/ydb/core/tx/datashard/finish_propose_unit.cpp index ab66444e0e5..de0e9e4ad2e 100644 --- a/ydb/core/tx/datashard/finish_propose_unit.cpp +++ b/ydb/core/tx/datashard/finish_propose_unit.cpp @@ -78,7 +78,7 @@ EExecutionStatus TFinishProposeUnit::Execute(TOperation::TPtr op, if (!op->HasResultSentFlag() && (op->IsDirty() || !Pipeline.WaitCompletion(op))) CompleteRequest(op, ctx); - if (!DataShard.IsFollower()) + if (!DataShard.IsFollower()) DataShard.PlanCleanup(ctx); // Release acquired snapshot for immediate and aborted operations @@ -171,7 +171,7 @@ void TFinishProposeUnit::AddDiagnosticsResult(TOutputOpData::TResultPtr &res) tabletInfo.SetTabletId(DataShard.TabletID()); tabletInfo.SetGeneration(DataShard.Generation()); tabletInfo.SetStep(DataShard.GetExecutorStep()); - tabletInfo.SetIsFollower(DataShard.IsFollower()); + tabletInfo.SetIsFollower(DataShard.IsFollower()); } void TFinishProposeUnit::UpdateCounters(TOperation::TPtr op, diff --git a/ydb/core/tx/datashard/import_common.h b/ydb/core/tx/datashard/import_common.h index 45866fc5cdf..a7cb38b18e7 100644 --- a/ydb/core/tx/datashard/import_common.h +++ b/ydb/core/tx/datashard/import_common.h @@ -33,7 +33,7 @@ namespace NKikimr { namespace NDataShard { -struct TImportJobProduct: public IDestructable { +struct TImportJobProduct: public IDestructable { bool Success; TString Error; ui64 BytesWritten; diff --git a/ydb/core/tx/datashard/import_s3.cpp b/ydb/core/tx/datashard/import_s3.cpp index 1009f51a238..9ea7fbab5c0 100644 --- a/ydb/core/tx/datashard/import_s3.cpp +++ b/ydb/core/tx/datashard/import_s3.cpp @@ -436,7 +436,7 @@ class TS3Downloader: public TActorBootstrapped<TS3Downloader>, private TS3User { << ", writtenBytes# " << WrittenBytes << ", writtenRows# " << WrittenRows); - TAutoPtr<IDestructable> prod = new TImportJobProduct(success, error, WrittenBytes, WrittenRows); + TAutoPtr<IDestructable> prod = new TImportJobProduct(success, error, WrittenBytes, WrittenRows); Send(DataShard, new TDataShard::TEvPrivate::TEvAsyncJobComplete(prod), 0, TxId); Y_VERIFY(TaskId); diff --git a/ydb/core/tx/datashard/operation.h b/ydb/core/tx/datashard/operation.h index f344fee96de..0f4b713e91c 100644 --- a/ydb/core/tx/datashard/operation.h +++ b/ydb/core/tx/datashard/operation.h @@ -427,8 +427,8 @@ struct TInputOpData { TVector<NKikimrTx::TEvReadSet> DelayedInReadSets; TCoverageBuilders CoverageBuilders; ui32 RemainReadSets; - TAutoPtr<IDestructable> ScanResult; - TAutoPtr<IDestructable> AsyncJobResult; + TAutoPtr<IDestructable> ScanResult; + TAutoPtr<IDestructable> AsyncJobResult; }; struct TOutputOpData { @@ -577,12 +577,12 @@ public: DelayedInReadSets().emplace_back(rs); } - TAutoPtr<IDestructable> &ScanResult() { return InputDataRef().ScanResult; } - void SetScanResult(TAutoPtr<IDestructable> prod) { InputDataRef().ScanResult = prod; } + TAutoPtr<IDestructable> &ScanResult() { return InputDataRef().ScanResult; } + void SetScanResult(TAutoPtr<IDestructable> prod) { InputDataRef().ScanResult = prod; } bool HasScanResult() const { return InputData ? (bool)InputData->ScanResult : false; } - TAutoPtr<IDestructable> &AsyncJobResult() { return InputDataRef().AsyncJobResult; } - void SetAsyncJobResult(TAutoPtr<IDestructable> prod) { InputDataRef().AsyncJobResult = prod; } + TAutoPtr<IDestructable> &AsyncJobResult() { return InputDataRef().AsyncJobResult; } + void SetAsyncJobResult(TAutoPtr<IDestructable> prod) { InputDataRef().AsyncJobResult = prod; } bool HasAsyncJobResult() const { return InputData ? (bool)InputData->AsyncJobResult : false; } //////////////////////////////////////// diff --git a/ydb/core/tx/datashard/read_iterator.h b/ydb/core/tx/datashard/read_iterator.h index 07377d60043..1e7dd221b55 100644 --- a/ydb/core/tx/datashard/read_iterator.h +++ b/ydb/core/tx/datashard/read_iterator.h @@ -1,153 +1,153 @@ -#pragma once - -#include "datashard.h" - -#include <ydb/core/base/row_version.h> -#include <ydb/core/tablet_flat/flat_row_eggs.h> - -#include <util/digest/multi.h> - -#include <memory> -#include <unordered_map> -#include <unordered_set> -#include <vector> - -namespace NKikimr::NDataShard { - -struct TReadIteratorId { - TActorId Sender; - ui64 ReadId = 0; - - TReadIteratorId(const TActorId& sender, ui64 readId) - : Sender(sender) - , ReadId(readId) - {} - - bool operator ==(const TReadIteratorId& rhs) const = default; - - struct THash { - size_t operator ()(const TReadIteratorId& id) const { - return MultiHash(id.Sender.Hash(), id.ReadId); - } - }; - - TString ToString() const { - TStringStream ss; - ss << "{" << Sender << ", " << ReadId << "}"; - return ss.Str(); - } -}; - -struct TReadIteratorState { - enum class EState { - Init, - Executing, - Exhausted, - }; - - struct TQuota { - TQuota() = default; - - TQuota(ui64 rows, ui64 bytes) - : Rows(rows) - , Bytes(bytes) - {} - - ui64 Rows = Max<ui64>(); - ui64 Bytes = Max<ui64>(); - }; - -public: - TReadIteratorState() = default; - - bool IsExhausted() const { return State == EState::Exhausted; } - - // must be called only once per SeqNo - void ConsumeSeqNo(ui64 rows, ui64 bytes) { - ++SeqNo; - ReadStats.emplace_back(rows, bytes); - - if (Quota.Rows <= rows) { - Quota.Rows = 0; - } else { - Quota.Rows -= rows; - } - - if (Quota.Bytes <= bytes) { - Quota.Bytes = 0; - } else { - Quota.Bytes -= bytes; - } - - if (Quota.Rows == 0 || Quota.Bytes == 0) { - State = EState::Exhausted; - } - } - - void UpQuota(ui64 seqNo, ui64 rows, ui64 bytes) { - Y_ASSERT(seqNo <= ReadStats.size()); - // user provided quota for seqNo, if we have sent messages - // with higher seqNo then we should account their bytes to - // this quota - ui64 consumedBytes = 0, consumedRows = 0; - for (ui64 i = seqNo; i < ReadStats.size(); ++i) { - consumedRows += ReadStats[i].Rows; - consumedBytes += ReadStats[i].Bytes; - } - - if (consumedRows >= rows) { - Quota.Rows = 0; - } else { - Quota.Rows = rows - consumedRows; - } - - if (consumedBytes >= bytes) { - Quota.Bytes = 0; - } else { - Quota.Bytes = bytes - consumedBytes; - } - - if (Quota.Rows == 0 || Quota.Bytes == 0) { - State = EState::Exhausted; - } else { - State = EState::Executing; - } - } - -public: - EState State = EState::Init; - - // Data from original request // - - ui64 ReadId = 0; - TPathId PathId; - std::vector<NTable::TTag> Columns; - TRowVersion ReadVersion = TRowVersion::Max(); - ui64 LockTxId = 0; - - // note that will be always overwritten by values from request - NKikimrTxDataShard::EScanDataFormat Format = NKikimrTxDataShard::EScanDataFormat::CELLVEC; - - // mainly for tests - ui64 MaxRowsInResult = Max<ui64>(); - - ui64 SchemaVersion = 0; - - bool Reverse = false; - - std::shared_ptr<TEvDataShard::TEvRead> Request; - - // State itself // - - TQuota Quota; - TVector<TQuota> ReadStats; // each index corresponds to SeqNo-1 - - ui64 SeqNo = 0; - ui32 FirstUnprocessedQuery = 0; - TString LastProcessedKey = 0; -}; - -using TReadIteratorStatePtr = std::unique_ptr<TReadIteratorState>; -using TReadIteratorsMap = std::unordered_map<TReadIteratorId, TReadIteratorStatePtr, TReadIteratorId::THash>; - -} // NKikimr::NDataShard +#pragma once + +#include "datashard.h" + +#include <ydb/core/base/row_version.h> +#include <ydb/core/tablet_flat/flat_row_eggs.h> + +#include <util/digest/multi.h> + +#include <memory> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +namespace NKikimr::NDataShard { + +struct TReadIteratorId { + TActorId Sender; + ui64 ReadId = 0; + + TReadIteratorId(const TActorId& sender, ui64 readId) + : Sender(sender) + , ReadId(readId) + {} + + bool operator ==(const TReadIteratorId& rhs) const = default; + + struct THash { + size_t operator ()(const TReadIteratorId& id) const { + return MultiHash(id.Sender.Hash(), id.ReadId); + } + }; + + TString ToString() const { + TStringStream ss; + ss << "{" << Sender << ", " << ReadId << "}"; + return ss.Str(); + } +}; + +struct TReadIteratorState { + enum class EState { + Init, + Executing, + Exhausted, + }; + + struct TQuota { + TQuota() = default; + + TQuota(ui64 rows, ui64 bytes) + : Rows(rows) + , Bytes(bytes) + {} + + ui64 Rows = Max<ui64>(); + ui64 Bytes = Max<ui64>(); + }; + +public: + TReadIteratorState() = default; + + bool IsExhausted() const { return State == EState::Exhausted; } + + // must be called only once per SeqNo + void ConsumeSeqNo(ui64 rows, ui64 bytes) { + ++SeqNo; + ReadStats.emplace_back(rows, bytes); + + if (Quota.Rows <= rows) { + Quota.Rows = 0; + } else { + Quota.Rows -= rows; + } + + if (Quota.Bytes <= bytes) { + Quota.Bytes = 0; + } else { + Quota.Bytes -= bytes; + } + + if (Quota.Rows == 0 || Quota.Bytes == 0) { + State = EState::Exhausted; + } + } + + void UpQuota(ui64 seqNo, ui64 rows, ui64 bytes) { + Y_ASSERT(seqNo <= ReadStats.size()); + // user provided quota for seqNo, if we have sent messages + // with higher seqNo then we should account their bytes to + // this quota + ui64 consumedBytes = 0, consumedRows = 0; + for (ui64 i = seqNo; i < ReadStats.size(); ++i) { + consumedRows += ReadStats[i].Rows; + consumedBytes += ReadStats[i].Bytes; + } + + if (consumedRows >= rows) { + Quota.Rows = 0; + } else { + Quota.Rows = rows - consumedRows; + } + + if (consumedBytes >= bytes) { + Quota.Bytes = 0; + } else { + Quota.Bytes = bytes - consumedBytes; + } + + if (Quota.Rows == 0 || Quota.Bytes == 0) { + State = EState::Exhausted; + } else { + State = EState::Executing; + } + } + +public: + EState State = EState::Init; + + // Data from original request // + + ui64 ReadId = 0; + TPathId PathId; + std::vector<NTable::TTag> Columns; + TRowVersion ReadVersion = TRowVersion::Max(); + ui64 LockTxId = 0; + + // note that will be always overwritten by values from request + NKikimrTxDataShard::EScanDataFormat Format = NKikimrTxDataShard::EScanDataFormat::CELLVEC; + + // mainly for tests + ui64 MaxRowsInResult = Max<ui64>(); + + ui64 SchemaVersion = 0; + + bool Reverse = false; + + std::shared_ptr<TEvDataShard::TEvRead> Request; + + // State itself // + + TQuota Quota; + TVector<TQuota> ReadStats; // each index corresponds to SeqNo-1 + + ui64 SeqNo = 0; + ui32 FirstUnprocessedQuery = 0; + TString LastProcessedKey = 0; +}; + +using TReadIteratorStatePtr = std::unique_ptr<TReadIteratorState>; +using TReadIteratorsMap = std::unordered_map<TReadIteratorId, TReadIteratorStatePtr, TReadIteratorId::THash>; + +} // NKikimr::NDataShard diff --git a/ydb/core/tx/datashard/read_table_scan.cpp b/ydb/core/tx/datashard/read_table_scan.cpp index e983f32a09d..63e94fde967 100644 --- a/ydb/core/tx/datashard/read_table_scan.cpp +++ b/ydb/core/tx/datashard/read_table_scan.cpp @@ -427,7 +427,7 @@ private: IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); } - THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override + THello Prepare(IDriver *driver, TIntrusiveConstPtr<TScheme> scheme) noexcept override { Driver = driver; @@ -564,7 +564,7 @@ private: return cmp <= 0; } - TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override + TAutoPtr<IDestructable> Finish(EAbort abort) noexcept override { auto ctx = TActivationContext::ActorContextFor(SelfId()); @@ -614,7 +614,7 @@ private: bool SchemaChanged = false; }; -TAutoPtr<NTable::IScan> CreateReadTableScan(ui64 txId, +TAutoPtr<NTable::IScan> CreateReadTableScan(ui64 txId, ui64 shardId, TUserTable::TCPtr tableInfo, const NKikimrTxDataShard::TReadTableTransaction &tx, diff --git a/ydb/core/tx/datashard/read_table_scan.h b/ydb/core/tx/datashard/read_table_scan.h index 725ba8e04db..0650c6ef67a 100644 --- a/ydb/core/tx/datashard/read_table_scan.h +++ b/ydb/core/tx/datashard/read_table_scan.h @@ -6,7 +6,7 @@ namespace NKikimr { namespace NDataShard { -class TReadTableProd : public IDestructable { +class TReadTableProd : public IDestructable { public: TReadTableProd(const TString &error, bool schemaChanged = false) : Error(error) @@ -17,7 +17,7 @@ public: bool SchemaChanged; }; -TAutoPtr<NTable::IScan> CreateReadTableScan(ui64 txId, +TAutoPtr<NTable::IScan> CreateReadTableScan(ui64 txId, ui64 shardId, TUserTable::TCPtr tableInfo, const NKikimrTxDataShard::TReadTableTransaction &tx, diff --git a/ydb/core/tx/datashard/ut_background_compaction/ya.make b/ydb/core/tx/datashard/ut_background_compaction/ya.make index 1c12e4f2650..c9f5aa45c4e 100644 --- a/ydb/core/tx/datashard/ut_background_compaction/ya.make +++ b/ydb/core/tx/datashard/ut_background_compaction/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_background_compaction.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_background_compaction.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_build_index/ya.make b/ydb/core/tx/datashard/ut_build_index/ya.make index 7db6ac48b0e..0312e41f2d2 100644 --- a/ydb/core/tx/datashard/ut_build_index/ya.make +++ b/ydb/core/tx/datashard/ut_build_index/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_build_index.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_build_index.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_change_collector/ya.make b/ydb/core/tx/datashard/ut_change_collector/ya.make index 7473625d708..187b8bc827e 100644 --- a/ydb/core/tx/datashard/ut_change_collector/ya.make +++ b/ydb/core/tx/datashard/ut_change_collector/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(8) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(8) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_change_collector.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_change_collector.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_change_exchange/ya.make b/ydb/core/tx/datashard/ut_change_exchange/ya.make index ac61077c430..073f3f2aaa6 100644 --- a/ydb/core/tx/datashard/ut_change_exchange/ya.make +++ b/ydb/core/tx/datashard/ut_change_exchange/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(4) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(4) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_change_exchange.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_change_exchange.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_erase_rows/ya.make b/ydb/core/tx/datashard/ut_erase_rows/ya.make index 2bf3746ab84..e21f7072575 100644 --- a/ydb/core/tx/datashard/ut_erase_rows/ya.make +++ b/ydb/core/tx/datashard/ut_erase_rows/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(15) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(15) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_erase_rows.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_erase_rows.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_followers/ya.make b/ydb/core/tx/datashard/ut_followers/ya.make index e8fc88111e5..64dd9b7ce62 100644 --- a/ydb/core/tx/datashard/ut_followers/ya.make +++ b/ydb/core/tx/datashard/ut_followers/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_followers.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_followers.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_init/ya.make b/ydb/core/tx/datashard/ut_init/ya.make index 844d7129be3..39f0cf7f8c8 100644 --- a/ydb/core/tx/datashard/ut_init/ya.make +++ b/ydb/core/tx/datashard/ut_init/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_init.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_init.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_keys/ya.make b/ydb/core/tx/datashard/ut_keys/ya.make index 0f781f06338..5091c5b1340 100644 --- a/ydb/core/tx/datashard/ut_keys/ya.make +++ b/ydb/core/tx/datashard/ut_keys/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_keys.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_keys.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp/ya.make b/ydb/core/tx/datashard/ut_kqp/ya.make index 15e706fd885..b59d47eabca 100644 --- a/ydb/core/tx/datashard/ut_kqp/ya.make +++ b/ydb/core/tx/datashard/ut_kqp/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(2) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_kqp.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp_errors/ya.make b/ydb/core/tx/datashard/ut_kqp_errors/ya.make index ed6355e9129..daae41758d9 100644 --- a/ydb/core/tx/datashard/ut_kqp_errors/ya.make +++ b/ydb/core/tx/datashard/ut_kqp_errors/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(3) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_kqp_errors.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp_errors.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_kqp_scan/ya.make b/ydb/core/tx/datashard/ut_kqp_scan/ya.make index aae6c18e76c..94c76ad31e9 100644 --- a/ydb/core/tx/datashard/ut_kqp_scan/ya.make +++ b/ydb/core/tx/datashard/ut_kqp_scan/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(3) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_kqp_scan.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_kqp_scan.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_locks/ya.make b/ydb/core/tx/datashard/ut_locks/ya.make index 2a3517b4992..aab152335d8 100644 --- a/ydb/core/tx/datashard/ut_locks/ya.make +++ b/ydb/core/tx/datashard/ut_locks/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(3) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(3) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_locks.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_locks.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_minikql/ya.make b/ydb/core/tx/datashard/ut_minikql/ya.make index 0ce64295444..8a5e2a232fe 100644 --- a/ydb/core/tx/datashard/ut_minikql/ya.make +++ b/ydb/core/tx/datashard/ut_minikql/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(8) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(8) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_minikql.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_minikql.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_minstep/ya.make b/ydb/core/tx/datashard/ut_minstep/ya.make index 240629b163d..c39e4eec66b 100644 --- a/ydb/core/tx/datashard/ut_minstep/ya.make +++ b/ydb/core/tx/datashard/ut_minstep/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(2) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(2) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_minstep.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_minstep.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_order/ya.make b/ydb/core/tx/datashard/ut_order/ya.make index 37370972b1d..179ea554f70 100644 --- a/ydb/core/tx/datashard/ut_order/ya.make +++ b/ydb/core/tx/datashard/ut_order/ya.make @@ -1,44 +1,44 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - -OWNER( - vvvv - g:kikimr -) - -FORK_SUBTESTS() - -SPLIT_FACTOR(40) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx +UNITTEST_FOR(ydb/core/tx/datashard) + +OWNER( + vvvv + g:kikimr +) + +FORK_SUBTESTS() + +SPLIT_FACTOR(40) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_order.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_order.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_avl_tree/ya.make b/ydb/core/tx/datashard/ut_range_avl_tree/ya.make index 1495b45ed04..40392ab0df7 100644 --- a/ydb/core/tx/datashard/ut_range_avl_tree/ya.make +++ b/ydb/core/tx/datashard/ut_range_avl_tree/ya.make @@ -1,42 +1,42 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - -OWNER( - eivanov89 - g:kikimr -) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx +UNITTEST_FOR(ydb/core/tx/datashard) + +OWNER( + eivanov89 + g:kikimr +) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - range_avl_tree_ut.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + range_avl_tree_ut.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_ops/ya.make b/ydb/core/tx/datashard/ut_range_ops/ya.make index f4a1917d7f1..bbf105e5a13 100644 --- a/ydb/core/tx/datashard/ut_range_ops/ya.make +++ b/ydb/core/tx/datashard/ut_range_ops/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_range_ops.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_range_ops.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_range_treap/ya.make b/ydb/core/tx/datashard/ut_range_treap/ya.make index d491ed77577..d7809af0108 100644 --- a/ydb/core/tx/datashard/ut_range_treap/ya.make +++ b/ydb/core/tx/datashard/ut_range_treap/ya.make @@ -1,42 +1,42 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - -OWNER( - eivanov89 - g:kikimr -) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx +UNITTEST_FOR(ydb/core/tx/datashard) + +OWNER( + eivanov89 + g:kikimr +) + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - range_treap_ut.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + range_treap_ut.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_read_iterator/ya.make b/ydb/core/tx/datashard/ut_read_iterator/ya.make index ac59db2adde..b004ed18fa4 100644 --- a/ydb/core/tx/datashard/ut_read_iterator/ya.make +++ b/ydb/core/tx/datashard/ut_read_iterator/ya.make @@ -1,44 +1,44 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - -OWNER( - eivanov89 - g:kikimr -) - -FORK_SUBTESTS() - -SPLIT_FACTOR(10) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx +UNITTEST_FOR(ydb/core/tx/datashard) + +OWNER( + eivanov89 + g:kikimr +) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_read_iterator.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_read_iterator.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_read_table/ya.make b/ydb/core/tx/datashard/ut_read_table/ya.make index e189f3f6a3e..91fb31013fb 100644 --- a/ydb/core/tx/datashard/ut_read_table/ya.make +++ b/ydb/core/tx/datashard/ut_read_table/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(5) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_read_table.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_read_table.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_reassign/ya.make b/ydb/core/tx/datashard/ut_reassign/ya.make index 9e6daccf544..2ce9b7519d5 100644 --- a/ydb/core/tx/datashard/ut_reassign/ya.make +++ b/ydb/core/tx/datashard/ut_reassign/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_reassign.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_reassign.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_replication/ya.make b/ydb/core/tx/datashard/ut_replication/ya.make index 656b3f74a16..114ed723c83 100644 --- a/ydb/core/tx/datashard/ut_replication/ya.make +++ b/ydb/core/tx/datashard/ut_replication/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_replication.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_replication.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_rs/ya.make b/ydb/core/tx/datashard/ut_rs/ya.make index bd209d775b2..a19b9478806 100644 --- a/ydb/core/tx/datashard/ut_rs/ya.make +++ b/ydb/core/tx/datashard/ut_rs/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_rs.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_rs.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_snapshot/ya.make b/ydb/core/tx/datashard/ut_snapshot/ya.make index 246c8fd3b6e..be8c097fc29 100644 --- a/ydb/core/tx/datashard/ut_snapshot/ya.make +++ b/ydb/core/tx/datashard/ut_snapshot/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(6) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(6) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_snapshot.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_snapshot.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_stats/ya.make b/ydb/core/tx/datashard/ut_stats/ya.make index 8c330ceaeef..a2e97b17b96 100644 --- a/ydb/core/tx/datashard/ut_stats/ya.make +++ b/ydb/core/tx/datashard/ut_stats/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(1) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(1) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_stats.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_stats.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ut_upload_rows/ya.make b/ydb/core/tx/datashard/ut_upload_rows/ya.make index fb09ab4361a..8b0c5206f63 100644 --- a/ydb/core/tx/datashard/ut_upload_rows/ya.make +++ b/ydb/core/tx/datashard/ut_upload_rows/ya.make @@ -1,41 +1,41 @@ -UNITTEST_FOR(ydb/core/tx/datashard) - +UNITTEST_FOR(ydb/core/tx/datashard) + OWNER(g:kikimr) - -FORK_SUBTESTS() - -SPLIT_FACTOR(5) - -IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) - REQUIREMENTS(ram:16) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( - library/cpp/getopt - library/cpp/regex/pcre - library/cpp/svnversion - ydb/core/kqp/ut/common - ydb/core/testlib - ydb/core/tx + +FORK_SUBTESTS() + +SPLIT_FACTOR(5) + +IF (SANITIZER_TYPE == "thread" OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) + REQUIREMENTS(ram:16) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( + library/cpp/getopt + library/cpp/regex/pcre + library/cpp/svnversion + ydb/core/kqp/ut/common + ydb/core/testlib + ydb/core/tx ydb/library/yql/public/udf/service/exception_policy ydb/public/lib/yson_value ydb/public/sdk/cpp/client/ydb_result -) - -YQL_LAST_ABI_VERSION() - -SRCS( - datashard_ut_common.cpp - datashard_ut_common.h - datashard_ut_upload_rows.cpp -) - -REQUIREMENTS(ram:32) - -END() +) + +YQL_LAST_ABI_VERSION() + +SRCS( + datashard_ut_common.cpp + datashard_ut_common.h + datashard_ut_upload_rows.cpp +) + +REQUIREMENTS(ram:32) + +END() diff --git a/ydb/core/tx/datashard/ya.make b/ydb/core/tx/datashard/ya.make index 1ec42b2b4b8..9c98e8e79b0 100644 --- a/ydb/core/tx/datashard/ya.make +++ b/ydb/core/tx/datashard/ya.make @@ -40,7 +40,7 @@ SRCS( datashard__build_index.cpp datashard__cancel_tx_proposal.cpp datashard__compact_borrowed.cpp - datashard__compaction.cpp + datashard__compaction.cpp datashard__cleanup_borrowed.cpp datashard__cleanup_in_rs.cpp datashard__cleanup_tx.cpp @@ -59,7 +59,7 @@ SRCS( datashard__progress_tx.cpp datashard__propose_tx_base.cpp datashard__readset.cpp - datashard__read_iterator.cpp + datashard__read_iterator.cpp datashard__read_columns.cpp datashard__s3.cpp datashard__s3_download_txs.cpp @@ -169,7 +169,7 @@ SRCS( range_avl_tree.cpp range_ops.cpp range_treap.cpp - read_iterator.h + read_iterator.h restore_unit.cpp setup_sys_locks.h store_and_send_out_rs_unit.cpp @@ -248,31 +248,31 @@ ENDIF() END() RECURSE_FOR_TESTS( - ut_background_compaction - ut_build_index - ut_change_collector - ut_change_exchange + ut_background_compaction + ut_build_index + ut_change_collector + ut_change_exchange ut_compaction - ut_erase_rows - ut_followers - ut_init - ut_keys - ut_kqp - ut_kqp_errors - ut_kqp_scan - ut_locks - ut_minikql - ut_minstep - ut_order - ut_range_avl_tree - ut_range_ops - ut_range_treap - ut_read_iterator - ut_read_table - ut_reassign - ut_replication - ut_rs - ut_snapshot - ut_stats - ut_upload_rows + ut_erase_rows + ut_followers + ut_init + ut_keys + ut_kqp + ut_kqp_errors + ut_kqp_scan + ut_locks + ut_minikql + ut_minstep + ut_order + ut_range_avl_tree + ut_range_ops + ut_range_treap + ut_read_iterator + ut_read_table + ut_reassign + ut_replication + ut_rs + ut_snapshot + ut_stats + ut_upload_rows ) diff --git a/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp b/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp index 42a0faec692..b3e5967eaf9 100644 --- a/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp +++ b/ydb/core/tx/long_tx_service/acquire_snapshot_impl.cpp @@ -22,7 +22,7 @@ namespace NLongTxService { , Cookie(cookie) , DatabaseName(databaseName) , SchemeCache(MakeSchemeCacheID()) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) , LogPrefix("LongTxService.AcquireSnapshot ") { } @@ -37,7 +37,7 @@ namespace NLongTxService { private: void PassAway() override { - Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); TActor::PassAway(); } @@ -165,7 +165,7 @@ namespace NLongTxService { private: void SendToTablet(ui64 tabletId, THolder<IEventBase> event, bool subscribe = true) { - Send(LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, subscribe), + Send(LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, subscribe), IEventHandle::FlagTrackDelivery); } @@ -174,7 +174,7 @@ namespace NLongTxService { const ui64 Cookie; const TString DatabaseName; const TActorId SchemeCache; - const TActorId LeaderPipeCache; + const TActorId LeaderPipeCache; TString LogPrefix; THashSet<ui64> WaitingCoordinators; }; diff --git a/ydb/core/tx/long_tx_service/commit_impl.cpp b/ydb/core/tx/long_tx_service/commit_impl.cpp index 17a47e8f055..3a2872bad07 100644 --- a/ydb/core/tx/long_tx_service/commit_impl.cpp +++ b/ydb/core/tx/long_tx_service/commit_impl.cpp @@ -41,8 +41,8 @@ namespace NLongTxService { private: void PassAway() override { - if (Services.LeaderPipeCache) { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + if (Services.LeaderPipeCache) { + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); } TActor::PassAway(); } @@ -327,7 +327,7 @@ namespace NLongTxService { private: void SendToTablet(ui64 tabletId, THolder<IEventBase> event, bool subscribe = true) { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, subscribe)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(event.Release(), tabletId, subscribe)); } private: diff --git a/ydb/core/tx/replication/ydb_proxy/ydb_proxy_ut.cpp b/ydb/core/tx/replication/ydb_proxy/ydb_proxy_ut.cpp index ac5412c9b56..d536a6db195 100644 --- a/ydb/core/tx/replication/ydb_proxy/ydb_proxy_ut.cpp +++ b/ydb/core/tx/replication/ydb_proxy/ydb_proxy_ut.cpp @@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(YdbProxyTests) { auto req = MakeHolder<NSchemeShard::TEvSchemeShard::TEvLogin>(); req->Record.SetUser(user); req->Record.SetPassword(password); - ForwardToTablet(*Server.GetRuntime(), schemeShardId, Sender, req.Release()); + ForwardToTablet(*Server.GetRuntime(), schemeShardId, Sender, req.Release()); auto resp = Server.GetRuntime()->GrabEdgeEvent<NSchemeShard::TEvSchemeShard::TEvLoginResult>(Sender); UNIT_ASSERT(resp->Get()->Record.GetError().empty()); diff --git a/ydb/core/tx/scheme_board/cache_ut.cpp b/ydb/core/tx/scheme_board/cache_ut.cpp index 7d0a6727960..c27b3517b34 100644 --- a/ydb/core/tx/scheme_board/cache_ut.cpp +++ b/ydb/core/tx/scheme_board/cache_ut.cpp @@ -27,7 +27,7 @@ public: TIntrusivePtr<TConfig> config = new TConfig(); config->Counters = new NMonitoring::TDynamicCounters; - config->Roots.push_back(TConfig::TTagEntry(0, TTestTxConfig::SchemeShard, "Root")); + config->Roots.push_back(TConfig::TTagEntry(0, TTestTxConfig::SchemeShard, "Root")); SchemeCache = Context->Register(CreateSchemeBoardSchemeCache(config.Get())); Context->EnableScheduleForActor(SchemeCache, true); @@ -112,7 +112,7 @@ void TCacheTest::Navigate() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); auto entry = TestNavigate("/Root/DirA", TNavigate::EStatus::Ok); @@ -128,7 +128,7 @@ void TCacheTest::Attributes() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA", {NKikimrScheme::StatusAccepted}, attrs); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); auto entry = TestNavigate("/Root/DirA", TNavigate::EStatus::Ok); UNIT_ASSERT_VALUES_EQUAL(entry.Attributes.size(), 1); @@ -142,7 +142,7 @@ void TCacheTest::List() { TestMkDir(*Context, ++txId, "/Root", "DirA"); TestMkDir(*Context, ++txId, "/Root/DirA", "DirB"); TestMkDir(*Context, ++txId, "/Root/DirA", "DirC"); - TestWaitNotification(*Context, {txId - 2, txId - 1, txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId - 2, txId - 1, txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); { auto entry = TestNavigate("/Root/DirA", TNavigate::EStatus::Ok); @@ -160,18 +160,18 @@ void TCacheTest::Recreate() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); Context->CreateSubscriber<TSchemeBoardEvents::TEvNotifyUpdate>(edge, "/Root/DirA"); TestRmDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); auto ev = Context->GrabEdgeEvent<TSchemeBoardEvents::TEvNotifyDelete>(edge); auto pathId = ev->Get()->PathId; TTableId tableId(pathId.OwnerId, pathId.LocalPathId); TestResolve(tableId, TResolve::EStatus::PathErrorNotExist); TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); Context->GrabEdgeEvent<TSchemeBoardEvents::TEvNotifyUpdate>(edge); TestNavigate("/Root/DirA", TNavigate::EStatus::Ok); } @@ -211,7 +211,7 @@ void TCacheTest::RacyCreateAndSync() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); Context->TTestBasicRuntime::Send(delayedSyncRequest.Release(), 0, true); auto ev = Context->GrabEdgeEvent<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(edge); @@ -224,11 +224,11 @@ void TCacheTest::RacyRecreateAndSync() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); TestNavigate("/Root/DirA", TNavigate::EStatus::Ok, "", TNavigate::EOp::OpPath, false, true, true); TestRmDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); TestNavigate("/Root/DirA", TNavigate::EStatus::PathErrorUnknown, "", TNavigate::EOp::OpPath, false, true, true); THolder<IEventHandle> delayedSyncRequest; @@ -264,7 +264,7 @@ void TCacheTest::RacyRecreateAndSync() { Context->SetObserverFunc(prevObserver); TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); Context->TTestBasicRuntime::Send(delayedSyncRequest.Release(), 0, true); auto ev = Context->GrabEdgeEvent<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(edge); @@ -296,7 +296,7 @@ void TCacheTest::CheckAccess() { void TCacheTest::CheckSystemViewAccess() { ui64 txId = 100; TestCreateSubDomain(*Context, ++txId, "/Root", "Name: \"SubDomainA\""); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); TestModifyACL(*Context, ++txId, "/Root", "SubDomainA", TString(), "user0@builtin"); auto entry = TestNavigate("/Root/SubDomainA/.sys/partition_stats", @@ -348,7 +348,7 @@ void TCacheTest::TableSchemaVersion() { } )", {NKikimrScheme::StatusAccepted}); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); { auto entry = TestNavigate("/Root/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_VALUES_EQUAL(entry.TableId.SchemaVersion, 1); @@ -359,7 +359,7 @@ void TCacheTest::TableSchemaVersion() { Columns { Name: "added" Type: "Uint64"} )"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); { auto entry = TestNavigate("/Root/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_VALUES_EQUAL(entry.TableId.SchemaVersion, 2); @@ -470,7 +470,7 @@ TPathId TCacheTest::ExpectWatchDeleted(const TActorId& watcher) { } void TCacheTest::CreateAndMigrateWithoutDecision(ui64& txId) { - auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); + auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); TestCreateSubDomain(*Context, ++txId, "/Root", "Name: \"USER_0\""); @@ -498,20 +498,20 @@ void TCacheTest::CreateAndMigrateWithoutDecision(ui64& txId) { { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } @@ -535,7 +535,7 @@ void TCacheTest::MigrationCommon() { { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(entry.DomainInfo->Params.GetSchemeShard(), 1)); } @@ -543,13 +543,13 @@ void TCacheTest::MigrationCommon() { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } }; @@ -557,7 +557,7 @@ void TCacheTest::MigrationCommon() { checkMigratedPathes(); // global ss do not wipe migrated pathes after restart - RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); + RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); checkMigratedPathes(); } @@ -573,7 +573,7 @@ void TCacheTest::MigrationCommit() { { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(entry.DomainInfo->Params.GetSchemeShard(), 1)); } @@ -581,13 +581,13 @@ void TCacheTest::MigrationCommit() { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } }; @@ -596,12 +596,12 @@ void TCacheTest::MigrationCommit() { TestUpgradeSubDomainDecision(*Context, ++txId, "/Root", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Commit); - auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); + auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); TestWaitNotification(*Context, {txId}, domainSSNotifier); checkMigratedPathes(); - RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); + RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); checkMigratedPathes(); } @@ -617,7 +617,7 @@ void TCacheTest::MigrationLostMessage() { { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(entry.DomainInfo->Params.GetSchemeShard(), 1)); } @@ -625,13 +625,13 @@ void TCacheTest::MigrationLostMessage() { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } }; @@ -640,7 +640,7 @@ void TCacheTest::MigrationLostMessage() { TestUpgradeSubDomainDecision(*Context, ++txId, "/Root", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Commit); - auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); + auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); TestWaitNotification(*Context, {txId}, domainSSNotifier); checkMigratedPathes(); @@ -650,7 +650,7 @@ void TCacheTest::MigrationLostMessage() { { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); tentantSchemeShard = entry.DomainInfo->Params.GetSchemeShard(); @@ -686,7 +686,7 @@ void TCacheTest::MigrationLostMessage() { { // hang in chache auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } @@ -696,7 +696,7 @@ void TCacheTest::MigrationLostMessage() { { // hang in chache auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } @@ -714,7 +714,7 @@ void TCacheTest::MigrationLostMessage() { } { - TestNavigateByTableId(TTableId(TTestTxConfig::SchemeShard, 3), TNavigate::EStatus::Ok, "/Root/USER_0/DirA"); + TestNavigateByTableId(TTableId(TTestTxConfig::SchemeShard, 3), TNavigate::EStatus::Ok, "/Root/USER_0/DirA"); TestNavigateByTableId(TTableId(tentantSchemeShard, 2), TNavigate::EStatus::Ok, "/Root/USER_0/DirA"); } @@ -723,7 +723,7 @@ void TCacheTest::MigrationLostMessage() { { // hang in chache still auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } @@ -765,7 +765,7 @@ void TCacheTest::MigrationUndo() { { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(entry.DomainInfo->Params.GetSchemeShard(), 1)); } @@ -773,13 +773,13 @@ void TCacheTest::MigrationUndo() { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); } }; @@ -788,7 +788,7 @@ void TCacheTest::MigrationUndo() { TestUpgradeSubDomainDecision(*Context, ++txId, "/Root", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Undo); - auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); + auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); TestWaitNotification(*Context, {txId}, domainSSNotifier); auto checkRevertedPathes = [&] () { @@ -796,20 +796,20 @@ void TCacheTest::MigrationUndo() { auto entry = TestNavigate("/Root/USER_0", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 2)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA", TNavigate::EStatus::Ok); Cerr << entry.ToString() << Endl; UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 3)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(!entry.DomainInfo->Params.HasSchemeShard()); } }; @@ -817,7 +817,7 @@ void TCacheTest::MigrationUndo() { checkRevertedPathes(); - RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); + RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, Context->AllocateEdgeActor()); checkRevertedPathes(); } @@ -837,7 +837,7 @@ void TCacheTest::MigrationDeletedPathNavigate() { TestUpgradeSubDomainDecision(*Context, ++txId, "/Root", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Commit); - auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); + auto domainSSNotifier = CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard); TestWaitNotification(*Context, {txId}, domainSSNotifier); ui64 tentantSchemeShard = 0; @@ -845,7 +845,7 @@ void TCacheTest::MigrationDeletedPathNavigate() { { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_EQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); tentantSchemeShard = entry.DomainInfo->Params.GetSchemeShard(); @@ -872,7 +872,7 @@ void TCacheTest::MigrationDeletedPathNavigate() { { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); UNIT_ASSERT(entry.DomainInfo->Params.HasSchemeShard()); newPathId = entry.TableId.PathId; @@ -883,7 +883,7 @@ void TCacheTest::MigrationDeletedPathNavigate() { auto entry = TestNavigate("/Root/USER_0/DirA/Table1", TNavigate::EStatus::Ok); UNIT_ASSERT_EQUAL(JoinPath(entry.Path), "Root/USER_0/DirA/Table1"); - UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); + UNIT_ASSERT_UNEQUAL(entry.TableId.PathId, TPathId(TTestTxConfig::SchemeShard, 4)); } { @@ -892,7 +892,7 @@ void TCacheTest::MigrationDeletedPathNavigate() { } void TCacheTest::WatchRoot() { - auto watcher = TestWatch(TPathId(TTestTxConfig::SchemeShard, 1)); + auto watcher = TestWatch(TPathId(TTestTxConfig::SchemeShard, 1)); { auto result = ExpectWatchUpdated(watcher, "/Root"); @@ -904,7 +904,7 @@ void TCacheTest::WatchRoot() { ui64 txId = 100; TestMkDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); // Ignore notification before create finished ExpectWatchUpdated(watcher); @@ -918,7 +918,7 @@ void TCacheTest::WatchRoot() { dirPathId = result->GetPathDescription().GetChildren(0).GetPathId(); } - TestWatch(TPathId(TTestTxConfig::SchemeShard, dirPathId), watcher); + TestWatch(TPathId(TTestTxConfig::SchemeShard, dirPathId), watcher); { auto result = ExpectWatchUpdated(watcher, "/Root/DirA"); @@ -927,7 +927,7 @@ void TCacheTest::WatchRoot() { } TestRmDir(*Context, ++txId, "/Root", "DirA"); - TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {txId}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); { auto deleted = ExpectWatchDeleted(watcher); diff --git a/ydb/core/tx/scheme_board/populator_ut.cpp b/ydb/core/tx/scheme_board/populator_ut.cpp index c1f718aaa68..c0eb1cb62fa 100644 --- a/ydb/core/tx/scheme_board/populator_ut.cpp +++ b/ydb/core/tx/scheme_board/populator_ut.cpp @@ -32,7 +32,7 @@ public: void Boot() { const TActorId edge = Context->AllocateEdgeActor(); - NKikimr::TPathId rootPathId(TTestTxConfig::SchemeShard, RootPathId); + NKikimr::TPathId rootPathId(TTestTxConfig::SchemeShard, RootPathId); Context->CreateSubscriber(edge, rootPathId); auto ev = Context->GrabEdgeEvent<TSchemeBoardEvents::TEvNotifyUpdate>(edge); @@ -48,7 +48,7 @@ public: TestMkDir(*Context, 100, "/Root", "DirA"); auto describe = DescribePath(*Context, "/Root/DirA"); - NKikimr::TPathId pathId(TTestTxConfig::SchemeShard, describe.GetPathId()); + NKikimr::TPathId pathId(TTestTxConfig::SchemeShard, describe.GetPathId()); Context->CreateSubscriber(edge, pathId); auto ev = Context->GrabEdgeEvent<TSchemeBoardEvents::TEvNotifyUpdate>(edge); @@ -64,7 +64,7 @@ public: TestMkDir(*Context, 100, "/Root", "DirB"); auto describe = DescribePath(*Context, "/Root/DirB"); - NKikimr::TPathId pathId(TTestTxConfig::SchemeShard, describe.GetPathId()); + NKikimr::TPathId pathId(TTestTxConfig::SchemeShard, describe.GetPathId()); Context->CreateSubscriber<TSchemeBoardEvents::TEvNotifyUpdate>(edge, pathId); TestRmDir(*Context, 101, "/Root", "DirB"); @@ -114,7 +114,7 @@ public: void UpdateAck() { DropFirstAcks = true; TestMkDir(*Context, 100, "/Root", "DirC"); - TestWaitNotification(*Context, {100}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); + TestWaitNotification(*Context, {100}, CreateNotificationSubscriber(*Context, TTestTxConfig::SchemeShard)); } private: diff --git a/ydb/core/tx/scheme_board/ut_helpers.h b/ydb/core/tx/scheme_board/ut_helpers.h index b5688aa8d56..1f2e4d5e9b8 100644 --- a/ydb/core/tx/scheme_board/ut_helpers.h +++ b/ydb/core/tx/scheme_board/ut_helpers.h @@ -201,7 +201,7 @@ class TTestWithSchemeshard: public NUnitTest::TTestBase { } TAppPrepare app; - AddDomain(runtime, app, "Root", 0, 0, TTestTxConfig::Hive, TTestTxConfig::SchemeShard); + AddDomain(runtime, app, "Root", 0, 0, TTestTxConfig::Hive, TTestTxConfig::SchemeShard); SetupChannelProfiles(app, 0, 1); SetupTabletServices(runtime, &app, true); } @@ -209,7 +209,7 @@ class TTestWithSchemeshard: public NUnitTest::TTestBase { static void BootSchemeShard(TTestActorRuntime& runtime, ui64 tabletId) { using namespace NSchemeShard; - CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::FLAT_SCHEMESHARD), &CreateFlatTxSchemeShard); const TActorId edge = runtime.AllocateEdgeActor(); @@ -223,7 +223,7 @@ class TTestWithSchemeshard: public NUnitTest::TTestBase { } static void BootTxAllocator(TTestActorRuntime& runtime, ui64 tabletId) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); } void BootCoordinator(TTestActorRuntime& runtime, ui64 tabletId) { @@ -247,10 +247,10 @@ public: Context->SetObserverFunc(ObserverFunc()); SetupRuntime(*Context); - BootSchemeShard(*Context, TTestTxConfig::SchemeShard); - BootTxAllocator(*Context, TTestTxConfig::TxAllocator); - BootCoordinator(*Context, TTestTxConfig::Coordinator); - BootHive(*Context, TTestTxConfig::Hive); + BootSchemeShard(*Context, TTestTxConfig::SchemeShard); + BootTxAllocator(*Context, TTestTxConfig::TxAllocator); + BootCoordinator(*Context, TTestTxConfig::Coordinator); + BootHive(*Context, TTestTxConfig::Hive); } void TurnOnTabletsScheduling() { @@ -260,8 +260,8 @@ public: TActorId sender = Context->AllocateEdgeActor(); TVector<ui64> tabletIds; - tabletIds.push_back((ui64)TTestTxConfig::SchemeShard); - for (auto x: xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)) { + tabletIds.push_back((ui64)TTestTxConfig::SchemeShard); + for (auto x: xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)) { tabletIds.push_back(x); } @@ -269,7 +269,7 @@ public: // make schemeShard visible for ScheduledEventsGuard // trigger actor resolving for existed tablet - RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, sender); + RebootTablet(*Context, (ui64)TTestTxConfig::SchemeShard, sender); } void TearDown() override { diff --git a/ydb/core/tx/schemeshard/operation_queue_timer.h b/ydb/core/tx/schemeshard/operation_queue_timer.h index 3b8a9d20be8..655fde7c18e 100644 --- a/ydb/core/tx/schemeshard/operation_queue_timer.h +++ b/ydb/core/tx/schemeshard/operation_queue_timer.h @@ -1,133 +1,133 @@ -#pragma once - -#include "schemeshard_identificators.h" - +#pragma once + +#include "schemeshard_identificators.h" + #include <ydb/core/actorlib_impl/long_timer.h> #include <ydb/core/base/appdata.h> #include <ydb/core/util/operation_queue.h> - -// TODO: this is a good candidate for core/util, but since -// it uses actorlib_impl, which depends on core/util, it -// can't be part of util. No other better place yet and since -// it is used in schemedard only then I put it here. - -namespace NKikimr { - -// TODO: make part of util? -namespace NOperationQueue { - -template <typename T, typename TQueue, int Ev> -class TOperationQueueWithTimer - : public TActor<TOperationQueueWithTimer<T, TQueue, Ev>> - , public ITimer - , public TOperationQueue<T, TQueue> -{ - using TThis = ::NKikimr::NOperationQueue::TOperationQueueWithTimer<T, TQueue, Ev>; - using TActorBase = TActor<TOperationQueueWithTimer<T, TQueue, Ev>>; - using TBase = TOperationQueue<T, TQueue>; - - struct TEvWakeupQueue : public TEventLocal<TEvWakeupQueue, Ev> { - TEvWakeupQueue() = default; - }; - -private: - TActorId LongTimerId; - TInstant When; - -public: - TOperationQueueWithTimer(const typename TBase::TConfig& config, - typename TBase::IStarter& starter) - : TActorBase(&TThis::StateWork) - , TBase(config, starter, *this) - { } - - void Shutdown(const TActorContext &ctx) { - if (LongTimerId) - ctx.Send(LongTimerId, new TEvents::TEvPoison); - - TActorBase::PassAway(); - } - -private: - // ITimer, note that it is made private, - // since it should be called only from TBase - void SetWakeupTimer(TInstant t) override { - if (When > t) - this->Send(LongTimerId, new TEvents::TEvPoison); - - When = t; - LongTimerId = CreateLongTimer(t - Now(), - new IEventHandle(TActorBase::SelfId(), TActorBase::SelfId(), new TEvWakeupQueue)); - } - - TInstant Now() override { - return AppData()->TimeProvider->Now(); - } - - void HandleWakeup() { - TBase::Wakeup(); - } - - STFUNC(StateWork) { - Y_UNUSED(ctx); - switch (ev->GetTypeRewrite()) { - cFunc(TEvWakeupQueue::EventType, HandleWakeup); - } - } -}; - -} // NOperationQueue - -namespace NSchemeShard { - -struct TShardCompactionInfo { - TShardIdx ShardIdx; - ui64 SearchHeight = 0; - - explicit TShardCompactionInfo(const TShardIdx& id) - : ShardIdx(id) - {} - - TShardCompactionInfo(const TShardIdx& id, ui64 searchHeight) - : ShardIdx(id) - , SearchHeight(searchHeight) - {} - + +// TODO: this is a good candidate for core/util, but since +// it uses actorlib_impl, which depends on core/util, it +// can't be part of util. No other better place yet and since +// it is used in schemedard only then I put it here. + +namespace NKikimr { + +// TODO: make part of util? +namespace NOperationQueue { + +template <typename T, typename TQueue, int Ev> +class TOperationQueueWithTimer + : public TActor<TOperationQueueWithTimer<T, TQueue, Ev>> + , public ITimer + , public TOperationQueue<T, TQueue> +{ + using TThis = ::NKikimr::NOperationQueue::TOperationQueueWithTimer<T, TQueue, Ev>; + using TActorBase = TActor<TOperationQueueWithTimer<T, TQueue, Ev>>; + using TBase = TOperationQueue<T, TQueue>; + + struct TEvWakeupQueue : public TEventLocal<TEvWakeupQueue, Ev> { + TEvWakeupQueue() = default; + }; + +private: + TActorId LongTimerId; + TInstant When; + +public: + TOperationQueueWithTimer(const typename TBase::TConfig& config, + typename TBase::IStarter& starter) + : TActorBase(&TThis::StateWork) + , TBase(config, starter, *this) + { } + + void Shutdown(const TActorContext &ctx) { + if (LongTimerId) + ctx.Send(LongTimerId, new TEvents::TEvPoison); + + TActorBase::PassAway(); + } + +private: + // ITimer, note that it is made private, + // since it should be called only from TBase + void SetWakeupTimer(TInstant t) override { + if (When > t) + this->Send(LongTimerId, new TEvents::TEvPoison); + + When = t; + LongTimerId = CreateLongTimer(t - Now(), + new IEventHandle(TActorBase::SelfId(), TActorBase::SelfId(), new TEvWakeupQueue)); + } + + TInstant Now() override { + return AppData()->TimeProvider->Now(); + } + + void HandleWakeup() { + TBase::Wakeup(); + } + + STFUNC(StateWork) { + Y_UNUSED(ctx); + switch (ev->GetTypeRewrite()) { + cFunc(TEvWakeupQueue::EventType, HandleWakeup); + } + } +}; + +} // NOperationQueue + +namespace NSchemeShard { + +struct TShardCompactionInfo { + TShardIdx ShardIdx; + ui64 SearchHeight = 0; + + explicit TShardCompactionInfo(const TShardIdx& id) + : ShardIdx(id) + {} + + TShardCompactionInfo(const TShardIdx& id, ui64 searchHeight) + : ShardIdx(id) + , SearchHeight(searchHeight) + {} + TShardCompactionInfo(const TShardCompactionInfo&) = default; - bool operator ==(const TShardCompactionInfo& rhs) const { - // note that only identity intentionally checked - return ShardIdx == rhs.ShardIdx; - } - - TShardCompactionInfo& operator =(const TShardCompactionInfo& rhs) { - // TODO: assert that ID's are the same, because we - // use it as update rather than real assignment - SearchHeight = rhs.SearchHeight; - return *this; + bool operator ==(const TShardCompactionInfo& rhs) const { + // note that only identity intentionally checked + return ShardIdx == rhs.ShardIdx; + } + + TShardCompactionInfo& operator =(const TShardCompactionInfo& rhs) { + // TODO: assert that ID's are the same, because we + // use it as update rather than real assignment + SearchHeight = rhs.SearchHeight; + return *this; + } + + size_t Hash() const { + return ShardIdx.Hash(); + } + + explicit operator size_t() const { + return Hash(); } - - size_t Hash() const { - return ShardIdx.Hash(); - } - - explicit operator size_t() const { - return Hash(); - } - - struct TLessBySearchHeight { - bool operator()(const TShardCompactionInfo& lhs, const TShardCompactionInfo& rhs) const { - // note ">" is intentional to have on top items with bigger search height - return lhs.SearchHeight > rhs.SearchHeight; - } - }; - - TString ToString() const { - TStringStream ss; - ss << "{" << ShardIdx << "," << SearchHeight << "}"; - return ss.Str(); - } -}; - -} // NSchemeShard -} // NKikimr + + struct TLessBySearchHeight { + bool operator()(const TShardCompactionInfo& lhs, const TShardCompactionInfo& rhs) const { + // note ">" is intentional to have on top items with bigger search height + return lhs.SearchHeight > rhs.SearchHeight; + } + }; + + TString ToString() const { + TStringStream ss; + ss << "{" << ShardIdx << "," << SearchHeight << "}"; + return ss.Str(); + } +}; + +} // NSchemeShard +} // NKikimr diff --git a/ydb/core/tx/schemeshard/schemeshard__compaction.cpp b/ydb/core/tx/schemeshard/schemeshard__compaction.cpp index ee8e00d695a..faad71935cb 100644 --- a/ydb/core/tx/schemeshard/schemeshard__compaction.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__compaction.cpp @@ -1,82 +1,82 @@ -#include "schemeshard_impl.h" - -namespace NKikimr { +#include "schemeshard_impl.h" + +namespace NKikimr { namespace NSchemeShard { - -NOperationQueue::EStartStatus TSchemeShard::StartBackgroundCompaction(const TShardIdx& shardId) { - TabletCounters->Simple()[COUNTER_BACKGROUND_COMPACTION_QUEUE_SIZE].Set(CompactionQueue->Size()); - TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_TIMEOUT].Increment(CompactionQueue->ResetTimeoutCount()); - - auto ctx = TActivationContext::ActorContextFor(SelfId()); - - auto it = ShardInfos.find(shardId); - if (it == ShardInfos.end()) { - LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Unable to resolve shard info " - "for background compaction# " << shardId - << " at schemeshard# " << TabletID()); - - return NOperationQueue::EStartStatus::EOperationRemove; - } - - const auto& datashardId = it->second.TabletID; - const auto& pathId = it->second.PathId; - - LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "RunBackgroundCompaction " - "for pathId# " << pathId << ", datashard# " << datashardId - << ", in queue# " << CompactionQueue->Size() << " shards" - << ", running# " << CompactionQueue->RunningSize() << " shards" - << " at schemeshard " << TabletID()); - - PipeClientCache->Send( - ctx, - ui64(datashardId), - new TEvDataShard::TEvCompactTable(pathId.OwnerId, pathId.LocalPathId)); - - return NOperationQueue::EStartStatus::EOperationRunning; -} - + +NOperationQueue::EStartStatus TSchemeShard::StartBackgroundCompaction(const TShardIdx& shardId) { + TabletCounters->Simple()[COUNTER_BACKGROUND_COMPACTION_QUEUE_SIZE].Set(CompactionQueue->Size()); + TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_TIMEOUT].Increment(CompactionQueue->ResetTimeoutCount()); + + auto ctx = TActivationContext::ActorContextFor(SelfId()); + + auto it = ShardInfos.find(shardId); + if (it == ShardInfos.end()) { + LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Unable to resolve shard info " + "for background compaction# " << shardId + << " at schemeshard# " << TabletID()); + + return NOperationQueue::EStartStatus::EOperationRemove; + } + + const auto& datashardId = it->second.TabletID; + const auto& pathId = it->second.PathId; + + LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "RunBackgroundCompaction " + "for pathId# " << pathId << ", datashard# " << datashardId + << ", in queue# " << CompactionQueue->Size() << " shards" + << ", running# " << CompactionQueue->RunningSize() << " shards" + << " at schemeshard " << TabletID()); + + PipeClientCache->Send( + ctx, + ui64(datashardId), + new TEvDataShard::TEvCompactTable(pathId.OwnerId, pathId.LocalPathId)); + + return NOperationQueue::EStartStatus::EOperationRunning; +} + void TSchemeShard::Handle(TEvDataShard::TEvCompactTableResult::TPtr &ev, const TActorContext &ctx) { - const auto& record = ev->Get()->Record; - - const TTabletId tabletId(record.GetTabletId()); - const TShardIdx shardIdx = GetShardIdx(tabletId); - - auto pathId = TPathId( - record.GetPathId().GetOwnerId(), - record.GetPathId().GetLocalId()); - - // it's OK to OnDone InvalidShardIdx - // note, that we set 0 search height to move shard to the end of queue - auto duration = CompactionQueue->OnDone(TShardCompactionInfo(shardIdx, 0)); - - if (shardIdx == InvalidShardIdx) { - LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Finished background compaction of unknown shard " - "for pathId# " << pathId << ", datashard# " << tabletId - << ", in queue# " << CompactionQueue->Size() << " shards" - << ", running# " << CompactionQueue->RunningSize() << " shards" - << " at schemeshard " << TabletID()); - } else { - LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Finished background compaction " - "for pathId# " << pathId << ", datashard# " << tabletId - << ", in queue# " << CompactionQueue->Size() << " shards" - << ", running# " << CompactionQueue->RunningSize() << " shards" - << " at schemeshard " << TabletID()); - } - - auto& histCounters = TabletCounters->Percentile(); - - switch (record.GetStatus()) { - case NKikimrTxDataShard::TEvCompactTableResult::OK: - case NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED: - TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_OK].Increment(1); - if (duration) - histCounters[COUNTER_BACKGROUND_COMPACTION_OK_LATENCY].IncrementFor(duration.MilliSeconds()); - break; - case NKikimrTxDataShard::TEvCompactTableResult::FAILED: - TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_FAILED].Increment(1); - break; - } -} - + const auto& record = ev->Get()->Record; + + const TTabletId tabletId(record.GetTabletId()); + const TShardIdx shardIdx = GetShardIdx(tabletId); + + auto pathId = TPathId( + record.GetPathId().GetOwnerId(), + record.GetPathId().GetLocalId()); + + // it's OK to OnDone InvalidShardIdx + // note, that we set 0 search height to move shard to the end of queue + auto duration = CompactionQueue->OnDone(TShardCompactionInfo(shardIdx, 0)); + + if (shardIdx == InvalidShardIdx) { + LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Finished background compaction of unknown shard " + "for pathId# " << pathId << ", datashard# " << tabletId + << ", in queue# " << CompactionQueue->Size() << " shards" + << ", running# " << CompactionQueue->RunningSize() << " shards" + << " at schemeshard " << TabletID()); + } else { + LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Finished background compaction " + "for pathId# " << pathId << ", datashard# " << tabletId + << ", in queue# " << CompactionQueue->Size() << " shards" + << ", running# " << CompactionQueue->RunningSize() << " shards" + << " at schemeshard " << TabletID()); + } + + auto& histCounters = TabletCounters->Percentile(); + + switch (record.GetStatus()) { + case NKikimrTxDataShard::TEvCompactTableResult::OK: + case NKikimrTxDataShard::TEvCompactTableResult::NOT_NEEDED: + TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_OK].Increment(1); + if (duration) + histCounters[COUNTER_BACKGROUND_COMPACTION_OK_LATENCY].IncrementFor(duration.MilliSeconds()); + break; + case NKikimrTxDataShard::TEvCompactTableResult::FAILED: + TabletCounters->Cumulative()[COUNTER_BACKGROUND_COMPACTION_FAILED].Increment(1); + break; + } +} + } // NSchemeShard -} // NKikimr +} // NKikimr diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp index fa7f7c7eb99..650506549e0 100644 --- a/ydb/core/tx/schemeshard/schemeshard__init.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp @@ -1762,8 +1762,8 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> { TPartitionConfigMerger::DeduplicateColumnFamiliesById(config); } - if (config.HasCrossDataCenterFollowerCount()) { - config.ClearFollowerCount(); + if (config.HasCrossDataCenterFollowerCount()) { + config.ClearFollowerCount(); } } diff --git a/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp b/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp index 7f65fb5d4eb..76e73182496 100644 --- a/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__monitoring.cpp @@ -154,7 +154,7 @@ public: } bool inserted = InFlight.emplace(coordinator, &item).second; if (inserted) { - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvSubDomain::TEvConfigure(item.Params), coordinator, true), IEventHandle::FlagTrackDelivery); @@ -201,8 +201,8 @@ public: } void Finish(const TActorContext& ctx) { - if (Services.LeaderPipeCache) { - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + if (Services.LeaderPipeCache) { + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); } Callback(Log, ctx); Die(ctx); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_common.h b/ydb/core/tx/schemeshard/schemeshard__operation_common.h index 2e2bbb18fab..5a3da32cade 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_common.h +++ b/ydb/core/tx/schemeshard/schemeshard__operation_common.h @@ -698,17 +698,17 @@ public: allowedDomain->SetPathId(resourcesDomainId.LocalPathId); if (tablePartitionConfig) { - if (tablePartitionConfig->FollowerGroupsSize()) { - ev->Record.MutableFollowerGroups()->CopyFrom(tablePartitionConfig->GetFollowerGroups()); + if (tablePartitionConfig->FollowerGroupsSize()) { + ev->Record.MutableFollowerGroups()->CopyFrom(tablePartitionConfig->GetFollowerGroups()); } else { - if (tablePartitionConfig->HasAllowFollowerPromotion()) { - ev->Record.SetAllowFollowerPromotion(tablePartitionConfig->GetAllowFollowerPromotion()); + if (tablePartitionConfig->HasAllowFollowerPromotion()) { + ev->Record.SetAllowFollowerPromotion(tablePartitionConfig->GetAllowFollowerPromotion()); } - if (tablePartitionConfig->HasCrossDataCenterFollowerCount()) { - ev->Record.SetCrossDataCenterFollowerCount(tablePartitionConfig->GetCrossDataCenterFollowerCount()); - } else if (tablePartitionConfig->HasFollowerCount()) { - ev->Record.SetFollowerCount(tablePartitionConfig->GetFollowerCount()); + if (tablePartitionConfig->HasCrossDataCenterFollowerCount()) { + ev->Record.SetCrossDataCenterFollowerCount(tablePartitionConfig->GetCrossDataCenterFollowerCount()); + } else if (tablePartitionConfig->HasFollowerCount()) { + ev->Record.SetFollowerCount(tablePartitionConfig->GetFollowerCount()); } } } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_consistent_copy_tables.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_consistent_copy_tables.cpp index b9ec6c864a1..4cc467dedc2 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_consistent_copy_tables.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_consistent_copy_tables.cpp @@ -17,7 +17,7 @@ NKikimrSchemeOp::TModifyScheme CopyTableTask(NKikimr::NSchemeShard::TPath& src, auto operation = scheme.MutableCreateTable(); operation->SetName(dst.LeafName()); operation->SetCopyFromTable(src.PathString()); - operation->SetOmitFollowers(omitFollowers); + operation->SetOmitFollowers(omitFollowers); operation->SetIsBackup(isBackup); return scheme; @@ -118,7 +118,7 @@ TVector<ISubOperationBase::TPtr> CreateConsistentCopyTables(TOperationId nextId, result.push_back(CreateCopyTable(TOperationId(nextId.GetTxId(), nextId.GetSubTxId() + result.size()), - CopyTableTask(srcPath, dstPath, descr.GetOmitFollowers(), descr.GetIsBackup()))); + CopyTableTask(srcPath, dstPath, descr.GetOmitFollowers(), descr.GetIsBackup()))); if (descr.GetOmitIndexes()) { continue; @@ -151,7 +151,7 @@ TVector<ISubOperationBase::TPtr> CreateConsistentCopyTables(TOperationId nextId, TPath dstImplTable = dstIndexPath.Child(srcImplTableName); result.push_back(CreateCopyTable(NextPartId(nextId, result), - CopyTableTask(srcImplTable, dstImplTable, descr.GetOmitFollowers(), descr.GetIsBackup()))); + CopyTableTask(srcImplTable, dstImplTable, descr.GetOmitFollowers(), descr.GetIsBackup()))); } } diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp index 1a8ed64f7d3..f504c34ef58 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp @@ -466,11 +466,11 @@ public: } auto schema = Transaction.GetCreateTable(); - const bool omitFollowers = schema.GetOmitFollowers(); + const bool omitFollowers = schema.GetOmitFollowers(); const bool isBackup = schema.GetIsBackup(); PrepareScheme(&schema, name, srcTableInfo, context); - if (omitFollowers) { - schema.MutablePartitionConfig()->AddFollowerGroups()->Clear(); + if (omitFollowers) { + schema.MutablePartitionConfig()->AddFollowerGroups()->Clear(); } schema.SetIsBackup(isBackup); @@ -699,7 +699,7 @@ TVector<ISubOperationBase::TPtr> CreateCopyTable(TOperationId nextId, const TTxT auto operation = schema.MutableCreateTable(); operation->SetName(copying.GetName()); operation->SetCopyFromTable(copying.GetCopyFromTable()); - operation->SetOmitFollowers(copying.GetOmitFollowers()); + operation->SetOmitFollowers(copying.GetOmitFollowers()); operation->SetIsBackup(copying.GetIsBackup()); operation->MutablePartitionConfig()->CopyFrom(copying.GetPartitionConfig()); @@ -749,7 +749,7 @@ TVector<ISubOperationBase::TPtr> CreateCopyTable(TOperationId nextId, const TTxT auto operation = schema.MutableCreateTable(); operation->SetName(implTableName); operation->SetCopyFromTable(implTable.PathString()); - operation->SetOmitFollowers(copying.GetOmitFollowers()); + operation->SetOmitFollowers(copying.GetOmitFollowers()); operation->SetIsBackup(copying.GetIsBackup()); result.push_back(CreateCopyTable(NextPartId(nextId, result), schema)); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp index 8af747938a8..648fcd3c4d5 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_rtmr.cpp @@ -394,8 +394,8 @@ public: context.SS->ClearDescribePathCaches(newRtmrVolume); context.OnComplete.PublishToSchemeBoard(OperationId, newRtmrVolume->PathId); - Y_VERIFY(shardsToCreate == txState.Shards.size(), "shardsToCreate=%ld != txStateShards=%ld", - shardsToCreate, txState.Shards.size()); + Y_VERIFY(shardsToCreate == txState.Shards.size(), "shardsToCreate=%ld != txStateShards=%ld", + shardsToCreate, txState.Shards.size()); dstPath.DomainInfo()->IncPathsInside(); dstPath.DomainInfo()->AddInternalShards(txState); diff --git a/ydb/core/tx/schemeshard/schemeshard__table_stats.cpp b/ydb/core/tx/schemeshard/schemeshard__table_stats.cpp index 1dd25c9d8b7..b2e7db88b79 100644 --- a/ydb/core/tx/schemeshard/schemeshard__table_stats.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__table_stats.cpp @@ -174,7 +174,7 @@ bool TTxStorePartitionStats::Execute(TTransactionContext& txc, const TActorConte newStats.ReadIops = GetIops(tabletMetrics.GetGroupReadIops()); newStats.WriteIops = GetIops(tabletMetrics.GetGroupWriteIops()); newStats.PartCount = tableStats.GetPartCount(); - newStats.SearchHeight = tableStats.GetSearchHeight(); + newStats.SearchHeight = tableStats.GetSearchHeight(); newStats.StartTime = TInstant::MilliSeconds(rec.GetStartTime()); for (ui64 tabletId : rec.GetUserTablePartOwners()) { newStats.PartOwners.insert(TTabletId(tabletId)); @@ -190,16 +190,16 @@ bool TTxStorePartitionStats::Execute(TTransactionContext& txc, const TActorConte auto oldAggrStats = table->GetStats().Aggregated; table->UpdateShardStats(shardIdx, newStats); - if (Self->CompactionQueue) { - TShardCompactionInfo compactionInfo(shardIdx, newStats.SearchHeight); - if (newStats.SearchHeight >= Self->CompactionSearchHeightThreshold) { - if (!Self->CompactionQueue->Update(compactionInfo)) - Self->CompactionQueue->Enqueue(std::move(compactionInfo)); - } else { - Self->CompactionQueue->Remove(std::move(compactionInfo)); - } - } - + if (Self->CompactionQueue) { + TShardCompactionInfo compactionInfo(shardIdx, newStats.SearchHeight); + if (newStats.SearchHeight >= Self->CompactionSearchHeightThreshold) { + if (!Self->CompactionQueue->Update(compactionInfo)) + Self->CompactionQueue->Enqueue(std::move(compactionInfo)); + } else { + Self->CompactionQueue->Remove(std::move(compactionInfo)); + } + } + NIceDb::TNiceDb db(txc.DB); if (!table->IsBackup && !table->IsShardsStatsDetached()) { diff --git a/ydb/core/tx/schemeshard/schemeshard_export_flow_proposals.cpp b/ydb/core/tx/schemeshard/schemeshard_export_flow_proposals.cpp index f8b02239970..17223ef5a59 100644 --- a/ydb/core/tx/schemeshard/schemeshard_export_flow_proposals.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_export_flow_proposals.cpp @@ -61,7 +61,7 @@ THolder<TEvSchemeShard::TEvModifySchemeTransaction> CopyTablesPropose( desc.SetSrcPath(item.SourcePathName); desc.SetDstPath(ExportItemPathName(exportPathName, itemIdx)); desc.SetOmitIndexes(true); - desc.SetOmitFollowers(true); + desc.SetOmitFollowers(true); desc.SetIsBackup(true); } diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.cpp b/ydb/core/tx/schemeshard/schemeshard_impl.cpp index a2e40502255..0715543a229 100644 --- a/ydb/core/tx/schemeshard/schemeshard_impl.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_impl.cpp @@ -90,8 +90,8 @@ void TSchemeShard::ActivateAfterInitialization(const TActorContext& ctx, ScheduleCleanDroppedPaths(); ScheduleCleanDroppedSubDomains(); - StartStopCompactionQueue(); - + StartStopCompactionQueue(); + ctx.Send(TxAllocatorClient, MakeHolder<TEvTxAllocatorClient::TEvAllocate>(InitiateCachedTxIdsCount)); Become(&TThis::StateWork); @@ -285,8 +285,8 @@ TMessageSeqNo TSchemeShard::NextRound() { void TSchemeShard::Clear() { PathsById.clear(); Tables.clear(); - if (CompactionQueue) - CompactionQueue->Clear(); + if (CompactionQueue) + CompactionQueue->Clear(); PersQueueGroups.clear(); RtmrVolumes.clear(); SubDomains.clear(); @@ -2062,15 +2062,15 @@ void TSchemeShard::PersistTablePartitioning(NIceDb::TNiceDb& db, const TPathId p } void TSchemeShard::DeleteTablePartitioning(NIceDb::TNiceDb& db, const TPathId pathId, const TTableInfo::TPtr tableInfo) { - const auto& partitions = tableInfo->GetPartitions(); - for (ui64 pi = 0; pi < partitions.size(); ++pi) { + const auto& partitions = tableInfo->GetPartitions(); + for (ui64 pi = 0; pi < partitions.size(); ++pi) { if (IsLocalId(pathId)) { db.Table<Schema::TablePartitions>().Key(pathId.LocalPathId, pi).Delete(); } db.Table<Schema::MigratedTablePartitions>().Key(pathId.OwnerId, pathId.LocalPathId, pi).Delete(); db.Table<Schema::TablePartitionStats>().Key(pathId.OwnerId, pathId.LocalPathId, pi).Delete(); - - CompactionQueue->Remove(TShardCompactionInfo(partitions[pi].ShardIdx)); + + CompactionQueue->Remove(TShardCompactionInfo(partitions[pi].ShardIdx)); } } @@ -3242,10 +3242,10 @@ void TSchemeShard::PersistRemoveTable(NIceDb::TNiceDb& db, TPathId pathId, const } } - for (const auto& p: tableInfo->GetPartitions()) { - CompactionQueue->Remove(TShardCompactionInfo(p.ShardIdx)); - } - + for (const auto& p: tableInfo->GetPartitions()) { + CompactionQueue->Remove(TShardCompactionInfo(p.ShardIdx)); + } + Tables.erase(pathId); DecrementPathDbRefCount(pathId, "remove table"); @@ -3638,7 +3638,7 @@ TSchemeShard::TSchemeShard(const TActorId &tablet, TTabletStorageInfo *info) GetPipeClientConfig(), new TPipeClientFactory(this))) , PipeTracker(*PipeClientCache) - , CompactionStarter(this) + , CompactionStarter(this) , ShardDeleter(info->TabletID) , AllowDataColumnForIndexTable(0, 0, 1) , EnableAsyncIndexes(0, 0, 1) @@ -3706,9 +3706,9 @@ void TSchemeShard::Die(const TActorContext &ctx) { PipeClientCache->Detach(ctx); - if (CompactionQueue) - CompactionQueue->Shutdown(ctx); - + if (CompactionQueue) + CompactionQueue->Shutdown(ctx); + return IActor::Die(ctx); } @@ -3744,11 +3744,11 @@ void TSchemeShard::OnActivateExecutor(const TActorContext &ctx) { EnableBackgroundCompaction = appData->FeatureFlags.GetEnableBackgroundCompaction(); EnableBackgroundCompactionServerless = appData->FeatureFlags.GetEnableBackgroundCompactionServerless(); - if (!CompactionQueue) - ConfigureCompactionQueue(appData->CompactionConfig.GetBackgroundCompactionConfig(), ctx); - - ctx.RegisterWithSameMailbox(CompactionQueue); - + if (!CompactionQueue) + ConfigureCompactionQueue(appData->CompactionConfig.GetBackgroundCompactionConfig(), ctx); + + ctx.RegisterWithSameMailbox(CompactionQueue); + if (appData->ChannelProfiles) { ChannelProfiles = appData->ChannelProfiles; } @@ -3926,7 +3926,7 @@ void TSchemeShard::StateWork(STFUNC_SIG) { HFuncTraced(TEvSchemeShard::TEvPublishTenantResult, Handle); HFuncTraced(TEvSchemeShard::TEvMigrateSchemeShardResult, Handle); HFuncTraced(TEvDataShard::TEvMigrateSchemeShardResponse, Handle); - HFuncTraced(TEvDataShard::TEvCompactTableResult, Handle); + HFuncTraced(TEvDataShard::TEvCompactTableResult, Handle); HFuncTraced(TEvSchemeShard::TEvSyncTenantSchemeShard, Handle); HFuncTraced(TEvSchemeShard::TEvUpdateTenantSchemeShard, Handle); @@ -4541,7 +4541,7 @@ void TSchemeShard::Handle(TEvTabletPipe::TEvClientConnected::TPtr &ev, const TAc << ", status: " << NKikimrProto::EReplyStatus_Name(ev->Get()->Status) << ", at schemeshard: " << TabletID()); - Y_VERIFY(ev->Get()->Leader); + Y_VERIFY(ev->Get()->Leader); if (PipeClientCache->OnConnect(ev)) { return; //all Ok @@ -5779,20 +5779,20 @@ void TSchemeShard::SetPartitioning(TPathId pathId, TTableInfo::TPtr tableInfo, T Send(SysPartitionStatsCollector, ev.Release()); } - if (!tableInfo->IsBackup) { - for (const auto& p: newPartitioning) { - ui64 searchHeight = 0; - const auto& partitionStats = tableInfo->GetStats().PartitionStats; - auto it = partitionStats.find(p.ShardIdx); - if (it != partitionStats.end()) - searchHeight = it->second.SearchHeight; - - if (searchHeight >= CompactionSearchHeightThreshold) { - CompactionQueue->Enqueue(TShardCompactionInfo(p.ShardIdx, searchHeight)); - } - } - } - + if (!tableInfo->IsBackup) { + for (const auto& p: newPartitioning) { + ui64 searchHeight = 0; + const auto& partitionStats = tableInfo->GetStats().PartitionStats; + auto it = partitionStats.find(p.ShardIdx); + if (it != partitionStats.end()) + searchHeight = it->second.SearchHeight; + + if (searchHeight >= CompactionSearchHeightThreshold) { + CompactionQueue->Enqueue(TShardCompactionInfo(p.ShardIdx, searchHeight)); + } + } + } + tableInfo->SetPartitioning(std::move(newPartitioning)); } @@ -5926,29 +5926,29 @@ bool TSchemeShard::TDedicatedPipePool::Has(TActorId actorId) const { } void TSchemeShard::SubscribeConsoleConfigs(const TActorContext &ctx) { - ctx.Send( - NConsole::MakeConfigsDispatcherID(ctx.SelfID.NodeId()), - new NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionRequest({ - (ui32)NKikimrConsole::TConfigItem::FeatureFlagsItem, - (ui32)NKikimrConsole::TConfigItem::CompactionConfigItem, - })); + ctx.Send( + NConsole::MakeConfigsDispatcherID(ctx.SelfID.NodeId()), + new NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionRequest({ + (ui32)NKikimrConsole::TConfigItem::FeatureFlagsItem, + (ui32)NKikimrConsole::TConfigItem::CompactionConfigItem, + })); } void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TAppConfig& appConfig, const TActorContext& ctx) { if (appConfig.HasFeatureFlags()) { ApplyConsoleConfigs(appConfig.GetFeatureFlags(), ctx); } - - if (appConfig.HasCompactionConfig()) { - const auto& compactionConfig = appConfig.GetCompactionConfig(); - if (compactionConfig.HasBackgroundCompactionConfig()) { - ConfigureCompactionQueue(compactionConfig.GetBackgroundCompactionConfig(), ctx); - } - } - - if (IsShemeShardConfigured()) { - StartStopCompactionQueue(); - } + + if (appConfig.HasCompactionConfig()) { + const auto& compactionConfig = appConfig.GetCompactionConfig(); + if (compactionConfig.HasBackgroundCompactionConfig()) { + ConfigureCompactionQueue(compactionConfig.GetBackgroundCompactionConfig(), ctx); + } + } + + if (IsShemeShardConfigured()) { + StartStopCompactionQueue(); + } } void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TFeatureFlags& featureFlags, const TActorContext& ctx) { @@ -5969,60 +5969,60 @@ void TSchemeShard::ApplyConsoleConfigs(const NKikimrConfig::TFeatureFlags& featu << ", new: " << (bool)featureFlags.GetEnableSchemeTransactionsAtSchemeShard()); EnableSchemeTransactionsAtSchemeShard = (i64)featureFlags.GetEnableSchemeTransactionsAtSchemeShard(); } - - EnableBackgroundCompaction = featureFlags.GetEnableBackgroundCompaction(); - EnableBackgroundCompactionServerless = featureFlags.GetEnableBackgroundCompactionServerless(); + + EnableBackgroundCompaction = featureFlags.GetEnableBackgroundCompaction(); + EnableBackgroundCompactionServerless = featureFlags.GetEnableBackgroundCompactionServerless(); } void TSchemeShard::ConfigureCompactionQueue( - const NKikimrConfig::TCompactionConfig::TBackgroundCompactionConfig& config, - const TActorContext &ctx) -{ - CompactionSearchHeightThreshold = config.GetSearchHeightThreshold(); - - TCompactionQueue::TConfig compactionConfig; - - // schemeshard specific - compactionConfig.IsCircular = true; - - compactionConfig.Timeout = TDuration::Seconds(config.GetTimeoutSeconds()); - compactionConfig.WakeupInterval = TDuration::Seconds(config.GetWakeupIntervalSeconds()); - compactionConfig.InflightLimit = config.GetInflightLimit(); - compactionConfig.Rate = config.GetRate(); - compactionConfig.MinOperationRepeatDelay = TDuration::Seconds(config.GetMinCompactionRepeatDelay()); - - LOG_NOTICE_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "CompactionQueue configured: Timeout# " << compactionConfig.Timeout - << ", WakeupInterval# " << compactionConfig.WakeupInterval - << ", InflightLimit# " << compactionConfig.InflightLimit - << ", Rate# " << compactionConfig.Rate); - - if (CompactionQueue) { - CompactionQueue->UpdateConfig(compactionConfig); - } else { - CompactionQueue = new TCompactionQueue( - compactionConfig, - CompactionStarter); - } -} - + const NKikimrConfig::TCompactionConfig::TBackgroundCompactionConfig& config, + const TActorContext &ctx) +{ + CompactionSearchHeightThreshold = config.GetSearchHeightThreshold(); + + TCompactionQueue::TConfig compactionConfig; + + // schemeshard specific + compactionConfig.IsCircular = true; + + compactionConfig.Timeout = TDuration::Seconds(config.GetTimeoutSeconds()); + compactionConfig.WakeupInterval = TDuration::Seconds(config.GetWakeupIntervalSeconds()); + compactionConfig.InflightLimit = config.GetInflightLimit(); + compactionConfig.Rate = config.GetRate(); + compactionConfig.MinOperationRepeatDelay = TDuration::Seconds(config.GetMinCompactionRepeatDelay()); + + LOG_NOTICE_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, + "CompactionQueue configured: Timeout# " << compactionConfig.Timeout + << ", WakeupInterval# " << compactionConfig.WakeupInterval + << ", InflightLimit# " << compactionConfig.InflightLimit + << ", Rate# " << compactionConfig.Rate); + + if (CompactionQueue) { + CompactionQueue->UpdateConfig(compactionConfig); + } else { + CompactionQueue = new TCompactionQueue( + compactionConfig, + CompactionStarter); + } +} + void TSchemeShard::StartStopCompactionQueue() { - // note, that we don't need to check current state of compaction queue - if (IsServerlessDomain(TPath::Init(RootPathId(), this))) { - if (EnableBackgroundCompactionServerless) { - CompactionQueue->Start(); - } else { - CompactionQueue->Stop(); - } - } else { - if (EnableBackgroundCompaction) { - CompactionQueue->Start(); - } else { - CompactionQueue->Stop(); - } - } -} - + // note, that we don't need to check current state of compaction queue + if (IsServerlessDomain(TPath::Init(RootPathId(), this))) { + if (EnableBackgroundCompactionServerless) { + CompactionQueue->Start(); + } else { + CompactionQueue->Stop(); + } + } else { + if (EnableBackgroundCompaction) { + CompactionQueue->Start(); + } else { + CompactionQueue->Stop(); + } + } +} + void TSchemeShard::Handle(NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionResponse::TPtr &, const TActorContext &ctx) { LOG_NOTICE_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Subscribtion to Console has been set up" diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.h b/ydb/core/tx/schemeshard/schemeshard_impl.h index 645a67541ba..e1a1d08b9a6 100644 --- a/ydb/core/tx/schemeshard/schemeshard_impl.h +++ b/ydb/core/tx/schemeshard/schemeshard_impl.h @@ -16,8 +16,8 @@ #include "schemeshard__operation.h" -#include "operation_queue_timer.h" - +#include "operation_queue_timer.h" + #include <ydb/core/base/hive.h> #include <ydb/core/base/storage_pools.h> #include <ydb/core/base/subdomain.h> @@ -75,29 +75,29 @@ private: TSchemeShard* Self; }; - using TCompactionBackendQueue = NOperationQueue::TQueueWithPriority< - TShardCompactionInfo, - TShardCompactionInfo::TLessBySearchHeight>; - - using TCompactionQueue = NOperationQueue::TOperationQueueWithTimer< - TShardCompactionInfo, - TCompactionBackendQueue, - TEvPrivate::EvRunBackgroundCompaction>; - - class TCompactionStarter : public TCompactionQueue::IStarter { - public: + using TCompactionBackendQueue = NOperationQueue::TQueueWithPriority< + TShardCompactionInfo, + TShardCompactionInfo::TLessBySearchHeight>; + + using TCompactionQueue = NOperationQueue::TOperationQueueWithTimer< + TShardCompactionInfo, + TCompactionBackendQueue, + TEvPrivate::EvRunBackgroundCompaction>; + + class TCompactionStarter : public TCompactionQueue::IStarter { + public: TCompactionStarter(TSchemeShard* self) - : Self(self) - { } - - NOperationQueue::EStartStatus StartOperation(const TShardCompactionInfo& info) { - return Self->StartBackgroundCompaction(info.ShardIdx); - } - - private: + : Self(self) + { } + + NOperationQueue::EStartStatus StartOperation(const TShardCompactionInfo& info) { + return Self->StartBackgroundCompaction(info.ShardIdx); + } + + private: TSchemeShard* Self; - }; - + }; + public: static constexpr ui32 DefaultPQTabletPartitionsCount = 1; static constexpr ui32 MaxPQTabletPartitionsCount = 1000; @@ -196,11 +196,11 @@ public: TPipeTracker PipeTracker; TCompactionStarter CompactionStarter; - TCompactionQueue* CompactionQueue = nullptr; - bool EnableBackgroundCompaction = false; - bool EnableBackgroundCompactionServerless = false; - ui32 CompactionSearchHeightThreshold = 0; - + TCompactionQueue* CompactionQueue = nullptr; + bool EnableBackgroundCompaction = false; + bool EnableBackgroundCompactionServerless = false; + ui32 CompactionSearchHeightThreshold = 0; + TShardDeleter ShardDeleter; // Counter-strike stuff @@ -287,11 +287,11 @@ public: void ApplyConsoleConfigs(const NKikimrConfig::TAppConfig& appConfig, const TActorContext& ctx); void ApplyConsoleConfigs(const NKikimrConfig::TFeatureFlags& featureFlags, const TActorContext& ctx); - void ConfigureCompactionQueue( - const NKikimrConfig::TCompactionConfig::TBackgroundCompactionConfig& config, - const TActorContext &ctx); - void StartStopCompactionQueue(); - + void ConfigureCompactionQueue( + const NKikimrConfig::TCompactionConfig::TBackgroundCompactionConfig& config, + const TActorContext &ctx); + void StartStopCompactionQueue(); + bool ApplyStorageConfig(const TStoragePools& storagePools, const NKikimrSchemeOp::TStorageConfig& storageConfig, TChannelsBindings& channelsBinding, @@ -628,8 +628,8 @@ public: void ScheduleCleanDroppedPaths(); void Handle(TEvPrivate::TEvCleanDroppedPaths::TPtr& ev, const TActorContext& ctx); - NOperationQueue::EStartStatus StartBackgroundCompaction(const TShardIdx& shardId); - + NOperationQueue::EStartStatus StartBackgroundCompaction(const TShardIdx& shardId); + struct TTxCleanDroppedSubDomains; NTabletFlatExecutor::ITransaction* CreateTxCleanDroppedSubDomains(); @@ -793,7 +793,7 @@ public: void Handle(TEvSchemeShard::TEvMigrateSchemeShard::TPtr& ev, const TActorContext& ctx); void Handle(TEvSchemeShard::TEvMigrateSchemeShardResult::TPtr& ev, const TActorContext& ctx); void Handle(TEvDataShard::TEvMigrateSchemeShardResponse::TPtr& ev, const TActorContext& ctx); - void Handle(TEvDataShard::TEvCompactTableResult::TPtr &ev, const TActorContext &ctx); + void Handle(TEvDataShard::TEvCompactTableResult::TPtr &ev, const TActorContext &ctx); void Handle(TEvSchemeShard::TEvSyncTenantSchemeShard::TPtr& ev, const TActorContext& ctx); void Handle(TEvSchemeShard::TEvUpdateTenantSchemeShard::TPtr& ev, const TActorContext& ctx); diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.cpp b/ydb/core/tx/schemeshard/schemeshard_info_types.cpp index 49928766255..fcb564b6065 100644 --- a/ydb/core/tx/schemeshard/schemeshard_info_types.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_info_types.cpp @@ -423,66 +423,66 @@ bool TPartitionConfigMerger::ApplyChanges( } - if (changes.FollowerGroupsSize()) { - // use FollowerGroups - if (result.HasFollowerCount()) { - // migration into FollowerCount -> HasFollowerGroup - // just abandon FollowerCount - result.ClearFollowerCount(); + if (changes.FollowerGroupsSize()) { + // use FollowerGroups + if (result.HasFollowerCount()) { + // migration into FollowerCount -> HasFollowerGroup + // just abandon FollowerCount + result.ClearFollowerCount(); } - if (result.HasCrossDataCenterFollowerCount()) { - // migration into CrossDataCenterFollowerCount -> HasFollowerGroup - // just abandon CrossDataCenterFollowerCount - result.ClearCrossDataCenterFollowerCount(); + if (result.HasCrossDataCenterFollowerCount()) { + // migration into CrossDataCenterFollowerCount -> HasFollowerGroup + // just abandon CrossDataCenterFollowerCount + result.ClearCrossDataCenterFollowerCount(); } - if (changes.HasAllowFollowerPromotion()) { - // migration into AllowFollowerPromotion -> HasFollowerGroup - // just abandon AllowFollowerPromotion - result.ClearAllowFollowerPromotion(); + if (changes.HasAllowFollowerPromotion()) { + // migration into AllowFollowerPromotion -> HasFollowerGroup + // just abandon AllowFollowerPromotion + result.ClearAllowFollowerPromotion(); } - // here is the right place to compare and check src->FollowerGroups and changes->FollowerGroup for wise update - result.MutableFollowerGroups()->CopyFrom(changes.GetFollowerGroups()); + // here is the right place to compare and check src->FollowerGroups and changes->FollowerGroup for wise update + result.MutableFollowerGroups()->CopyFrom(changes.GetFollowerGroups()); } - if (changes.HasCrossDataCenterFollowerCount()) { - if (result.FollowerGroupsSize()) { - errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the HasCrossDataCenterFollowerCount option"; + if (changes.HasCrossDataCenterFollowerCount()) { + if (result.FollowerGroupsSize()) { + errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the HasCrossDataCenterFollowerCount option"; return false; } - if (result.HasFollowerCount()) { - // migration into FollowerCount -> CrossDataCenterFollowerCount - // just abandon FollowerCount - result.ClearFollowerCount(); + if (result.HasFollowerCount()) { + // migration into FollowerCount -> CrossDataCenterFollowerCount + // just abandon FollowerCount + result.ClearFollowerCount(); } - result.SetCrossDataCenterFollowerCount(changes.GetCrossDataCenterFollowerCount()); + result.SetCrossDataCenterFollowerCount(changes.GetCrossDataCenterFollowerCount()); } - if (changes.HasFollowerCount()) { - if (result.HasCrossDataCenterFollowerCount()) { - errDesr = TStringBuilder() << "Forbided downgrade from CrossDataCenterFollowerCount option to the FollowerGroup option"; + if (changes.HasFollowerCount()) { + if (result.HasCrossDataCenterFollowerCount()) { + errDesr = TStringBuilder() << "Forbided downgrade from CrossDataCenterFollowerCount option to the FollowerGroup option"; return false; } - if (result.FollowerGroupsSize()) { - errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the FollowerGroup option"; + if (result.FollowerGroupsSize()) { + errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the FollowerGroup option"; return false; } - result.SetFollowerCount(changes.GetFollowerCount()); + result.SetFollowerCount(changes.GetFollowerCount()); } - if (changes.HasAllowFollowerPromotion()) { - if (result.FollowerGroupsSize()) { - errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the AllowFollowerPromotion option"; + if (changes.HasAllowFollowerPromotion()) { + if (result.FollowerGroupsSize()) { + errDesr = TStringBuilder() << "Forbided downgrade from FollowerGroup option to the AllowFollowerPromotion option"; return false; } - result.SetAllowFollowerPromotion(changes.GetAllowFollowerPromotion()); + result.SetAllowFollowerPromotion(changes.GetAllowFollowerPromotion()); } if (changes.HasExecutorCacheSize()) { @@ -765,73 +765,73 @@ bool TPartitionConfigMerger::VerifyCreateParams( } } - if (config.HasFollowerCount()) { - ui32 count = config.GetFollowerCount(); - if (count > MaxFollowersCount) { + if (config.HasFollowerCount()) { + ui32 count = config.GetFollowerCount(); + if (count > MaxFollowersCount) { errDescr = TStringBuilder() - << "Too much followers: " << count; + << "Too much followers: " << count; return false; } } - if (config.HasCrossDataCenterFollowerCount()) { - ui32 count = config.GetCrossDataCenterFollowerCount(); - if (count > MaxFollowersCount) { + if (config.HasCrossDataCenterFollowerCount()) { + ui32 count = config.GetCrossDataCenterFollowerCount(); + if (count > MaxFollowersCount) { errDescr = TStringBuilder() - << "Too much followers: " << count; + << "Too much followers: " << count; return false; } } - for (const auto& followerGroup: config.GetFollowerGroups()) { - if (followerGroup.HasFollowerCount()) { - if (followerGroup.GetFollowerCount() > MaxFollowersCount) { + for (const auto& followerGroup: config.GetFollowerGroups()) { + if (followerGroup.HasFollowerCount()) { + if (followerGroup.GetFollowerCount() > MaxFollowersCount) { errDescr = TStringBuilder() - << "FollowerGroup: Too much followers: " << followerGroup.GetFollowerCount(); + << "FollowerGroup: Too much followers: " << followerGroup.GetFollowerCount(); return false; } } - if (followerGroup.HasAllowClientRead()) { + if (followerGroup.HasAllowClientRead()) { errDescr = TStringBuilder() - << "FollowerGroup: AllowClientRead is enabled, but hasn't been tested"; + << "FollowerGroup: AllowClientRead is enabled, but hasn't been tested"; return false; } - if (followerGroup.AllowedNodeIDsSize()) { + if (followerGroup.AllowedNodeIDsSize()) { errDescr = TStringBuilder() - << "FollowerGroup: AllowedNodeIDs is enabled, but hasn't been tested"; + << "FollowerGroup: AllowedNodeIDs is enabled, but hasn't been tested"; return false; } if (followerGroup.AllowedDataCenterNumIDsSize() || followerGroup.AllowedDataCentersSize()) { errDescr = TStringBuilder() - << "FollowerGroup: AllowedDataCenterIDs is enabled, hasn't been tested"; + << "FollowerGroup: AllowedDataCenterIDs is enabled, hasn't been tested"; return false; } - if (followerGroup.HasLocalNodeOnly()) { + if (followerGroup.HasLocalNodeOnly()) { errDescr = TStringBuilder() - << "FollowerGroup: LocalNodeOnly is enabled, but hasn't been tested"; + << "FollowerGroup: LocalNodeOnly is enabled, but hasn't been tested"; return false; } - if (followerGroup.HasRequireDifferentNodes()) { + if (followerGroup.HasRequireDifferentNodes()) { errDescr = TStringBuilder() - << "FollowerGroup: LocalNodeOnly is enabled, but hasn't been tested"; + << "FollowerGroup: LocalNodeOnly is enabled, but hasn't been tested"; return false; } } - if (config.HasFollowerCount() + config.HasCrossDataCenterFollowerCount() + (config.FollowerGroupsSize() > 0) > 1) { + if (config.HasFollowerCount() + config.HasCrossDataCenterFollowerCount() + (config.FollowerGroupsSize() > 0) > 1) { errDescr = TStringBuilder() - << "PartitionConfig: FollowerCount, CrossDataCenterFollowerCount and FollowerGroup are mutually exclusive."; + << "PartitionConfig: FollowerCount, CrossDataCenterFollowerCount and FollowerGroup are mutually exclusive."; return false; } - if (config.FollowerGroupsSize() > 1) { + if (config.FollowerGroupsSize() > 1) { errDescr = TStringBuilder() - << "FollowerGroup: only one follower group is allowed for now"; + << "FollowerGroup: only one follower group is allowed for now"; return false; } @@ -1152,14 +1152,14 @@ void TTableInfo::FinishAlter() { if (newConfig.HasPipelineConfig()) { partitionConfig.MutablePipelineConfig()->CopyFrom(newConfig.GetPipelineConfig()); } - if (newConfig.HasFollowerCount()) { - partitionConfig.SetFollowerCount(newConfig.GetFollowerCount()); + if (newConfig.HasFollowerCount()) { + partitionConfig.SetFollowerCount(newConfig.GetFollowerCount()); } - if (newConfig.HasAllowFollowerPromotion()) { - partitionConfig.SetAllowFollowerPromotion(newConfig.GetAllowFollowerPromotion()); + if (newConfig.HasAllowFollowerPromotion()) { + partitionConfig.SetAllowFollowerPromotion(newConfig.GetAllowFollowerPromotion()); } - if (newConfig.HasCrossDataCenterFollowerCount()) { - partitionConfig.SetCrossDataCenterFollowerCount(newConfig.GetCrossDataCenterFollowerCount()); + if (newConfig.HasCrossDataCenterFollowerCount()) { + partitionConfig.SetCrossDataCenterFollowerCount(newConfig.GetCrossDataCenterFollowerCount()); } if (newConfig.HasEnableFilterByKey()) { partitionConfig.SetEnableFilterByKey(newConfig.GetEnableFilterByKey()); diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h index 167b517cede..2e5710c3d3e 100644 --- a/ydb/core/tx/schemeshard/schemeshard_info_types.h +++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h @@ -123,7 +123,7 @@ private: }; struct TPartitionConfigMerger { - static constexpr ui32 MaxFollowersCount = 3; + static constexpr ui32 MaxFollowersCount = 3; static NKikimrSchemeOp::TPartitionConfig DefaultConfig(const TAppData* appData); static bool ApplyChanges( @@ -241,7 +241,7 @@ struct TTableInfo : public TSimpleRefCount<TTableInfo> { THashSet<TTabletId> PartOwners; ui64 PartCount = 0; - ui64 SearchHeight = 0; + ui64 SearchHeight = 0; ui32 ShardState = NKikimrTxDataShard::Unknown; // True when PartOwners has parts from other tablets @@ -605,16 +605,16 @@ public: return false; } - auto srcFollowerParams = std::tuple<ui64, bool, ui32>( - PartitionConfig().GetFollowerCount(), - PartitionConfig().GetAllowFollowerPromotion(), - PartitionConfig().GetCrossDataCenterFollowerCount() + auto srcFollowerParams = std::tuple<ui64, bool, ui32>( + PartitionConfig().GetFollowerCount(), + PartitionConfig().GetAllowFollowerPromotion(), + PartitionConfig().GetCrossDataCenterFollowerCount() ); - auto alterFollowerParams = std::tuple<ui64, bool, ui32>( - AlterData->PartitionConfigCompatible().GetFollowerCount(), - AlterData->PartitionConfigCompatible().GetAllowFollowerPromotion(), - AlterData->PartitionConfigCompatible().GetCrossDataCenterFollowerCount() + auto alterFollowerParams = std::tuple<ui64, bool, ui32>( + AlterData->PartitionConfigCompatible().GetFollowerCount(), + AlterData->PartitionConfigCompatible().GetAllowFollowerPromotion(), + AlterData->PartitionConfigCompatible().GetCrossDataCenterFollowerCount() ); @@ -634,10 +634,10 @@ public: - return srcFollowerParams != alterFollowerParams + return srcFollowerParams != alterFollowerParams || !equals_proto_array( - PartitionConfig().GetFollowerGroups(), - AlterData->PartitionConfigCompatible().GetFollowerGroups()); + PartitionConfig().GetFollowerGroups(), + AlterData->PartitionConfigCompatible().GetFollowerGroups()); } const TTableShardInfo* GetScheduledCondEraseShard() const { diff --git a/ydb/core/tx/schemeshard/schemeshard_private.h b/ydb/core/tx/schemeshard/schemeshard_private.h index 113d2369acf..207fd8d2c77 100644 --- a/ydb/core/tx/schemeshard/schemeshard_private.h +++ b/ydb/core/tx/schemeshard/schemeshard_private.h @@ -20,7 +20,7 @@ struct TEvPrivate { EvCleanDroppedSubDomains, EvSubscribeToShardDeletion, EvNotifyShardDeleted, - EvRunBackgroundCompaction, + EvRunBackgroundCompaction, EvCompletePublication, EvCompleteBarrier, EvEnd diff --git a/ydb/core/tx/schemeshard/schemeshard_utils.cpp b/ydb/core/tx/schemeshard/schemeshard_utils.cpp index 8550b049917..4ee28e35435 100644 --- a/ydb/core/tx/schemeshard/schemeshard_utils.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_utils.cpp @@ -394,15 +394,15 @@ NKikimrSchemeOp::TPartitionConfig PartitionConfigForIndexes( if (baseTablePartitionConfig.HasCompactionPolicy()) { result.MutableCompactionPolicy()->CopyFrom(baseTablePartitionConfig.GetCompactionPolicy()); } - // skip optional uint64 FollowerCount = 3; + // skip optional uint64 FollowerCount = 3; if (baseTablePartitionConfig.HasExecutorCacheSize()) { result.SetExecutorCacheSize(baseTablePartitionConfig.GetExecutorCacheSize()); } - // skip optional bool AllowFollowerPromotion = 5 [default = true]; + // skip optional bool AllowFollowerPromotion = 5 [default = true]; if (baseTablePartitionConfig.HasTxReadSizeLimit()) { result.SetTxReadSizeLimit(baseTablePartitionConfig.GetTxReadSizeLimit()); } - // skip optional uint32 CrossDataCenterFollowerCount = 8; + // skip optional uint32 CrossDataCenterFollowerCount = 8; if (baseTablePartitionConfig.HasChannelProfileId()) { result.SetChannelProfileId(baseTablePartitionConfig.GetChannelProfileId()); } @@ -454,7 +454,7 @@ NKikimrSchemeOp::TPartitionConfig PartitionConfigForIndexes( result.SetKeepSnapshotTimeout(baseTablePartitionConfig.GetKeepSnapshotTimeout()); } // skip repeated NKikimrStorageSettings.TStorageRoom StorageRooms = 17; - // skip optional NKikimrHive.TFollowerGroup FollowerGroup = 23; + // skip optional NKikimrHive.TFollowerGroup FollowerGroup = 23; return result; } diff --git a/ydb/core/tx/schemeshard/schemeshard_utils.h b/ydb/core/tx/schemeshard/schemeshard_utils.h index 58890fab0c6..de7d17f316f 100644 --- a/ydb/core/tx/schemeshard/schemeshard_utils.h +++ b/ydb/core/tx/schemeshard/schemeshard_utils.h @@ -13,10 +13,10 @@ #include <ydb/library/yql/minikql/mkql_type_ops.h> #include <library/cpp/actors/core/actorid.h> - + #include <util/generic/hash.h> #include <util/generic/hash_set.h> -#include <util/generic/intrlist.h> +#include <util/generic/intrlist.h> namespace NKikimr { namespace NSchemeShard { diff --git a/ydb/core/tx/schemeshard/ut_async_index.cpp b/ydb/core/tx/schemeshard/ut_async_index.cpp index abade549470..a2fc2d39741 100644 --- a/ydb/core/tx/schemeshard/ut_async_index.cpp +++ b/ydb/core/tx/schemeshard/ut_async_index.cpp @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TAsyncIndexTests) { ? Ydb::StatusIds::SUCCESS : Ydb::StatusIds::UNSUPPORTED; - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", TBuildIndexConfig{ + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", TBuildIndexConfig{ "UserDefinedIndex", NKikimrSchemeOp::EIndexTypeGlobalAsync, {"indexed"}, {} }, status); diff --git a/ydb/core/tx/schemeshard/ut_base.cpp b/ydb/core/tx/schemeshard/ut_base.cpp index f537be7e4e2..a76dcf9d5bb 100644 --- a/ydb/core/tx/schemeshard/ut_base.cpp +++ b/ydb/core/tx/schemeshard/ut_base.cpp @@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TTestEnv env(runtime); - auto result = env.InitRoot(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor(), "MyRoot"); + auto result = env.InitRoot(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor(), "MyRoot"); UNIT_ASSERT_VALUES_EQUAL((ui32)result, (ui32)TEvSchemeShard::TEvInitRootShardResult::StatusAlreadyInitialized); } @@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TString newOwner = "something@builtin"; - auto result = env.InitRoot(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor(), "MyRoot", {}, newOwner); + auto result = env.InitRoot(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor(), "MyRoot", {}, newOwner); UNIT_ASSERT_VALUES_EQUAL((ui32)result, (ui32)TEvSchemeShard::TEvInitRootShardResult::StatusSuccess); auto checkOwner = [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { @@ -615,7 +615,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestUserAttrs(runtime, ++txId, "/", "MyRoot", AlterUserAttrs({{"__extra_path_symbols_allowed", "_.-"}})); env.TestWaitNotification(runtime, txId); - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); TestMkDir(runtime, ++txId, "/MyRoot", "Dir1!", {NKikimrScheme::StatusSchemeError}); TestMkDir(runtime, ++txId, "/MyRoot", "Dir1?", {NKikimrScheme::StatusSchemeError}); @@ -1421,7 +1421,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { { TestUserAttrs(runtime, ++txId, "/", "MyRoot", AlterUserAttrs({{"__extra_path_symbols_allowed", "-_."}})); env.TestWaitNotification(runtime, txId); - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); TestConsistentCopyTables(runtime, ++txId, "/", R"( CopyTableDescriptions { @@ -1811,7 +1811,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/Table1"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); } Y_UNIT_TEST(CopyIndexedTable) { //+ @@ -2143,13 +2143,13 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestCreateIndexedTable(runtime, ++txId, "/MyRoot/DirA", R"( TableDescription { - Name: "WithFollowerGroup" + Name: "WithFollowerGroup" Columns { Name: "key" Type: "Uint64" } Columns { Name: "value0" Type: "Uint64" } KeyColumnNames: ["key"] PartitionConfig { - FollowerGroups { - FollowerCount: 1 + FollowerGroups { + FollowerCount: 1 } } } @@ -2162,12 +2162,12 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestCreateIndexedTable(runtime, ++txId, "/MyRoot/DirA", R"( TableDescription { - Name: "WithFollowerCount" + Name: "WithFollowerCount" Columns { Name: "key" Type: "Uint64" } Columns { Name: "value0" Type: "Uint64" } KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } } IndexDescription { @@ -2179,12 +2179,12 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestCreateIndexedTable(runtime, ++txId, "/MyRoot/DirA", R"( TableDescription { - Name: "WithNoFollowers" + Name: "WithNoFollowers" Columns { Name: "key" Type: "Uint64" } Columns { Name: "value0" Type: "Uint64" } KeyColumnNames: ["key"] PartitionConfig { - FollowerGroups { + FollowerGroups { } } } @@ -2196,30 +2196,30 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { env.TestWaitNotification(runtime, txId); TestAlterTable(runtime, ++txId, "/MyRoot/DirA", R"( - Name: "WithNoFollowers" + Name: "WithNoFollowers" PartitionConfig { - CrossDataCenterFollowerCount: 1 + CrossDataCenterFollowerCount: 1 } )", {TEvSchemeShard::EStatus::StatusInvalidParameter}); TestAlterTable(runtime, ++txId, "/MyRoot/DirA", R"( - Name: "WithNoFollowers" + Name: "WithNoFollowers" PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } )", {TEvSchemeShard::EStatus::StatusInvalidParameter}); TestAlterTable(runtime, ++txId, "/MyRoot/DirA", R"( - Name: "WithNoFollowers" + Name: "WithNoFollowers" PartitionConfig { - FollowerGroups { - FollowerCount: 1 + FollowerGroups { + FollowerCount: 1 } } )"); env.TestWaitNotification(runtime, txId); - TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithFollowerGroup"); - TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithFollowerCount"); - TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithNoFollowers"); + TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithFollowerGroup"); + TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithFollowerCount"); + TestDropTable(runtime, ++txId, "/MyRoot/DirA", "WithNoFollowers"); env.TestWaitNotification(runtime, {txId, txId-1, txId-2}); TestDropTable(runtime, ++txId, "/", "Table1", {TEvSchemeShard::EStatus::StatusPathDoesNotExist}); @@ -2258,7 +2258,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDropTable(runtime, ++txId, "/MyRoot/DirA", "Table1", {TEvSchemeShard::EStatus::StatusPathDoesNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 20)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 20)); } Y_UNIT_TEST(CreateIndexedTableAndForceDrop) { //+ @@ -2305,7 +2305,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { NLs::PathVersionEqual(7), NLs::ChildrenCount(0)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); } Y_UNIT_TEST(CreateIndexedTableAndForceDropSimonteniously) { //+ @@ -2347,7 +2347,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { {NLs::Finished, NLs::ChildrenCount(0)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); } Y_UNIT_TEST(DropIndexedTableAndForceDropSimonteniously) { //+ @@ -2391,7 +2391,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { {NLs::Finished, NLs::ChildrenCount(0)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); } Y_UNIT_TEST(IgnoreUserColumnIds) { //+ @@ -2584,7 +2584,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto t1 = DescribePath(runtime, "/MyRoot/Table1"); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); auto t2 = DescribePath(runtime, "/MyRoot/Table1"); @@ -2610,7 +2610,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto t1 = DescribePath(runtime, "/MyRoot/Table2"); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); auto t2 = DescribePath(runtime, "/MyRoot/Table2"); @@ -2660,7 +2660,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto t1 = DescribePath(runtime, "/MyRoot/Table1"); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); auto t2 = DescribePath(runtime, "/MyRoot/Table1"); @@ -2690,7 +2690,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto t3 = DescribePath(runtime, "/MyRoot/Table1"); UNIT_ASSERT(t2.DebugString() != t3.DebugString()); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); auto t4 = DescribePath(runtime, "/MyRoot/Table1"); UNIT_ASSERT_VALUES_EQUAL(t3.DebugString(), t4.DebugString()); @@ -2907,8 +2907,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); - fnWriteRow(TTestTxConfig::FakeHiveTablets+1, 0x80000000u); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); + fnWriteRow(TTestTxConfig::FakeHiveTablets+1, 0x80000000u); AsyncCopyTable(runtime, ++txId, "/MyRoot", "NewTable", "/MyRoot/Table"); AsyncCopyTable(runtime, ++txId, "/MyRoot", "NewTable2", "/MyRoot/NewTable"); @@ -3067,7 +3067,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestModificationResult(runtime, txId, NKikimrScheme::StatusAccepted); env.TestWaitNotification(runtime, {txId-1, txId}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); } Y_UNIT_TEST(CopyTableAndConcurrentMerge) { //+ @@ -3117,7 +3117,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestModificationResult(runtime, txId, NKikimrScheme::StatusAccepted); env.TestWaitNotification(runtime, {txId-1, txId}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); } Y_UNIT_TEST(CopyTableAndConcurrentSplitMerge) { //+ @@ -3183,7 +3183,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { AsyncDropTable(runtime, ++txId, "/MyRoot", "NewTable"); env.TestWaitNotification(runtime, {txId-1, txId}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); } Y_UNIT_TEST(CopyTableWithAlterConfig) { //+ @@ -3364,25 +3364,25 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { }; // /Root/Table - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 2); checher(NKikimrSchemeOp::EColumnCache::ColumnCacheEver)(tableDescription); } // /Root/CopyTable - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4, TTestTxConfig::FakeHiveTablets+5}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4, TTestTxConfig::FakeHiveTablets+5}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 3); checher(NKikimrSchemeOp::EColumnCache::ColumnCacheOnce)(tableDescription); } // /Root/CopyTable2 - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+6, TTestTxConfig::FakeHiveTablets+7, TTestTxConfig::FakeHiveTablets+8}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+6, TTestTxConfig::FakeHiveTablets+7, TTestTxConfig::FakeHiveTablets+8}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 4); checher(NKikimrSchemeOp::EColumnCache::ColumnCacheNone, 2)(tableDescription); } // /Root/CopyTable3 - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+9, TTestTxConfig::FakeHiveTablets+10, TTestTxConfig::FakeHiveTablets+11}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+9, TTestTxConfig::FakeHiveTablets+10, TTestTxConfig::FakeHiveTablets+11}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 5); checher(NKikimrSchemeOp::EColumnCache::ColumnCacheEver)(tableDescription); } @@ -3408,7 +3408,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { {descrChecker(1)}); } - Y_UNIT_TEST(CopyTableOmitFollowers) { + Y_UNIT_TEST(CopyTableOmitFollowers) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -3420,7 +3420,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "Value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } )"); env.TestWaitNotification(runtime, txId); @@ -3428,23 +3428,23 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { NLs::Finished, NLs::IsTable, - NLs::FollowerCount(1) + NLs::FollowerCount(1) }); // simple copy table TestCreateTable(runtime, ++txId, "/MyRoot", R"( Name: "CopyTable" CopyFromTable: "/MyRoot/Table" - OmitFollowers: true + OmitFollowers: true )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/CopyTable", true), { NLs::Finished, NLs::IsTable, - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::FollowerGroups({NKikimrHive::TFollowerGroup()}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::FollowerGroups({NKikimrHive::TFollowerGroup()}) }); // consistent copy table @@ -3452,7 +3452,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { CopyTableDescriptions { SrcPath: "/MyRoot/Table" DstPath: "/MyRoot/ConsistentCopyTable" - OmitFollowers: true + OmitFollowers: true } )"); env.TestWaitNotification(runtime, txId); @@ -3460,9 +3460,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/ConsistentCopyTable", true), { NLs::Finished, NLs::IsTable, - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::FollowerGroups({NKikimrHive::TFollowerGroup()}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::FollowerGroups({NKikimrHive::TFollowerGroup()}) }); } @@ -3608,8 +3608,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); - fnWriteRow(TTestTxConfig::FakeHiveTablets+1, 0x80000000u); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); + fnWriteRow(TTestTxConfig::FakeHiveTablets+1, 0x80000000u); AsyncSplitTable(runtime, ++txId, "/MyRoot/Table", R"( SourceTabletId: 9437194 @@ -3671,22 +3671,22 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TString errStr; // Check local scheme on datashards - LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets, "", true, scheme, errStr); + LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets, "", true, scheme, errStr); UNIT_ASSERT_VALUES_EQUAL(errStr, ""); UNIT_ASSERT_C(!ToString(scheme).Contains("ExecutorCacheSize: 12121212"), "Old shard must not participate in ALTER"); - LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+1, "", true, scheme, errStr); + LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+1, "", true, scheme, errStr); UNIT_ASSERT_VALUES_EQUAL(errStr, ""); UNIT_ASSERT_C(!ToString(scheme).Contains("ExecutorCacheSize: 12121212"), "Old shard must not participate in ALTER"); - LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+2, "", true, scheme, errStr); + LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+2, "", true, scheme, errStr); UNIT_ASSERT_VALUES_EQUAL(errStr, ""); UNIT_ASSERT_STRING_CONTAINS_C(ToString(scheme), "ExecutorCacheSize: 12121212", "New shard must participate in ALTER"); { // Read user table schema from new shard; NKikimrMiniKQL::TResult result; TString err; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( ( (let range '('('Tid (Uint64 '0) (Void)))) (let select '('LocalTid 'Schema)) @@ -3712,7 +3712,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { UNIT_ASSERT_VALUES_EQUAL(tableDescr.GetPartitionConfig().GetCompactionPolicy().GetGeneration(1).GetForceSizeToCompact(), 536870912); } - LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+3, "", true, scheme, errStr); + LocalSchemeTx(runtime, TTestTxConfig::FakeHiveTablets+3, "", true, scheme, errStr); UNIT_ASSERT_VALUES_EQUAL(errStr, ""); UNIT_ASSERT_STRING_CONTAINS_C(ToString(scheme), "ExecutorCacheSize: 12121212", "Non-splitted shard must participate in ALTER"); @@ -3720,7 +3720,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDropTable(runtime, ++txId, "/MyRoot", "Table"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); } Y_UNIT_TEST(DropTableAndConcurrentSplit) { //+ @@ -3757,7 +3757,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { env.TestWaitNotification(runtime, {txId, txId-1, txId-2}); // Wait for everything to be cleaned up - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); } Y_UNIT_TEST(AlterTable) { //+ @@ -4112,7 +4112,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { )"); env.TestWaitNotification(runtime, txId); - ui64 datashardTabletId = TTestTxConfig::FakeHiveTablets; + ui64 datashardTabletId = TTestTxConfig::FakeHiveTablets; UNIT_ASSERT_VALUES_EQUAL(GetTxReadSizeLimit(runtime, datashardTabletId), 100); UNIT_ASSERT_VALUES_EQUAL(GetExecutorCacheSize(runtime, datashardTabletId), 42); @@ -4175,7 +4175,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 1 + CrossDataCenterFollowerCount: 1 } )"); @@ -4224,7 +4224,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; - TVector<ui64> tabletIds = {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}; + TVector<ui64> tabletIds = {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}; TestCreateTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -4555,7 +4555,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { {descrChecker(1)}); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); Cerr << "Checking Table1" << Endl; TestDescribeResult(DescribePath(runtime, "/MyRoot/Table1", true), @@ -4660,21 +4660,21 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { // /MyRoot/Table1 Cerr << "Checking tablets for Table1" << Endl; - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+0, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+0, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 2); schemaChecker()(tableDescription); } // /MyRoot/Table2 Cerr << "Checking tablets for Table2" << Endl; - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4, TTestTxConfig::FakeHiveTablets+5}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4, TTestTxConfig::FakeHiveTablets+5}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 3); schemaChecker()(tableDescription); } // /MyRoot/Table3 Cerr << "Checking tablets for Table3" << Endl; - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+6, TTestTxConfig::FakeHiveTablets+7, TTestTxConfig::FakeHiveTablets+8}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+6, TTestTxConfig::FakeHiveTablets+7, TTestTxConfig::FakeHiveTablets+8}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 4); schemaChecker()(tableDescription); } @@ -4975,7 +4975,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto checkSchema = [&] (const TSchemaChecker& checker) { Cerr << "Checking tablets for Table1" << Endl; - for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+0, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { + for (ui64 tabletId : {TTestTxConfig::FakeHiveTablets+0, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 2); checker(tableDescription); } @@ -5138,7 +5138,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TTestEnv env(runtime); ui64 txId = 100; - const ui64 datashardTabletId = TTestTxConfig::FakeHiveTablets; + const ui64 datashardTabletId = TTestTxConfig::FakeHiveTablets; NKikimr::NLocalDb::TCompactionPolicyPtr defaultUserTablePolicy = NKikimr::NLocalDb::CreateDefaultUserTablePolicy(); NKikimr::NLocalDb::TCompactionPolicyPtr defaultSystemTablePolicy = NKikimr::NLocalDb::CreateDefaultTablePolicy(); @@ -5205,7 +5205,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { NLs::PathVersionEqual(4)}); } - Y_UNIT_TEST(AlterTableFollowers) { //+ + Y_UNIT_TEST(AlterTableFollowers) { //+ TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; @@ -5216,7 +5216,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 100 + FollowerCount: 100 } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5226,8 +5226,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 1 - CrossDataCenterFollowerCount: 1 + FollowerCount: 1 + CrossDataCenterFollowerCount: 1 } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5238,8 +5238,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 1 - FollowerGroups { } + FollowerCount: 1 + FollowerGroups { } } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5249,8 +5249,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - CrossDataCenterFollowerCount: 1 - FollowerGroups { } + CrossDataCenterFollowerCount: 1 + FollowerGroups { } } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5260,9 +5260,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerCount: 1 - CrossDataCenterFollowerCount: 1 - FollowerGroups { } + FollowerCount: 1 + CrossDataCenterFollowerCount: 1 + FollowerGroups { } } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5272,8 +5272,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Columns { Name: "value" Type: "Utf8"} KeyColumnNames: ["key"] PartitionConfig { - FollowerGroups { } - FollowerGroups { } + FollowerGroups { } + FollowerGroups { } } )", {NKikimrScheme::StatusInvalidParameter}); @@ -5291,32 +5291,32 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 100 - AllowFollowerPromotion: true + FollowerCount: 100 + AllowFollowerPromotion: true } )", {NKikimrScheme::StatusInvalidParameter}); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 100 - AllowFollowerPromotion: true + CrossDataCenterFollowerCount: 100 + AllowFollowerPromotion: true } )", {NKikimrScheme::StatusInvalidParameter}); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 2 - AllowFollowerPromotion: true + FollowerCount: 2 + AllowFollowerPromotion: true } )"); env.TestWaitNotification(runtime, txId); @@ -5326,10 +5326,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(2), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(2), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); ////////// @@ -5337,17 +5337,17 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Name: "Table" DropColumns { Name: "value" } PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(1), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(1), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); TestDescribeResult(DescribePath(runtime, "/MyRoot"), @@ -5359,24 +5359,24 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { Name: "Table" Columns { Name: "value" Type: "Utf8" } PartitionConfig { - AllowFollowerPromotion: false + AllowFollowerPromotion: false } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(1), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({}) + NLs::FollowerCount(1), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - AllowFollowerPromotion: true + AllowFollowerPromotion: true ExecutorCacheSize: 100500 } )"); @@ -5384,113 +5384,113 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(1), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(1), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 0 - AllowFollowerPromotion: false + FollowerCount: 0 + AllowFollowerPromotion: false } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 1 - AllowFollowerPromotion: true + CrossDataCenterFollowerCount: 1 + AllowFollowerPromotion: true } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(1), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(1), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 0 + CrossDataCenterFollowerCount: 0 } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(true), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(true), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - AllowFollowerPromotion: false + AllowFollowerPromotion: false } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({}) }); ////////// TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 2 + CrossDataCenterFollowerCount: 2 } )"); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(2), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(2), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({}) }); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(2), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(2), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({}) }); ///////// @@ -5498,22 +5498,22 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { - FollowerCount: 1 + FollowerGroups { + FollowerCount: 1 } } )"); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5522,20 +5522,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 1 + FollowerCount: 1 } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5544,20 +5544,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - CrossDataCenterFollowerCount: 2 + CrossDataCenterFollowerCount: 2 } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5566,20 +5566,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - AllowFollowerPromotion: false + AllowFollowerPromotion: false } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5588,24 +5588,24 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { - FollowerCount: 10 - AllowLeaderPromotion: false + FollowerGroups { + FollowerCount: 10 + AllowLeaderPromotion: false RequireAllDataCenters: true } } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5614,22 +5614,22 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { + FollowerGroups { LocalNodeOnly: true } } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5638,22 +5638,22 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { + FollowerGroups { RequireDifferentNodes: true } } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5662,29 +5662,29 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { - FollowerCount: 3 - AllowLeaderPromotion: true + FollowerGroups { + FollowerCount: 3 + AllowLeaderPromotion: true RequireAllDataCenters: true } - FollowerGroups { - FollowerCount: 3 - AllowLeaderPromotion: true + FollowerGroups { + FollowerCount: 3 + AllowLeaderPromotion: true RequireAllDataCenters: true } } )", {NKikimrScheme::StatusInvalidParameter}); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(1); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(1); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } @@ -5693,26 +5693,26 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerGroups { - FollowerCount: 3 - AllowLeaderPromotion: true + FollowerGroups { + FollowerCount: 3 + AllowLeaderPromotion: true RequireAllDataCenters: true } } )"); env.TestWaitNotification(runtime, txId); - NKikimrHive::TFollowerGroup control; - control.SetFollowerCount(3); - control.SetAllowLeaderPromotion(true); + NKikimrHive::TFollowerGroup control; + control.SetFollowerCount(3); + control.SetAllowLeaderPromotion(true); control.SetRequireAllDataCenters(true); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), { - NLs::FollowerCount(0), - NLs::CrossDataCenterFollowerCount(0), - NLs::AllowFollowerPromotion(false), - NLs::FollowerGroups({control}) + NLs::FollowerCount(0), + NLs::CrossDataCenterFollowerCount(0), + NLs::AllowFollowerPromotion(false), + NLs::FollowerGroups({control}) }); } } @@ -5766,7 +5766,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { auto checkSchema = [&](TVector<int> tabletIdxs, TVector<TString> columns) { auto checker = schemaChecker(std::move(columns)); for (int tabletIdx : tabletIdxs) { - ui64 tabletId = TTestTxConfig::FakeHiveTablets + tabletIdx; + ui64 tabletId = TTestTxConfig::FakeHiveTablets + tabletIdx; NKikimrSchemeOp::TTableDescription tableDescription = GetDatashardSchema(runtime, tabletId, 2); checker(tableDescription); } @@ -5843,8 +5843,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{true}, TCheckEnableFilterByKey{false}}); - UNIT_ASSERT_VALUES_EQUAL_C(true, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets), "FastLogPolicy must be enabled by default"); - UNIT_ASSERT_VALUES_EQUAL_C(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001), "ByKeyFilter must be disabled by default"); + UNIT_ASSERT_VALUES_EQUAL_C(true, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets), "FastLogPolicy must be enabled by default"); + UNIT_ASSERT_VALUES_EQUAL_C(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001), "ByKeyFilter must be disabled by default"); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -5857,8 +5857,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{false}, TCheckEnableFilterByKey{false}}); - UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); - UNIT_ASSERT_VALUES_EQUAL(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); + UNIT_ASSERT_VALUES_EQUAL(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -5871,8 +5871,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{false}, TCheckEnableFilterByKey{true}}); - UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); - UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); + UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -5885,9 +5885,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{false}, TCheckEnableFilterByKey{true}}); - UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); - UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); - UNIT_ASSERT_VALUES_EQUAL(true, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); + UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(true, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -5900,9 +5900,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{false}, TCheckEnableFilterByKey{true}}); - UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); - UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); - UNIT_ASSERT_VALUES_EQUAL(false, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); + UNIT_ASSERT_VALUES_EQUAL(true, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); TestAlterTable(runtime, ++txId, "/MyRoot", R"( Name: "Table" @@ -5916,9 +5916,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {TCheckExecutorFastLogPolicy{true}, TCheckEnableFilterByKey{false}}); - UNIT_ASSERT_VALUES_EQUAL(true, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); - UNIT_ASSERT_VALUES_EQUAL(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); - UNIT_ASSERT_VALUES_EQUAL(false, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(true, GetFastLogPolicy(runtime, TTestTxConfig::FakeHiveTablets)); + UNIT_ASSERT_VALUES_EQUAL(false, GetByKeyFilterEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); + UNIT_ASSERT_VALUES_EQUAL(false, GetEraseCacheEnabled(runtime, TTestTxConfig::FakeHiveTablets, 1001)); } Y_UNIT_TEST(CreatePersQueueGroup) { //+ @@ -5967,7 +5967,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { NLs::NotFinished}); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); env.TestWaitNotification(runtime, txId); @@ -6079,7 +6079,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); env.TestWaitNotification(runtime, txId-1); TestDescribeResult(DescribePath(runtime, "/MyRoot/PQGroup", true), @@ -6275,7 +6275,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Ops"), {NLs::NoChildren}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); Cdbg << "Create, Drop (partitioned table)" << Endl; @@ -6295,7 +6295,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Ops"), {NLs::NoChildren}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); } Y_UNIT_TEST(DropTableById) { //+ @@ -6325,7 +6325,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::NoChildren}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); } Y_UNIT_TEST(DropPQ) { //+ @@ -6428,10 +6428,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestModificationResult(runtime, txId, NKikimrScheme::StatusAccepted); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); env.TestWaitNotification(runtime, {txId, txId-1, txId-2}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+20)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+20)); TestDescribeResult(DescribePath(runtime, "/MyRoot/Ops/DropMeBaby"), {NLs::PathNotExist}); @@ -6447,7 +6447,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestRmDir(runtime, ++txId, "/MyRoot", "Ops", {NKikimrScheme::StatusPathDoesNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+40)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+40)); } Y_UNIT_TEST(ParallelModifying) { //+ @@ -6551,7 +6551,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDropPQGroup(runtime, ++txId, "/MyRoot", "Isolda"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+40)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+40)); } Y_UNIT_TEST(DropPQFail) { //+ @@ -6595,7 +6595,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDropPQGroup(runtime, ++txId, path, "Isolda"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); } Y_UNIT_TEST(DropPQAbort) { //+ @@ -6665,7 +6665,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, pqPath), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+20)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+20)); } Y_UNIT_TEST(PQGroupExplicitChannels) { @@ -6825,7 +6825,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { AsyncMkDir(runtime, ++txId, "/MyRoot/DirA/SubDirA", "CCC"); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist}); @@ -6863,7 +6863,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { // Set ReadOnly SetSchemeshardReadOnlyMode(runtime, true); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); // Verify that table creation successfully finished env.TestWaitNotification(runtime, txId); @@ -6887,7 +6887,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { // Disable ReadOnly SetSchemeshardReadOnlyMode(runtime, false); sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); // Check that modifications now work again TestMkDir(runtime, ++txId, "/MyRoot", "SubDirBBBB"); @@ -7705,7 +7705,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::Finished, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); @@ -7741,7 +7741,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::Finished, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); @@ -8493,7 +8493,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Kesus2"), {NLs::Finished}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(1)}); @@ -8503,7 +8503,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Kesus2"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 1); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 1); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); } @@ -8572,7 +8572,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Solomon"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 40)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 40)); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::Finished, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); @@ -8668,7 +8668,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Solomon"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::Finished, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); @@ -9301,7 +9301,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { // Drop the table and wait for everytTFamilyDescriptionhing to be cleaned up TestDropTable(runtime, ++txId, "/MyRoot/USER_0", "Table"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets+2, TTestTxConfig::FakeHiveTablets+10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets+2, TTestTxConfig::FakeHiveTablets+10)); } Y_UNIT_TEST(RejectSystemViewPath) { @@ -9722,13 +9722,13 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(res, 0); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 0); } - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table1", "Sync", {"value"}); - env.TestWaitNotification(runtime, txId, TTestTxConfig::SchemeShard); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table1", "Sync", {"value"}); + env.TestWaitNotification(runtime, txId, TTestTxConfig::SchemeShard); - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", txId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", txId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_DONE); TestCopyTable(runtime, ++txId, "/MyRoot", "Copy1", "/MyRoot/Table1"); @@ -9833,7 +9833,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) { TVector<THolder<IEventHandle>> supressed; auto defOberver = SetSuppressObserver(runtime, supressed, TEvTxProcessing::EvPlanStep); - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); env.TestWaitNotification(runtime, 103); diff --git a/ydb/core/tx/schemeshard/ut_base_reboots.cpp b/ydb/core/tx/schemeshard/ut_base_reboots.cpp index d37822564a8..05fef3170c3 100644 --- a/ydb/core/tx/schemeshard/ut_base_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_base_reboots.cpp @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { {NKikimrScheme::StatusAccepted, NKikimrScheme::StatusPathDoesNotExist, NKikimrScheme::StatusMultipleModifications}); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); { TInactiveZone inactive(activeZone); @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { AsyncDropTable(runtime, ++t.TxId, "/MyRoot", "DropMe"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); { TInactiveZone inactive(activeZone); @@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "Table"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); + t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets); { TInactiveZone inactive(activeZone); @@ -226,7 +226,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "Table"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { TInactiveZone inactive(activeZone); @@ -273,7 +273,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { {NLs::PathNotExist}); } - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); }); } @@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); } - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); }); } @@ -347,7 +347,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { {NLs::PathNotExist}); } - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 7)); }); } @@ -458,7 +458,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { }); } - Y_UNIT_TEST(AlterTableFollowersWithReboots) { //+ + Y_UNIT_TEST(AlterTableFollowersWithReboots) { //+ TTestWithReboots t; t.Run([&](TTestActorRuntime& runtime, bool& activeZone) { { @@ -476,32 +476,32 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestAlterTable(runtime, ++t.TxId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 2 - AllowFollowerPromotion: true + FollowerCount: 2 + AllowFollowerPromotion: true } )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - // TODO: check followers + // TODO: check followers TestAlterTable(runtime, ++t.TxId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 1 - AllowFollowerPromotion: false + FollowerCount: 1 + AllowFollowerPromotion: false } )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - // TODO: check followers + // TODO: check followers TestAlterTable(runtime, ++t.TxId, "/MyRoot", R"( Name: "Table" PartitionConfig { - FollowerCount: 0 - AllowFollowerPromotion: true + FollowerCount: 0 + AllowFollowerPromotion: true } )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - // TODO: check followers + // TODO: check followers }); } @@ -524,7 +524,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); - datashardTabletId = TTestTxConfig::FakeHiveTablets; + datashardTabletId = TTestTxConfig::FakeHiveTablets; UNIT_ASSERT_VALUES_EQUAL(GetTxReadSizeLimit(runtime, datashardTabletId), 100); UNIT_ASSERT_VALUES_EQUAL(GetExecutorCacheSize(runtime, datashardTabletId), 42); } @@ -597,7 +597,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "NewTable"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); } }); } @@ -641,7 +641,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "Table"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); } }); } @@ -680,7 +680,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { { TInactiveZone inactive(activeZone); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1)); TestDescribeResult(DescribePath(runtime, "/MyRoot") , {NLs::NoChildren}); } @@ -750,7 +750,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "NewTable"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); }); } @@ -783,7 +783,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); } TestCopyTable(runtime, ++t.TxId, "/MyRoot", "NewTable", "/MyRoot/Table"); @@ -795,7 +795,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { { TInactiveZone inactive(activeZone); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); } }); } @@ -832,7 +832,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); // Make a chain of copy-of-copy for (int i = 2; i <= maxTableIdx; ++i) { @@ -853,7 +853,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { { TInactiveZone inactive(activeZone); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 9)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 9)); } }); } @@ -888,7 +888,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); TestCopyTable(runtime, ++t.TxId, "/MyRoot", "Table2", "/MyRoot/Table1"); t.TestEnv->TestWaitNotification(runtime, t.TxId); @@ -914,7 +914,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot", "Table2"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); }); } @@ -941,7 +941,7 @@ Y_UNIT_TEST_SUITE(TTablesWithReboots) { AsyncForceDropUnsafe(runtime, ++t.TxId, pathVer.PathId.LocalPathId); t.TestEnv->TestWaitNotification(runtime, {t.TxId - 1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2)); { TInactiveZone inactive(activeZone); diff --git a/ydb/core/tx/schemeshard/ut_bsvolume.cpp b/ydb/core/tx/schemeshard/ut_bsvolume.cpp index a117987bd90..c5824e6a640 100644 --- a/ydb/core/tx/schemeshard/ut_bsvolume.cpp +++ b/ydb/core/tx/schemeshard/ut_bsvolume.cpp @@ -35,18 +35,18 @@ Y_UNIT_TEST_SUITE(TBSV) { TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::Finished, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); @@ -76,13 +76,13 @@ Y_UNIT_TEST_SUITE(TBSV) { TestDropBlockStoreVolume(runtime, ++txId, "/MyRoot", "BSVolume"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { // Read user table schema from new shard; NKikimrMiniKQL::TResult result; TString err; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::SchemeShard, R"( + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::SchemeShard, R"( ( (let range '('('ShardIdx (Uint64 '0) (Void)))) (let select '('ShardIdx)) diff --git a/ydb/core/tx/schemeshard/ut_bsvolume_reboots.cpp b/ydb/core/tx/schemeshard/ut_bsvolume_reboots.cpp index 17928995022..5dbdecf8e6d 100644 --- a/ydb/core/tx/schemeshard/ut_bsvolume_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_bsvolume_reboots.cpp @@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TBSVWithReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); TestDescribeResult(DescribePath(runtime, "/MyRoot/BSVolume"), {NLs::PathNotExist}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); } }); } @@ -285,7 +285,7 @@ Y_UNIT_TEST_SUITE(TBSVWithReboots) { TestForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); { TInactiveZone inactive(activeZone); diff --git a/ydb/core/tx/schemeshard/ut_compaction.cpp b/ydb/core/tx/schemeshard/ut_compaction.cpp index 145c55c09e8..59f8de87094 100644 --- a/ydb/core/tx/schemeshard/ut_compaction.cpp +++ b/ydb/core/tx/schemeshard/ut_compaction.cpp @@ -2,427 +2,427 @@ #include <ydb/core/tx/schemeshard/ut_helpers/helpers.h> #include <ydb/core/tx/schemeshard/schemeshard_billing_helpers.h> #include <ydb/core/tx/datashard/datashard.h> - -using namespace NKikimr; -using namespace NSchemeShardUT_Private; - -namespace { - -using TTableInfoMap = THashMap<TString, NKikimrTxDataShard::TEvGetInfoResponse::TUserTable>; - -std::pair<TTableInfoMap, ui64> GetTables( - TTestActorRuntime &runtime, - ui64 tabletId) -{ - auto sender = runtime.AllocateEdgeActor(); - auto request = MakeHolder<TEvDataShard::TEvGetInfoRequest>(); - runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); - - TTableInfoMap result; - - TAutoPtr<IEventHandle> handle; - auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetInfoResponse>(handle); - for (auto& table: response->Record.GetUserTables()) { - result[table.GetName()] = table; - } - - auto ownerId = response->Record.GetTabletInfo().GetSchemeShard(); - - return std::make_pair(result, ownerId); -} - -void SetFeatures( - TTestActorRuntime &runtime, - TTestEnv&, - ui64 schemeShard, - const NKikimrConfig::TFeatureFlags& features) -{ - auto request = MakeHolder<NConsole::TEvConsole::TEvConfigNotificationRequest>(); - *request->Record.MutableConfig()->MutableFeatureFlags() = features; - - // little hack to simplify life - auto* compactionConfig = request->Record.MutableConfig()->MutableCompactionConfig(); - compactionConfig->MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); - - auto sender = runtime.AllocateEdgeActor(); - - runtime.SendToPipe(schemeShard, sender, request.Release(), 0, GetPipeConfigWithRetries()); - - TAutoPtr<IEventHandle> handle; - runtime.GrabEdgeEventRethrow<NConsole::TEvConsole::TEvConfigNotificationResponse>(handle); -} - -void SetBackgroundCompactionServerless(TTestActorRuntime &runtime, TTestEnv& env, ui64 schemeShard, bool value) { - NKikimrConfig::TFeatureFlags features; - features.SetEnableBackgroundCompactionServerless(value); - SetFeatures(runtime, env, schemeShard, features); -} - -void SetBackgroundCompaction(TTestActorRuntime &runtime, TTestEnv& env, ui64 schemeShard, bool value) { - NKikimrConfig::TFeatureFlags features; - features.SetEnableBackgroundCompaction(value); - SetFeatures(runtime, env, schemeShard, features); -} - -void DisableBackgroundCompactionViaRestart( - TTestActorRuntime& runtime, - TTestEnv&, - ui64 schemeShard) -{ - // turn on background compaction and restart to apply + +using namespace NKikimr; +using namespace NSchemeShardUT_Private; + +namespace { + +using TTableInfoMap = THashMap<TString, NKikimrTxDataShard::TEvGetInfoResponse::TUserTable>; + +std::pair<TTableInfoMap, ui64> GetTables( + TTestActorRuntime &runtime, + ui64 tabletId) +{ + auto sender = runtime.AllocateEdgeActor(); + auto request = MakeHolder<TEvDataShard::TEvGetInfoRequest>(); + runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); + + TTableInfoMap result; + + TAutoPtr<IEventHandle> handle; + auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetInfoResponse>(handle); + for (auto& table: response->Record.GetUserTables()) { + result[table.GetName()] = table; + } + + auto ownerId = response->Record.GetTabletInfo().GetSchemeShard(); + + return std::make_pair(result, ownerId); +} + +void SetFeatures( + TTestActorRuntime &runtime, + TTestEnv&, + ui64 schemeShard, + const NKikimrConfig::TFeatureFlags& features) +{ + auto request = MakeHolder<NConsole::TEvConsole::TEvConfigNotificationRequest>(); + *request->Record.MutableConfig()->MutableFeatureFlags() = features; + + // little hack to simplify life + auto* compactionConfig = request->Record.MutableConfig()->MutableCompactionConfig(); + compactionConfig->MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); + + auto sender = runtime.AllocateEdgeActor(); + + runtime.SendToPipe(schemeShard, sender, request.Release(), 0, GetPipeConfigWithRetries()); + + TAutoPtr<IEventHandle> handle; + runtime.GrabEdgeEventRethrow<NConsole::TEvConsole::TEvConfigNotificationResponse>(handle); +} + +void SetBackgroundCompactionServerless(TTestActorRuntime &runtime, TTestEnv& env, ui64 schemeShard, bool value) { + NKikimrConfig::TFeatureFlags features; + features.SetEnableBackgroundCompactionServerless(value); + SetFeatures(runtime, env, schemeShard, features); +} + +void SetBackgroundCompaction(TTestActorRuntime &runtime, TTestEnv& env, ui64 schemeShard, bool value) { + NKikimrConfig::TFeatureFlags features; + features.SetEnableBackgroundCompaction(value); + SetFeatures(runtime, env, schemeShard, features); +} + +void DisableBackgroundCompactionViaRestart( + TTestActorRuntime& runtime, + TTestEnv&, + ui64 schemeShard) +{ + // turn on background compaction and restart to apply runtime.GetAppData().FeatureFlags.SetEnableBackgroundCompactionForTest(false); runtime.GetAppData().FeatureFlags.SetEnableBackgroundCompactionServerlessForTest(false); - - // little hack to simplify life - auto& compactionConfig = runtime.GetAppData().CompactionConfig; - compactionConfig.MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); - - TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, schemeShard, sender); -} - -void EnableBackgroundCompactionViaRestart( - TTestActorRuntime& runtime, - TTestEnv&, - ui64 schemeShard, - bool enableServerless) -{ - // turn on background compaction and restart to apply + + // little hack to simplify life + auto& compactionConfig = runtime.GetAppData().CompactionConfig; + compactionConfig.MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); + + TActorId sender = runtime.AllocateEdgeActor(); + RebootTablet(runtime, schemeShard, sender); +} + +void EnableBackgroundCompactionViaRestart( + TTestActorRuntime& runtime, + TTestEnv&, + ui64 schemeShard, + bool enableServerless) +{ + // turn on background compaction and restart to apply runtime.GetAppData().FeatureFlags.SetEnableBackgroundCompactionForTest(true); runtime.GetAppData().FeatureFlags.SetEnableBackgroundCompactionServerlessForTest(enableServerless); - - // little hack to simplify life - auto& compactionConfig = runtime.GetAppData().CompactionConfig; - compactionConfig.MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); - - TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, schemeShard, sender); -} - -ui64 GetCompactionsCount( - TTestActorRuntime &runtime, - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - ui64 tabletId, - ui64 ownerId) -{ - auto sender = runtime.AllocateEdgeActor(); - - auto request = MakeHolder<TEvDataShard::TEvGetCompactTableStats>(ownerId, userTable.GetPathId()); - runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); - - TAutoPtr<IEventHandle> handle; - auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetCompactTableStatsResult>(handle); - UNIT_ASSERT(response->Record.HasBackgroundCompactionRequests()); - - return response->Record.GetBackgroundCompactionRequests(); -} - -ui64 GetCompactionsCount( - TTestActorRuntime &runtime, - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - const TVector<ui64>& shards, - ui64 ownerId) -{ - ui64 compactionsCount = 0; - for (auto shard: shards) { - compactionsCount += GetCompactionsCount( - runtime, - userTable, - shard, - ownerId); - } - - return compactionsCount; -} - -void CheckShardCompacted( - TTestActorRuntime &runtime, - const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, - ui64 tabletId, - ui64 ownerId, - bool shouldCompacted = true) -{ - auto count = GetCompactionsCount( - runtime, - userTable, - tabletId, - ownerId); - - if (shouldCompacted) { - UNIT_ASSERT(count > 0); - } else { - UNIT_ASSERT_VALUES_EQUAL(count, 0UL); - } -} - -void CheckNoCompactions( - TTestActorRuntime &runtime, - TTestEnv& env, - ui64 schemeshardId, - const TString& path) -{ + + // little hack to simplify life + auto& compactionConfig = runtime.GetAppData().CompactionConfig; + compactionConfig.MutableBackgroundCompactionConfig()->SetSearchHeightThreshold(0); + + TActorId sender = runtime.AllocateEdgeActor(); + RebootTablet(runtime, schemeShard, sender); +} + +ui64 GetCompactionsCount( + TTestActorRuntime &runtime, + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + ui64 tabletId, + ui64 ownerId) +{ + auto sender = runtime.AllocateEdgeActor(); + + auto request = MakeHolder<TEvDataShard::TEvGetCompactTableStats>(ownerId, userTable.GetPathId()); + runtime.SendToPipe(tabletId, sender, request.Release(), 0, GetPipeConfigWithRetries()); + + TAutoPtr<IEventHandle> handle; + auto response = runtime.GrabEdgeEventRethrow<TEvDataShard::TEvGetCompactTableStatsResult>(handle); + UNIT_ASSERT(response->Record.HasBackgroundCompactionRequests()); + + return response->Record.GetBackgroundCompactionRequests(); +} + +ui64 GetCompactionsCount( + TTestActorRuntime &runtime, + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + const TVector<ui64>& shards, + ui64 ownerId) +{ + ui64 compactionsCount = 0; + for (auto shard: shards) { + compactionsCount += GetCompactionsCount( + runtime, + userTable, + shard, + ownerId); + } + + return compactionsCount; +} + +void CheckShardCompacted( + TTestActorRuntime &runtime, + const NKikimrTxDataShard::TEvGetInfoResponse::TUserTable& userTable, + ui64 tabletId, + ui64 ownerId, + bool shouldCompacted = true) +{ + auto count = GetCompactionsCount( + runtime, + userTable, + tabletId, + ownerId); + + if (shouldCompacted) { + UNIT_ASSERT(count > 0); + } else { + UNIT_ASSERT_VALUES_EQUAL(count, 0UL); + } +} + +void CheckNoCompactions( + TTestActorRuntime &runtime, + TTestEnv& env, + ui64 schemeshardId, + const TString& path) +{ auto description = DescribePrivatePath(runtime, schemeshardId, path, true, true); - TVector<ui64> shards; - for (auto &part : description.GetPathDescription().GetTablePartitions()) - shards.push_back(part.GetDatashardId()); - - UNIT_ASSERT(!shards.empty()); - - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - auto [tables, ownerId] = GetTables(runtime, shards.at(0)); - - auto userTableName = TStringBuf(path).RNextTok('/'); - const auto& userTable = tables[userTableName]; - - auto count1 = GetCompactionsCount( - runtime, - userTable, - shards, - ownerId); - - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - auto count2 = GetCompactionsCount( - runtime, - userTable, - shards, - ownerId); - - UNIT_ASSERT_VALUES_EQUAL(count1, count2); -} - -template<typename F> -void TestBackgroundCompaction( - TTestActorRuntime& runtime, - TTestEnv& env, - F&& enableBackgroundCompactionFunc) -{ - ui64 txId = 1000; - - TestCreateTable(runtime, ++txId, "/MyRoot", - R"____( - Name: "Simple" - Columns { Name: "key1" Type: "Uint32"} - Columns { Name: "Value" Type: "Utf8"} - KeyColumnNames: ["key1"] - UniformPartitionsCount: 2 - )____"); - env.TestWaitNotification(runtime, txId); - - enableBackgroundCompactionFunc(runtime, env); - + TVector<ui64> shards; + for (auto &part : description.GetPathDescription().GetTablePartitions()) + shards.push_back(part.GetDatashardId()); + + UNIT_ASSERT(!shards.empty()); + + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + auto [tables, ownerId] = GetTables(runtime, shards.at(0)); + + auto userTableName = TStringBuf(path).RNextTok('/'); + const auto& userTable = tables[userTableName]; + + auto count1 = GetCompactionsCount( + runtime, + userTable, + shards, + ownerId); + + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + auto count2 = GetCompactionsCount( + runtime, + userTable, + shards, + ownerId); + + UNIT_ASSERT_VALUES_EQUAL(count1, count2); +} + +template<typename F> +void TestBackgroundCompaction( + TTestActorRuntime& runtime, + TTestEnv& env, + F&& enableBackgroundCompactionFunc) +{ + ui64 txId = 1000; + + TestCreateTable(runtime, ++txId, "/MyRoot", + R"____( + Name: "Simple" + Columns { Name: "key1" Type: "Uint32"} + Columns { Name: "Value" Type: "Utf8"} + KeyColumnNames: ["key1"] + UniformPartitionsCount: 2 + )____"); + env.TestWaitNotification(runtime, txId); + + enableBackgroundCompactionFunc(runtime, env); + auto description = DescribePrivatePath(runtime, "/MyRoot/Simple", true, true); - TVector<ui64> shards; - for (auto &part : description.GetPathDescription().GetTablePartitions()) - shards.push_back(part.GetDatashardId()); - - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - auto [tables, ownerId] = GetTables(runtime, shards.at(0)); - - for (auto shard: shards) - CheckShardCompacted(runtime, tables["Simple"], shard, ownerId); -} - -ui64 TestServerless( - TTestActorRuntime& runtime, - TTestEnv& env, - bool enableServerless) -{ - ui64 txId = 100; - ui64 schemeshardId = TTestTxConfig::SchemeShard; - - TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", R"( - Name: "Shared" - )"); - env.TestWaitNotification(runtime, txId); - - TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( - PlanResolution: 50 - Coordinators: 1 - Mediators: 1 - TimeCastBucketsPerMediator: 2 - ExternalSchemeShard: true - Name: "Shared" - StoragePools { - Name: "name_User_kind_hdd-1" - Kind: "common" - } - StoragePools { - Name: "name_User_kind_hdd-2" - Kind: "external" - } - )"); - env.TestWaitNotification(runtime, txId); - - const auto attrs = AlterUserAttrs({ - {"cloud_id", "CLOUD_ID_VAL"}, - {"folder_id", "FOLDER_ID_VAL"}, - {"database_id", "DATABASE_ID_VAL"} - }); - - TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( - Name: "User" - ResourcesDomainKey { - SchemeShard: %lu - PathId: 2 - } - )", schemeshardId), attrs); - env.TestWaitNotification(runtime, txId); - - TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( - PlanResolution: 50 - Coordinators: 1 - Mediators: 1 - TimeCastBucketsPerMediator: 2 - ExternalSchemeShard: true - ExternalHive: false - Name: "User" - StoragePools { - Name: "name_User_kind_hdd-1" - Kind: "common" - } - StoragePools { - Name: "name_User_kind_hdd-2" - Kind: "external" - } - )"); - env.TestWaitNotification(runtime, txId); - - TestDescribeResult(DescribePath(runtime, "/MyRoot/User"), { - NLs::PathExist, - NLs::ExtractTenantSchemeshard(&schemeshardId) - }); - - TestCreateTable(runtime, schemeshardId, ++txId, "/MyRoot/User", - R"____( - Name: "Simple" - Columns { Name: "key1" Type: "Uint32"} - Columns { Name: "Value" Type: "Utf8"} - KeyColumnNames: ["key1"] - UniformPartitionsCount: 2 - )____"); - env.TestWaitNotification(runtime, txId, schemeshardId); - - // turn on background compaction - EnableBackgroundCompactionViaRestart(runtime, env, schemeshardId, enableServerless); - + TVector<ui64> shards; + for (auto &part : description.GetPathDescription().GetTablePartitions()) + shards.push_back(part.GetDatashardId()); + + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + auto [tables, ownerId] = GetTables(runtime, shards.at(0)); + + for (auto shard: shards) + CheckShardCompacted(runtime, tables["Simple"], shard, ownerId); +} + +ui64 TestServerless( + TTestActorRuntime& runtime, + TTestEnv& env, + bool enableServerless) +{ + ui64 txId = 100; + ui64 schemeshardId = TTestTxConfig::SchemeShard; + + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", R"( + Name: "Shared" + )"); + env.TestWaitNotification(runtime, txId); + + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( + PlanResolution: 50 + Coordinators: 1 + Mediators: 1 + TimeCastBucketsPerMediator: 2 + ExternalSchemeShard: true + Name: "Shared" + StoragePools { + Name: "name_User_kind_hdd-1" + Kind: "common" + } + StoragePools { + Name: "name_User_kind_hdd-2" + Kind: "external" + } + )"); + env.TestWaitNotification(runtime, txId); + + const auto attrs = AlterUserAttrs({ + {"cloud_id", "CLOUD_ID_VAL"}, + {"folder_id", "FOLDER_ID_VAL"}, + {"database_id", "DATABASE_ID_VAL"} + }); + + TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( + Name: "User" + ResourcesDomainKey { + SchemeShard: %lu + PathId: 2 + } + )", schemeshardId), attrs); + env.TestWaitNotification(runtime, txId); + + TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", R"( + PlanResolution: 50 + Coordinators: 1 + Mediators: 1 + TimeCastBucketsPerMediator: 2 + ExternalSchemeShard: true + ExternalHive: false + Name: "User" + StoragePools { + Name: "name_User_kind_hdd-1" + Kind: "common" + } + StoragePools { + Name: "name_User_kind_hdd-2" + Kind: "external" + } + )"); + env.TestWaitNotification(runtime, txId); + + TestDescribeResult(DescribePath(runtime, "/MyRoot/User"), { + NLs::PathExist, + NLs::ExtractTenantSchemeshard(&schemeshardId) + }); + + TestCreateTable(runtime, schemeshardId, ++txId, "/MyRoot/User", + R"____( + Name: "Simple" + Columns { Name: "key1" Type: "Uint32"} + Columns { Name: "Value" Type: "Utf8"} + KeyColumnNames: ["key1"] + UniformPartitionsCount: 2 + )____"); + env.TestWaitNotification(runtime, txId, schemeshardId); + + // turn on background compaction + EnableBackgroundCompactionViaRestart(runtime, env, schemeshardId, enableServerless); + auto description = DescribePrivatePath(runtime, schemeshardId, "/MyRoot/User/Simple", true, true); - TVector<ui64> shards; - for (auto &part : description.GetPathDescription().GetTablePartitions()) - shards.push_back(part.GetDatashardId()); - - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - auto [tables, ownerId] = GetTables(runtime, shards.at(0)); - - for (auto shard: shards) - CheckShardCompacted(runtime, tables["Simple"], shard, ownerId, enableServerless); - - return schemeshardId; -} - -} // namespace - -Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCompactionTest) { - Y_UNIT_TEST(SchemeshardShouldRequestCompactionsSchemeshardRestart) { - // enabled via schemeshard restart - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - // disable for the case, when compaction is enabled by default - DisableBackgroundCompactionViaRestart(runtime, env, TTestTxConfig::SchemeShard); - - TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { - EnableBackgroundCompactionViaRestart(runtime, env, TTestTxConfig::SchemeShard, false); - }); - } - - Y_UNIT_TEST(SchemeshardShouldRequestCompactionsConfigRequest) { - // enabled via configuration change - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - // disable for the case, when compaction is enabled by default - SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); - - TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { - SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, true); - }); - } - - Y_UNIT_TEST(SchemeshardShouldNotRequestCompactionsAfterDisable) { - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - // disable for the case, when compaction is enabled by default - SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); - - TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { - SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, true); - }); - - // disable - SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); - - // some time to finish compactions in progress - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - CheckNoCompactions(runtime, env, TTestTxConfig::SchemeShard, "/MyRoot/Simple"); - } - - Y_UNIT_TEST(ShouldNotCompactServerless) { - // enable regular background compaction, but not serverless - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - TestServerless(runtime, env, false); - } - - Y_UNIT_TEST(ShouldCompactServerless) { - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - TestServerless(runtime, env, true); - } - - Y_UNIT_TEST(ShouldNotCompactServerlessAfterDisable) { - TTestBasicRuntime runtime; - TTestEnv env(runtime); - - runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); - runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); - runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); - - auto schemeshardId = TestServerless(runtime, env, true); - - // disable - SetBackgroundCompactionServerless(runtime, env, schemeshardId, false); - - // some time to finish compactions in progress - env.SimulateSleep(runtime, TDuration::Seconds(30)); - - CheckNoCompactions(runtime, env, schemeshardId, "/MyRoot/User/Simple"); - } -} + TVector<ui64> shards; + for (auto &part : description.GetPathDescription().GetTablePartitions()) + shards.push_back(part.GetDatashardId()); + + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + auto [tables, ownerId] = GetTables(runtime, shards.at(0)); + + for (auto shard: shards) + CheckShardCompacted(runtime, tables["Simple"], shard, ownerId, enableServerless); + + return schemeshardId; +} + +} // namespace + +Y_UNIT_TEST_SUITE(TSchemeshardBackgroundCompactionTest) { + Y_UNIT_TEST(SchemeshardShouldRequestCompactionsSchemeshardRestart) { + // enabled via schemeshard restart + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + // disable for the case, when compaction is enabled by default + DisableBackgroundCompactionViaRestart(runtime, env, TTestTxConfig::SchemeShard); + + TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { + EnableBackgroundCompactionViaRestart(runtime, env, TTestTxConfig::SchemeShard, false); + }); + } + + Y_UNIT_TEST(SchemeshardShouldRequestCompactionsConfigRequest) { + // enabled via configuration change + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + // disable for the case, when compaction is enabled by default + SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); + + TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { + SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, true); + }); + } + + Y_UNIT_TEST(SchemeshardShouldNotRequestCompactionsAfterDisable) { + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + // disable for the case, when compaction is enabled by default + SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); + + TestBackgroundCompaction(runtime, env, [](auto& runtime, auto& env) { + SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, true); + }); + + // disable + SetBackgroundCompaction(runtime, env, TTestTxConfig::SchemeShard, false); + + // some time to finish compactions in progress + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + CheckNoCompactions(runtime, env, TTestTxConfig::SchemeShard, "/MyRoot/Simple"); + } + + Y_UNIT_TEST(ShouldNotCompactServerless) { + // enable regular background compaction, but not serverless + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + TestServerless(runtime, env, false); + } + + Y_UNIT_TEST(ShouldCompactServerless) { + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + TestServerless(runtime, env, true); + } + + Y_UNIT_TEST(ShouldNotCompactServerlessAfterDisable) { + TTestBasicRuntime runtime; + TTestEnv env(runtime); + + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); + runtime.SetLogPriority(NKikimrServices::TX_PROXY, NLog::PRI_DEBUG); + runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE); + + auto schemeshardId = TestServerless(runtime, env, true); + + // disable + SetBackgroundCompactionServerless(runtime, env, schemeshardId, false); + + // some time to finish compactions in progress + env.SimulateSleep(runtime, TDuration::Seconds(30)); + + CheckNoCompactions(runtime, env, schemeshardId, "/MyRoot/User/Simple"); + } +} diff --git a/ydb/core/tx/schemeshard/ut_compaction/ya.make b/ydb/core/tx/schemeshard/ut_compaction/ya.make index 591dc4b2c80..c4d629df4d6 100644 --- a/ydb/core/tx/schemeshard/ut_compaction/ya.make +++ b/ydb/core/tx/schemeshard/ut_compaction/ya.make @@ -1,37 +1,37 @@ UNITTEST_FOR(ydb/core/tx/schemeshard) - -OWNER( - eivanov89 - g:kikimr -) - -FORK_SUBTESTS() - -SPLIT_FACTOR(10) - -IF (SANITIZER_TYPE OR WITH_VALGRIND) - TIMEOUT(3600) - SIZE(LARGE) - TAG(ya:fat) -ELSE() - TIMEOUT(600) - SIZE(MEDIUM) -ENDIF() - -PEERDIR( + +OWNER( + eivanov89 + g:kikimr +) + +FORK_SUBTESTS() + +SPLIT_FACTOR(10) + +IF (SANITIZER_TYPE OR WITH_VALGRIND) + TIMEOUT(3600) + SIZE(LARGE) + TAG(ya:fat) +ELSE() + TIMEOUT(600) + SIZE(MEDIUM) +ENDIF() + +PEERDIR( library/cpp/getopt - library/cpp/regex/pcre + library/cpp/regex/pcre ydb/core/cms ydb/core/testlib ydb/core/tx ydb/core/tx/schemeshard/ut_helpers ydb/core/wrappers/ut_helpers -) - -SRCS( - ut_compaction.cpp -) - -YQL_LAST_ABI_VERSION() - -END() +) + +SRCS( + ut_compaction.cpp +) + +YQL_LAST_ABI_VERSION() + +END() diff --git a/ydb/core/tx/schemeshard/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export.cpp index 83af168df56..20c5353befc 100644 --- a/ydb/core/tx/schemeshard/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export.cpp @@ -21,7 +21,7 @@ namespace { ui64 txId = 100; - ui64 schemeshardId = TTestTxConfig::SchemeShard; + ui64 schemeshardId = TTestTxConfig::SchemeShard; if (dbName != "/MyRoot") { TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( Name: "%s" @@ -59,7 +59,7 @@ namespace { SchemeShard: %lu PathId: 2 } - )", TStringBuf(dbName).RNextTok('/').data(), TTestTxConfig::SchemeShard), attrs); + )", TStringBuf(dbName).RNextTok('/').data(), TTestTxConfig::SchemeShard), attrs); env.TestWaitNotification(runtime, txId); TestAlterExtSubDomain(runtime, ++txId, "/MyRoot", Sprintf(R"( @@ -597,8 +597,8 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { )"); env.TestWaitNotification(runtime, txId); - writeRow(TTestTxConfig::FakeHiveTablets, "a", "valueA"); - writeRow(TTestTxConfig::FakeHiveTablets, "b", "valueB"); + writeRow(TTestTxConfig::FakeHiveTablets, "a", "valueA"); + writeRow(TTestTxConfig::FakeHiveTablets, "b", "valueB"); runtime.SetLogPriority(NKikimrServices::S3_WRAPPER, NActors::NLog::PRI_TRACE); runtime.SetLogPriority(NKikimrServices::DATASHARD_BACKUP, NActors::NLog::PRI_TRACE); @@ -681,7 +681,7 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { runtime.SetObserverFunc(prevObserver); - RebootTablet(runtime, *tabletId, runtime.AllocateEdgeActor()); + RebootTablet(runtime, *tabletId, runtime.AllocateEdgeActor()); env.TestWaitNotification(runtime, exportId); TestGetExport(runtime, exportId, "/MyRoot", expectedStatus); @@ -753,7 +753,7 @@ Y_UNIT_TEST_SUITE(TExportToS3Tests) { env.TestWaitNotification(runtime, txId); for (int i = 1; i < 500; ++i) { - writeRow(TTestTxConfig::FakeHiveTablets, Sprintf("a%i", i), "value"); + writeRow(TTestTxConfig::FakeHiveTablets, Sprintf("a%i", i), "value"); } // trigger memtable's compaction diff --git a/ydb/core/tx/schemeshard/ut_extsubdomain.cpp b/ydb/core/tx/schemeshard/ut_extsubdomain.cpp index cb9acd85015..0fa6a27bce0 100644 --- a/ydb/core/tx/schemeshard/ut_extsubdomain.cpp +++ b/ydb/core/tx/schemeshard/ut_extsubdomain.cpp @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { "Name: \"USER_0\""); TestDescribeResult(DescribePath(runtime, "/MyRoot/dir/USER_0"), {NLs::PathExist, - NLs::DomainKey(3, TTestTxConfig::SchemeShard), + NLs::DomainKey(3, TTestTxConfig::SchemeShard), NLs::DomainCoordinators({}), NLs::DomainMediators({}), NLs::DomainSchemeshard(0)}); @@ -178,7 +178,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { UNIT_ASSERT(tenantSchemeShard != 0 && tenantSchemeShard != (ui64)-1 - && tenantSchemeShard != TTestTxConfig::SchemeShard); + && tenantSchemeShard != TTestTxConfig::SchemeShard); ui64 tenantSchemeShard2 = 0; TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/table"), @@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { TestMkDir(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "dir"); env.TestWaitNotification(runtime, txId, tenantSchemeShard); - TestDescribeResult(DescribePath(runtime, TTestTxConfig::SchemeShard, "/MyRoot/USER_0/dir"), + TestDescribeResult(DescribePath(runtime, TTestTxConfig::SchemeShard, "/MyRoot/USER_0/dir"), {NLs::PathRedirected}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/dir"), @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { UNIT_ASSERT(tenantSchemeShard != 0 && tenantSchemeShard != (ui64)-1 - && tenantSchemeShard != TTestTxConfig::SchemeShard); + && tenantSchemeShard != TTestTxConfig::SchemeShard); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, @@ -298,7 +298,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { TestUserAttrs(runtime, ++txId, "/", "MyRoot", AlterUserAttrs({{"__extra_path_symbols_allowed", lowLimits.ExtraPathSymbolsAllowed}})); env.TestWaitNotification(runtime, txId); - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", "Name: \"USER+0\"", @@ -617,8 +617,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { "} "); env.TestWaitNotification(runtime, {txId, txId - 1}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); ui64 tenantSchemeShard = 0; TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), @@ -628,7 +628,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { UNIT_ASSERT(tenantSchemeShard != 0 && tenantSchemeShard != (ui64)-1 - && tenantSchemeShard != TTestTxConfig::SchemeShard); + && tenantSchemeShard != TTestTxConfig::SchemeShard); TestMkDir(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "dir"); TestCreateTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0/dir", @@ -670,9 +670,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(SysViewProcessorSync) { @@ -731,7 +731,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { UNIT_ASSERT(tenantSchemeShard != 0 && tenantSchemeShard != (ui64)-1 - && tenantSchemeShard != TTestTxConfig::SchemeShard); + && tenantSchemeShard != TTestTxConfig::SchemeShard); UNIT_ASSERT(tenantSVP != 0 && tenantSVP != (ui64)-1); @@ -742,7 +742,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { UNIT_ASSERT_EQUAL(tenantSVP, tenantSVPOnTSS); - RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); TestCreateTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "Name: \"table\"" @@ -755,7 +755,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/table"), {NLs::PathExist}); - RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, @@ -854,7 +854,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardExtSubDomainTest) { // Quotas consuption is persistent, on reboot they should stay consumed { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, tenantSchemeShard, sender); + RebootTablet(runtime, tenantSchemeShard, sender); } TestCreateTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", R"( Name: "Table7" diff --git a/ydb/core/tx/schemeshard/ut_extsubdomain_reboots.cpp b/ydb/core/tx/schemeshard/ut_extsubdomain_reboots.cpp index c367bc00cfc..cf819403e8f 100644 --- a/ydb/core/tx/schemeshard/ut_extsubdomain_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_extsubdomain_reboots.cpp @@ -26,15 +26,15 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), - NLs::DomainKey(3, TTestTxConfig::SchemeShard), + NLs::DomainKey(3, TTestTxConfig::SchemeShard), NLs::DomainCoordinators({}), NLs::DomainMediators({}), NLs::DomainSchemeshard(0) }); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::ChildrenCount(2)}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); } TestAlterExtSubDomain(runtime, ++t.TxId, "/MyRoot", @@ -55,19 +55,19 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), - NLs::DomainKey(3, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets+5) + NLs::DomainKey(3, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets+5) }); - TestDescribeResult(DescribePath(runtime, TTestTxConfig::FakeHiveTablets+5, "/MyRoot/USER_0"), + TestDescribeResult(DescribePath(runtime, TTestTxConfig::FakeHiveTablets+5, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(3, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets+5) + NLs::DomainKey(3, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+4}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets+5) }); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::ChildrenCount(2)}); @@ -92,8 +92,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { {NLs::PathNotExist}); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::ChildrenCount(1)}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { {NKikimrScheme::StatusAccepted}); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); { TInactiveZone inactive(activeZone); @@ -132,8 +132,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::ChildrenCount(1)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3, 4, 5, 6}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -181,14 +181,14 @@ Y_UNIT_TEST_SUITE(TSchemeShardTestExtSubdomainReboots) { {NLs::ChildrenCount(2), NLs::DomainLimitsIs(limits.MaxPaths, limits.MaxShards)}); - ui64 extSchemeSahrd = TTestTxConfig::FakeHiveTablets+2; + ui64 extSchemeSahrd = TTestTxConfig::FakeHiveTablets+2; - TestDescribeResult(DescribePath(runtime, TTestTxConfig::FakeHiveTablets+2, "/MyRoot/USER_0"), + TestDescribeResult(DescribePath(runtime, TTestTxConfig::FakeHiveTablets+2, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(3, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+1}), + NLs::DomainKey(3, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets+1}), NLs::DomainSchemeshard(extSchemeSahrd), NLs::DomainLimitsIs(limits.MaxPaths, limits.MaxShards), NLs::ShardsInsideDomain(3), diff --git a/ydb/core/tx/schemeshard/ut_filestore_reboots.cpp b/ydb/core/tx/schemeshard/ut_filestore_reboots.cpp index d12131a4da8..0fdfd871de2 100644 --- a/ydb/core/tx/schemeshard/ut_filestore_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_filestore_reboots.cpp @@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TFileStoreWithReboots) { TestForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); { TInactiveZone inactive(activeZone); @@ -224,7 +224,7 @@ Y_UNIT_TEST_SUITE(TFileStoreWithReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); TestDescribeResult(DescribePath(runtime, "/MyRoot/FS"), {NLs::PathNotExist}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+5)); } }); } diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp index 2175f8001e7..6f999b268bb 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.cpp @@ -175,7 +175,7 @@ namespace NSchemeShardUT_Private { } void AsyncModifyACL(TTestActorRuntime& runtime, ui64 txId, TString parentPath, TString name, const TString& diffAcl, const TString& newOwner) { - return AsyncModifyACL(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, diffAcl, newOwner); + return AsyncModifyACL(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, diffAcl, newOwner); } void TestModifyACL(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, TString parentPath, TString name, @@ -188,7 +188,7 @@ namespace NSchemeShardUT_Private { void TestModifyACL(TTestActorRuntime& runtime, ui64 txId, TString parentPath, TString name, const TString& diffAcl, const TString& newOwner, TEvSchemeShard::EStatus expectedResult) { - TestModifyACL(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, diffAcl, newOwner, expectedResult); + TestModifyACL(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, diffAcl, newOwner, expectedResult); } @@ -198,7 +198,7 @@ namespace NSchemeShardUT_Private { TActorId sender = runtime.AllocateEdgeActor(); auto evLs = new TEvSchemeShard::TEvDescribeScheme(path); evLs->Record.MutableOptions()->CopyFrom(opts); - ForwardToTablet(runtime, schemeShard, sender, evLs); + ForwardToTablet(runtime, schemeShard, sender, evLs); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvSchemeShard::TEvDescribeSchemeResult>(handle); UNIT_ASSERT(event); @@ -210,7 +210,7 @@ namespace NSchemeShardUT_Private { TActorId sender = runtime.AllocateEdgeActor(); auto evLs = new TEvSchemeShard::TEvDescribeScheme(schemeShard, pathId); evLs->Record.MutableOptions()->CopyFrom(opts); - ForwardToTablet(runtime, schemeShard, sender, evLs); + ForwardToTablet(runtime, schemeShard, sender, evLs); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvSchemeShard::TEvDescribeSchemeResult>(handle); UNIT_ASSERT(event); @@ -219,11 +219,11 @@ namespace NSchemeShardUT_Private { } NKikimrScheme::TEvDescribeSchemeResult DescribePath(TTestActorRuntime& runtime, const TString& path, const NKikimrSchemeOp::TDescribeOptions& opts) { - return DescribePath(runtime, TTestTxConfig::SchemeShard, path, opts); + return DescribePath(runtime, TTestTxConfig::SchemeShard, path, opts); } NKikimrScheme::TEvDescribeSchemeResult DescribePathId(TTestActorRuntime& runtime, ui64 pathId, const NKikimrSchemeOp::TDescribeOptions& opts = { }) { - return DescribePathId(runtime, TTestTxConfig::SchemeShard, pathId, opts); + return DescribePathId(runtime, TTestTxConfig::SchemeShard, pathId, opts); } NKikimrScheme::TEvDescribeSchemeResult DescribePrivatePath(TTestActorRuntime& runtime, ui64 schemeShard, const TString& path, bool returnPartitioning, bool returnBoundaries) { @@ -242,11 +242,11 @@ namespace NSchemeShardUT_Private { } NKikimrScheme::TEvDescribeSchemeResult DescribePrivatePath(TTestActorRuntime& runtime, const TString& path, bool returnPartitioning, bool returnBoundaries) { - return DescribePath(runtime, TTestTxConfig::SchemeShard, path, returnPartitioning, returnBoundaries, true); + return DescribePath(runtime, TTestTxConfig::SchemeShard, path, returnPartitioning, returnBoundaries, true); } NKikimrScheme::TEvDescribeSchemeResult DescribePath(TTestActorRuntime& runtime, const TString& path, bool returnPartitioning, bool returnBoundaries, bool showPrivate, bool returnBackups) { - return DescribePath(runtime, TTestTxConfig::SchemeShard, path, returnPartitioning, returnBoundaries, showPrivate, returnBackups); + return DescribePath(runtime, TTestTxConfig::SchemeShard, path, returnPartitioning, returnBoundaries, showPrivate, returnBackups); } TPathVersion ExtructPathVersion(const NKikimrScheme::TEvDescribeSchemeResult& describe) { @@ -295,7 +295,7 @@ namespace NSchemeShardUT_Private { } TEvSchemeShard::TEvModifySchemeTransaction* CopyTableRequest(ui64 txId, const TString& dstPath, const TString& dstName, const TString& srcFullName, TApplyIf applyIf) { - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateTable); transaction->SetWorkingDir(dstPath); @@ -311,12 +311,12 @@ namespace NSchemeShardUT_Private { void AsyncCopyTable(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& dstPath, const TString& dstName, const TString& srcFullName) { TActorId sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, schemeShardId, sender, CopyTableRequest(txId, dstPath, dstName, srcFullName)); + ForwardToTablet(runtime, schemeShardId, sender, CopyTableRequest(txId, dstPath, dstName, srcFullName)); } void AsyncCopyTable(TTestActorRuntime& runtime, ui64 txId, const TString& dstPath, const TString& dstName, const TString& srcFullName) { - AsyncCopyTable(runtime, TTestTxConfig::SchemeShard, txId, dstPath, dstName, srcFullName); + AsyncCopyTable(runtime, TTestTxConfig::SchemeShard, txId, dstPath, dstName, srcFullName); } void TestCopyTable(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, @@ -329,7 +329,7 @@ namespace NSchemeShardUT_Private { void TestCopyTable(TTestActorRuntime& runtime, ui64 txId, const TString& dstPath, const TString& dstName, const TString& srcFullName, TEvSchemeShard::EStatus expectedResult) { - TestCopyTable(runtime, TTestTxConfig::SchemeShard, txId, dstPath, dstName, srcFullName, expectedResult); + TestCopyTable(runtime, TTestTxConfig::SchemeShard, txId, dstPath, dstName, srcFullName, expectedResult); } TString TestDescribe(TTestActorRuntime& runtime, const TString& path) { @@ -352,11 +352,11 @@ namespace NSchemeShardUT_Private { void AsyncMoveTable(TTestActorRuntime& runtime, ui64 txId, const TString& srcPath, const TString& dstPath, ui64 schemeShard) { TActorId sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, schemeShard, sender, MoveTableRequest(txId, srcPath, dstPath, schemeShard)); + ForwardToTablet(runtime, schemeShard, sender, MoveTableRequest(txId, srcPath, dstPath, schemeShard)); } void TestMoveTable(TTestActorRuntime& runtime, ui64 txId, const TString& src, const TString& dst, const TVector<TEvSchemeShard::EStatus>& expectedResults) { - TestMoveTable(runtime, TTestTxConfig::SchemeShard, txId, src, dst, expectedResults); + TestMoveTable(runtime, TTestTxConfig::SchemeShard, txId, src, dst, expectedResults); } void TestMoveTable(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, const TString& src, const TString& dst, const TVector<TEvSchemeShard::EStatus>& expectedResults) { @@ -366,7 +366,7 @@ namespace NSchemeShardUT_Private { TEvSchemeShard::TEvModifySchemeTransaction* LockRequest(ui64 txId, const TString &parentPath, const TString& name) { - THolder<TEvSchemeShard::TEvModifySchemeTransaction> evTx = MakeHolder<TEvSchemeShard::TEvModifySchemeTransaction>(txId, TTestTxConfig::SchemeShard); + THolder<TEvSchemeShard::TEvModifySchemeTransaction> evTx = MakeHolder<TEvSchemeShard::TEvModifySchemeTransaction>(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateLockForIndexBuild); transaction->SetWorkingDir(parentPath); @@ -377,11 +377,11 @@ namespace NSchemeShardUT_Private { void AsyncLock(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, const TString& parentPath, const TString& name) { TActorId sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, schemeShard, sender, LockRequest(txId, parentPath, name)); + ForwardToTablet(runtime, schemeShard, sender, LockRequest(txId, parentPath, name)); } void AsyncLock(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& name) { - AsyncLock(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name); + AsyncLock(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name); } void TestLock(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, const TString& parentPath, const TString& name, @@ -392,11 +392,11 @@ namespace NSchemeShardUT_Private { void TestLock(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& name, const TVector<TEvSchemeShard::EStatus> expectedResults) { - TestLock(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, expectedResults); + TestLock(runtime, TTestTxConfig::SchemeShard, txId, parentPath, name, expectedResults); } TEvSchemeShard::TEvModifySchemeTransaction* UnlockRequest(ui64 txId, ui64 lockId, const TString &parentPath, const TString& name) { - THolder<TEvSchemeShard::TEvModifySchemeTransaction> evTx = MakeHolder<TEvSchemeShard::TEvModifySchemeTransaction>(txId, TTestTxConfig::SchemeShard); + THolder<TEvSchemeShard::TEvModifySchemeTransaction> evTx = MakeHolder<TEvSchemeShard::TEvModifySchemeTransaction>(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpDropLock); transaction->SetWorkingDir(parentPath); @@ -409,11 +409,11 @@ namespace NSchemeShardUT_Private { void AsyncUnlock(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, ui64 lockId, const TString& parentPath, const TString& name) { TActorId sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, schemeShard, sender, UnlockRequest(txId, lockId, parentPath, name)); + ForwardToTablet(runtime, schemeShard, sender, UnlockRequest(txId, lockId, parentPath, name)); } void AsyncUnlock(TTestActorRuntime& runtime, ui64 txId, ui64 lockId,const TString& parentPath, const TString& name) { - AsyncUnlock(runtime, TTestTxConfig::SchemeShard, txId, lockId, parentPath, name); + AsyncUnlock(runtime, TTestTxConfig::SchemeShard, txId, lockId, parentPath, name); } void TestUnlock(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, ui64 lockId, const TString& parentPath, const TString& name, @@ -424,7 +424,7 @@ namespace NSchemeShardUT_Private { void TestUnlock(TTestActorRuntime& runtime, ui64 txId, ui64 lockId, const TString& parentPath, const TString& name, const TVector<TEvSchemeShard::EStatus> expectedResults) { - TestUnlock(runtime, TTestTxConfig::SchemeShard, txId, lockId, parentPath, name, expectedResults); + TestUnlock(runtime, TTestTxConfig::SchemeShard, txId, lockId, parentPath, name, expectedResults); } template <typename T> @@ -590,16 +590,16 @@ namespace NSchemeShardUT_Private { } \ \ TEvTx* name##Request(ui64 txId, const TString& parentPath, const TString& scheme, const TApplyIf& applyIf) { \ - return name##Request(TTestTxConfig::SchemeShard, txId, parentPath, scheme, applyIf); \ + return name##Request(TTestTxConfig::SchemeShard, txId, parentPath, scheme, applyIf); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& parentPath, const TString& scheme, const TApplyIf& applyIf) { \ - ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), \ + ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), \ name##Request(schemeShardId, txId, parentPath, scheme, applyIf)); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& scheme, const TApplyIf& applyIf) { \ - Async##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, applyIf); \ + Async##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, applyIf); \ } \ \ ui64 Test##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& parentPath, const TString& scheme, \ @@ -612,7 +612,7 @@ namespace NSchemeShardUT_Private { ui64 Test##name(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& scheme, \ const TVector<TEvSchemeShard::EStatus>& expectedResults, const TApplyIf& applyIf) \ { \ - return Test##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, expectedResults, applyIf); \ + return Test##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, expectedResults, applyIf); \ } #define GENERIC_WITH_ATTRS_HELPERS(name, op, func) \ @@ -625,7 +625,7 @@ namespace NSchemeShardUT_Private { TEvTx* name##Request(ui64 txId, const TString& parentPath, const TString& scheme, \ const NKikimrSchemeOp::TAlterUserAttributes& userAttrs, const TApplyIf& applyIf) \ { \ - return name##Request(TTestTxConfig::SchemeShard, txId, parentPath, scheme, userAttrs, applyIf); \ + return name##Request(TTestTxConfig::SchemeShard, txId, parentPath, scheme, userAttrs, applyIf); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& parentPath, const TString& scheme, \ @@ -639,13 +639,13 @@ namespace NSchemeShardUT_Private { pbPool->SetName(pool.GetName()); \ } \ } \ - ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), req); \ + ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), req); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& scheme, \ const NKikimrSchemeOp::TAlterUserAttributes& userAttrs, const TApplyIf& applyIf) \ { \ - Async##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, userAttrs, applyIf); \ + Async##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, userAttrs, applyIf); \ } \ \ ui64 Test##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, const TString& parentPath, const TString& scheme, \ @@ -658,7 +658,7 @@ namespace NSchemeShardUT_Private { ui64 Test##name(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& scheme, \ const TVector<TEvSchemeShard::EStatus>& expectedResults, const NKikimrSchemeOp::TAlterUserAttributes& userAttrs, const TApplyIf& applyIf) \ { \ - return Test##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, expectedResults, userAttrs, applyIf); \ + return Test##name(runtime, TTestTxConfig::SchemeShard, txId, parentPath, scheme, expectedResults, userAttrs, applyIf); \ } #define DROP_BY_PATH_ID_HELPERS(name, op) \ @@ -667,16 +667,16 @@ namespace NSchemeShardUT_Private { } \ \ TEvTx* name##Request(ui64 txId, ui64 pathId, const TApplyIf& applyIf) { \ - return name##Request(TTestTxConfig::SchemeShard, txId, pathId, applyIf); \ + return name##Request(TTestTxConfig::SchemeShard, txId, pathId, applyIf); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, ui64 pathId, const TApplyIf& applyIf) { \ - ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), \ + ForwardToTablet(runtime, schemeShardId, runtime.AllocateEdgeActor(), \ name##Request(schemeShardId, txId, pathId, applyIf)); \ } \ \ void Async##name(TTestActorRuntime& runtime, ui64 txId, ui64 pathId, const TApplyIf& applyIf) { \ - Async##name(runtime, TTestTxConfig::SchemeShard, txId, pathId, applyIf); \ + Async##name(runtime, TTestTxConfig::SchemeShard, txId, pathId, applyIf); \ } \ \ ui64 Test##name(TTestActorRuntime& runtime, ui64 schemeShardId, ui64 txId, ui64 pathId, \ @@ -689,7 +689,7 @@ namespace NSchemeShardUT_Private { ui64 Test##name(TTestActorRuntime& runtime, ui64 txId, ui64 pathId, \ const TVector<TEvSchemeShard::EStatus>& expectedResults, const TApplyIf& applyIf) \ { \ - return Test##name(runtime, TTestTxConfig::SchemeShard, txId, pathId, expectedResults, applyIf); \ + return Test##name(runtime, TTestTxConfig::SchemeShard, txId, pathId, expectedResults, applyIf); \ } // subdomain @@ -811,7 +811,7 @@ namespace NSchemeShardUT_Private { const TString& mountToken, ui64 tokenVersion) { TActorId sender = runtime.AllocateEdgeActor(); - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetWorkingDir(parentPath); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAssignBlockStoreVolume); @@ -820,7 +820,7 @@ namespace NSchemeShardUT_Private { transaction->MutableAssignBlockStoreVolume()->SetNewMountToken(mountToken); transaction->MutableAssignBlockStoreVolume()->SetTokenVersion(tokenVersion); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); } void TestAssignBlockStoreVolume(TTestActorRuntime& runtime, ui64 txId, const TString& parentPath, const TString& name, @@ -839,7 +839,7 @@ namespace NSchemeShardUT_Private { void AsyncCancelTxTable(TTestActorRuntime& runtime, ui64 txId, ui64 targetTxId) { TActorId sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, CancelTxRequest(txId, targetTxId)); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, CancelTxRequest(txId, targetTxId)); } void TestCancelTxTable(TTestActorRuntime& runtime, ui64 txId, ui64 targetTxId, @@ -877,11 +877,11 @@ namespace NSchemeShardUT_Private { ev->Record.SetUserSID(userSID); } - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), ev.Release()); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), ev.Release()); } void AsyncExport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TString& requestStr, const TString& userSID) { - AsyncExport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, userSID); + AsyncExport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, userSID); } void TestExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, const TString& requestStr, const TString& userSID, @@ -895,12 +895,12 @@ namespace NSchemeShardUT_Private { void TestExport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TString& requestStr, const TString& userSID, Ydb::StatusIds::StatusCode expectedStatus) { - TestExport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, userSID, expectedStatus); + TestExport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, userSID, expectedStatus); } NKikimrExport::TEvGetExportResponse TestGetExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses) { - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvExport::TEvGetExportRequest(dbName, id)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvExport::TEvGetExportRequest(dbName, id)); TAutoPtr<IEventHandle> handle; auto ev = runtime.GrabEdgeEvent<TEvExport::TEvGetExportResponse>(handle); @@ -923,7 +923,7 @@ namespace NSchemeShardUT_Private { NKikimrExport::TEvGetExportResponse TestGetExport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses) { - return TestGetExport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatuses); + return TestGetExport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatuses); } NKikimrExport::TEvGetExportResponse TestGetExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, @@ -933,7 +933,7 @@ namespace NSchemeShardUT_Private { NKikimrExport::TEvGetExportResponse TestGetExport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, Ydb::StatusIds::StatusCode expectedStatus) { - return TestGetExport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatus); + return TestGetExport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatus); } TEvExport::TEvCancelExportRequest* CancelExportRequest(ui64 txId, const TString& dbName, ui64 exportId) { @@ -942,7 +942,7 @@ namespace NSchemeShardUT_Private { NKikimrExport::TEvCancelExportResponse TestCancelExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 txId, const TString& dbName, ui64 exportId, Ydb::StatusIds::StatusCode expectedStatus) { - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), CancelExportRequest(txId, dbName, exportId)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), CancelExportRequest(txId, dbName, exportId)); TAutoPtr<IEventHandle> handle; auto ev = runtime.GrabEdgeEvent<TEvExport::TEvCancelExportResponse>(handle); @@ -953,7 +953,7 @@ namespace NSchemeShardUT_Private { NKikimrExport::TEvCancelExportResponse TestCancelExport(TTestActorRuntime& runtime, ui64 txId, const TString& dbName, ui64 exportId, Ydb::StatusIds::StatusCode expectedStatus) { - return TestCancelExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId, expectedStatus); + return TestCancelExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId, expectedStatus); } TEvExport::TEvForgetExportRequest* ForgetExportRequest(ui64 txId, const TString& dbName, ui64 exportId) { @@ -961,11 +961,11 @@ namespace NSchemeShardUT_Private { } void AsyncForgetExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 txId, const TString& dbName, ui64 exportId) { - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), ForgetExportRequest(txId, dbName, exportId)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), ForgetExportRequest(txId, dbName, exportId)); } void AsyncForgetExport(TTestActorRuntime& runtime, ui64 txId, const TString& dbName, ui64 exportId) { - AsyncForgetExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId); + AsyncForgetExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId); } NKikimrExport::TEvForgetExportResponse TestForgetExport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 txId, const TString& dbName, ui64 exportId, @@ -981,18 +981,18 @@ namespace NSchemeShardUT_Private { NKikimrExport::TEvForgetExportResponse TestForgetExport(TTestActorRuntime& runtime, ui64 txId, const TString& dbName, ui64 exportId, Ydb::StatusIds::StatusCode expectedStatus) { - return TestForgetExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId, expectedStatus); + return TestForgetExport(runtime, TTestTxConfig::SchemeShard, txId, dbName, exportId, expectedStatus); } void AsyncImport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, const TString& requestStr) { NKikimrImport::TCreateImportRequest request; UNIT_ASSERT(google::protobuf::TextFormat::ParseFromString(requestStr, &request)); - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvImport::TEvCreateImportRequest(id, dbName, request)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvImport::TEvCreateImportRequest(id, dbName, request)); } void AsyncImport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TString& requestStr) { - AsyncImport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr); + AsyncImport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr); } void TestImport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, const TString& requestStr, @@ -1006,12 +1006,12 @@ namespace NSchemeShardUT_Private { void TestImport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TString& requestStr, Ydb::StatusIds::StatusCode expectedStatus) { - TestImport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, expectedStatus); + TestImport(runtime, TTestTxConfig::SchemeShard, id, dbName, requestStr, expectedStatus); } NKikimrImport::TEvGetImportResponse TestGetImport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses) { - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvImport::TEvGetImportRequest(dbName, id)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), new TEvImport::TEvGetImportRequest(dbName, id)); TAutoPtr<IEventHandle> handle; auto ev = runtime.GrabEdgeEvent<TEvImport::TEvGetImportResponse>(handle); @@ -1034,7 +1034,7 @@ namespace NSchemeShardUT_Private { NKikimrImport::TEvGetImportResponse TestGetImport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses) { - return TestGetImport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatuses); + return TestGetImport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatuses); } NKikimrImport::TEvGetImportResponse TestGetImport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 id, const TString& dbName, @@ -1044,7 +1044,7 @@ namespace NSchemeShardUT_Private { NKikimrImport::TEvGetImportResponse TestGetImport(TTestActorRuntime& runtime, ui64 id, const TString& dbName, Ydb::StatusIds::StatusCode expectedStatus) { - return TestGetImport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatus); + return TestGetImport(runtime, TTestTxConfig::SchemeShard, id, dbName, expectedStatus); } TEvImport::TEvCancelImportRequest* CancelImportRequest(ui64 txId, const TString& dbName, ui64 importId) { @@ -1053,7 +1053,7 @@ namespace NSchemeShardUT_Private { NKikimrImport::TEvCancelImportResponse TestCancelImport(TTestActorRuntime& runtime, ui64 schemeshardId, ui64 txId, const TString& dbName, ui64 importId, Ydb::StatusIds::StatusCode expectedStatus) { - ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), CancelImportRequest(txId, dbName, importId)); + ForwardToTablet(runtime, schemeshardId, runtime.AllocateEdgeActor(), CancelImportRequest(txId, dbName, importId)); TAutoPtr<IEventHandle> handle; auto ev = runtime.GrabEdgeEvent<TEvImport::TEvCancelImportResponse>(handle); @@ -1064,7 +1064,7 @@ namespace NSchemeShardUT_Private { NKikimrImport::TEvCancelImportResponse TestCancelImport(TTestActorRuntime& runtime, ui64 txId, const TString& dbName, ui64 importId, Ydb::StatusIds::StatusCode expectedStatus) { - return TestCancelImport(runtime, TTestTxConfig::SchemeShard, txId, dbName, importId, expectedStatus); + return TestCancelImport(runtime, TTestTxConfig::SchemeShard, txId, dbName, importId, expectedStatus); } NKikimrSchemeOp::TCreateSolomonVolume TakeTabletsFromAnotherSolomonVol(TString name, TString ls, ui32 count) { @@ -1098,7 +1098,7 @@ namespace NSchemeShardUT_Private { auto *mkql = evTx->Record.MutableProgram(); mkql->MutableProgram()->SetText(query); - ForwardToTablet(runtime, tabletId, sender, evTx); + ForwardToTablet(runtime, tabletId, sender, evTx); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvTablet::TEvLocalMKQLResponse>(handle); @@ -1155,7 +1155,7 @@ namespace NSchemeShardUT_Private { bool parseResult = ::google::protobuf::TextFormat::ParseFromString(schemeChangesStr, schemeChanges); UNIT_ASSERT_C(parseResult, "protobuf parsing failed"); - ForwardToTablet(runtime, tabletId, sender, evTx); + ForwardToTablet(runtime, tabletId, sender, evTx); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvTablet::TEvLocalSchemeTxResponse>(handle); @@ -1323,7 +1323,7 @@ namespace NSchemeShardUT_Private { } void SetSchemeshardReadOnlyMode(TTestActorRuntime& runtime, bool isReadOnly) { - ui64 schemeshardTabletId = TTestTxConfig::SchemeShard; + ui64 schemeshardTabletId = TTestTxConfig::SchemeShard; NKikimrMiniKQL::TResult result; TString err; NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, schemeshardTabletId, @@ -1339,7 +1339,7 @@ namespace NSchemeShardUT_Private { } void SetSchemeshardSchemaLimits(TTestActorRuntime& runtime, NSchemeShard::TSchemeLimits limits) { - SetSchemeshardSchemaLimits(runtime, limits, TTestTxConfig::SchemeShard); + SetSchemeshardSchemaLimits(runtime, limits, TTestTxConfig::SchemeShard); } @@ -1390,12 +1390,12 @@ namespace NSchemeShardUT_Private { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, schemeShard, sender); + RebootTablet(runtime, schemeShard, sender); } void SetSchemeshardDatabaseQuotas(TTestActorRuntime& runtime, Ydb::Cms::DatabaseQuotas databaseQuotas, ui64 domainId) { - SetSchemeshardDatabaseQuotas(runtime, databaseQuotas, domainId, TTestTxConfig::SchemeShard); + SetSchemeshardDatabaseQuotas(runtime, databaseQuotas, domainId, TTestTxConfig::SchemeShard); } void SetSchemeshardDatabaseQuotas(TTestActorRuntime& runtime, Ydb::Cms::DatabaseQuotas databaseQuotas, ui64 domainId, ui64 schemeShard) { @@ -1419,7 +1419,7 @@ namespace NSchemeShardUT_Private { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, schemeShard, sender); + RebootTablet(runtime, schemeShard, sender); } @@ -1444,7 +1444,7 @@ namespace NSchemeShardUT_Private { } TEvSchemeShard::TEvModifySchemeTransaction *UpgradeSubDomainRequest(ui64 txId, const TString &parentPath, const TString &name) { - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpUpgradeSubDomain); transaction->SetWorkingDir(parentPath); @@ -1455,7 +1455,7 @@ namespace NSchemeShardUT_Private { void AsyncUpgradeSubDomain(TTestActorRuntime &runtime, ui64 txId, const TString &parentPath, const TString &name) { TActorId sender = runtime.AllocateEdgeActor(); auto evTx = UpgradeSubDomainRequest(txId, parentPath, name); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); } void TestUpgradeSubDomain(TTestActorRuntime &runtime, ui64 txId, const TString &parentPath, const TString &name, const TVector<TEvSchemeShard::EStatus> &expectedResults) { @@ -1469,7 +1469,7 @@ namespace NSchemeShardUT_Private { } TEvSchemeShard::TEvModifySchemeTransaction *UpgradeSubDomainDecisionRequest(ui64 txId, const TString &parentPath, const TString &name, NKikimrSchemeOp::TUpgradeSubDomain::EDecision decision) { - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpUpgradeSubDomainDecision); transaction->SetWorkingDir(parentPath); @@ -1481,7 +1481,7 @@ namespace NSchemeShardUT_Private { void AsyncUpgradeSubDomainDecision(TTestActorRuntime &runtime, ui64 txId, const TString &parentPath, const TString &name, NKikimrSchemeOp::TUpgradeSubDomain::EDecision decision) { TActorId sender = runtime.AllocateEdgeActor(); auto evTx = UpgradeSubDomainDecisionRequest(txId, parentPath, name, decision); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evTx); } void TestUpgradeSubDomainDecision(TTestActorRuntime &runtime, ui64 txId, const TString &parentPath, const TString &name, const TVector<TEvSchemeShard::EStatus> &expectedResults, NKikimrSchemeOp::TUpgradeSubDomain::EDecision decision) { @@ -1562,7 +1562,7 @@ namespace NSchemeShardUT_Private { auto sender = runtime.AllocateEdgeActor(); auto request = CreateBuildIndexRequest(id, dbName, src, cfg); - ForwardToTablet(runtime, schemeShard, sender, request); + ForwardToTablet(runtime, schemeShard, sender, request); } void AsyncBuilIndex(TTestActorRuntime& runtime, ui64 id, ui64 schemeShard, const TString &dbName, @@ -1626,7 +1626,7 @@ namespace NSchemeShardUT_Private { auto sender = runtime.AllocateEdgeActor(); auto request = CreateCancelBuildIndexRequest(id, dbName, buildIndexId); - ForwardToTablet(runtime, schemeShard, sender, request); + ForwardToTablet(runtime, schemeShard, sender, request); TAutoPtr<IEventHandle> handle; TEvIndexBuilder::TEvCancelResponse* event = runtime.GrabEdgeEvent<TEvIndexBuilder::TEvCancelResponse>(handle); @@ -1647,7 +1647,7 @@ namespace NSchemeShardUT_Private { auto sender = runtime.AllocateEdgeActor(); auto request = ListBuildIndexRequest(dbName); - ForwardToTablet(runtime, schemeShard, sender, request); + ForwardToTablet(runtime, schemeShard, sender, request); TAutoPtr<IEventHandle> handle; TEvIndexBuilder::TEvListResponse* event = runtime.GrabEdgeEvent<TEvIndexBuilder::TEvListResponse>(handle); @@ -1666,7 +1666,7 @@ namespace NSchemeShardUT_Private { auto sender = runtime.AllocateEdgeActor(); auto request = GetBuildIndexRequest(dbName, id); - ForwardToTablet(runtime, schemeShard, sender, request); + ForwardToTablet(runtime, schemeShard, sender, request); TAutoPtr<IEventHandle> handle; TEvIndexBuilder::TEvGetResponse* event = runtime.GrabEdgeEvent<TEvIndexBuilder::TEvGetResponse>(handle); @@ -1692,7 +1692,7 @@ namespace NSchemeShardUT_Private { auto sender = runtime.AllocateEdgeActor(); auto request = ForgetBuildIndexRequest(id, dbName, buildIndexId); - ForwardToTablet(runtime, schemeShard, sender, request); + ForwardToTablet(runtime, schemeShard, sender, request); TAutoPtr<IEventHandle> handle; TEvIndexBuilder::TEvForgetResponse* event = runtime.GrabEdgeEvent<TEvIndexBuilder::TEvForgetResponse>(handle); @@ -1708,7 +1708,7 @@ namespace NSchemeShardUT_Private { TTestActorRuntime& runtime, ui64 tabletId, NKikimrScheme::TEvFindTabletSubDomainPathIdResult::EStatus expected) { - return TestFindTabletSubDomainPathId(runtime, TTestTxConfig::SchemeShard, tabletId, expected); + return TestFindTabletSubDomainPathId(runtime, TTestTxConfig::SchemeShard, tabletId, expected); } TPathId TestFindTabletSubDomainPathId( @@ -1716,7 +1716,7 @@ namespace NSchemeShardUT_Private { NKikimrScheme::TEvFindTabletSubDomainPathIdResult::EStatus expected) { auto sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, schemeShard, sender, new TEvSchemeShard::TEvFindTabletSubDomainPathId(tabletId)); + ForwardToTablet(runtime, schemeShard, sender, new TEvSchemeShard::TEvFindTabletSubDomainPathId(tabletId)); auto ev = runtime.GrabEdgeEvent<TEvSchemeShard::TEvFindTabletSubDomainPathIdResult>(sender); UNIT_ASSERT(ev); @@ -1733,7 +1733,7 @@ namespace NSchemeShardUT_Private { } TEvSchemeShard::TEvModifySchemeTransaction* CreateAlterLoginCreateUser(ui64 txId, const TString& user, const TString& password) { - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(txId, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterLogin); auto createUser = transaction->MutableAlterLogin()->MutableCreateUser(); @@ -1747,7 +1747,7 @@ namespace NSchemeShardUT_Private { auto evLogin = new TEvSchemeShard::TEvLogin(); evLogin->Record.SetUser(user); evLogin->Record.SetPassword(password); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evLogin); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, evLogin); TAutoPtr<IEventHandle> handle; auto event = runtime.GrabEdgeEvent<TEvSchemeShard::TEvLoginResult>(handle); UNIT_ASSERT(event); @@ -2029,7 +2029,7 @@ namespace NSchemeShardUT_Private { } void AsyncSendTransaction(TTestActorRuntime &runtime, ui64 schemeShard, TEvSchemeShard::TEvModifySchemeTransaction *evTx) { - ForwardToTablet(runtime, schemeShard, runtime.AllocateEdgeActor(), evTx); + ForwardToTablet(runtime, schemeShard, runtime.AllocateEdgeActor(), evTx); } TTestActorRuntimeBase::TEventObserver SetSuppressObserver(TTestActorRuntime &runtime, TVector<THolder<IEventHandle> > &suppressed, ui32 type) { diff --git a/ydb/core/tx/schemeshard/ut_helpers/helpers.h b/ydb/core/tx/schemeshard/ut_helpers/helpers.h index 9a7b0d544de..6b12c25534a 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/helpers.h +++ b/ydb/core/tx/schemeshard/ut_helpers/helpers.h @@ -238,8 +238,8 @@ namespace NSchemeShardUT_Private { void TestCopyTable(TTestActorRuntime& runtime, ui64 txId, const TString& dstPath, const TString& dstName, const TString& srcFullName, TEvSchemeShard::EStatus expectedResult = NKikimrScheme::StatusAccepted); // move table - TEvTx* MoveTableRequest(ui64 txId, const TString& srcPath, const TString& dstPath, ui64 schemeShard = TTestTxConfig::SchemeShard, const TApplyIf& applyIf = {}); - void AsyncMoveTable(TTestActorRuntime& runtime, ui64 txId, const TString& srcPath, const TString& dstPath, ui64 schemeShard = TTestTxConfig::SchemeShard); + TEvTx* MoveTableRequest(ui64 txId, const TString& srcPath, const TString& dstPath, ui64 schemeShard = TTestTxConfig::SchemeShard, const TApplyIf& applyIf = {}); + void AsyncMoveTable(TTestActorRuntime& runtime, ui64 txId, const TString& srcPath, const TString& dstPath, ui64 schemeShard = TTestTxConfig::SchemeShard); void TestMoveTable(TTestActorRuntime& runtime, ui64 txId, const TString& srcMove, const TString& dstMove, const TVector<TEvSchemeShard::EStatus>& expectedResults = {NKikimrScheme::StatusAccepted}); void TestMoveTable(TTestActorRuntime& runtime, ui64 schemeShard, ui64 txId, const TString& srcMove, const TString& dstMove, const TVector<TEvSchemeShard::EStatus>& expectedResults = {NKikimrScheme::StatusAccepted}); diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp index 684597c47d6..c5d6c5a973a 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp @@ -709,33 +709,33 @@ TCheckFunc PartitionCount(ui32 count) { }; } -TCheckFunc FollowerCount(ui32 count) { +TCheckFunc FollowerCount(ui32 count) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { - UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerCount(), count); + UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerCount(), count); }; } -TCheckFunc CrossDataCenterFollowerCount(ui32 count) { +TCheckFunc CrossDataCenterFollowerCount(ui32 count) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { - UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetCrossDataCenterFollowerCount(), count); + UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetCrossDataCenterFollowerCount(), count); }; } -TCheckFunc AllowFollowerPromotion(bool val) { +TCheckFunc AllowFollowerPromotion(bool val) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { - UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetAllowFollowerPromotion(), val); + UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().GetAllowFollowerPromotion(), val); }; } -TCheckFunc FollowerGroups(const TVector<NKikimrHive::TFollowerGroup>& followerGroups) { +TCheckFunc FollowerGroups(const TVector<NKikimrHive::TFollowerGroup>& followerGroups) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { - UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().FollowerGroupsSize(), followerGroups.size()); - for (size_t i = 0; i < followerGroups.size(); ++i) { - const auto& srcSG = record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerGroups(i); - const auto& dstSG = followerGroups[i]; + UNIT_ASSERT_VALUES_EQUAL(record.GetPathDescription().GetTable().GetPartitionConfig().FollowerGroupsSize(), followerGroups.size()); + for (size_t i = 0; i < followerGroups.size(); ++i) { + const auto& srcSG = record.GetPathDescription().GetTable().GetPartitionConfig().GetFollowerGroups(i); + const auto& dstSG = followerGroups[i]; - UNIT_ASSERT_VALUES_EQUAL(srcSG.GetFollowerCount(), dstSG.GetFollowerCount()); - UNIT_ASSERT_VALUES_EQUAL(srcSG.GetAllowLeaderPromotion(), dstSG.GetAllowLeaderPromotion()); + UNIT_ASSERT_VALUES_EQUAL(srcSG.GetFollowerCount(), dstSG.GetFollowerCount()); + UNIT_ASSERT_VALUES_EQUAL(srcSG.GetAllowLeaderPromotion(), dstSG.GetAllowLeaderPromotion()); UNIT_ASSERT_VALUES_EQUAL(srcSG.GetAllowClientRead(), dstSG.GetAllowClientRead()); UNIT_ASSERT_VALUES_EQUAL(srcSG.AllowedNodeIDsSize(), dstSG.AllowedNodeIDsSize()); diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h index 5fbeb1551c8..33022e42576 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h +++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h @@ -83,10 +83,10 @@ namespace NLs { void CheckBoundaries(const NKikimrScheme::TEvDescribeSchemeResult& record); TCheckFunc PartitionCount(ui32 count); TCheckFunc PartitionKeys(TVector<TString> lastShardKeys); - TCheckFunc FollowerCount(ui32 count); - TCheckFunc CrossDataCenterFollowerCount(ui32 count); - TCheckFunc AllowFollowerPromotion(bool val); - TCheckFunc FollowerGroups(const TVector<NKikimrHive::TFollowerGroup>& followerGroup = TVector<NKikimrHive::TFollowerGroup>{}); + TCheckFunc FollowerCount(ui32 count); + TCheckFunc CrossDataCenterFollowerCount(ui32 count); + TCheckFunc AllowFollowerPromotion(bool val); + TCheckFunc FollowerGroups(const TVector<NKikimrHive::TFollowerGroup>& followerGroup = TVector<NKikimrHive::TFollowerGroup>{}); TCheckFunc SizeToSplitEqual(ui32 size); TCheckFunc MinPartitionsCountEqual(ui32 count); TCheckFunc MaxPartitionsCountEqual(ui32 count); diff --git a/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp b/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp index 82ef504ca80..9cfd8037b7e 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp +++ b/ydb/core/tx/schemeshard/ut_helpers/test_env.cpp @@ -487,10 +487,10 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe , CoordinatorState(new TFakeCoordinator::TState) , ChannelsCount(opts.NChannels_) { - ui64 hive = TTestTxConfig::Hive; - ui64 schemeRoot = TTestTxConfig::SchemeShard; - ui64 coordinator = TTestTxConfig::Coordinator; - ui64 txAllocator = TTestTxConfig::TxAllocator; + ui64 hive = TTestTxConfig::Hive; + ui64 schemeRoot = TTestTxConfig::SchemeShard; + ui64 coordinator = TTestTxConfig::Coordinator; + ui64 txAllocator = TTestTxConfig::TxAllocator; TAppPrepare app(dsExportFactory ? dsExportFactory : static_cast<std::shared_ptr<NKikimr::NDataShard::IExportFactory>>(std::make_shared<TDataShardExportFactory>())); @@ -511,13 +511,13 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe app.AddSystemBackupSID(sid); } - AddDomain(runtime, app, TTestTxConfig::DomainUid, 0, hive, schemeRoot); + AddDomain(runtime, app, TTestTxConfig::DomainUid, 0, hive, schemeRoot); SetupLogging(runtime); - SetupChannelProfiles(app, TTestTxConfig::DomainUid, ChannelsCount); + SetupChannelProfiles(app, TTestTxConfig::DomainUid, ChannelsCount); for (ui32 node = 0; node < runtime.GetNodeCount(); ++node) { - SetupSchemeCache(runtime, node, app.Domains->GetDomain(TTestTxConfig::DomainUid).Name); + SetupSchemeCache(runtime, node, app.Domains->GetDomain(TTestTxConfig::DomainUid).Name); } SetupTabletServices(runtime, &app); @@ -526,13 +526,13 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe } TActorId sender = runtime.AllocateEdgeActor(); - //CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(TTestTxConfig::DomainUid), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); + //CreateTestBootstrapper(runtime, CreateTestTabletInfo(MakeBSControllerID(TTestTxConfig::DomainUid), TTabletTypes::FLAT_BS_CONTROLLER), &CreateFlatBsController); BootSchemeShard(runtime, schemeRoot); BootTxAllocator(runtime, txAllocator); BootFakeCoordinator(runtime, coordinator, CoordinatorState); BootFakeHive(runtime, hive, HiveState, &GetTabletCreationFunc); - InitRootStoragePools(runtime, schemeRoot, sender, TTestTxConfig::DomainUid); + InitRootStoragePools(runtime, schemeRoot, sender, TTestTxConfig::DomainUid); for (ui32 node = 0; node < runtime.GetNodeCount(); ++node) { IActor* txProxy = CreateTxProxy(runtime.GetTxAllocatorTabletIds()); @@ -540,7 +540,7 @@ NSchemeShardUT_Private::TTestEnv::TTestEnv(TTestActorRuntime& runtime, const TTe runtime.RegisterService(MakeTxProxyID(), txProxyId, node); } - //SetupBoxAndStoragePool(runtime, sender, TTestTxConfig::DomainUid); + //SetupBoxAndStoragePool(runtime, sender, TTestTxConfig::DomainUid); TxReliablePropose = runtime.Register(new TTxReliablePropose(schemeRoot)); CreateFakeMetering(runtime); @@ -648,7 +648,7 @@ TAutoPtr<ITabletScheduledEventsGuard> NSchemeShardUT_Private::TTestEnv::EnableSc TActorId sender = runtime.AllocateEdgeActor(); TVector<ui64> tabletIds; // Add schemeshard tabletId to white list - tabletIds.push_back((ui64)TTestTxConfig::SchemeShard); + tabletIds.push_back((ui64)TTestTxConfig::SchemeShard); return CreateTabletScheduledEventsGuard(tabletIds, runtime, sender); } @@ -707,7 +707,7 @@ void NSchemeShardUT_Private::TTestEnv::TestWaitTabletDeletion(NActors::TTestActo for (ui64 tabletId : tabletIds) { Cerr << "wait until " << tabletId << " is deleted" << Endl; auto ev = new TEvFakeHive::TEvSubscribeToTabletDeletion(tabletId); - ForwardToTablet(runtime, TTestTxConfig::Hive, sender, ev); + ForwardToTablet(runtime, TTestTxConfig::Hive, sender, ev); } TAutoPtr<IEventHandle> handle; @@ -733,7 +733,7 @@ void NSchemeShardUT_Private::TTestEnv::TestWaitShardDeletion(NActors::TTestActor for (auto shardIdx : shardIds) { Cerr << "Waiting until shard idx " << shardIdx << " is deleted" << Endl; auto ev = new TEvPrivate::TEvSubscribeToShardDeletion(shardIdx); - ForwardToTablet(runtime, schemeShard, sender, ev); + ForwardToTablet(runtime, schemeShard, sender, ev); } while (!shardIds.empty()) { @@ -753,7 +753,7 @@ void NSchemeShardUT_Private::TTestEnv::TestWaitShardDeletion(NActors::TTestActor } void NSchemeShardUT_Private::TTestEnv::TestWaitShardDeletion(NActors::TTestActorRuntime &runtime, TSet<ui64> localIds) { - TestWaitShardDeletion(runtime, TTestTxConfig::SchemeShard, std::move(localIds)); + TestWaitShardDeletion(runtime, TTestTxConfig::SchemeShard, std::move(localIds)); } void NSchemeShardUT_Private::TTestEnv::SimulateSleep(NActors::TTestActorRuntime &runtime, TDuration duration) { @@ -801,7 +801,7 @@ TEvSchemeShard::TEvInitRootShardResult::EStatus NSchemeShardUT_Private::TTestEnv void NSchemeShardUT_Private::TTestEnv::InitRootStoragePools(NActors::TTestActorRuntime &runtime, ui64 schemeRoot, const NActors::TActorId &sender, ui64 domainUid) { const TDomainsInfo::TDomain& domain = runtime.GetAppData().DomainsInfo->GetDomain(domainUid); - auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(1, TTestTxConfig::SchemeShard); + auto evTx = new TEvSchemeShard::TEvModifySchemeTransaction(1, TTestTxConfig::SchemeShard); auto transaction = evTx->Record.AddTransaction(); transaction->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterSubDomain); transaction->SetWorkingDir("/"); @@ -835,20 +835,20 @@ void NSchemeShardUT_Private::TTestEnv::InitRootStoragePools(NActors::TTestActorR void NSchemeShardUT_Private::TTestEnv::BootSchemeShard(NActors::TTestActorRuntime &runtime, ui64 schemeRoot) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(schemeRoot, TTabletTypes::FLAT_SCHEMESHARD), SchemeShardFactory); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(schemeRoot, TTabletTypes::FLAT_SCHEMESHARD), SchemeShardFactory); } void NSchemeShardUT_Private::TTestEnv::BootTxAllocator(NActors::TTestActorRuntime &runtime, ui64 tabletId) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(tabletId, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); } NSchemeShardUT_Private::TTestWithReboots::TTestWithReboots(bool killOnCommit, NSchemeShardUT_Private::TTestEnv::TSchemeShardFactory ssFactory) : EnvOpts(GetDefaultTestEnvOptions()) , SchemeShardFactory(ssFactory) - , HiveTabletId(TTestTxConfig::Hive) - , SchemeShardTabletId(TTestTxConfig::SchemeShard) - , CoordinatorTabletId(TTestTxConfig::Coordinator) - , TxAllocatorId(TTestTxConfig::TxAllocator) + , HiveTabletId(TTestTxConfig::Hive) + , SchemeShardTabletId(TTestTxConfig::SchemeShard) + , CoordinatorTabletId(TTestTxConfig::Coordinator) + , TxAllocatorId(TTestTxConfig::TxAllocator) , KillOnCommit(killOnCommit) { TabletIds.push_back(HiveTabletId); @@ -856,7 +856,7 @@ NSchemeShardUT_Private::TTestWithReboots::TTestWithReboots(bool killOnCommit, NS TabletIds.push_back(SchemeShardTabletId); TabletIds.push_back(TxAllocatorId); - ui64 datashard = TTestTxConfig::FakeHiveTablets; + ui64 datashard = TTestTxConfig::FakeHiveTablets; TabletIds.push_back(datashard+0); TabletIds.push_back(datashard+1); TabletIds.push_back(datashard+2); diff --git a/ydb/core/tx/schemeshard/ut_helpers/test_env.h b/ydb/core/tx/schemeshard/ut_helpers/test_env.h index 1e192892c4e..72b934c570d 100644 --- a/ydb/core/tx/schemeshard/ut_helpers/test_env.h +++ b/ydb/core/tx/schemeshard/ut_helpers/test_env.h @@ -75,13 +75,13 @@ namespace NSchemeShardUT_Private { ui32 ReliablePropose(TTestActorRuntime& runtime, TEvExport::TEvForgetExportRequest* ev, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses = {Ydb::StatusIds::SUCCESS}); ui32 ReliablePropose(TTestActorRuntime& runtime, TEvImport::TEvCancelImportRequest* ev, const TVector<Ydb::StatusIds::StatusCode>& expectedStatuses = {Ydb::StatusIds::SUCCESS}); template <class TContainer> - void TestWaitNotification(TTestActorRuntime& runtime, TContainer txs, ui64 schemeshardId = TTestTxConfig::SchemeShard) { + void TestWaitNotification(TTestActorRuntime& runtime, TContainer txs, ui64 schemeshardId = TTestTxConfig::SchemeShard) { TSet<ui64> set(txs.begin(), txs.end()); TestWaitNotification(runtime, std::move(set), schemeshardId); } - void TestWaitNotification(TTestActorRuntime& runtime, TSet<ui64> txIds, ui64 schemeshardId = TTestTxConfig::SchemeShard); - void TestWaitNotification(TTestActorRuntime& runtime, int txId, ui64 schemeshardId = TTestTxConfig::SchemeShard); - void TestWaitNotification(TTestActorRuntime& runtime, ui64 txId, ui64 schemeshardId = TTestTxConfig::SchemeShard); + void TestWaitNotification(TTestActorRuntime& runtime, TSet<ui64> txIds, ui64 schemeshardId = TTestTxConfig::SchemeShard); + void TestWaitNotification(TTestActorRuntime& runtime, int txId, ui64 schemeshardId = TTestTxConfig::SchemeShard); + void TestWaitNotification(TTestActorRuntime& runtime, ui64 txId, ui64 schemeshardId = TTestTxConfig::SchemeShard); template <class TContainer> void TestWaitTabletDeletion(TTestActorRuntime& runtime, TContainer tabletIds) { diff --git a/ydb/core/tx/schemeshard/ut_index_build.cpp b/ydb/core/tx/schemeshard/ut_index_build.cpp index 2795f820d88..88860481cc5 100644 --- a/ydb/core/tx/schemeshard/ut_index_build.cpp +++ b/ydb/core/tx/schemeshard/ut_index_build.cpp @@ -207,7 +207,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { SchemeShard: %lu PathId: 2 } - )", TTestTxConfig::SchemeShard), attrs); + )", TTestTxConfig::SchemeShard), attrs); env.TestWaitNotification(runtime, txId); TString alterData = TStringBuilder() @@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; for (ui32 delta = 0; delta < 101; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets + 6, 1 + delta, 1000 + delta, "aaaa", "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 6, 1 + delta, 1000 + delta, "aaaa", "Table"); } runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); @@ -314,7 +314,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { )"); env.TestWaitNotification(runtime, txId, tenantSchemeShard); - RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, tenantSchemeShard, runtime.AllocateEdgeActor()); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB/Table"), {NLs::PathExist, @@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { env.TestWaitNotification(runtime, txId, tenantSchemeShard); for (ui32 delta = 0; delta < 101; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets + 12, 1 + delta, 1000 + delta, "aaaa", "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 12, 1 + delta, 1000 + delta, "aaaa", "Table"); } TVector<TString> billRecords; @@ -432,7 +432,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { TVector<char> longStrData(100000, 'a'); TString longString(longStrData.begin(), longStrData.end()); for (ui32 delta = 0; delta < 1000; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, longString, "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, longString, "Table"); } runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_DEBUG); @@ -483,7 +483,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { auto request = new TEvIndexBuilder::TEvCreateRequest(++txId, "/MyRoot", std::move(settings)); auto sender = runtime.AllocateEdgeActor(); - ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, request); + ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, request); TAutoPtr<IEventHandle> handle; TEvIndexBuilder::TEvCreateResponse* event = runtime.GrabEdgeEvent<TEvIndexBuilder::TEvCreateResponse>(handle); @@ -497,12 +497,12 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { } ui64 builIndexId = txId; - auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); Y_ASSERT(listing.EntriesSize() == 1); env.TestWaitNotification(runtime, txId); - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", txId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", txId); UNIT_ASSERT_EQUAL(descr.GetIndexBuild().GetState(),Ydb::Table::IndexBuildState::STATE_REJECTED); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), @@ -513,8 +513,8 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table/index1", true, true, true), {NLs::PathNotExist}); - TestForgetBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", builIndexId); - listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + TestForgetBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", builIndexId); + listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); Y_ASSERT(listing.EntriesSize() == 0); } @@ -523,52 +523,52 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { TTestEnv env(runtime); ui64 txId = 100; - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); - NKikimrIndexBuilder::TEvListResponse listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + NKikimrIndexBuilder::TEvListResponse listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); Y_ASSERT(listing.EntriesSize() == 0); } - Y_UNIT_TEST(WithFollowers) { + Y_UNIT_TEST(WithFollowers) { TTestBasicRuntime runtime; TTestEnv env(runtime); ui64 txId = 100; TestCreateTable(runtime, ++txId, "/MyRoot", R"( - Name: "WithFollowers" + Name: "WithFollowers" Columns { Name: "key" Type: "Uint64" } Columns { Name: "value0" Type: "Utf8" } Columns { Name: "value1" Type: "Utf8" } Columns { Name: "valueFloat" Type: "Float" } KeyColumnNames: ["key"] PartitionConfig { - FollowerGroups { - FollowerCount: 1 + FollowerGroups { + FollowerCount: 1 } } )"); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/WithFollowers", "UserDefinedIndexByValue0", {"value0"}); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/WithFollowers", "UserDefinedIndexByValue0", {"value0"}); env.TestWaitNotification(runtime, txId); ui64 buildId = txId; - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_DONE); - TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers"), + TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers"), {NLs::PathExist, NLs::IndexesCount(1), NLs::PathVersionEqual(5)}); - TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers/UserDefinedIndexByValue0", true, true, true), + TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers/UserDefinedIndexByValue0", true, true, true), {NLs::PathExist, NLs::IndexState(NKikimrSchemeOp::EIndexState::EIndexStateReady)}); - TestForgetBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildId); - auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + TestForgetBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildId); + auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); Y_ASSERT(listing.EntriesSize() == 0); TestDropTableIndex(runtime, ++txId, "/MyRoot", R"( @@ -577,7 +577,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { )"); env.TestWaitNotification(runtime, txId); - TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers"), + TestDescribeResult(DescribePath(runtime, "/MyRoot/WithFollowers"), {NLs::PathExist, NLs::IndexesCount(0), NLs::PathVersionEqual(7)}); @@ -588,13 +588,13 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { TTestEnv env(runtime); ui64 txId = 100; - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/NotExist", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/NotExist", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); - TestMkDir(runtime, TTestTxConfig::SchemeShard, ++txId, "/MyRoot", "DIR"); + TestMkDir(runtime, TTestTxConfig::SchemeShard, ++txId, "/MyRoot", "DIR"); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/DIR", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/DIR", "index1", {"index"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); TestCreateIndexedTable(runtime, ++txId, "/MyRoot", R"( @@ -617,16 +617,16 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { )"); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "UserDefinedIndexByValue0", {"value0"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "UserDefinedIndexByValue0", {"value0"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "UserDefinedIndexByValue0", {"value1"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "UserDefinedIndexByValue0", {"value1"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"NotExist"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"NotExist"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"valueFloat"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"valueFloat"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); TSchemeLimits lowLimits; @@ -634,25 +634,25 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { lowLimits.ExtraPathSymbolsAllowed = "_-."; lowLimits.MaxTableIndices = 2; SetSchemeshardSchemaLimits(runtime, lowLimits); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "!name!", {"value0"}, Ydb::StatusIds::BAD_REQUEST); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "!name!", {"value0"}, Ydb::StatusIds::BAD_REQUEST); env.TestWaitNotification(runtime, txId); lowLimits.MaxTableIndices = 2; SetSchemeshardSchemaLimits(runtime, lowLimits); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::PRECONDITION_FAILED); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::PRECONDITION_FAILED); env.TestWaitNotification(runtime, txId); lowLimits.MaxTableIndices = 3; lowLimits.MaxChildrenInDir = 2; SetSchemeshardSchemaLimits(runtime, lowLimits); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::PRECONDITION_FAILED); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::PRECONDITION_FAILED); env.TestWaitNotification(runtime, txId); lowLimits.MaxTableIndices = 3; lowLimits.MaxChildrenInDir = 3; SetSchemeshardSchemaLimits(runtime, lowLimits); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::SUCCESS); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::OVERLOADED); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::SUCCESS); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"value0", "value1"}, Ydb::StatusIds::OVERLOADED); env.TestWaitNotification(runtime, {txId, txId - 1}); } @@ -671,7 +671,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { )"); env.TestWaitNotification(runtime, txId); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"index"}); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "nameOK", {"index"}); ui64 builIndexId = txId; TestAlterTable(runtime, ++txId, "/MyRoot", R"( @@ -702,7 +702,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { {NLs::PathExist, NLs::IndexState(NKikimrSchemeOp::EIndexState::EIndexStateReady)}); - NKikimrIndexBuilder::TEvGetResponse descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", builIndexId); + NKikimrIndexBuilder::TEvGetResponse descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", builIndexId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_DONE); // KIKIMR-9945 @@ -895,7 +895,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; for (ui32 delta = 0; delta < 101; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, "aaaa", "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, "aaaa", "Table"); } runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); @@ -905,17 +905,17 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { NLs::IndexesCount(0), NLs::PathVersionEqual(3)}); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}); ui64 buildIndexId = txId; - auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + auto listing = TestListBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); Y_ASSERT(listing.EntriesSize() == 1); - TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); env.TestWaitNotification(runtime, buildIndexId); - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_CANCELLED); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), @@ -958,7 +958,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK); }; for (ui32 delta = 0; delta < 101; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, "aaaa", "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 1000 + delta, "aaaa", "Table"); } runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); @@ -968,24 +968,24 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) { NLs::IndexesCount(0), NLs::PathVersionEqual(3)}); - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}); + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "index1", {"index"}); ui64 buildIndexId = txId; { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_PREPARING); } // - TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId + 1, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::NOT_FOUND}); - TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot/DirNoExist", buildIndexId, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::NOT_FOUND}); + TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId + 1, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::NOT_FOUND}); + TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot/DirNoExist", buildIndexId, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::NOT_FOUND}); env.TestWaitNotification(runtime, buildIndexId); - TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::PRECONDITION_FAILED}); + TestCancelBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::PRECONDITION_FAILED}); { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_DONE); } diff --git a/ydb/core/tx/schemeshard/ut_index_build_reboots.cpp b/ydb/core/tx/schemeshard/ut_index_build_reboots.cpp index 564ebbfc9e9..d270fd87e67 100644 --- a/ydb/core/tx/schemeshard/ut_index_build_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_index_build_reboots.cpp @@ -82,22 +82,22 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); for (ui32 delta = 0; delta < 2; ++delta) { - WriteRows(runtime, TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); + WriteRows(runtime, TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); } } - AsyncBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}); + AsyncBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}); ui64 buildIndexId = t.TxId; { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); UNIT_ASSERT_VALUES_EQUAL((ui64)descr.GetIndexBuild().GetState(), (ui64)Ydb::Table::IndexBuildState::STATE_PREPARING); } t.TestEnv->TestWaitNotification(runtime, buildIndexId); { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); UNIT_ASSERT_VALUES_EQUAL((ui64)descr.GetIndexBuild().GetState(), (ui64)Ydb::Table::IndexBuildState::STATE_DONE); } @@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { NKikimrMiniKQL::TResult result; TString err; - ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( + ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( ( (let range '( '('index (Uint32 '0) (Void) ) '('key (Uint32 '0) (Void) ))) (let columns '('key 'index) ) @@ -152,22 +152,22 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { t.TestEnv->TestWaitNotification(runtime, t.TxId); for (ui32 delta = 0; delta < 2; ++delta) { - WriteRows(runtime, TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); + WriteRows(runtime, TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); } } - AsyncBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}, {"value"}); + AsyncBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}, {"value"}); ui64 buildIndexId = t.TxId; { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); UNIT_ASSERT_VALUES_EQUAL((ui64)descr.GetIndexBuild().GetState(), (ui64)Ydb::Table::IndexBuildState::STATE_PREPARING); } t.TestEnv->TestWaitNotification(runtime, buildIndexId); { - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildIndexId); UNIT_ASSERT_VALUES_EQUAL((ui64)descr.GetIndexBuild().GetState(), (ui64)Ydb::Table::IndexBuildState::STATE_DONE); } @@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { NKikimrMiniKQL::TResult result; TString err; - ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( + ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets+2, R"( ( (let range '( '('index (Uint32 '0) (Void) ) '('key (Uint32 '0) (Void) ))) (let columns '('key 'index 'value) ) @@ -383,21 +383,21 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; for (ui32 delta = 0; delta < 1; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); + fnWriteRow(TTestTxConfig::FakeHiveTablets, 1 + delta, 100 + delta); } - TestBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}); + TestBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/dir/Table", "index1", {"index"}); } ui64 buildId = t.TxId; - auto response = TestCancelBuildIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", buildId, + auto response = TestCancelBuildIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", buildId, TVector<Ydb::StatusIds::StatusCode>{Ydb::StatusIds::SUCCESS, Ydb::StatusIds::PRECONDITION_FAILED}); t.TestEnv->TestWaitNotification(runtime, t.TxId); t.TestEnv->TestWaitNotification(runtime, buildId); - auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildId); + auto descr = TestGetBuilIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", buildId); if (response.GetStatus() == Ydb::StatusIds::SUCCESS) { Y_ASSERT(descr.GetIndexBuild().GetState() == Ydb::Table::IndexBuildState::STATE_CANCELLED); @@ -421,7 +421,7 @@ Y_UNIT_TEST_SUITE(IndexBuildTestReboots) { {NLs::PathExist}); } - TestForgetBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", buildId); + TestForgetBuilIndex(runtime, ++t.TxId, TTestTxConfig::SchemeShard, "/MyRoot", buildId); }); } diff --git a/ydb/core/tx/schemeshard/ut_login.cpp b/ydb/core/tx/schemeshard/ut_login.cpp index d6f2920d064..1a46fafeb1d 100644 --- a/ydb/core/tx/schemeshard/ut_login.cpp +++ b/ydb/core/tx/schemeshard/ut_login.cpp @@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) { ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, transaction.release()); auto resultLogin = Login(runtime, "user1", "password1"); UNIT_ASSERT_VALUES_EQUAL(resultLogin.error(), ""); - auto describe = DescribePath(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); + auto describe = DescribePath(runtime, TTestTxConfig::SchemeShard, "/MyRoot"); UNIT_ASSERT(describe.HasPathDescription()); UNIT_ASSERT(describe.GetPathDescription().HasDomainDescription()); UNIT_ASSERT(describe.GetPathDescription().GetDomainDescription().HasSecurityState()); diff --git a/ydb/core/tx/schemeshard/ut_move.cpp b/ydb/core/tx/schemeshard/ut_move.cpp index 5c12c6c5a4d..bb20b599583 100644 --- a/ydb/core/tx/schemeshard/ut_move.cpp +++ b/ydb/core/tx/schemeshard/ut_move.cpp @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto second = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/Moved2"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusInvalidParameter); } } @@ -128,14 +128,14 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { { ++txId; auto op = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Table2"); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, op); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, op); TestModificationResult(runtime, txId, NKikimrScheme::StatusSchemeError); } { ++txId; auto op = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Table1"); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, op); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, op); TestModificationResult(runtime, txId, NKikimrScheme::StatusSchemeError); } @@ -145,7 +145,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto second = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Moved2"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusInvalidParameter); } @@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto second = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/Moved1"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusInvalidParameter); } @@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = DropTableRequest(txId, "/MyRoot", "Table1"); auto second = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Table1"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusInvalidParameter); } @@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto second = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Moved1"); auto third = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/Moved1"); auto combination = CombineSchemeTransactions({first, second, third}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusInvalidParameter); } @@ -183,7 +183,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Table2"); auto second = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/Table1"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId, NKikimrScheme::StatusSchemeError); } @@ -216,7 +216,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/Moved2"); auto second = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/Table2"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId); env.TestWaitNotification(runtime, txId); @@ -339,7 +339,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = MoveTableRequest(txId, "/MyRoot/Table1", "/MyRoot/TableMove1"); auto second = MoveTableRequest(txId, "/MyRoot/Table2", "/MyRoot/TableMove2"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId); env.TestWaitNotification(runtime, txId); @@ -423,12 +423,12 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = DropTableRequest(txId, "/MyRoot", "Dst"); auto second = MoveTableRequest(txId, "/MyRoot/Src", "/MyRoot/Dst"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId); env.TestWaitNotification(runtime, txId); } - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+6)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets+3, TTestTxConfig::FakeHiveTablets+6)); TestDescribeResult(DescribePath(runtime, "/MyRoot/Src"), @@ -471,12 +471,12 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = DropTableRequest(txId, "/MyRoot", "Dst"); auto second = MoveTableRequest(txId, "/MyRoot/Src", "/MyRoot/Dst"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId); env.TestWaitNotification(runtime, txId); } - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+3)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+3)); TestDescribeResult(DescribePath(runtime, "/MyRoot/Src"), {NLs::PathNotExist}); @@ -552,7 +552,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { auto first = MoveTableRequest(txId, "/MyRoot/table2", "/MyRoot/table3"); auto second = MoveTableRequest(txId, "/MyRoot/table1", "/MyRoot/table2"); auto combination = CombineSchemeTransactions({first, second}); - AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); + AsyncSendTransaction(runtime, TTestTxConfig::SchemeShard, combination); TestModificationResult(runtime, txId); env.TestWaitNotification(runtime, txId); @@ -816,7 +816,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { TVector<THolder<IEventHandle>> supressed; auto defOberver = SetSuppressObserver(runtime, supressed, NDataShard::TEvChangeExchange::EvApplyRecords); - req1.Plan(TTestTxConfig::Coordinator); + req1.Plan(TTestTxConfig::Coordinator); WaitForSuppressed(runtime, supressed, 1, defOberver); UNIT_ASSERT(supressed.size() == 1); @@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveTest) { { NKikimrMiniKQL::TResult result; TString err; - ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, R"( + ui32 status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, R"( ( (let range '( '('indexed (Uint64 '0) (Void) ) '('key (Uint64 '0) (Void) ))) (let columns '('key 'indexed) ) diff --git a/ydb/core/tx/schemeshard/ut_move_reboots.cpp b/ydb/core/tx/schemeshard/ut_move_reboots.cpp index 07a4b7e5cd8..58e9bebd9ba 100644 --- a/ydb/core/tx/schemeshard/ut_move_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_move_reboots.cpp @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveRebootsTest) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); pathVersion = TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist, @@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveRebootsTest) { } - t.TestEnv->ReliablePropose(runtime, MoveTableRequest(++t.TxId, "/MyRoot/Table", "/MyRoot/TableMove", TTestTxConfig::SchemeShard, {pathVersion}), + t.TestEnv->ReliablePropose(runtime, MoveTableRequest(++t.TxId, "/MyRoot/Table", "/MyRoot/TableMove", TTestTxConfig::SchemeShard, {pathVersion}), {NKikimrScheme::StatusAccepted, NKikimrScheme::StatusMultipleModifications, NKikimrScheme::StatusPreconditionFailed}); t.TestEnv->TestWaitNotification(runtime, t.TxId); @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveRebootsTest) { ++t.TxId; auto first = DropTableRequest(t.TxId, "/MyRoot", "Table"); ++pathVersion.Version; - auto second = MoveTableRequest(t.TxId, "/MyRoot/tmp", "/MyRoot/Table", TTestTxConfig::SchemeShard, {pathVersion}); + auto second = MoveTableRequest(t.TxId, "/MyRoot/tmp", "/MyRoot/Table", TTestTxConfig::SchemeShard, {pathVersion}); auto combination = CombineSchemeTransactions({first, second}); t.TestEnv->ReliablePropose(runtime, combination, @@ -292,8 +292,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveRebootsTest) { } ++t.TxId; - auto first = MoveTableRequest(t.TxId, "/MyRoot/Table", "/MyRoot/backup", TTestTxConfig::SchemeShard, {pathVersion}); - auto second = MoveTableRequest(t.TxId, "/MyRoot/tmp", "/MyRoot/Table", TTestTxConfig::SchemeShard); + auto first = MoveTableRequest(t.TxId, "/MyRoot/Table", "/MyRoot/backup", TTestTxConfig::SchemeShard, {pathVersion}); + auto second = MoveTableRequest(t.TxId, "/MyRoot/tmp", "/MyRoot/Table", TTestTxConfig::SchemeShard); auto combination = CombineSchemeTransactions({first, second}); t.TestEnv->ReliablePropose(runtime, combination, diff --git a/ydb/core/tx/schemeshard/ut_pq_reboots.cpp b/ydb/core/tx/schemeshard/ut_pq_reboots.cpp index 5ad1c130999..86278552974 100644 --- a/ydb/core/tx/schemeshard/ut_pq_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_pq_reboots.cpp @@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TPqGroupTestReboots) { auto numChannels = runtime.GetAppData().ChannelProfiles->Profiles[0].Channels.size(); { - auto itTablet = env.GetHiveState()->Tablets.find({TTestTxConfig::SchemeShard, 1}); + auto itTablet = env.GetHiveState()->Tablets.find({TTestTxConfig::SchemeShard, 1}); UNIT_ASSERT_UNEQUAL(itTablet, env.GetHiveState()->Tablets.end()); UNIT_ASSERT_VALUES_EQUAL(itTablet->second.Type, TTabletTypes::PersQueue); UNIT_ASSERT_VALUES_EQUAL(itTablet->second.BoundChannels.size(), numChannels); @@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TPqGroupTestReboots) { NLs::PathVersionEqual(3)}); { - auto itTablet = env.GetHiveState()->Tablets.find({TTestTxConfig::SchemeShard, 1}); + auto itTablet = env.GetHiveState()->Tablets.find({TTestTxConfig::SchemeShard, 1}); UNIT_ASSERT_UNEQUAL(itTablet, env.GetHiveState()->Tablets.end()); UNIT_ASSERT_VALUES_EQUAL(itTablet->second.Type, TTabletTypes::PersQueue); UNIT_ASSERT_VALUES_UNEQUAL(itTablet->second.BoundChannels.size(), numChannels); @@ -269,7 +269,7 @@ Y_UNIT_TEST_SUITE(TPqGroupTestReboots) { TestDropPQGroup(runtime, t.TxId++, "/MyRoot/DirA", "Isolda", {ESts::StatusAccepted, ESts::StatusPathDoesNotExist}); t.TestEnv->TestWaitNotification(runtime, t.TxId-1); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}); TestLs(runtime, "/MyRoot/DirA/Isolda", true, NLs::PathNotExist); TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA"), @@ -292,7 +292,7 @@ Y_UNIT_TEST_SUITE(TPqGroupTestReboots) { TestForceDropUnsafe(runtime, txId++, 3); t.TestEnv->TestWaitNotification(runtime, {txId-2, txId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}); TestLs(runtime, "/MyRoot/Isolda", true, NLs::PathNotExist); TestDescribeResult(DescribePath(runtime, "/MyRoot"), diff --git a/ydb/core/tx/schemeshard/ut_reboots.cpp b/ydb/core/tx/schemeshard/ut_reboots.cpp index b954b908280..dce2c127122 100644 --- a/ydb/core/tx/schemeshard/ut_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_reboots.cpp @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); pathVersion = TestDescribeResult(DescribePath(runtime, "/MyRoot/DirB"), {NLs::PathVersionEqual(7)}); @@ -294,7 +294,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { UNIT_ASSERT_VALUES_EQUAL(err, ""); UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - fnWriteRow(TTestTxConfig::FakeHiveTablets); + fnWriteRow(TTestTxConfig::FakeHiveTablets); TestConsistentCopyTables(runtime, ++t.TxId, "/", R"( CopyTableDescriptions { @@ -313,7 +313,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { AsyncDropTable(runtime, ++t.TxId, "/MyRoot/DirB", "dst1"); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 2}); { TInactiveZone inactive(activeZone); @@ -445,7 +445,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { NLs::ChildrenCount(0)}); TestDescribeResult(DescribePath(runtime, "/MyRoot/DirB/Table1"), {NLs::PathNotExist}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 3)); } }); } @@ -491,7 +491,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { TestForceDropUnsafe(runtime, ++t.TxId, dirAVersion.PathId.LocalPathId); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); { TInactiveZone inactive(activeZone); @@ -532,7 +532,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { })"); AsyncForceDropUnsafe(runtime, ++t.TxId, dirAVersion.PathId.LocalPathId); t.TestEnv->TestWaitNotification(runtime, {t.TxId - 1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); { TInactiveZone inactive(activeZone); @@ -588,7 +588,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { t.TestEnv->TestWaitNotification(runtime, {t.TxId - 1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10)); { TInactiveZone inactive(activeZone); @@ -642,7 +642,7 @@ Y_UNIT_TEST_SUITE(TConsistentOpsWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot/DirB", "TestNotNullTable"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 10}); { TInactiveZone inactive(activeZone); @@ -675,7 +675,7 @@ Y_UNIT_TEST_SUITE(TSolomonReboots) { ++t.TxId; TestDropSolomon(runtime, ++t.TxId, "/MyRoot", "Solomon"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1}); { TInactiveZone inactive(activeZone); @@ -714,7 +714,7 @@ Y_UNIT_TEST_SUITE(TSolomonReboots) { TestDropSolomon(runtime, ++t.TxId, "/MyRoot", "Solomon"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1}); { TInactiveZone inactive(activeZone); @@ -753,7 +753,7 @@ Y_UNIT_TEST_SUITE(TSolomonReboots) { ++t.TxId; TestDropSolomon(runtime, ++t.TxId, "/MyRoot", "Solomon"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 4)); { TInactiveZone inactive(activeZone); diff --git a/ydb/core/tx/schemeshard/ut_restore.cpp b/ydb/core/tx/schemeshard/ut_restore.cpp index 96140748236..a8b33dcbdce 100644 --- a/ydb/core/tx/schemeshard/ut_restore.cpp +++ b/ydb/core/tx/schemeshard/ut_restore.cpp @@ -276,7 +276,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } @@ -299,11 +299,11 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { )", {a, b}); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(a.YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(b.YsonStr, content); } } @@ -321,7 +321,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint32", "0"}); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint32", "0"}); NKqp::CompareYson(data.YsonStr, content); } @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}, data.Csv.size() + 1); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}, { + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}, { "key", "int32_value", "uint32_value", @@ -450,7 +450,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { auto writeRow = [&](ui64 key, double doubleValue, float floatValue) { NKikimrMiniKQL::TResult result; TString error; - NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, Sprintf(R"( + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, TTestTxConfig::FakeHiveTablets, Sprintf(R"( ( (let key '( '('key (Uint32 '%lu) ) ) ) (let row '( '('double_value (Double '%lf ) ) '('float_value (Float '%f) ) ) ) @@ -548,7 +548,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } @@ -564,7 +564,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } @@ -580,7 +580,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { KeyColumnNames: ["key"] )", {data}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}); NKqp::CompareYson(data.YsonStr, content); } @@ -603,11 +603,11 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { )", {a, b}); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(a.YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(b.YsonStr, content); } } @@ -710,7 +710,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { TestCancelTxTable(runtime, ++txId, restoreTxId); env.TestWaitNotification(runtime, {restoreTxId, txId}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } @@ -776,7 +776,7 @@ Y_UNIT_TEST_SUITE(TRestoreTests) { runtime.Send(progress.Release(), 0, true); env.TestWaitNotification(runtime, {restoreTxId, txId}); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } } @@ -838,7 +838,7 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } }); @@ -868,11 +868,11 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(a.YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(b.YsonStr, content); } } @@ -920,11 +920,11 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(a.YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(b.YsonStr, content); } } @@ -950,7 +950,7 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint32", "0"}); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint32", "0"}); NKqp::CompareYson(data.YsonStr, content); } }); @@ -974,7 +974,7 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } }); @@ -998,7 +998,7 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.YsonStr, content); } }); @@ -1022,7 +1022,7 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets, "Table", {"key", "Uint64", "0"}); NKqp::CompareYson(data.YsonStr, content); } }); @@ -1052,11 +1052,11 @@ Y_UNIT_TEST_SUITE(TRestoreWithRebootsTests) { { TInactiveZone inactive(activeZone); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(a.YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(b.YsonStr, content); } } @@ -1132,7 +1132,7 @@ Y_UNIT_TEST_SUITE(TImportTests) { TS3Mock s3Mock(data, TS3Mock::TSettings(port)); UNIT_ASSERT(s3Mock.Start()); - ui64 schemeshardId = TTestTxConfig::SchemeShard; + ui64 schemeshardId = TTestTxConfig::SchemeShard; if (dbName != "/MyRoot") { TestCreateExtSubDomain(runtime, ++id, "/MyRoot", Sprintf(R"( Name: "%s" @@ -1170,7 +1170,7 @@ Y_UNIT_TEST_SUITE(TImportTests) { SchemeShard: %lu PathId: 2 } - )", TStringBuf(dbName).RNextTok('/').data(), TTestTxConfig::SchemeShard), attrs); + )", TStringBuf(dbName).RNextTok('/').data(), TTestTxConfig::SchemeShard), attrs); env.TestWaitNotification(runtime, id); TestAlterExtSubDomain(runtime, ++id, "/MyRoot", Sprintf(R"( @@ -1242,7 +1242,7 @@ Y_UNIT_TEST_SUITE(TImportTests) { } )"); - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets); NKqp::CompareYson(data.Data[0].YsonStr, content); } @@ -1279,11 +1279,11 @@ Y_UNIT_TEST_SUITE(TImportTests) { )"); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(data.Data[0].YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1); NKqp::CompareYson(data.Data[1].YsonStr, content); } } @@ -1327,12 +1327,12 @@ Y_UNIT_TEST_SUITE(TImportTests) { )"); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0); NKqp::CompareYson(data.Data[0].YsonStr, content); } for (ui32 i = 0; i < indexes; ++i) { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1 + i, + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1 + i, "indexImplTable", {"value", "Utf8", "\"\""}, {"value", "key"}); NKqp::CompareYson(data.Data[0].YsonStr, content); } @@ -1393,11 +1393,11 @@ Y_UNIT_TEST_SUITE(TImportTests) { )"); { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0, "TableA"); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 0, "TableA"); NKqp::CompareYson(a.Data[0].YsonStr, content); } { - auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1, "TableB"); + auto content = ReadTable(runtime, TTestTxConfig::FakeHiveTablets + 1, "TableB"); NKqp::CompareYson(b.Data[0].YsonStr, content); } } @@ -1671,23 +1671,23 @@ Y_UNIT_TEST_SUITE(TImportTests) { } Y_UNIT_TEST(ShouldRestorePerAzReadReplicas) { - NKikimrHive::TFollowerGroup group; - group.SetFollowerCount(1); + NKikimrHive::TFollowerGroup group; + group.SetFollowerCount(1); group.SetRequireAllDataCenters(true); - group.SetFollowerCountPerDataCenter(true); + group.SetFollowerCountPerDataCenter(true); ShouldRestoreSettings(R"( read_replicas_settings { per_az_read_replicas_count: 1 } )", { - NLs::FollowerGroups({group}), + NLs::FollowerGroups({group}), }); } Y_UNIT_TEST(ShouldRestoreAnyAzReadReplicas) { - NKikimrHive::TFollowerGroup group; - group.SetFollowerCount(1); + NKikimrHive::TFollowerGroup group; + group.SetFollowerCount(1); group.SetRequireAllDataCenters(false); ShouldRestoreSettings(R"( @@ -1695,7 +1695,7 @@ Y_UNIT_TEST_SUITE(TImportTests) { any_az_read_replicas_count: 1 } )", { - NLs::FollowerGroups({group}), + NLs::FollowerGroups({group}), }); } diff --git a/ydb/core/tx/schemeshard/ut_serverless.cpp b/ydb/core/tx/schemeshard/ut_serverless.cpp index cef0d364957..4bc3a6207a7 100644 --- a/ydb/core/tx/schemeshard/ut_serverless.cpp +++ b/ydb/core/tx/schemeshard/ut_serverless.cpp @@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) { env.TestWaitNotification(runtime, txId); TString createData = TStringBuilder() - << "ResourcesDomainKey { SchemeShard: " << TTestTxConfig::SchemeShard << " PathId: " << 2 << " } " + << "ResourcesDomainKey { SchemeShard: " << TTestTxConfig::SchemeShard << " PathId: " << 2 << " } " << "Name: \"ServerLess0\""; TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", createData); env.TestWaitNotification(runtime, txId); @@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) { UNIT_ASSERT(tenantSchemeShard != 0 && tenantSchemeShard != (ui64)-1 - && tenantSchemeShard != TTestTxConfig::SchemeShard); + && tenantSchemeShard != TTestTxConfig::SchemeShard); TestCreateTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/ServerLess0", "Name: \"dir/table0\"" @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 10)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 10)); } Y_UNIT_TEST(StorageBilling) { @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) { runtime.UpdateCurrentTime(now); TString createData = TStringBuilder() - << "ResourcesDomainKey { SchemeShard: " << TTestTxConfig::SchemeShard << " PathId: " << 2 << " } " + << "ResourcesDomainKey { SchemeShard: " << TTestTxConfig::SchemeShard << " PathId: " << 2 << " } " << "Name: \"ServerLessDB\""; TestCreateExtSubDomain(runtime, ++txId, "/MyRoot", createData); env.TestWaitNotification(runtime, txId); @@ -186,7 +186,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardServerLess) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; for (ui32 delta = 0; delta < 101; ++delta) { - fnWriteRow(TTestTxConfig::FakeHiveTablets + 6, 1 + delta, 1000 + delta, "aaaa", "Table"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 6, 1 + delta, 1000 + delta, "aaaa", "Table"); } TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/ServerLessDB/Table"), {NLs::PathExist, diff --git a/ydb/core/tx/schemeshard/ut_split_merge.cpp b/ydb/core/tx/schemeshard/ut_split_merge.cpp index 352652c2017..7d91e7ae317 100644 --- a/ydb/core/tx/schemeshard/ut_split_merge.cpp +++ b/ydb/core/tx/schemeshard/ut_split_merge.cpp @@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTest) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; for (ui64 key = 0; key < 1000; ++key) { - fnWriteRow(TTestTxConfig::FakeHiveTablets, key* 1'000'000); + fnWriteRow(TTestTxConfig::FakeHiveTablets, key* 1'000'000); } TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), @@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTest) { {NLs::PartitionCount(1000)}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1000)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1000)); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionCount(1)}); @@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTest) { } suppressed.clear(); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+111)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+111)); // test requeres more txids than cached at start } @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTest) { WaitForSuppressed(runtime, suppressed, 1, prevObserver); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1)); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionKeys({""})}); diff --git a/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp b/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp index d900beb4b0b..4118f3c01cd 100644 --- a/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp @@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { } supressed.clear(); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1)); { TInactiveZone inactive(activeZone); @@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { )"); t.TestEnv->TestWaitNotification(runtime, {t.TxId -2, t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); { TInactiveZone inactive(activeZone); @@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { AsyncDropTable(runtime, ++t.TxId, "/MyRoot", "Table"); t.TestEnv->TestWaitNotification(runtime, {t.TxId -2, t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); { TInactiveZone inactive(activeZone); @@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { })"); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId-1}); - t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); //delete src + t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); //delete src { TInactiveZone inactive(activeZone); @@ -451,9 +451,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - //fnWriteRow(TTestTxConfig::FakeHiveTablets, "AAA"); //we need to make a mix of shards which have shared blobs and don't - fnWriteRow(TTestTxConfig::FakeHiveTablets + 1, "BBB"); - fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "CCC"); + //fnWriteRow(TTestTxConfig::FakeHiveTablets, "AAA"); //we need to make a mix of shards which have shared blobs and don't + fnWriteRow(TTestTxConfig::FakeHiveTablets + 1, "BBB"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "CCC"); } @@ -482,7 +482,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { TInactiveZone inactive(activeZone); TestDropTable(runtime, ++t.TxId, "/MyRoot", "Copy"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+10)); } }, true); } @@ -506,7 +506,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionKeys({"A", "B", ""})}); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); } AsyncSplitTable(runtime, ++t.TxId, "/MyRoot/Table", R"( @@ -521,7 +521,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { } })"); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+3)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+3)); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); { @@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionKeys({"A", ""})}); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); } AsyncSplitTable(runtime, ++t.TxId, "/MyRoot/Table", R"( @@ -566,7 +566,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { Columns { Name: "add_2" Type: "Uint64"} )"); - t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); + t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+1); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); { @@ -710,7 +710,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionKeys({"A", ""})}); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); } AsyncSplitTable(runtime, ++t.TxId, "/MyRoot/Table", @@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { AsyncDropTable(runtime, ++t.TxId, "/MyRoot", "Table"); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+4)); { TInactiveZone inactive(activeZone); @@ -776,7 +776,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { {NLs::PathVersionEqual(3), NLs::PartitionKeys({"A", ""})}); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+2, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+2, false); } AsyncSplitTable(runtime, ++t.TxId, "/MyRoot/DirA/USER_0/Table", @@ -815,7 +815,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets, false); } AsyncCopyTable(runtime, ++t.TxId, "/MyRoot/DirA", "TableCopy", "/MyRoot/DirA/Table"); @@ -833,10 +833,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { t.TestEnv->TestWaitNotification(runtime, {t.TxId-2, t.TxId-1, t.TxId}); t.TestEnv->TestWaitTabletDeletion(runtime, - {TTestTxConfig::FakeHiveTablets //Ds - , TTestTxConfig::FakeHiveTablets+1 //CopyDS - , TTestTxConfig::FakeHiveTablets+2 //FirstSplit - , TTestTxConfig::FakeHiveTablets+3 //FirstSplit + {TTestTxConfig::FakeHiveTablets //Ds + , TTestTxConfig::FakeHiveTablets+1 //CopyDS + , TTestTxConfig::FakeHiveTablets+2 //FirstSplit + , TTestTxConfig::FakeHiveTablets+3 //FirstSplit }); { @@ -863,8 +863,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) { )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets, false); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets, false); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+1, false); TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true), {NLs::PartitionKeys({"A", ""})}); diff --git a/ydb/core/tx/schemeshard/ut_subdomain.cpp b/ydb/core/tx/schemeshard/ut_subdomain.cpp index 12c662e567f..d0d30bf7da8 100644 --- a/ydb/core/tx/schemeshard/ut_subdomain.cpp +++ b/ydb/core/tx/schemeshard/ut_subdomain.cpp @@ -8,27 +8,27 @@ using namespace NSchemeShardUT_Private; NLs::TCheckFunc LsCheckSubDomainParamsAfterAlter(const TString name, ui64 descrVersion = 2, ui64 pathId = 2, - TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets}, - TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) + TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets}, + TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) { NLs::PathExist(record); NLs::PathIdEqual(pathId)(record); NLs::IsSubDomain(name)(record); NLs::SubDomainVersion(descrVersion)(record); - NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); + NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); NLs::DomainCoordinators(coordinators)(record); NLs::DomainMediators(mediators)(record); }; } NLs::TCheckFunc LsCheckSubDomainParamsInCommonCase(const TString name, - ui64 pathId = 2, ui64 schemeshardId = TTestTxConfig::SchemeShard, + ui64 pathId = 2, ui64 schemeshardId = TTestTxConfig::SchemeShard, ui64 createTxId = 100, ui64 createStep = 5000001, ui64 parentPathId = 1, ui64 descrVersion = 1, ui32 planResolution = 50, ui32 timeCastBucketsPerMediator = 2, - TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets}, - TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) + TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets}, + TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}) { Y_UNUSED(createTxId); Y_UNUSED(schemeshardId); @@ -40,19 +40,19 @@ NLs::TCheckFunc LsCheckSubDomainParamsInCommonCase(const TString name, NLs::IsSubDomain(name)(record); NLs::SubDomainVersion(descrVersion)(record); NLs::DomainSettings(planResolution, timeCastBucketsPerMediator)(record); - NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); + NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); NLs::DomainCoordinators(coordinators)(record); NLs::DomainMediators(mediators)(record); }; } NLs::TCheckFunc LsCheckSubDomainParamsInMassiveCase(const TString name = "", - ui64 pathId = 2, ui64 schemeshardId = TTestTxConfig::SchemeShard, + ui64 pathId = 2, ui64 schemeshardId = TTestTxConfig::SchemeShard, ui64 createTxId = 100, ui64 createStep = 5000001, ui64 parentPathId = 1, ui64 descrVersion = 1, ui32 planResolution = 10, ui32 timeCastBucketsPerMediator = 2, - TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}, - TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 4, TTestTxConfig::FakeHiveTablets + 5}) { + TVector<ui64> coordinators = {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 1, TTestTxConfig::FakeHiveTablets + 2}, + TVector<ui64> mediators = {TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 4, TTestTxConfig::FakeHiveTablets + 5}) { Y_UNUSED(createTxId); Y_UNUSED(schemeshardId); @@ -64,7 +64,7 @@ NLs::TCheckFunc LsCheckSubDomainParamsInMassiveCase(const TString name = "", NLs::IsSubDomain(name)(record); NLs::SubDomainVersion(descrVersion)(record); NLs::DomainSettings(planResolution, timeCastBucketsPerMediator)(record); - NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); + NLs::DomainKey(pathId, TTestTxConfig::SchemeShard)(record); NLs::DomainCoordinators(coordinators)(record); NLs::DomainMediators(mediators)(record); }; @@ -489,8 +489,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { "Name: \"USER_0\""); env.TestWaitNotification(runtime, 100); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); TestDropSubDomain(runtime, txId++, "/MyRoot", "USER_0"); @@ -499,8 +499,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(CreateSubDomainWithoutTabletsThenForceDrop) { @@ -514,8 +514,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { "Name: \"USER_0\""); env.TestWaitNotification(runtime, 100); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); TestForceDropSubDomain(runtime, txId++, "/MyRoot", "USER_0"); @@ -524,8 +524,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist, NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(CreateSubDomainsInSeparateDir) { @@ -623,8 +623,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::PathVersionEqual(7), // it is 6 if drop simultaneous with create NLs::PathsInsideDomain(0), NLs::ShardsInsideDomainOneOf({0, 1, 2, 3})}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(ForceDropTwice) { @@ -896,8 +896,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::PathsInsideDomain(0), NLs::ShardsInsideDomainOneOf({0, 1, 2, 3, 4, 5, 6})}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(SimultaneousCreateTenantTableFroceDrop) { @@ -931,8 +931,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::PathsInsideDomain(0), NLs::ShardsInsideDomain(0)}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(SimultaneousCreateTenantTable) { @@ -1114,10 +1114,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestCreateSolomon(runtime, txId++, "/MyRoot/USER_0", "Name: \"Solomon\" " "PartitionCount: 40 "); env.TestWaitNotification(runtime, {txId-2, txId-1}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SolomonVolumes", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SolomonVolumes", "PathId", 3)); TestLs(runtime, "/MyRoot", false); TestLs(runtime, "/MyRoot/USER_0", false, NLs::InSubdomain); @@ -1130,13 +1130,13 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestDropSolomon(runtime, txId++, "/MyRoot/USER_0", "Solomon"); env.TestWaitNotification(runtime, txId-1); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SolomonVolumes", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SolomonVolumes", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); TestForceDropSubDomain(runtime, txId++, "/MyRoot", "USER_0"); env.TestWaitNotification(runtime, txId-1); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); TestLs(runtime, "/MyRoot/USER_0/Solomon", false, NLs::PathNotExist); TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); @@ -1172,10 +1172,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { " BlockSize: 4096 Partitions { BlockCount: 16 } } "); env.TestWaitNotification(runtime, {txId-2, txId-1}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "BlockStoreVolumes", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "BlockStoreVolumes", "PathId", 3)); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::SubdomainWithNoEmptyStoragePools}); @@ -1185,10 +1185,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { TestForceDropSubDomain(runtime, txId++, "/MyRoot", "USER_0"); env.TestWaitNotification(runtime, txId-1); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "BlockStoreVolumes", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "BlockStoreVolumes", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); TestLs(runtime, "/MyRoot/USER_0/BSVolume", false, NLs::PathNotExist); TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); @@ -1352,7 +1352,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::ShardsInsideDomain(0)}); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, @@ -1379,7 +1379,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { "Name: \"USER_0\""); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); env.TestWaitNotification(runtime, 100); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), @@ -1420,7 +1420,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { NLs::PathsInsideDomain(0), NLs::ShardsInsideDomainOneOf({0, 1, 2, 3})}); - env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); + env.TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist, @@ -1494,7 +1494,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); } env.TestWaitNotification(runtime, 101); @@ -1502,7 +1502,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); } TestLs(runtime, "/MyRoot/USER_0", false, NLs::PathNotExist); @@ -2748,7 +2748,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { // Quotas consuption is persistent, on reboot they should stay consumed { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); } TestCreateTable(runtime, ++txId, "/MyRoot/USER_0", R"( Name: "Table7" @@ -2791,7 +2791,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { // Quotas removal is persistent, on reboot they should not reactivate { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); } TestCreateTable(runtime, ++txId, "/MyRoot/USER_0", R"( Name: "Table10" @@ -2848,7 +2848,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { return result; }; - ui64 tabletId = TTestTxConfig::FakeHiveTablets; + ui64 tabletId = TTestTxConfig::FakeHiveTablets; ui64 txId = 100; // single-shard table @@ -2867,7 +2867,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { auto du = getDiskSpaceUsage(); UNIT_ASSERT_C(du.GetTables().GetTotalSize() > 0, du.ShortDebugString()); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); UNIT_ASSERT_VALUES_EQUAL(du.ShortDebugString(), getDiskSpaceUsage().ShortDebugString()); } @@ -2891,7 +2891,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { auto du = getDiskSpaceUsage(); UNIT_ASSERT_C(du.GetTables().GetTotalSize() > 0, du.ShortDebugString()); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); UNIT_ASSERT_VALUES_EQUAL(du.ShortDebugString(), getDiskSpaceUsage().ShortDebugString()); } } @@ -2953,7 +2953,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardSubDomainTest) { {LsCheckDiskQuotaExceeded(false)}); // skip a single coordinator and mediator - ui64 tabletId = TTestTxConfig::FakeHiveTablets + 2; + ui64 tabletId = TTestTxConfig::FakeHiveTablets + 2; TestCreateTable(runtime, ++txId, "/MyRoot/USER_0", R"( Name: "Table1" diff --git a/ydb/core/tx/schemeshard/ut_subdomain_reboots.cpp b/ydb/core/tx/schemeshard/ut_subdomain_reboots.cpp index 569722559fa..8d867909d90 100644 --- a/ydb/core/tx/schemeshard/ut_subdomain_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_subdomain_reboots.cpp @@ -44,8 +44,8 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { NLs::PathsInsideDomain(2), NLs::ShardsInsideDomain(0)}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); } }); } @@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { TestDescribeResult(DescribePath(runtime, "/MyRoot"), {NLs::PathExist, NLs::StoragePoolsEqual({"pool-1", "pool-2"}), - NLs::DomainCoordinators(TVector<ui64>{TTestTxConfig::Coordinator})}); + NLs::DomainCoordinators(TVector<ui64>{TTestTxConfig::Coordinator})}); } AsyncAlterSubDomain(runtime, ++t.TxId, "/", @@ -233,7 +233,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { AsyncDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { TInactiveZone inactive(activeZone); @@ -244,8 +244,8 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { TestDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { TInactiveZone inactive(activeZone); @@ -285,8 +285,8 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { } )"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+2); //delete src + t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+2); //delete src TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/USER_0"), {NLs::PathVersionEqual(5), @@ -364,7 +364,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { TestForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); { TInactiveZone inactive(activeZone); @@ -376,10 +376,10 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { NLs::ShardsInsideDomain(0)}); // FIXME: DropTable breaks down during ForceDropSubDomain and leaves table half-dropped // an additional reboot "fixes" the half-dropped table - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3, 4, 5}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -450,7 +450,7 @@ Y_UNIT_TEST_SUITE(SubDomainWithReboots) { {NLs::PathVersionEqual(5), NLs::PathsInsideDomain(1), NLs::ShardsInsideDomainOneOf({5, 6})}); - t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+2); //delete src + t.TestEnv->TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets+2); //delete src TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/USER_0"), {NLs::PathVersionEqual(5), NLs::PathsInsideDomain(1), @@ -526,22 +526,22 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { "TimeCastBucketsPerMediator: 2 " "Name: \"USER_0\""); t.TestEnv->TestWaitNotification(runtime, t.TxId); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); } AsyncForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { TInactiveZone inactive(activeZone); TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/USER_0"), {NLs::PathNotExist}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -559,15 +559,15 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { AsyncForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId} ); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1}); { TInactiveZone inactive(activeZone); TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/USER_0"), {NLs::PathNotExist}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -594,7 +594,7 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { t.TestEnv->TestWaitNotification(runtime, {t.TxId-3, t.TxId-2, t.TxId-1, t.TxId} ); Cerr << Endl << "Ok notification " << Endl; - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); { TInactiveZone inactive(activeZone); @@ -605,8 +605,8 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -633,7 +633,7 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { t.TestEnv->TestWaitNotification(runtime, {t.TxId-3, t.TxId-2, t.TxId-1, t.TxId} ); Cerr << Endl << "Ok notification " << Endl; - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); { TInactiveZone inactive(activeZone); @@ -644,8 +644,8 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -690,7 +690,7 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { AsyncForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 5)); { TInactiveZone inactive(activeZone); @@ -701,8 +701,8 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3, 4, 5}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -740,7 +740,7 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { TestDropTable(runtime, ++t.TxId, "/MyRoot/DirA/USER_0", "table_0"); AsyncForceDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); t.TestEnv->TestWaitNotification(runtime, {t.TxId-1, t.TxId}); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); { TInactiveZone inactive(activeZone); @@ -752,10 +752,10 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { NLs::ShardsInsideDomain(0)}); // FIXME: DropTable breaks down during ForceDropSubDomain and leaves table half-dropped // an additional reboot "fixes" the half-dropped table - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -804,11 +804,11 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - fnWriteRow(TTestTxConfig::FakeHiveTablets+2); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+2, false); + fnWriteRow(TTestTxConfig::FakeHiveTablets+2); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+2, false); - fnWriteRow(TTestTxConfig::FakeHiveTablets+3); - SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+3, true); + fnWriteRow(TTestTxConfig::FakeHiveTablets+3); + SetAllowLogBatching(runtime, TTestTxConfig::FakeHiveTablets+3, true); TestCopyTable(runtime, ++t.TxId, "/MyRoot/USER_0", "Table2", "/MyRoot/USER_0/Table1"); t.TestEnv->TestWaitNotification(runtime, t.TxId); @@ -826,7 +826,7 @@ Y_UNIT_TEST_SUITE(ForceDropWithReboots) { TestForceDropUnsafe(runtime, ++t.TxId, pathVersion.PathId.LocalPathId); t.TestEnv->TestWaitNotification(runtime, t.TxId); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 6)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets + 6)); }); } diff --git a/ydb/core/tx/schemeshard/ut_ttl.cpp b/ydb/core/tx/schemeshard/ut_ttl.cpp index 52761e1551d..d512ad0033c 100644 --- a/ydb/core/tx/schemeshard/ut_ttl.cpp +++ b/ydb/core/tx/schemeshard/ut_ttl.cpp @@ -380,7 +380,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) { ? Ydb::StatusIds::SUCCESS : Ydb::StatusIds::PRECONDITION_FAILED; - TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/TTLEnabledTable", + TestBuilIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/TTLEnabledTable", TBuildIndexConfig{"UserDefinedIndexByValue", indexType, {"value"}, {}}, status); if (shouldSucceed) { @@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) { const TInstant now = TInstant::ParseIso8601("2020-09-18T18:00:00.000000Z"); runtime.UpdateCurrentTime(now); - ui64 tabletId = TTestTxConfig::FakeHiveTablets; + ui64 tabletId = TTestTxConfig::FakeHiveTablets; ui64 txId = 100; { diff --git a/ydb/core/tx/schemeshard/ut_upgradesubdomain.cpp b/ydb/core/tx/schemeshard/ut_upgradesubdomain.cpp index 8f6f60e42a1..1ee6456acb1 100644 --- a/ydb/core/tx/schemeshard/ut_upgradesubdomain.cpp +++ b/ydb/core/tx/schemeshard/ut_upgradesubdomain.cpp @@ -28,9 +28,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4)}); TestUpgradeSubDomain(runtime, ++txId, "/MyRoot", "USER_0"); @@ -41,20 +41,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(5)}); - UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); + UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestMkDir(runtime, ++txId, "/MyRoot/USER_0", "DirA", {NKikimrScheme::StatusMultipleModifications}); TestMkDir(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "DirA", {NKikimrScheme::StatusReadOnly}); @@ -67,18 +67,18 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(6)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestMkDir(runtime, ++txId, "/MyRoot/USER_0", "DirA", {NKikimrScheme::StatusRedirectDomain}); TestMkDir(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "DirA"); @@ -104,9 +104,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4)}); TestUpgradeSubDomain(runtime, ++txId, "/MyRoot", "USER_0"); @@ -117,21 +117,21 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), NLs::PathVersionEqual(5)}); - UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); + UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestUpgradeSubDomainDecision(runtime, ++txId, "/MyRoot", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Undo); // 104 env.TestWaitNotification(runtime, txId); @@ -139,16 +139,16 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::DomainSchemeshard(0), NLs::PathVersionEqual(105)}); TestMkDir(runtime, ++txId, "/MyRoot/USER_0", "DirA"); env.TestWaitNotification(runtime, txId); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 2); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 2); } @@ -170,9 +170,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4), NLs::NoChildren}); @@ -187,20 +187,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(1)}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirB"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), NLs::NoChildren}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA/DirC"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), NLs::NoChildren}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, @@ -216,19 +216,19 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), NLs::PathVersionEqual(9)}); - UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); + UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestUpgradeSubDomainDecision(runtime, ++txId, "/MyRoot", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Commit); env.TestWaitNotification(runtime, txId); @@ -236,9 +236,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::DomainSchemeshard(tenantSchemeShard), NLs::PathVersionEqual(10), NLs::NoChildren}); @@ -250,28 +250,28 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::PathIdEqual(NKikimr::TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(2)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(1)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirB"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), NLs::NoChildren, NLs::UserAttrsEqual(userAttrs)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA/DirC"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), NLs::NoChildren}); } @@ -293,9 +293,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4), NLs::NoChildren}); @@ -310,20 +310,20 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(1)}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirB"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), NLs::NoChildren}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA/DirC"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 5)), NLs::NoChildren}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, @@ -340,19 +340,19 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 2), NLs::PathVersionEqual(9)}); - UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); + UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 2); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestUpgradeSubDomainDecision(runtime, ++txId, "/MyRoot", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Undo); env.TestWaitNotification(runtime, txId); @@ -360,15 +360,15 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::DomainSchemeshard(0), NLs::PathVersionEqual(109), NLs::ChildrenCount(2), NLs::PathsInsideDomain(3)}); - env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 2); + env.TestWaitTabletDeletion(runtime, TTestTxConfig::FakeHiveTablets + 2); } Y_UNIT_TEST(UpgradeDomainWithTablesCommit) { @@ -389,9 +389,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4), NLs::NoChildren, NLs::ShardsInsideDomain(2)}); @@ -428,18 +428,18 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::Finished, NLs::IsTable, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 6)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 6)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirB/table_2"), {NLs::PathExist, NLs::Finished, NLs::IsTable, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 7)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 7)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA/DirC"), {NLs::PathExist, NLs::Finished, @@ -448,10 +448,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::Finished, NLs::IsTable, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 8)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 8)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), @@ -466,44 +466,44 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), NLs::NoChildren, NLs::PathVersionEqual(9)}); - UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 5); + UNIT_ASSERT(tenantSchemeShard == TTestTxConfig::FakeHiveTablets + 5); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0"), {NLs::PathExist, NLs::PathIdEqual(1), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA"), {NLs::PathRedirected, NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5)}); + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA"), {NLs::PathExist, - NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA/table_1"), {NLs::PathExist, NLs::IsTable, - NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 6)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 6)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestUpgradeSubDomainDecision(runtime, ++txId, "/MyRoot", "USER_0", NKikimrSchemeOp::TUpgradeSubDomain::Commit); env.TestWaitNotification(runtime, txId); @@ -511,9 +511,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::DomainSchemeshard(tenantSchemeShard), NLs::PathVersionEqual(10), NLs::NoChildren}); @@ -522,9 +522,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::PathIdEqual(NKikimr::TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(2), NLs::PathsInsideDomain(6), NLs::ShardsInsideDomain(6)}); @@ -532,19 +532,19 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(2)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA/table_1"), {NLs::PathExist, NLs::IsTable, - NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 6)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 6)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); } Y_UNIT_TEST(UpgradeDomainCommitDelete) { @@ -562,8 +562,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TimeCastBucketsPerMediator: 2 )"); env.TestWaitNotification(runtime, {txId, txId - 1}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); TestMkDir(runtime, ++txId, "/MyRoot/USER_0", "DirA"); TestCreateTable(runtime, ++txId, "/MyRoot/USER_0/DirA",R"( @@ -595,8 +595,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard)}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); TestMkDir(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0", "DirB"); TestCreateTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0/DirB",R"( Name: "Table3" @@ -629,9 +629,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA/Table1"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+9)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); + env.TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+9)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 2)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 2)); } Y_UNIT_TEST(UpgradeDomainCommitRecreateShard) { @@ -677,7 +677,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestAlterTable(runtime, tenantSchemeShard, ++txId, "/MyRoot/USER_0/DirA",R"( Name: "Table1" PartitionConfig { - CrossDataCenterFollowerCount: 1 + CrossDataCenterFollowerCount: 1 } )"); env.TestWaitNotification(runtime, txId, tenantSchemeShard); @@ -705,9 +705,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::PathVersionEqual(4), NLs::NoChildren, NLs::ShardsInsideDomain(2)}); @@ -739,8 +739,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; }; - fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "AAA"); - fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "ZZZ"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "AAA"); + fnWriteRow(TTestTxConfig::FakeHiveTablets + 2, "ZZZ"); } TestSplitTable(runtime, ++txId, "/MyRoot/USER_0/DirA/table_1", R"( @@ -753,8 +753,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { env.TestWaitNotification(runtime, txId); for (ui32 index = 2; index <= 4; ++index) { - auto subDomainPathId = TestFindTabletSubDomainPathId(runtime, TTestTxConfig::FakeHiveTablets + 2); - UNIT_ASSERT_VALUES_EQUAL(subDomainPathId, TPathId(TTestTxConfig::SchemeShard, 2)); + auto subDomainPathId = TestFindTabletSubDomainPathId(runtime, TTestTxConfig::FakeHiveTablets + 2); + UNIT_ASSERT_VALUES_EQUAL(subDomainPathId, TPathId(TTestTxConfig::SchemeShard, 2)); } TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0/DirA"), @@ -767,10 +767,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::Finished, NLs::IsTable, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 4)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsSubDomain("USER_0"), @@ -785,10 +785,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), NLs::NoChildren, NLs::PathVersionEqual(7)}); @@ -798,9 +798,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::DomainSchemeshard(tenantSchemeShard), NLs::PathVersionEqual(8), NLs::NoChildren}); @@ -809,9 +809,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { {NLs::PathExist, NLs::PathIdEqual(NKikimr::TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(1), NLs::PathsInsideDomain(2), NLs::ShardsInsideDomain(5)}); @@ -819,26 +819,26 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA"), {NLs::PathExist, NLs::Finished, - NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::PathIdEqual(NKikimr::TPathId(TTestTxConfig::SchemeShard, 3)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ChildrenCount(1)}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA/table_1"), {NLs::PathExist, NLs::IsTable, - NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 4)), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::PathIdEqual(TPathId(TTestTxConfig::SchemeShard, 4)), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); // Inactive shard is not migrated - TestFindTabletSubDomainPathId(runtime, tenantSchemeShard, TTestTxConfig::FakeHiveTablets + 2, + TestFindTabletSubDomainPathId(runtime, tenantSchemeShard, TTestTxConfig::FakeHiveTablets + 2, NKikimrScheme::TEvFindTabletSubDomainPathIdResult::SHARD_NOT_FOUND); for (ui32 index = 3; index <= 4; ++index) { - auto subDomainPathId = TestFindTabletSubDomainPathId(runtime, tenantSchemeShard, TTestTxConfig::FakeHiveTablets + index); + auto subDomainPathId = TestFindTabletSubDomainPathId(runtime, tenantSchemeShard, TTestTxConfig::FakeHiveTablets + index); UNIT_ASSERT_VALUES_EQUAL(subDomainPathId, TPathId(tenantSchemeShard, 1)); } @@ -846,7 +846,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { NKikimrMiniKQL::TResult result; TString err; ui32 status = LocalMiniKQL( - runtime, TTestTxConfig::FakeHiveTablets + index, R"( + runtime, TTestTxConfig::FakeHiveTablets + index, R"( ( (let range '('('Id (Uint64 '33) (Uint64 '34)))) (let select '('Id 'Uint64)) @@ -880,19 +880,19 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainTest) { TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirA/table_1"), {NLs::PathNotExist}); - env.TestWaitTabletDeletion(runtime, { TTestTxConfig::FakeHiveTablets + 2, TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 4}); + env.TestWaitTabletDeletion(runtime, { TTestTxConfig::FakeHiveTablets + 2, TTestTxConfig::FakeHiveTablets + 3, TTestTxConfig::FakeHiveTablets + 4}); TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); + RebootTablet(runtime, TTestTxConfig::SchemeShard, sender); TestDescribeResult(DescribePath(runtime, "/MyRoot/USER_0"), {NLs::PathExist, NLs::IsExternalSubDomain("USER_0"), NLs::ExtractTenantSchemeshard(&tenantSchemeShard), - NLs::DomainKey(2, TTestTxConfig::SchemeShard), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), - NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), + NLs::DomainKey(2, TTestTxConfig::SchemeShard), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainSchemeshard(TTestTxConfig::FakeHiveTablets + 5), NLs::NoChildren, NLs::PathVersionEqual(8)}); diff --git a/ydb/core/tx/schemeshard/ut_upgradesubdomain_reboots.cpp b/ydb/core/tx/schemeshard/ut_upgradesubdomain_reboots.cpp index c2edc5f559a..d1a4a4020b0 100644 --- a/ydb/core/tx/schemeshard/ut_upgradesubdomain_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_upgradesubdomain_reboots.cpp @@ -26,8 +26,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { "Mediators: 1 " "TimeCastBucketsPerMediator: 2"); t.TestEnv->TestWaitNotification(runtime, {t.TxId, t.TxId - 1}); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); - UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); TestMkDir(runtime, ++t.TxId, "/MyRoot/USER_0", "DirB", {NKikimrScheme::StatusAccepted}, AlterUserAttrs({{"AttrA1", "ValA1"}})); @@ -65,8 +65,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirB"), {NLs::PathExist}); @@ -137,8 +137,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); }); } @@ -199,8 +199,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); }); } @@ -272,8 +272,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); }); } @@ -345,8 +345,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainWithOutDesicion) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1}), NLs::ShardsInsideDomain(6)}); }); } @@ -483,8 +483,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainCommit) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirB"), {NLs::PathExist}); @@ -555,7 +555,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainCommit) { )"); t.TestEnv->TestWaitNotification(runtime, t.TxId, tenantSchemeShard); - RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); // one more reboot before propose deletion + RebootTablet(runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor()); // one more reboot before propose deletion } TestForceDropExtSubDomain(runtime, ++t.TxId, "/MyRoot", "USER_0"); //110 @@ -567,12 +567,12 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainCommit) { NLs::PathsInsideDomain(1), NLs::ShardsInsideDomain(0)}); - t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); + t.TestEnv->TestWaitTabletDeletion(runtime, xrange(TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+6)); { TInactiveZone inactive(activeZone); t.TestEnv->TestWaitShardDeletion(runtime, {1, 2, 3, 4, 5, 6}); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); - UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "SubDomains", "PathId", 3)); + UNIT_ASSERT(!CheckLocalRowExists(runtime, TTestTxConfig::SchemeShard, "Paths", "Id", 3)); } }); } @@ -633,8 +633,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainCommit) { NLs::PathIdEqual(TPathId(tenantSchemeShard, 1)), NLs::IsSubDomain("MyRoot/USER_0"), NLs::DomainKey(pathId), - NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), - NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); + NLs::DomainCoordinators({TTestTxConfig::FakeHiveTablets}), + NLs::DomainMediators({TTestTxConfig::FakeHiveTablets + 1})}); TestDescribeResult(DescribePath(runtime, tenantSchemeShard, "/MyRoot/USER_0/DirB"), {NLs::PathExist}); @@ -1120,7 +1120,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardUpgradeSubDomainCommit) { TestDropTable(runtime, tenantSchemeShard, ++t.TxId, "/MyRoot/USER_0/DirA", "Table"); t.TestEnv->TestWaitNotification(runtime, t.TxId, tenantSchemeShard); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets + 2, TTestTxConfig::FakeHiveTablets + 3}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets + 2, TTestTxConfig::FakeHiveTablets + 3}); } }); } diff --git a/ydb/core/tx/schemeshard/ut_user_attributes_reboots.cpp b/ydb/core/tx/schemeshard/ut_user_attributes_reboots.cpp index 3bd13caec11..8b58b94b0d7 100644 --- a/ydb/core/tx/schemeshard/ut_user_attributes_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_user_attributes_reboots.cpp @@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TUserAttrsTestWithReboots) { } AsyncDropSubDomain(runtime, ++t.TxId, "/MyRoot/DirA", "USER_0"); - t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); + t.TestEnv->TestWaitTabletDeletion(runtime, {TTestTxConfig::FakeHiveTablets, TTestTxConfig::FakeHiveTablets+1, TTestTxConfig::FakeHiveTablets+2}); t.TestEnv->TestWaitNotification(runtime, t.TxId); { diff --git a/ydb/core/tx/schemeshard/ya.make b/ydb/core/tx/schemeshard/ya.make index 91d603efde5..ceb87ce3883 100644 --- a/ydb/core/tx/schemeshard/ya.make +++ b/ydb/core/tx/schemeshard/ya.make @@ -1,12 +1,12 @@ RECURSE_FOR_TESTS( - ut_async_index - ut_base - ut_base_reboots - ut_bsvolume - ut_bsvolume_reboots - ut_cdc_stream + ut_async_index + ut_base + ut_base_reboots + ut_bsvolume + ut_bsvolume_reboots + ut_cdc_stream ut_cdc_stream_reboots - ut_compaction + ut_compaction ut_export ut_export_reboots_s3 ut_extsubdomain @@ -18,16 +18,16 @@ RECURSE_FOR_TESTS( ut_move ut_move_reboots ut_olap - ut_olap_reboots + ut_olap_reboots ut_pq ut_pq_reboots ut_reboots ut_replication ut_replication_reboots - ut_restore + ut_restore ut_rtmr ut_rtmr_reboots - ut_ru_calculator + ut_ru_calculator ut_sequence ut_sequence_reboots ut_serverless @@ -59,7 +59,7 @@ SRCS( defs.h schemeshard.h schemeshard.cpp - schemeshard__compaction.cpp + schemeshard__compaction.cpp schemeshard__clean_pathes.cpp schemeshard__conditional_erase.cpp schemeshard__describe_scheme.cpp @@ -204,7 +204,7 @@ SRCS( schemeshard_build_index__get.cpp schemeshard_build_index__progress.cpp schemeshard_validate_ttl.cpp - operation_queue_timer.h + operation_queue_timer.h ) GENERATE_ENUM_SERIALIZATION(schemeshard_info_types.h) diff --git a/ydb/core/tx/sequenceshard/ut_helpers.cpp b/ydb/core/tx/sequenceshard/ut_helpers.cpp index 935878559a9..8eb92569eaa 100644 --- a/ydb/core/tx/sequenceshard/ut_helpers.cpp +++ b/ydb/core/tx/sequenceshard/ut_helpers.cpp @@ -17,9 +17,9 @@ namespace NSequenceShard { SetupLogging(); SetupTabletServices(); - TActorId bootstrapper = CreateTestBootstrapper( + TActorId bootstrapper = CreateTestBootstrapper( *Runtime, - CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), + CreateTestTabletInfo(TabletId, TabletType, TErasureType::ErasureNone), &CreateSequenceShard); Runtime->EnableScheduleForActor(bootstrapper); @@ -36,9 +36,9 @@ namespace NSequenceShard { void TTestContext::RebootTablet() { ui32 nodeIndex = 0; - ForwardToTablet(*Runtime, TabletId, TActorId(), new TEvents::TEvPoison, nodeIndex); + ForwardToTablet(*Runtime, TabletId, TActorId(), new TEvents::TEvPoison, nodeIndex); WaitTabletBoot(); - InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); + InvalidateTabletResolverCache(*Runtime, TabletId, nodeIndex); ClientId = UnmarkedClientId = {}; } diff --git a/ydb/core/tx/tx.h b/ydb/core/tx/tx.h index a7fc8bee63f..bacde442371 100644 --- a/ydb/core/tx/tx.h +++ b/ydb/core/tx/tx.h @@ -107,7 +107,7 @@ struct TExecLevelHierarchy { // or 8 data shard in domain (##0-7) // one scheme shard (#F0) -struct TTestTxConfig { +struct TTestTxConfig { static constexpr ui64 DomainUid = 0; static constexpr ui64 Coordinator = 0x0000000000800001; static constexpr ui64 Mediator = 0x0000000000810001; diff --git a/ydb/core/tx/tx_allocator/txallocator_ut_helpers.cpp b/ydb/core/tx/tx_allocator/txallocator_ut_helpers.cpp index 39cfc835c34..95566493b6f 100644 --- a/ydb/core/tx/tx_allocator/txallocator_ut_helpers.cpp +++ b/ydb/core/tx/tx_allocator/txallocator_ut_helpers.cpp @@ -59,7 +59,7 @@ void AllocateAndCheck(NActors::TTestActorRuntime &runtime, ui64 size, TResultSta } void TTestEnv::Boot(TTestActorRuntime &runtime) { - CreateTestBootstrapper(runtime, CreateTestTabletInfo(TxAllocatorTablet, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(TxAllocatorTablet, TTabletTypes::TX_ALLOCATOR), &CreateTxAllocator); TDispatchOptions options; options.FinalEvents.push_back(TDispatchOptions::TFinalEventCondition(TEvTablet::EvBoot)); @@ -91,7 +91,7 @@ void TTestEnv::Setup(TTestActorRuntime &runtime) { void TTestEnv::Reboot(TTestActorRuntime &runtime) { TActorId sender = runtime.AllocateEdgeActor(); - RebootTablet(runtime, TxAllocatorTablet, sender); + RebootTablet(runtime, TxAllocatorTablet, sender); } void TIntersectionChecker::AssertIntersection(bool continuous) { diff --git a/ydb/core/tx/tx_allocator/txallocator_ut_helpers.h b/ydb/core/tx/tx_allocator/txallocator_ut_helpers.h index 746c3b8b8dc..1d90e633760 100644 --- a/ydb/core/tx/tx_allocator/txallocator_ut_helpers.h +++ b/ydb/core/tx/tx_allocator/txallocator_ut_helpers.h @@ -17,7 +17,7 @@ using namespace NKikimr; // Sets up everything needed for the tests (actually we need only boot txallocator tablet) class TTestEnv { public: - static constexpr ui64 TxAllocatorTablet = TTestTxConfig::TxAllocator; + static constexpr ui64 TxAllocatorTablet = TTestTxConfig::TxAllocator; static const TDuration SimTimeOut; public: diff --git a/ydb/core/tx/tx_proxy/datareq.cpp b/ydb/core/tx/tx_proxy/datareq.cpp index beb189303a0..af48b42d60f 100644 --- a/ydb/core/tx/tx_proxy/datareq.cpp +++ b/ydb/core/tx/tx_proxy/datareq.cpp @@ -305,7 +305,7 @@ private: TActorId RequestSource; ui32 TxFlags; - bool CanUseFollower; + bool CanUseFollower; bool StreamResponse; TIntrusivePtr<TFlatMKQLRequest> FlatMKQLRequest; @@ -365,8 +365,8 @@ private: void Die(const TActorContext &ctx) override { --*TxProxyMon->DataReqInFly; - Send(Services.FollowerPipeCache, new TEvPipeCache::TEvUnlink(0)); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.FollowerPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); ProcessStreamClearance(false, ctx); if (ReadTableRequest) { @@ -460,7 +460,7 @@ public: , SelectedCoordinator(0) , ProxyFlags(0) , TxFlags(0) - , CanUseFollower(true) + , CanUseFollower(true) , TabletsLeft(0) , TabletErrors(0) , AggrMinStep(0) @@ -964,7 +964,7 @@ void TDataReq::ProcessFlatMKQLResolve(NSchemeCache::TSchemeCacheRequest *cacheRe TxProxyMon->TxPrepareBuildShardProgramsHgram->Collect((afterBuild - beforeBuild).MicroSeconds()); if (engine.GetAffectedShardCount() > 1 || FlatMKQLRequest->Snapshot) // TODO KIKIMR-11912 - CanUseFollower = false; + CanUseFollower = false; TDuration shardCancelAfter = ExecTimeoutPeriod; if (CancelAfter) { @@ -1044,9 +1044,9 @@ void TDataReq::ProcessFlatMKQLResolve(NSchemeCache::TSchemeCacheRequest *cacheRe << " SEND TEvProposeTransaction to datashard " << shardData.ShardId << " with " << shardData.Program.size() << " bytes program" << " affected shards " << engine.GetAffectedShardCount() - << " followers " << (CanUseFollower ? "allowed" : "disallowed") << " marker# P4"); + << " followers " << (CanUseFollower ? "allowed" : "disallowed") << " marker# P4"); - const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; + const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; TEvDataShard::TEvProposeTransaction* ev; if (FlatMKQLRequest->Snapshot && FlatMKQLRequest->ReadOnlyProgram) { ev = new TEvDataShard::TEvProposeTransaction(NKikimrTxDataShard::TX_KIND_DATA, @@ -1073,7 +1073,7 @@ void TDataReq::ProcessReadTableResolve(NSchemeCache::TSchemeCacheRequest *cacheR ReadTableRequest->KeyDesc = std::move(entry.KeyDescription); bool singleShard = ReadTableRequest->KeyDesc->Partitions.size() == 1; - CanUseFollower = false; + CanUseFollower = false; bool immediate = singleShard; @@ -1121,9 +1121,9 @@ void TDataReq::ProcessReadTableResolve(NSchemeCache::TSchemeCacheRequest *cacheR << " SEND TEvProposeTransaction to datashard " << partition.ShardId << " with read table request" << " affected shards " << ReadTableRequest->KeyDesc->Partitions.size() - << " followers " << (CanUseFollower ? "allowed" : "disallowed") << " marker# P4b"); + << " followers " << (CanUseFollower ? "allowed" : "disallowed") << " marker# P4b"); - const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; + const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; Send(pipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransaction(NKikimrTxDataShard::TX_KIND_SCAN, @@ -1153,15 +1153,15 @@ TAutoPtr<TEvTxProxySchemeCache::TEvResolveKeySet> TDataReq::PrepareFlatMKQLReque WallClockResolveStarted = Now(); auto &keyDescriptions = FlatMKQLRequest->Engine->GetDbKeys(); - // check keys and set use follower flag - CanUseFollower = true; + // check keys and set use follower flag + CanUseFollower = true; request->ResultSet.reserve(keyDescriptions.size()); for (auto &keyd : keyDescriptions) { - if (keyd->RowOperation != TKeyDesc::ERowOperation::Read || keyd->ReadTarget.GetMode() != TReadTarget::EMode::Follower) { - CanUseFollower = false; + if (keyd->RowOperation != TKeyDesc::ERowOperation::Read || keyd->ReadTarget.GetMode() != TReadTarget::EMode::Follower) { + CanUseFollower = false; LOG_DEBUG_S_SAMPLED_BY(ctx, NKikimrServices::TX_PROXY, TxId, "Actor " << ctx.SelfID.ToString() << " txid " << TxId - << " disallow followers cause of operation " << (ui32)keyd->RowOperation + << " disallow followers cause of operation " << (ui32)keyd->RowOperation << " read target mode " << (ui32)keyd->ReadTarget.GetMode()); } request->ResultSet.emplace_back(std::move(keyd)); @@ -1613,7 +1613,7 @@ void TDataReq::Handle(TEvTxProxySchemeCache::TEvResolveKeySetResult::TPtr &ev, c if (entry.KeyDescription->RowOperation != TKeyDesc::ERowOperation::Read) { error = TStringBuilder() << "Non-read operations can't be performed on async index table" << ": " << entry.KeyDescription->TableId; - } else if (entry.KeyDescription->ReadTarget.GetMode() != TReadTarget::EMode::Follower) { + } else if (entry.KeyDescription->ReadTarget.GetMode() != TReadTarget::EMode::Follower) { error = TStringBuilder() << "Read operation can be performed on async index table" << ": " << entry.KeyDescription->TableId << " only with StaleRO isolation level"; } @@ -1657,7 +1657,7 @@ void TDataReq::Handle(TEvPrivate::TEvReattachToShard::TPtr &ev, const TActorCont "Actor# " << ctx.SelfID << " txid# " << TxId << " sending reattach to shard " << tabletId); // Try to reattach transaction to a new tablet - const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; + const TActorId pipeCache = CanUseFollower ? Services.FollowerPipeCache : Services.LeaderPipeCache; Send(pipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransactionAttach(tabletId, TxId), @@ -1944,12 +1944,12 @@ void TDataReq::HandlePrepare(TEvDataShard::TEvProposeTransactionResult::TPtr &ev } void TDataReq::CancelProposal(ui64 exceptTablet) { - if (CanUseFollower) + if (CanUseFollower) return; for (const auto &x : PerTablet) if (x.first != exceptTablet) { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(TxId), x.first, false @@ -2550,7 +2550,7 @@ void TDataReq::MergeResult(TEvDataShard::TEvProposeTransactionResult::TPtr &ev, std::pair<ui64, ui64>(info.GetActorId().GetRawX1(), info.GetActorId().GetRawX2()), info.GetGeneration(), info.GetStep(), - info.GetIsFollower(), + info.GetIsFollower(), std::move(txInfo) )); } @@ -2841,7 +2841,7 @@ void TDataReq::RegisterPlan(const TActorContext &ctx) { "Actor# " << ctx.SelfID.ToString() << " txid# " << TxId << " SEND EvProposeTransaction to# " << SelectedCoordinator << " Coordinator marker# P7 "); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); CoordinatorStatus = ECoordinatorStatus::Waiting; Become(&TThis::StateWaitPlan); } diff --git a/ydb/core/tx/tx_proxy/describe.cpp b/ydb/core/tx/tx_proxy/describe.cpp index beeeacf3e16..deb38ca2b7d 100644 --- a/ydb/core/tx/tx_proxy/describe.cpp +++ b/ydb/core/tx/tx_proxy/describe.cpp @@ -32,7 +32,7 @@ class TDescribeReq : public TActor<TDescribeReq> { void Die(const TActorContext &ctx) override { --*TxProxyMon->NavigateReqInFly; - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); TActor::Die(ctx); } @@ -263,7 +263,7 @@ void TDescribeReq::Handle(TEvTxProxyReq::TEvNavigateScheme::TPtr &ev, const TAct LOG_DEBUG_S(ctx, NKikimrServices::TX_PROXY, "Actor# " << ctx.SelfID.ToString() << " SEND to# " << shardToRequest << " shardToRequest " << req->ToString()); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardToRequest, true), 0, SourceCookie); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardToRequest, true), 0, SourceCookie); Become(&TThis::StateWaitExec); return; @@ -371,7 +371,7 @@ void TDescribeReq::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr & LOG_DEBUG_S(ctx, NKikimrServices::TX_PROXY, "Actor# " << ctx.SelfID.ToString() << " SEND to# " << shardToRequest << " shardToRequest " << req->ToString()); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardToRequest, true), 0, SourceCookie); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardToRequest, true), 0, SourceCookie); Become(&TThis::StateWaitExec); } diff --git a/ydb/core/tx/tx_proxy/proxy.h b/ydb/core/tx/tx_proxy/proxy.h index 34f561ca8d7..86d4f1ac79e 100644 --- a/ydb/core/tx/tx_proxy/proxy.h +++ b/ydb/core/tx/tx_proxy/proxy.h @@ -27,8 +27,8 @@ namespace NTxProxy { struct TTxProxyServices { TActorId Proxy; TActorId SchemeCache; - TActorId LeaderPipeCache; - TActorId FollowerPipeCache; + TActorId LeaderPipeCache; + TActorId FollowerPipeCache; }; } diff --git a/ydb/core/tx/tx_proxy/proxy_ext_tenant_ut.cpp b/ydb/core/tx/tx_proxy/proxy_ext_tenant_ut.cpp index 1c4f80b255d..ff7c9579d83 100644 --- a/ydb/core/tx/tx_proxy/proxy_ext_tenant_ut.cpp +++ b/ydb/core/tx/tx_proxy/proxy_ext_tenant_ut.cpp @@ -447,7 +447,7 @@ void CreateTableInsideAndAlterTable(TTestEnvWithPoolsSupport& env) { description.ClearKeyColumnNames(); description.ClearSplitBoundary(); description.ClearTableIndexes(); - description.MutablePartitionConfig()->SetFollowerCount(1); + description.MutablePartitionConfig()->SetFollowerCount(1); UNIT_ASSERT_VALUES_EQUAL(env.GetClient().AlterTable("/dc-1/USER_0", description), NMsgBusProxy::MSTATUS_OK); @@ -456,7 +456,7 @@ void CreateTableInsideAndAlterTable(TTestEnvWithPoolsSupport& env) { env.GetClient().RefreshPathCache(&env.GetRuntime(), "/dc-1/USER_0/SimpleTable"); auto ls = env.GetClient().Ls("/dc-1/USER_0/SimpleTable"); NKikimrSchemeOp::TTableDescription description = NTestLs::ExtractTableDescription(ls); - UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 1); + UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 1); } env.GetTenants().Stop(); @@ -518,7 +518,7 @@ void CreateTableInsideAndAlterDomainAndTable(TTestEnvWithPoolsSupport& env) { { auto tableDesc = GetTableSimpleDescription("SimpleTable"); - tableDesc.MutablePartitionConfig()->SetFollowerCount(0); + tableDesc.MutablePartitionConfig()->SetFollowerCount(0); UNIT_ASSERT_VALUES_EQUAL(env.GetClient().CreateTable("/dc-1/USER_0", tableDesc), NMsgBusProxy::MSTATUS_OK); @@ -535,7 +535,7 @@ void CreateTableInsideAndAlterDomainAndTable(TTestEnvWithPoolsSupport& env) { env.GetClient().RefreshPathCache(&env.GetRuntime(), "/dc-1/USER_0/SimpleTable"); auto ls = env.GetClient().Ls("/dc-1/USER_0/SimpleTable"); NKikimrSchemeOp::TTableDescription description = NTestLs::ExtractTableDescription(ls); - UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 0); + UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 0); } { @@ -588,7 +588,7 @@ void CreateTableInsideAndAlterDomainAndTable(TTestEnvWithPoolsSupport& env) { description.ClearKeyColumnNames(); description.ClearSplitBoundary(); description.ClearTableIndexes(); - description.MutablePartitionConfig()->SetFollowerCount(1); + description.MutablePartitionConfig()->SetFollowerCount(1); UNIT_ASSERT_VALUES_EQUAL(env.GetClient().AlterTable("/dc-1/USER_0", description), NMsgBusProxy::MSTATUS_OK); @@ -597,7 +597,7 @@ void CreateTableInsideAndAlterDomainAndTable(TTestEnvWithPoolsSupport& env) { env.GetClient().RefreshPathCache(&env.GetRuntime(), "/dc-1/USER_0/SimpleTable"); auto ls = env.GetClient().Ls("/dc-1/USER_0/SimpleTable"); NKikimrSchemeOp::TTableDescription description = NTestLs::ExtractTableDescription(ls); - UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 1); + UNIT_ASSERT_VALUES_EQUAL(description.GetPartitionConfig().GetFollowerCount(), 1); } env.GetTenants().Stop(); diff --git a/ydb/core/tx/tx_proxy/proxy_impl.cpp b/ydb/core/tx/tx_proxy/proxy_impl.cpp index 6a43f47d893..20dc8cce176 100644 --- a/ydb/core/tx/tx_proxy/proxy_impl.cpp +++ b/ydb/core/tx/tx_proxy/proxy_impl.cpp @@ -63,8 +63,8 @@ class TTxProxy : public TActorBootstrapped<TTxProxy> { void Die(const TActorContext &ctx) override { ctx.Send(Services.SchemeCache, new TEvents::TEvPoisonPill()); - ctx.Send(Services.LeaderPipeCache, new TEvents::TEvPoisonPill()); - ctx.Send(Services.FollowerPipeCache, new TEvents::TEvPoisonPill()); + ctx.Send(Services.LeaderPipeCache, new TEvents::TEvPoisonPill()); + ctx.Send(Services.FollowerPipeCache, new TEvents::TEvPoisonPill()); PipeClientCache->Detach(ctx); PipeClientCache.Destroy(); @@ -442,7 +442,7 @@ public: ctx.ExecutorThread.ActorSystem->RegisterLocalService(MakeSchemeCacheID(), Services.SchemeCache); // PipePeNodeCaches are an external dependency - Services.LeaderPipeCache = MakePipePeNodeCacheID(false); + Services.LeaderPipeCache = MakePipePeNodeCacheID(false); Services.FollowerPipeCache = MakePipePeNodeCacheID(true); TxAllocatorClient.Bootstrap(ctx); diff --git a/ydb/core/tx/tx_proxy/proxy_ut.cpp b/ydb/core/tx/tx_proxy/proxy_ut.cpp index 61250bda3cd..eba78928c5a 100644 --- a/ydb/core/tx/tx_proxy/proxy_ut.cpp +++ b/ydb/core/tx/tx_proxy/proxy_ut.cpp @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { c2->SetType("Uint64"); } tableDescr.SetUniformPartitionsCount(2); - tableDescr.MutablePartitionConfig()->SetFollowerCount(2); + tableDescr.MutablePartitionConfig()->SetFollowerCount(2); *tableDescr.AddKeyColumnNames() = "key"; return tableDescr; } @@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { UNIT_ASSERT_EQUAL( Max<ui32>(), - env.GetClient().GetLeaderNode(&env.GetRuntime(), result.GetTabletId())); + env.GetClient().GetLeaderNode(&env.GetRuntime(), result.GetTabletId())); } Y_UNIT_TEST(CreateDummyTabletsInDifferentDomains) { @@ -568,20 +568,20 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { ui64 somedatashard = partitions.back().GetDatashardId(); //datashard run on dynamic node - ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); + ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); UNIT_ASSERT(env.GetTenants().IsActive("/dc-1/USER_0", nodeId)); env.GetTenants().Stop("/dc-1/USER_0"); UNIT_ASSERT(env.GetClient().WaitForTabletDown(&env.GetRuntime(), somedatashard, true, WaitTimeOut)); // make sure that hive has seen tablet stopped - ui32 leaderNodeForDataShard = 1; - while (leaderNodeForDataShard != Max<ui32>()) { - leaderNodeForDataShard = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); + ui32 leaderNodeForDataShard = 1; + while (leaderNodeForDataShard != Max<ui32>()) { + leaderNodeForDataShard = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); } //datashard is not running - UNIT_ASSERT_VALUES_EQUAL(Max<ui32>(), env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard)); + UNIT_ASSERT_VALUES_EQUAL(Max<ui32>(), env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard)); //and there is no hope to run it up UNIT_ASSERT(!env.GetClient().WaitForTabletAlive(&env.GetRuntime(), somedatashard, true, WaitTimeOut)); @@ -609,7 +609,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { ui64 somedatashard = partitions.back().GetDatashardId(); //datashard run on dynamic node - ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); + ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); UNIT_ASSERT(env.GetTenants().IsActive("/dc-1/USER_0", nodeId)); //switch off the node @@ -619,7 +619,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { env.GetClient().WaitForTabletDown(&env.GetRuntime(), somedatashard, true, WaitTimeOut); UNIT_ASSERT(env.GetClient().WaitForTabletAlive(&env.GetRuntime(), somedatashard, true, WaitTimeOut)); - ui32 newNodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); + ui32 newNodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), somedatashard); UNIT_ASSERT(env.GetTenants().IsActive("/dc-1/USER_0", newNodeId)); } @@ -672,7 +672,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { ui64 coordinator = domaindescr.GetProcessingParams().GetCoordinators(0); //coordinator runs on dynamic node - ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); + ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); UNIT_ASSERT_C(env.GetTenants().IsActive("/dc-1/USER_0", nodeId), "assert IsActive nodeId " << nodeId); //create table, if it is OK then tenant node awakes @@ -685,7 +685,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { UNIT_ASSERT(env.GetClient().WaitForTabletAlive(&env.GetRuntime(), coordinator, true, WaitTimeOut)); //coordinator runs on dynamic node - ui32 newNodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); + ui32 newNodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); UNIT_ASSERT_C(env.GetTenants().IsActive("/dc-1/USER_0", newNodeId), "assert IsActive nodeId " << nodeId); //coordinator no runs on static node, when dynamic is offline @@ -752,7 +752,7 @@ Y_UNIT_TEST_SUITE(TSubDomainTest) { ui64 coordinator = domaindescr.GetProcessingParams().GetCoordinators(0); //coordinator runs on dynamic node - ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); + ui32 nodeId = env.GetClient().GetLeaderNode(&env.GetRuntime(), coordinator); UNIT_ASSERT_C(env.GetTenants().IsActive("/dc-1/USER_0", nodeId), "assert IsActive nodeId " << nodeId); } diff --git a/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp b/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp index 3ea637f29ef..a9becc80d7d 100644 --- a/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp +++ b/ydb/core/tx/tx_proxy/proxy_ut_helpers.cpp @@ -390,7 +390,7 @@ ui64 CreateSubDomainAndTabletInside(TBaseTestEnv &env, const TString &name, ui64 void CheckTableIsOfline(TBaseTestEnv &env, ui64 tablet_id) { UNIT_ASSERT_EQUAL( Max<ui32>(), - env.GetClient().GetLeaderNode(&env.GetRuntime(), tablet_id)); + env.GetClient().GetLeaderNode(&env.GetRuntime(), tablet_id)); } void CheckTableBecomeAlive(TBaseTestEnv &env, ui64 tablet_id) { @@ -410,7 +410,7 @@ void CheckTableBecomeOfline(TBaseTestEnv &env, ui64 tablet_id) { void CheckTableRunOnProperTenantNode(TBaseTestEnv &env, const TString &tenant, ui64 tablet_id) { UNIT_ASSERT( env.GetTenants().IsActive(tenant, - env.GetClient().GetLeaderNode(&env.GetRuntime(), + env.GetClient().GetLeaderNode(&env.GetRuntime(), tablet_id))); } @@ -450,7 +450,7 @@ NKikimrSchemeOp::TTableDescription GetTableSimpleDescription(const TString &name c2->SetType("Uint64"); } tableDescr.SetUniformPartitionsCount(2); - tableDescr.MutablePartitionConfig()->SetFollowerCount(2); + tableDescr.MutablePartitionConfig()->SetFollowerCount(2); *tableDescr.AddKeyColumnNames() = "key"; return tableDescr; } diff --git a/ydb/core/tx/tx_proxy/read_table_impl.cpp b/ydb/core/tx/tx_proxy/read_table_impl.cpp index 83455f32797..6c30975fd9b 100644 --- a/ydb/core/tx/tx_proxy/read_table_impl.cpp +++ b/ydb/core/tx/tx_proxy/read_table_impl.cpp @@ -313,7 +313,7 @@ public: private: void SendCancelSnapshotProposal(TShardState& state, const TActorContext& ctx) { - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(TxId), state.ShardId, false)); } @@ -321,10 +321,10 @@ private: void SendInterruptReadTable(TShardState& state, const TActorContext& ctx) { // We send TEvCancelTransactionProposal for cases where datashard // decided to prepare our immediate read table transaction. - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(state.ReadTxId), state.ShardId, false)); - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvTxProcessing::TEvInterruptTransaction(state.ReadTxId), state.ShardId, false)); } @@ -392,13 +392,13 @@ private: req->Record.SetPathId(TableId.PathId.LocalPathId); req->Record.SetStep(PlanStep); req->Record.SetTxId(TxId); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( req.Release(), shardId, false)); } } - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); - Send(Services.FollowerPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.FollowerPipeCache, new TEvPipeCache::TEvUnlink(0)); if (ResolveInProgress) { // Actor cannot die until it receives a reply @@ -828,7 +828,7 @@ private: const ui64 txFlags = 0; TXLOG_D("Sending CreateVolatileSnapshot tx to shard " << state.ShardId); - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransaction( NKikimrTxDataShard::TX_KIND_SNAPSHOT, ctx.SelfID, TxId, txBody, txFlags), @@ -1047,7 +1047,7 @@ private: state.State == EShardState::SnapshotPrepared)) { TXLOG_T("Sending TEvCancelTransactionProposal to shard " << shardId); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(TxId), shardId, false)); } @@ -1205,7 +1205,7 @@ private: TXLOG_D("Sending EvProposeTransaction to SelectedCoordinator# " << SelectedCoordinator); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); Become(&TThis::StateReadTable); } @@ -1443,8 +1443,8 @@ private: TxProxyMon->ReadTableResolveSentToShard->Inc(); TXLOG_D("Sending TEvProposeTransaction (scan) to shard " << shardId << " ReadTxId# " << state.ReadTxId); - // TODO: support followers? - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + // TODO: support followers? + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransaction(NKikimrTxDataShard::TX_KIND_SCAN, ctx.SelfID, state.ReadTxId, txBody, txFlags), shardId, true)); @@ -1774,7 +1774,7 @@ private: code = NKikimrIssues::TStatusIds::BAD_REQUEST; // Cancel proposal so it doesn't wait unnecessarily. - ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + ctx.Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(state.ReadTxId), state.ShardId, false)); break; @@ -2256,7 +2256,7 @@ private: req->Record.SetPathId(TableId.PathId.LocalPathId); req->Record.SetStep(PlanStep); req->Record.SetTxId(TxId); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardId, true)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), shardId, true)); } void HandleReadTable(TEvDataShard::TEvRefreshVolatileSnapshotResponse::TPtr& ev, const TActorContext& ctx) { diff --git a/ydb/core/tx/tx_proxy/snapshotreq.cpp b/ydb/core/tx/tx_proxy/snapshotreq.cpp index d033c0d55ca..4b2d7fe2756 100644 --- a/ydb/core/tx/tx_proxy/snapshotreq.cpp +++ b/ydb/core/tx/tx_proxy/snapshotreq.cpp @@ -59,7 +59,7 @@ private: private: void Die(const TActorContext &ctx) override { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); TActor::Die(ctx); } @@ -395,7 +395,7 @@ public: << " affected shards " << PerShardStates.size() << " marker# P3"); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvProposeTransaction(NKikimrTxDataShard::TX_KIND_SNAPSHOT, ctx.SelfID, TxId, txBody, TxFlags), shardId, true)); @@ -635,7 +635,7 @@ public: state.Status == TPerShardState::EStatus::Wait || state.Status == TPerShardState::EStatus::Prepared)) { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward( new TEvDataShard::TEvCancelTransactionProposal(TxId), shardId, false)); } @@ -743,7 +743,7 @@ public: "Actor# " << ctx.SelfID.ToString() << " txid# " << TxId << " SEND EvProposeTransaction to# " << SelectedCoordinator << " Coordinator marker# P5"); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(req.Release(), SelectedCoordinator, true)); Become(&TThis::StateWaitPlan); } @@ -1123,7 +1123,7 @@ private: private: void Die(const TActorContext &ctx) override { - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); TActor::Die(ctx); } @@ -1444,7 +1444,7 @@ public: << " SEND " << reqname << " to datashard " << shardId << " marker# P3"); - Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(tosend.Release(), shardId, true)); + Send(Services.LeaderPipeCache, new TEvPipeCache::TEvForward(tosend.Release(), shardId, true)); } void HandleResponse(TEvDataShard::TEvRefreshVolatileSnapshotResponse::TPtr& ev, const TActorContext& ctx) { diff --git a/ydb/core/tx/tx_proxy/upload_rows_common_impl.h b/ydb/core/tx/tx_proxy/upload_rows_common_impl.h index 4ce0af7cd9f..0aaee7e7f59 100644 --- a/ydb/core/tx/tx_proxy/upload_rows_common_impl.h +++ b/ydb/core/tx/tx_proxy/upload_rows_common_impl.h @@ -102,7 +102,7 @@ private: static constexpr TDuration DEFAULT_TIMEOUT = TDuration::Seconds(5*60); TActorId SchemeCache; - TActorId LeaderPipeCache; + TActorId LeaderPipeCache; TDuration Timeout; TInstant Deadline; TActorId TimeoutTimerActorId; @@ -162,7 +162,7 @@ public: explicit TUploadRowsBase(TDuration timeout = TDuration::Max()) : TBase() , SchemeCache(MakeSchemeCacheID()) - , LeaderPipeCache(MakePipePeNodeCacheID(false)) + , LeaderPipeCache(MakePipePeNodeCacheID(false)) , Timeout((timeout && timeout <= DEFAULT_TIMEOUT) ? timeout : DEFAULT_TIMEOUT) , WaitingResolveReply(false) , Finished(false) @@ -177,7 +177,7 @@ public: void Die(const NActors::TActorContext& ctx) override { Y_VERIFY(Finished); Y_VERIFY(!WaitingResolveReply); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(0)); if (TimeoutTimerActorId) { ctx.Send(TimeoutTimerActorId, new TEvents::TEvPoisonPill()); } @@ -886,7 +886,7 @@ private: LOG_DEBUG_S(ctx, NKikimrServices::MSGBUS_REQUEST, "Sending request to shards " << shardId); - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(shardRequests[idx].release(), shardId, true), IEventHandle::FlagTrackDelivery); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvForward(shardRequests[idx].release(), shardId, true), IEventHandle::FlagTrackDelivery); auto res = ShardRepliesLeft.insert(shardId); if (!res.second) { @@ -931,7 +931,7 @@ private: const auto& shardResponse = ev->Get()->Record; // Notify the cache that we are done with the pipe - ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); + ctx.Send(LeaderPipeCache, new TEvPipeCache::TEvUnlink(shardResponse.GetTabletID())); LOG_DEBUG_S(ctx, NKikimrServices::MSGBUS_REQUEST, "Upload rows: got " << NKikimrTxDataShard::TError::EKind_Name((NKikimrTxDataShard::TError::EKind)shardResponse.GetStatus()) diff --git a/ydb/core/tx/tx_proxy/ya.make b/ydb/core/tx/tx_proxy/ya.make index e6773c0c5b8..d412dc8988c 100644 --- a/ydb/core/tx/tx_proxy/ya.make +++ b/ydb/core/tx/tx_proxy/ya.make @@ -54,7 +54,7 @@ END() RECURSE_FOR_TESTS( ut_base_tenant - ut_encrypted_storage + ut_encrypted_storage ut_ext_tenant ut_storage_tenant ) diff --git a/ydb/core/util/circular_queue.h b/ydb/core/util/circular_queue.h index e039d7f957d..ffffb6db57e 100644 --- a/ydb/core/util/circular_queue.h +++ b/ydb/core/util/circular_queue.h @@ -1,197 +1,197 @@ -#pragma once - -#include <util/generic/hash.h> -#include <util/generic/intrlist.h> -#include <util/generic/vector.h> - -namespace NKikimr { - -template <typename T> -class TFifoQueue { -public: - struct TItem : public TIntrusiveListItem<TItem> { - T Data; - - explicit TItem(const T& data) - : Data(data) - {} - - explicit TItem(T&& data) - : Data(std::move(data)) - {} - - bool operator == (const TItem& other) const { - return Data == other.Data; - } - - bool operator == (const T& other) const { - return Data == other; - } - - struct THash { - size_t operator() (const TItem& item) const { - return ::THash<T>()(item.Data); - } - - size_t operator() (const T& item) const { - return ::THash<T>()(item); - } - }; - - struct TEqual { - template<typename T1, typename T2> - bool operator() (const T1& l, const T2& r) const { - return l == r; - } - }; - }; - -private: - using TList = TIntrusiveList<TItem>; - using TIndex = THashSet<TItem, typename TItem::THash, typename TItem::TEqual>; - -private: - TList List; - TIndex Index; - -public: - TFifoQueue() = default; - - template<typename T2> - bool Enqueue(T2&& item) { - return PushBack(std::forward<T2>(item)); - } - - template<typename T2> - bool PushBack(T2&& item) { - typename TIndex::insert_ctx insert_ctx; - auto it = Index.find(item, insert_ctx); - if (it != Index.end()) { - // seems to be ok to simply ignore - return false; - } - - auto indexIt = Index.emplace_direct(insert_ctx, std::forward<T2>(item)); - List.PushBack(const_cast<TItem*>(&*indexIt)); - - return true; - } - - bool Remove(const T& item) { - auto it = Index.find(item); - if (it == Index.end()) - return false; - - const_cast<TItem&>(*it).Unlink(); - Index.erase(it); - return true; - } - - bool UpdateIfFound(const T& item) { - auto it = Index.find(item); - if (it == Index.end()) - return false; - - const_cast<TItem&>(*it).Data = item; - return true; - } - - // item contains just key, the rest - // is copied if item found - bool CopyAndRemove(T& item) { - auto it = Index.find(item); - if (it == Index.end()) - return false; - - item = std::move(it->Data); - - const_cast<TItem&>(*it).Unlink(); - Index.erase(it); - return true; - } - - void Clear() { - List.Clear(); - Index.clear(); - } - - const T& Front() const { - return List.Front()->Data; - } - - void PopFront() { - Remove(Front()); - } - - bool Empty() const { - return Index.empty(); - } - - size_t Size() const { - return Index.size(); - } - - // copies items, should be used in tests only - TVector<T> GetQueue() const { - TVector<T> result; - result.reserve(Index.size()); - for (const auto& item: List) { - result.push_back(item.Data); - } - return result; - } - - // used to implement TCircularQueue over TFifoQueue - void PopFrontToBack() { - if (Index.size() > 1) - List.PushBack(List.Front()); - } -}; - -template <typename T, typename TQueue> -class TCircularQueue { -private: - TQueue Queue; - -public: - template<typename T2> - bool Enqueue(T2&& item) { - return Queue.Enqueue(std::forward<T2>(item)); - } - - template<typename T2> - bool PushBack(T2&& item) { - return Queue.PushBack(std::forward<T2>(item)); - } - - bool Remove(const T& item) { - return Queue.Remove(item); - } - - void Clear() { - Queue.Clear(); - } - - const T &Front() const { - return Queue.Front(); - } - - void PopFront() { - Queue.PopFrontToBack(); - } - - bool Empty() const { - return Queue.Empty(); - } - - size_t Size() const { - return Queue.Size(); - } - - // copies items, should be used in tests only - TVector<T> GetQueue() const { - return Queue.GetQueue(); - } -}; - -} // NKikimr +#pragma once + +#include <util/generic/hash.h> +#include <util/generic/intrlist.h> +#include <util/generic/vector.h> + +namespace NKikimr { + +template <typename T> +class TFifoQueue { +public: + struct TItem : public TIntrusiveListItem<TItem> { + T Data; + + explicit TItem(const T& data) + : Data(data) + {} + + explicit TItem(T&& data) + : Data(std::move(data)) + {} + + bool operator == (const TItem& other) const { + return Data == other.Data; + } + + bool operator == (const T& other) const { + return Data == other; + } + + struct THash { + size_t operator() (const TItem& item) const { + return ::THash<T>()(item.Data); + } + + size_t operator() (const T& item) const { + return ::THash<T>()(item); + } + }; + + struct TEqual { + template<typename T1, typename T2> + bool operator() (const T1& l, const T2& r) const { + return l == r; + } + }; + }; + +private: + using TList = TIntrusiveList<TItem>; + using TIndex = THashSet<TItem, typename TItem::THash, typename TItem::TEqual>; + +private: + TList List; + TIndex Index; + +public: + TFifoQueue() = default; + + template<typename T2> + bool Enqueue(T2&& item) { + return PushBack(std::forward<T2>(item)); + } + + template<typename T2> + bool PushBack(T2&& item) { + typename TIndex::insert_ctx insert_ctx; + auto it = Index.find(item, insert_ctx); + if (it != Index.end()) { + // seems to be ok to simply ignore + return false; + } + + auto indexIt = Index.emplace_direct(insert_ctx, std::forward<T2>(item)); + List.PushBack(const_cast<TItem*>(&*indexIt)); + + return true; + } + + bool Remove(const T& item) { + auto it = Index.find(item); + if (it == Index.end()) + return false; + + const_cast<TItem&>(*it).Unlink(); + Index.erase(it); + return true; + } + + bool UpdateIfFound(const T& item) { + auto it = Index.find(item); + if (it == Index.end()) + return false; + + const_cast<TItem&>(*it).Data = item; + return true; + } + + // item contains just key, the rest + // is copied if item found + bool CopyAndRemove(T& item) { + auto it = Index.find(item); + if (it == Index.end()) + return false; + + item = std::move(it->Data); + + const_cast<TItem&>(*it).Unlink(); + Index.erase(it); + return true; + } + + void Clear() { + List.Clear(); + Index.clear(); + } + + const T& Front() const { + return List.Front()->Data; + } + + void PopFront() { + Remove(Front()); + } + + bool Empty() const { + return Index.empty(); + } + + size_t Size() const { + return Index.size(); + } + + // copies items, should be used in tests only + TVector<T> GetQueue() const { + TVector<T> result; + result.reserve(Index.size()); + for (const auto& item: List) { + result.push_back(item.Data); + } + return result; + } + + // used to implement TCircularQueue over TFifoQueue + void PopFrontToBack() { + if (Index.size() > 1) + List.PushBack(List.Front()); + } +}; + +template <typename T, typename TQueue> +class TCircularQueue { +private: + TQueue Queue; + +public: + template<typename T2> + bool Enqueue(T2&& item) { + return Queue.Enqueue(std::forward<T2>(item)); + } + + template<typename T2> + bool PushBack(T2&& item) { + return Queue.PushBack(std::forward<T2>(item)); + } + + bool Remove(const T& item) { + return Queue.Remove(item); + } + + void Clear() { + Queue.Clear(); + } + + const T &Front() const { + return Queue.Front(); + } + + void PopFront() { + Queue.PopFrontToBack(); + } + + bool Empty() const { + return Queue.Empty(); + } + + size_t Size() const { + return Queue.Size(); + } + + // copies items, should be used in tests only + TVector<T> GetQueue() const { + return Queue.GetQueue(); + } +}; + +} // NKikimr diff --git a/ydb/core/util/circular_queue_ut.cpp b/ydb/core/util/circular_queue_ut.cpp index 76a1269eb11..e4b2355a1e5 100644 --- a/ydb/core/util/circular_queue_ut.cpp +++ b/ydb/core/util/circular_queue_ut.cpp @@ -1,161 +1,161 @@ -#include "circular_queue.h" - -#include <library/cpp/testing/unittest/registar.h> - -namespace NKikimr { - -using TIntFifoQueue = TFifoQueue<int>; - -Y_UNIT_TEST_SUITE(TFifoQueueTest) { - Y_UNIT_TEST(ShouldPushPop) { - TIntFifoQueue queue; - UNIT_ASSERT(queue.PushBack(1)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - UNIT_ASSERT(queue.PushBack(10)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 10); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); - } -}; - -using TIntCircularQueue = TCircularQueue<int, TFifoQueue<int>>; - -Y_UNIT_TEST_SUITE(TCircularQueueTest) { - - Y_UNIT_TEST(Empty) { - TIntCircularQueue queue; - UNIT_ASSERT(queue.Empty()); - } - - Y_UNIT_TEST(ShouldPush) { - TIntCircularQueue queue; - UNIT_ASSERT(queue.PushBack(1)); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - UNIT_ASSERT(queue.PushBack(2)); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - } - - Y_UNIT_TEST(ShouldNotPushTwice) { - TIntCircularQueue queue; - UNIT_ASSERT(queue.PushBack(1)); - UNIT_ASSERT(!queue.PushBack(1)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - - UNIT_ASSERT(queue.PushBack(2)); - UNIT_ASSERT(!queue.PushBack(2)); - UNIT_ASSERT(!queue.PushBack(1)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - } - - Y_UNIT_TEST(ShouldNextSingleItem) { - TIntCircularQueue queue; - queue.PushBack(1); - - queue.PopFront(); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - queue.PopFront(); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - } - - Y_UNIT_TEST(ShouldNextMulti) { - TIntCircularQueue queue; - queue.PushBack(1); - queue.PushBack(2); - - queue.PopFront(); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); - - queue.PopFront(); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - queue.PopFront(); - UNIT_ASSERT(!queue.Empty()); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); - } - - Y_UNIT_TEST(ShouldRemove) { - TIntCircularQueue queue; - queue.PushBack(1); - queue.PushBack(2); - queue.PushBack(3); - - UNIT_ASSERT(queue.Remove(2)); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); - } - - Y_UNIT_TEST(ShouldNotRemoveMissing) { - TIntCircularQueue queue; - queue.PushBack(1); - queue.PushBack(2); - queue.PushBack(3); - UNIT_ASSERT(!queue.Remove(4)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - } - - Y_UNIT_TEST(ShouldRemoveCurrent) { - TIntCircularQueue queue; - queue.PushBack(1); - queue.PushBack(2); - queue.PushBack(3); - queue.PopFront(); - - queue.Remove(2); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); - } - - Y_UNIT_TEST(ShouldRemoveCurrentLast) { - TIntCircularQueue queue; - queue.PushBack(1); - queue.PushBack(2); - queue.PushBack(3); - - queue.PopFront(); - queue.PopFront(); - - queue.Remove(3); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); - - queue.PopFront(); - UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); - } - - Y_UNIT_TEST(ShouldGetQueue) { - TIntCircularQueue queue; - queue.PushBack(3); - queue.PushBack(2); - queue.PushBack(1); - - auto items = queue.GetQueue(); - UNIT_ASSERT_VALUES_EQUAL(items.size(), queue.Size()); - UNIT_ASSERT_VALUES_EQUAL(items, TVector<int>({3, 2, 1})); - } -}; - -} // NKikimr +#include "circular_queue.h" + +#include <library/cpp/testing/unittest/registar.h> + +namespace NKikimr { + +using TIntFifoQueue = TFifoQueue<int>; + +Y_UNIT_TEST_SUITE(TFifoQueueTest) { + Y_UNIT_TEST(ShouldPushPop) { + TIntFifoQueue queue; + UNIT_ASSERT(queue.PushBack(1)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + UNIT_ASSERT(queue.PushBack(10)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 10); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); + } +}; + +using TIntCircularQueue = TCircularQueue<int, TFifoQueue<int>>; + +Y_UNIT_TEST_SUITE(TCircularQueueTest) { + + Y_UNIT_TEST(Empty) { + TIntCircularQueue queue; + UNIT_ASSERT(queue.Empty()); + } + + Y_UNIT_TEST(ShouldPush) { + TIntCircularQueue queue; + UNIT_ASSERT(queue.PushBack(1)); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + UNIT_ASSERT(queue.PushBack(2)); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + } + + Y_UNIT_TEST(ShouldNotPushTwice) { + TIntCircularQueue queue; + UNIT_ASSERT(queue.PushBack(1)); + UNIT_ASSERT(!queue.PushBack(1)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + + UNIT_ASSERT(queue.PushBack(2)); + UNIT_ASSERT(!queue.PushBack(2)); + UNIT_ASSERT(!queue.PushBack(1)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + } + + Y_UNIT_TEST(ShouldNextSingleItem) { + TIntCircularQueue queue; + queue.PushBack(1); + + queue.PopFront(); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + queue.PopFront(); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + } + + Y_UNIT_TEST(ShouldNextMulti) { + TIntCircularQueue queue; + queue.PushBack(1); + queue.PushBack(2); + + queue.PopFront(); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); + + queue.PopFront(); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + queue.PopFront(); + UNIT_ASSERT(!queue.Empty()); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); + } + + Y_UNIT_TEST(ShouldRemove) { + TIntCircularQueue queue; + queue.PushBack(1); + queue.PushBack(2); + queue.PushBack(3); + + UNIT_ASSERT(queue.Remove(2)); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); + } + + Y_UNIT_TEST(ShouldNotRemoveMissing) { + TIntCircularQueue queue; + queue.PushBack(1); + queue.PushBack(2); + queue.PushBack(3); + UNIT_ASSERT(!queue.Remove(4)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + } + + Y_UNIT_TEST(ShouldRemoveCurrent) { + TIntCircularQueue queue; + queue.PushBack(1); + queue.PushBack(2); + queue.PushBack(3); + queue.PopFront(); + + queue.Remove(2); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 3); + } + + Y_UNIT_TEST(ShouldRemoveCurrentLast) { + TIntCircularQueue queue; + queue.PushBack(1); + queue.PushBack(2); + queue.PushBack(3); + + queue.PopFront(); + queue.PopFront(); + + queue.Remove(3); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 2); + + queue.PopFront(); + UNIT_ASSERT_VALUES_EQUAL(queue.Front(), 1); + } + + Y_UNIT_TEST(ShouldGetQueue) { + TIntCircularQueue queue; + queue.PushBack(3); + queue.PushBack(2); + queue.PushBack(1); + + auto items = queue.GetQueue(); + UNIT_ASSERT_VALUES_EQUAL(items.size(), queue.Size()); + UNIT_ASSERT_VALUES_EQUAL(items, TVector<int>({3, 2, 1})); + } +}; + +} // NKikimr diff --git a/ydb/core/util/fragmented_buffer_ut.cpp b/ydb/core/util/fragmented_buffer_ut.cpp index b50b8ee4719..7e7dee86df5 100644 --- a/ydb/core/util/fragmented_buffer_ut.cpp +++ b/ydb/core/util/fragmented_buffer_ut.cpp @@ -161,20 +161,20 @@ Y_UNIT_TEST_SUITE(TFragmentedBufferTest) { } Y_UNIT_TEST(CopyFrom) { - TFragmentedBuffer buffer; - buffer.Write(0, "HELLO", 5); - buffer.Write(10, "WORLD", 5); + TFragmentedBuffer buffer; + buffer.Write(0, "HELLO", 5); + buffer.Write(10, "WORLD", 5); TFragmentedBuffer copy; - copy.CopyFrom(buffer, TIntervalSet<i32>(0, 5)); - buffer.Write(5, "BRAVE", 5); - copy.CopyFrom(buffer, TIntervalSet<i32>(5, 15)); + copy.CopyFrom(buffer, TIntervalSet<i32>(0, 5)); + buffer.Write(5, "BRAVE", 5); + copy.CopyFrom(buffer, TIntervalSet<i32>(5, 15)); UNIT_ASSERT(copy.Get(0).second == 5); UNIT_ASSERT(!memcmp(copy.Get(0).first, "HELLO", 5)); UNIT_ASSERT(copy.Get(10).second == 5); UNIT_ASSERT(!memcmp(copy.Get(10).first, "WORLD", 5)); UNIT_ASSERT(copy.Get(12).second == 3); UNIT_ASSERT(!memcmp(copy.Get(12).first, "RLD", 3)); - copy.CopyFrom(buffer, TIntervalSet<i32>(0, 15)); + copy.CopyFrom(buffer, TIntervalSet<i32>(0, 15)); UNIT_ASSERT(copy.Get(0).second == 5); UNIT_ASSERT(!memcmp(copy.Get(0).first, "HELLO", 5)); UNIT_ASSERT(copy.Get(5).second == 5); diff --git a/ydb/core/util/intrusive_heap.h b/ydb/core/util/intrusive_heap.h index a4b1d2349d9..1a7629cd4f6 100644 --- a/ydb/core/util/intrusive_heap.h +++ b/ydb/core/util/intrusive_heap.h @@ -155,13 +155,13 @@ public: return SiftDown(value) || SiftUp(value); } - void Clear() { - for (auto& x: Data) { - HeapIndex(x) = size_t(-1); - } - Data.clear(); - } - + void Clear() { + for (auto& x: Data) { + HeapIndex(x) = size_t(-1); + } + Data.clear(); + } + private: inline size_t& HeapIndex(T* value) const { return static_cast<const THeapIndex&>(*this)(*value); diff --git a/ydb/core/util/operation_queue.h b/ydb/core/util/operation_queue.h index b3f428bc7a0..bf70acc29be 100644 --- a/ydb/core/util/operation_queue.h +++ b/ydb/core/util/operation_queue.h @@ -1,598 +1,598 @@ -#pragma once - -#include "circular_queue.h" -#include "intrusive_heap.h" -#include "token_bucket.h" - -#include <library/cpp/time_provider/time_provider.h> - -#include <util/datetime/base.h> -#include <util/generic/algorithm.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/random/shuffle.h> -#include <util/string/join.h> -#include <util/system/compiler.h> - -namespace NKikimr { -namespace NOperationQueue { - -enum class EStartStatus { - EOperationRunning, - EOperationRetry, - EOperationRemove, -}; - -class ITimer { -public: - // asks to call TOperationQueue::Wakeup() - virtual void SetWakeupTimer(TInstant t) = 0; - - virtual TInstant Now() = 0; -}; - -template <typename T> -class IStarter { -public: - virtual ~IStarter() = default; - - virtual EStartStatus StartOperation(const T& item) = 0; -}; - -struct TConfig { - // after timeout item is considered as done - TDuration Timeout = TDuration::Zero(); - - // if every item in queue failed to start, then - // retry after this amount of time - TDuration WakeupInterval = TDuration::Seconds(1); - - // done and timeouted items are enqueued again - bool IsCircular = false; - - // shuffle added items on Start() - bool ShuffleOnStart = false; - - ui32 InflightLimit = 1; - double Rate = 0.0; // max rate operations/s - - // In case of circular queue start done operation - // again only after this interval of time - TDuration MinOperationRepeatDelay = TDuration::Minutes(0); - - TConfig() = default; - - TConfig(TDuration timeout, bool isCircular, ui32 inflight) - : Timeout(timeout) - , IsCircular(isCircular) - , InflightLimit(inflight) - { } -}; - -// Rich wrapper over TIntrusiveHeap, so that -// it can be used as queue in TOperationQueue. -template <typename T, class TCompare = TLess<T>> -class TQueueWithPriority { -private: - struct THeapItem { - T Item; - size_t HeapIndex = -1; - - explicit THeapItem(const T& item) - : Item(item) - {} - - explicit THeapItem(T&& item) - : Item(std::move(item)) - {} - - bool operator ==(const THeapItem& rhs) const { - return Item == rhs.Item; - } - - explicit operator size_t() const { - return size_t(Item); - } - - struct THeapIndex { - size_t& operator ()(THeapItem& item) const { - return item.HeapIndex; - } - }; - - struct THeapItemCompare { - bool operator()(const THeapItem& lhs, const THeapItem& rhs) const { - return TCompare()(lhs.Item, rhs.Item); - } - }; - }; - - using TItemsSet = THashSet<THeapItem>; - - TItemsSet Items; - TIntrusiveHeap<THeapItem, typename THeapItem::THeapIndex, typename THeapItem::THeapItemCompare> Heap; - -public: - template<typename T2> - bool Enqueue(T2&& item) { - THeapItem heapItem(std::forward<T2>(item)); - typename TItemsSet::insert_ctx insert_ctx; - auto it = Items.find(heapItem, insert_ctx); - if (it != Items.end()) { - // seems to be ok to simply ignore - return false; - } - - auto indexIt = Items.emplace_direct(insert_ctx, std::move(heapItem)); - Heap.Add(const_cast<THeapItem*>(&*indexIt)); - - return true; - } - - bool Remove(const T& item) { - THeapItem heapItem(item); - - auto it = Items.find(heapItem); - if (it == Items.end()) - return false; - - // note the order of Heap->Items - Heap.Remove(const_cast<THeapItem*>(&*it)); - Items.erase(it); - return true; - } - - bool UpdateIfFound(const T& item) { - THeapItem heapItem(item); - auto it = Items.find(heapItem); - if (it == Items.end()) - return false; - - auto& ref = const_cast<THeapItem&>(*it); - ref.Item = item; - Heap.Update(&ref); - return true; - } - - void Clear() { - Heap.Clear(); - Items.clear(); - } - - const T& Front() const { - return Heap.Top()->Item; - } - - void PopFront() { - Remove(Front()); - } - - bool Empty() const { - return Heap.Empty(); - } - - size_t Size() const { - return Heap.Size(); - } -}; - -template <typename T, typename TQueue> -class TOperationQueue { -public: - - struct TItemWithTs { - T Item; - TInstant Timestamp; - - explicit TItemWithTs(const T& item) - : Item(item) - { } - - TItemWithTs(const T& item, TInstant s) - : Item(item) - , Timestamp(s) - { } - - TItemWithTs(T&& item, TInstant s) - : Item(std::move(item)) - , Timestamp(s) - { } - +#pragma once + +#include "circular_queue.h" +#include "intrusive_heap.h" +#include "token_bucket.h" + +#include <library/cpp/time_provider/time_provider.h> + +#include <util/datetime/base.h> +#include <util/generic/algorithm.h> +#include <util/generic/vector.h> +#include <util/generic/xrange.h> +#include <util/random/shuffle.h> +#include <util/string/join.h> +#include <util/system/compiler.h> + +namespace NKikimr { +namespace NOperationQueue { + +enum class EStartStatus { + EOperationRunning, + EOperationRetry, + EOperationRemove, +}; + +class ITimer { +public: + // asks to call TOperationQueue::Wakeup() + virtual void SetWakeupTimer(TInstant t) = 0; + + virtual TInstant Now() = 0; +}; + +template <typename T> +class IStarter { +public: + virtual ~IStarter() = default; + + virtual EStartStatus StartOperation(const T& item) = 0; +}; + +struct TConfig { + // after timeout item is considered as done + TDuration Timeout = TDuration::Zero(); + + // if every item in queue failed to start, then + // retry after this amount of time + TDuration WakeupInterval = TDuration::Seconds(1); + + // done and timeouted items are enqueued again + bool IsCircular = false; + + // shuffle added items on Start() + bool ShuffleOnStart = false; + + ui32 InflightLimit = 1; + double Rate = 0.0; // max rate operations/s + + // In case of circular queue start done operation + // again only after this interval of time + TDuration MinOperationRepeatDelay = TDuration::Minutes(0); + + TConfig() = default; + + TConfig(TDuration timeout, bool isCircular, ui32 inflight) + : Timeout(timeout) + , IsCircular(isCircular) + , InflightLimit(inflight) + { } +}; + +// Rich wrapper over TIntrusiveHeap, so that +// it can be used as queue in TOperationQueue. +template <typename T, class TCompare = TLess<T>> +class TQueueWithPriority { +private: + struct THeapItem { + T Item; + size_t HeapIndex = -1; + + explicit THeapItem(const T& item) + : Item(item) + {} + + explicit THeapItem(T&& item) + : Item(std::move(item)) + {} + + bool operator ==(const THeapItem& rhs) const { + return Item == rhs.Item; + } + + explicit operator size_t() const { + return size_t(Item); + } + + struct THeapIndex { + size_t& operator ()(THeapItem& item) const { + return item.HeapIndex; + } + }; + + struct THeapItemCompare { + bool operator()(const THeapItem& lhs, const THeapItem& rhs) const { + return TCompare()(lhs.Item, rhs.Item); + } + }; + }; + + using TItemsSet = THashSet<THeapItem>; + + TItemsSet Items; + TIntrusiveHeap<THeapItem, typename THeapItem::THeapIndex, typename THeapItem::THeapItemCompare> Heap; + +public: + template<typename T2> + bool Enqueue(T2&& item) { + THeapItem heapItem(std::forward<T2>(item)); + typename TItemsSet::insert_ctx insert_ctx; + auto it = Items.find(heapItem, insert_ctx); + if (it != Items.end()) { + // seems to be ok to simply ignore + return false; + } + + auto indexIt = Items.emplace_direct(insert_ctx, std::move(heapItem)); + Heap.Add(const_cast<THeapItem*>(&*indexIt)); + + return true; + } + + bool Remove(const T& item) { + THeapItem heapItem(item); + + auto it = Items.find(heapItem); + if (it == Items.end()) + return false; + + // note the order of Heap->Items + Heap.Remove(const_cast<THeapItem*>(&*it)); + Items.erase(it); + return true; + } + + bool UpdateIfFound(const T& item) { + THeapItem heapItem(item); + auto it = Items.find(heapItem); + if (it == Items.end()) + return false; + + auto& ref = const_cast<THeapItem&>(*it); + ref.Item = item; + Heap.Update(&ref); + return true; + } + + void Clear() { + Heap.Clear(); + Items.clear(); + } + + const T& Front() const { + return Heap.Top()->Item; + } + + void PopFront() { + Remove(Front()); + } + + bool Empty() const { + return Heap.Empty(); + } + + size_t Size() const { + return Heap.Size(); + } +}; + +template <typename T, typename TQueue> +class TOperationQueue { +public: + + struct TItemWithTs { + T Item; + TInstant Timestamp; + + explicit TItemWithTs(const T& item) + : Item(item) + { } + + TItemWithTs(const T& item, TInstant s) + : Item(item) + , Timestamp(s) + { } + + TItemWithTs(T&& item, TInstant s) + : Item(std::move(item)) + , Timestamp(s) + { } + TItemWithTs(const TItemWithTs&) = default; - bool operator ==(const TItemWithTs& rhs) const { - return Item == rhs.Item; - } - - TItemWithTs& operator =(const TItemWithTs& rhs) { - Item = rhs.Item; - if (rhs.Timestamp) { - // avoid clearing ts, little bit hacky: - // in UpdateIfFound() we don't want to copy ts, - // but in other places we want. - // Though in UpdateIfFound rhs.Timestamp should - // be always missing while in other cases it - // always presents - Timestamp = rhs.Timestamp; - } - return *this; - } - - size_t Hash() const { - return THash<T>()(Item); - } - - explicit operator size_t() const { - return Hash(); - } - }; - - using IStarter = IStarter<T>; - using TConfig = ::NKikimr::NOperationQueue::TConfig; - -private: - using TRunningItems = TFifoQueue<TItemWithTs>; - using TWaitingItems = TFifoQueue<TItemWithTs>; - -private: - TConfig Config; - IStarter& Starter; - ITimer& Timer; - - // used only with ShuffleOnStart - TVector<T> ItemsToShuffle; - - TQueue ReadyQueue; - TRunningItems RunningItems; - TWaitingItems WaitingItems; - - TTokenBucket TokenBucket; - - TInstant NextWakeup; - bool Running = false; - bool WasRunning = false; - - ui64 TimeoutCount = 0; - -public: - TOperationQueue(const TConfig& config, - IStarter& starter, - ITimer& timer) - : Config(config) - , Starter(starter) - , Timer(timer) - { - UpdateConfig(Config); - } - - void UpdateConfig(const TConfig& config) { - if (&Config != &config) - Config = config; - - if (Config.Rate) { - // by default token bucket is unlimitted, so - // configure only when rate is limited - TokenBucket.SetCapacity(Config.InflightLimit); - TokenBucket.SetRate(Config.Rate); - TokenBucket.Fill(Timer.Now()); - } - } - - // Items enqueued before Start() will start - void Start(); - - // Can be used to pause, note that running items continue to run and - // need either OnDone() or timeout via Wakeup() - void Stop(); - - // returns true when item enqueued and false if it was already in queue. - // - // Note that when ShuffleOnStart is set, then it always returns true and - // duplicates are eliminated only when queue starts - bool Enqueue(const T& item); - - // returns true if item was in queue and removed, should - // not be called before Start() with ShuffleOnStart, because - // it will be O(N). - // - // note, that in case of circular queue it is possible - // to remove item which was already started: it's up - // to caller to stop it if needed. - bool Remove(const T& item); - - // updates operation either running/waiting/ready by - // copying item. Used in priority queues to modify - // priority - bool Update(const T& item); - - // done or failed doesn't matter, if item was running then - // returns duration between start and done - // Note that in case of circular queue item overwrites running - // item, which is useful, when new priority needed - TDuration OnDone(const T& item); - - // must be called by Starter on response to ITimer::SetWakeupTimer() - void Wakeup(); - - // Consider the case when there are running items, user clears the queue and: - // 1. Adds items with same ID and queue starts them - // 2. Calls OnDone() because previously added items done, but not new ones - void Clear(); - - // note that it is size of both ready and waiting queue, not running - size_t Size() const { return ReadyQueue.Size() + WaitingItems.Size() + ItemsToShuffle.size(); } - bool Empty() const { return ReadyQueue.Empty() && WaitingItems.Empty() && ItemsToShuffle.empty(); } - - size_t RunningSize() const { return RunningItems.Size(); } - bool RunningEmpty() const { return RunningItems.Empty(); } - - size_t WaitingSize() const { return WaitingItems.Size(); } - bool WaitingEmpty() const { return WaitingItems.Empty(); } - - ui64 ResetTimeoutCount() { return TimeoutCount; TimeoutCount = 0; } - - // copies items, should be used in tests only - TVector<T> GetQueue() const { return ReadyQueue.GetQueue(); } - TVector<TItemWithTs> GetRunning() const { return RunningItems.GetQueue(); } - TVector<TItemWithTs> GetWaiting() const { return WaitingItems.GetQueue(); } - - void Dump(IOutputStream& out) const; - -private: - template <typename T2> - bool EnqueueNoStart(T2&& item); - - template <typename T2> - void ReEnqueueNoStart(T2&& item); - - void CheckTimeoutOperations(); - void CheckWaitingOperations(); - void StartOperations(); - void ScheduleWakeup(); -}; - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::Start() { - if (Running) - return; - - if (Config.ShuffleOnStart && !ItemsToShuffle.empty()) { - ShuffleRange(ItemsToShuffle); - for (auto& item: ItemsToShuffle) { - EnqueueNoStart(std::move(item)); - } - TVector<T>().swap(ItemsToShuffle); - } - - Running = true; - WasRunning = true; - StartOperations(); -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::Stop() { - Running = false; -} - -template <typename T, typename TQueue> -bool TOperationQueue<T, TQueue>::Enqueue(const T& item) { - // note that there is no reason to reshuffle on start/stop - // also waiting/timeouted operations enqueued vid EnqueueNoStart - // thus don't use shuffling - if (!WasRunning && Config.ShuffleOnStart) { - ItemsToShuffle.push_back(item); - return true; // we don't check if item is unique - } - - if (EnqueueNoStart(item)) { - StartOperations(); - return true; - } - return false; -} - -template <typename T, typename TQueue> -template <typename T2> -bool TOperationQueue<T, TQueue>::EnqueueNoStart(T2&& item) { - return ReadyQueue.Enqueue(std::forward<T2>(item)); -} - -template <typename T, typename TQueue> -template <typename T2> -void TOperationQueue<T, TQueue>::ReEnqueueNoStart(T2&& item) { - auto now = Timer.Now(); - if (Config.MinOperationRepeatDelay) { - TItemWithTs runningItem(std::forward<T2>(item), now); - WaitingItems.PushBack(runningItem); - } else { - EnqueueNoStart(std::forward<T2>(item)); - } -} - -template <typename T, typename TQueue> -bool TOperationQueue<T, TQueue>::Remove(const T& item) { - bool removed = ReadyQueue.Remove(item); - - if (RunningItems.Remove(TItemWithTs(item))) { - StartOperations(); - } - - removed = WaitingItems.Remove(TItemWithTs(item)) || removed; - - if (ItemsToShuffle) { - auto it = Find(ItemsToShuffle.begin(), ItemsToShuffle.end(), item); - if (it != ItemsToShuffle.end()) { - ItemsToShuffle.erase(it); - return true; - } - } - - return removed; -} - -template <typename T, typename TQueue> -bool TOperationQueue<T, TQueue>::Update(const T& item) { - // note that no ts and below we will keep original ts - TItemWithTs tsItem(item); - - return ReadyQueue.UpdateIfFound(item) || - WaitingItems.UpdateIfFound(tsItem) || - RunningItems.UpdateIfFound(tsItem); -} - -template <typename T, typename TQueue> -TDuration TOperationQueue<T, TQueue>::OnDone(const T& item) { - TItemWithTs runningItem(item); - TDuration d; - if (RunningItems.CopyAndRemove(runningItem)) { - auto now = Timer.Now(); - d = now - runningItem.Timestamp; - if (Config.IsCircular) { - ReEnqueueNoStart(item); - } - StartOperations(); - } - - return d; -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::Wakeup() { - StartOperations(); - ScheduleWakeup(); -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::Clear() { - ReadyQueue.Clear(); - RunningItems.Clear(); - WaitingItems.Clear(); - ItemsToShuffle.clear(); -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::CheckTimeoutOperations() { - if (!Config.Timeout) - return; - - if (RunningItems.Empty()) - return; - - auto now = Timer.Now(); - while (!RunningItems.Empty()) { - const auto& item = RunningItems.Front(); - if (item.Timestamp + Config.Timeout <= now) { - ++TimeoutCount; - if (Config.IsCircular) - ReEnqueueNoStart(std::move(item.Item)); - RunningItems.PopFront(); - continue; - } - break; - } -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::CheckWaitingOperations() { - if (WaitingItems.Empty()) - return; - - auto now = Timer.Now(); - while (!WaitingItems.Empty()) { - const auto& item = WaitingItems.Front(); - if (item.Timestamp + Config.MinOperationRepeatDelay > now) - break; - EnqueueNoStart(std::move(item.Item)); - WaitingItems.PopFront(); - } -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::StartOperations() { - CheckTimeoutOperations(); - CheckWaitingOperations(); - - if (!Running) - return; - - if ((ReadyQueue.Empty() && WaitingItems.Empty()) || RunningItems.Size() == Config.InflightLimit) - return; - - Y_VERIFY(RunningItems.Size() < Config.InflightLimit); - - auto now = Timer.Now(); - TokenBucket.Fill(now); - auto maxTries = ReadyQueue.Size(); - for (size_t tries = 0; RunningItems.Size() != Config.InflightLimit && tries < maxTries && TokenBucket.Available() >= 0; ++tries) { - auto item = ReadyQueue.Front(); - auto status = Starter.StartOperation(item); - ReadyQueue.PopFront(); - switch (status) { - case EStartStatus::EOperationRunning: - TokenBucket.Take(1); - RunningItems.PushBack(TItemWithTs(std::move(item), now)); - break; - case EStartStatus::EOperationRetry: - ReadyQueue.Enqueue(std::move(item)); - break; - case EStartStatus::EOperationRemove: - break; - } - } - - ScheduleWakeup(); -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::ScheduleWakeup() { - if (RunningItems.Empty() && !Running) - return; - - auto now = Timer.Now(); - if (RunningItems.Empty() && !ReadyQueue.Empty()) { - // special case when we failed to start anything - if (!NextWakeup || NextWakeup <= now) { - NextWakeup = now + Config.WakeupInterval; - Timer.SetWakeupTimer(NextWakeup); - return; - } - } - - auto wakeup = TInstant::Max(); - - if (Config.Timeout && !RunningItems.Empty()) { - const auto& item = RunningItems.Front(); - wakeup = Min(wakeup, item.Timestamp + Config.Timeout); - } - - if (!WaitingItems.Empty()) { - const auto& item = WaitingItems.Front(); - wakeup = Min(wakeup, item.Timestamp + Config.MinOperationRepeatDelay); - } - - if (wakeup == TInstant::Max()) - return; - - // no sense to wakeup earlier that rate limit allows - if (Config.Rate) { - wakeup = Max(wakeup, now + TokenBucket.NextAvailableDelay()); - } - - if (!NextWakeup || NextWakeup > wakeup || NextWakeup <= now) { - NextWakeup = wakeup; - Timer.SetWakeupTimer(NextWakeup); - } -} - -template <typename T, typename TQueue> -void TOperationQueue<T, TQueue>::Dump(IOutputStream& out) const { - out << "{ ReadyQueue #" << ReadyQueue.Size() - << " {" << JoinSeq(", ", GetQueue()) << "}, " - << "Running #" << RunningItems.Size() - << " {" << JoinSeq(", ", GetRunning()) << "}, " - << "Waiting #" << WaitingItems.Size() - << " {" << JoinSeq(", ", GetWaiting()) << "}}"; -} - -} // NOperationQueue -} // NKikimr + bool operator ==(const TItemWithTs& rhs) const { + return Item == rhs.Item; + } + + TItemWithTs& operator =(const TItemWithTs& rhs) { + Item = rhs.Item; + if (rhs.Timestamp) { + // avoid clearing ts, little bit hacky: + // in UpdateIfFound() we don't want to copy ts, + // but in other places we want. + // Though in UpdateIfFound rhs.Timestamp should + // be always missing while in other cases it + // always presents + Timestamp = rhs.Timestamp; + } + return *this; + } + + size_t Hash() const { + return THash<T>()(Item); + } + + explicit operator size_t() const { + return Hash(); + } + }; + + using IStarter = IStarter<T>; + using TConfig = ::NKikimr::NOperationQueue::TConfig; + +private: + using TRunningItems = TFifoQueue<TItemWithTs>; + using TWaitingItems = TFifoQueue<TItemWithTs>; + +private: + TConfig Config; + IStarter& Starter; + ITimer& Timer; + + // used only with ShuffleOnStart + TVector<T> ItemsToShuffle; + + TQueue ReadyQueue; + TRunningItems RunningItems; + TWaitingItems WaitingItems; + + TTokenBucket TokenBucket; + + TInstant NextWakeup; + bool Running = false; + bool WasRunning = false; + + ui64 TimeoutCount = 0; + +public: + TOperationQueue(const TConfig& config, + IStarter& starter, + ITimer& timer) + : Config(config) + , Starter(starter) + , Timer(timer) + { + UpdateConfig(Config); + } + + void UpdateConfig(const TConfig& config) { + if (&Config != &config) + Config = config; + + if (Config.Rate) { + // by default token bucket is unlimitted, so + // configure only when rate is limited + TokenBucket.SetCapacity(Config.InflightLimit); + TokenBucket.SetRate(Config.Rate); + TokenBucket.Fill(Timer.Now()); + } + } + + // Items enqueued before Start() will start + void Start(); + + // Can be used to pause, note that running items continue to run and + // need either OnDone() or timeout via Wakeup() + void Stop(); + + // returns true when item enqueued and false if it was already in queue. + // + // Note that when ShuffleOnStart is set, then it always returns true and + // duplicates are eliminated only when queue starts + bool Enqueue(const T& item); + + // returns true if item was in queue and removed, should + // not be called before Start() with ShuffleOnStart, because + // it will be O(N). + // + // note, that in case of circular queue it is possible + // to remove item which was already started: it's up + // to caller to stop it if needed. + bool Remove(const T& item); + + // updates operation either running/waiting/ready by + // copying item. Used in priority queues to modify + // priority + bool Update(const T& item); + + // done or failed doesn't matter, if item was running then + // returns duration between start and done + // Note that in case of circular queue item overwrites running + // item, which is useful, when new priority needed + TDuration OnDone(const T& item); + + // must be called by Starter on response to ITimer::SetWakeupTimer() + void Wakeup(); + + // Consider the case when there are running items, user clears the queue and: + // 1. Adds items with same ID and queue starts them + // 2. Calls OnDone() because previously added items done, but not new ones + void Clear(); + + // note that it is size of both ready and waiting queue, not running + size_t Size() const { return ReadyQueue.Size() + WaitingItems.Size() + ItemsToShuffle.size(); } + bool Empty() const { return ReadyQueue.Empty() && WaitingItems.Empty() && ItemsToShuffle.empty(); } + + size_t RunningSize() const { return RunningItems.Size(); } + bool RunningEmpty() const { return RunningItems.Empty(); } + + size_t WaitingSize() const { return WaitingItems.Size(); } + bool WaitingEmpty() const { return WaitingItems.Empty(); } + + ui64 ResetTimeoutCount() { return TimeoutCount; TimeoutCount = 0; } + + // copies items, should be used in tests only + TVector<T> GetQueue() const { return ReadyQueue.GetQueue(); } + TVector<TItemWithTs> GetRunning() const { return RunningItems.GetQueue(); } + TVector<TItemWithTs> GetWaiting() const { return WaitingItems.GetQueue(); } + + void Dump(IOutputStream& out) const; + +private: + template <typename T2> + bool EnqueueNoStart(T2&& item); + + template <typename T2> + void ReEnqueueNoStart(T2&& item); + + void CheckTimeoutOperations(); + void CheckWaitingOperations(); + void StartOperations(); + void ScheduleWakeup(); +}; + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::Start() { + if (Running) + return; + + if (Config.ShuffleOnStart && !ItemsToShuffle.empty()) { + ShuffleRange(ItemsToShuffle); + for (auto& item: ItemsToShuffle) { + EnqueueNoStart(std::move(item)); + } + TVector<T>().swap(ItemsToShuffle); + } + + Running = true; + WasRunning = true; + StartOperations(); +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::Stop() { + Running = false; +} + +template <typename T, typename TQueue> +bool TOperationQueue<T, TQueue>::Enqueue(const T& item) { + // note that there is no reason to reshuffle on start/stop + // also waiting/timeouted operations enqueued vid EnqueueNoStart + // thus don't use shuffling + if (!WasRunning && Config.ShuffleOnStart) { + ItemsToShuffle.push_back(item); + return true; // we don't check if item is unique + } + + if (EnqueueNoStart(item)) { + StartOperations(); + return true; + } + return false; +} + +template <typename T, typename TQueue> +template <typename T2> +bool TOperationQueue<T, TQueue>::EnqueueNoStart(T2&& item) { + return ReadyQueue.Enqueue(std::forward<T2>(item)); +} + +template <typename T, typename TQueue> +template <typename T2> +void TOperationQueue<T, TQueue>::ReEnqueueNoStart(T2&& item) { + auto now = Timer.Now(); + if (Config.MinOperationRepeatDelay) { + TItemWithTs runningItem(std::forward<T2>(item), now); + WaitingItems.PushBack(runningItem); + } else { + EnqueueNoStart(std::forward<T2>(item)); + } +} + +template <typename T, typename TQueue> +bool TOperationQueue<T, TQueue>::Remove(const T& item) { + bool removed = ReadyQueue.Remove(item); + + if (RunningItems.Remove(TItemWithTs(item))) { + StartOperations(); + } + + removed = WaitingItems.Remove(TItemWithTs(item)) || removed; + + if (ItemsToShuffle) { + auto it = Find(ItemsToShuffle.begin(), ItemsToShuffle.end(), item); + if (it != ItemsToShuffle.end()) { + ItemsToShuffle.erase(it); + return true; + } + } + + return removed; +} + +template <typename T, typename TQueue> +bool TOperationQueue<T, TQueue>::Update(const T& item) { + // note that no ts and below we will keep original ts + TItemWithTs tsItem(item); + + return ReadyQueue.UpdateIfFound(item) || + WaitingItems.UpdateIfFound(tsItem) || + RunningItems.UpdateIfFound(tsItem); +} + +template <typename T, typename TQueue> +TDuration TOperationQueue<T, TQueue>::OnDone(const T& item) { + TItemWithTs runningItem(item); + TDuration d; + if (RunningItems.CopyAndRemove(runningItem)) { + auto now = Timer.Now(); + d = now - runningItem.Timestamp; + if (Config.IsCircular) { + ReEnqueueNoStart(item); + } + StartOperations(); + } + + return d; +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::Wakeup() { + StartOperations(); + ScheduleWakeup(); +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::Clear() { + ReadyQueue.Clear(); + RunningItems.Clear(); + WaitingItems.Clear(); + ItemsToShuffle.clear(); +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::CheckTimeoutOperations() { + if (!Config.Timeout) + return; + + if (RunningItems.Empty()) + return; + + auto now = Timer.Now(); + while (!RunningItems.Empty()) { + const auto& item = RunningItems.Front(); + if (item.Timestamp + Config.Timeout <= now) { + ++TimeoutCount; + if (Config.IsCircular) + ReEnqueueNoStart(std::move(item.Item)); + RunningItems.PopFront(); + continue; + } + break; + } +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::CheckWaitingOperations() { + if (WaitingItems.Empty()) + return; + + auto now = Timer.Now(); + while (!WaitingItems.Empty()) { + const auto& item = WaitingItems.Front(); + if (item.Timestamp + Config.MinOperationRepeatDelay > now) + break; + EnqueueNoStart(std::move(item.Item)); + WaitingItems.PopFront(); + } +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::StartOperations() { + CheckTimeoutOperations(); + CheckWaitingOperations(); + + if (!Running) + return; + + if ((ReadyQueue.Empty() && WaitingItems.Empty()) || RunningItems.Size() == Config.InflightLimit) + return; + + Y_VERIFY(RunningItems.Size() < Config.InflightLimit); + + auto now = Timer.Now(); + TokenBucket.Fill(now); + auto maxTries = ReadyQueue.Size(); + for (size_t tries = 0; RunningItems.Size() != Config.InflightLimit && tries < maxTries && TokenBucket.Available() >= 0; ++tries) { + auto item = ReadyQueue.Front(); + auto status = Starter.StartOperation(item); + ReadyQueue.PopFront(); + switch (status) { + case EStartStatus::EOperationRunning: + TokenBucket.Take(1); + RunningItems.PushBack(TItemWithTs(std::move(item), now)); + break; + case EStartStatus::EOperationRetry: + ReadyQueue.Enqueue(std::move(item)); + break; + case EStartStatus::EOperationRemove: + break; + } + } + + ScheduleWakeup(); +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::ScheduleWakeup() { + if (RunningItems.Empty() && !Running) + return; + + auto now = Timer.Now(); + if (RunningItems.Empty() && !ReadyQueue.Empty()) { + // special case when we failed to start anything + if (!NextWakeup || NextWakeup <= now) { + NextWakeup = now + Config.WakeupInterval; + Timer.SetWakeupTimer(NextWakeup); + return; + } + } + + auto wakeup = TInstant::Max(); + + if (Config.Timeout && !RunningItems.Empty()) { + const auto& item = RunningItems.Front(); + wakeup = Min(wakeup, item.Timestamp + Config.Timeout); + } + + if (!WaitingItems.Empty()) { + const auto& item = WaitingItems.Front(); + wakeup = Min(wakeup, item.Timestamp + Config.MinOperationRepeatDelay); + } + + if (wakeup == TInstant::Max()) + return; + + // no sense to wakeup earlier that rate limit allows + if (Config.Rate) { + wakeup = Max(wakeup, now + TokenBucket.NextAvailableDelay()); + } + + if (!NextWakeup || NextWakeup > wakeup || NextWakeup <= now) { + NextWakeup = wakeup; + Timer.SetWakeupTimer(NextWakeup); + } +} + +template <typename T, typename TQueue> +void TOperationQueue<T, TQueue>::Dump(IOutputStream& out) const { + out << "{ ReadyQueue #" << ReadyQueue.Size() + << " {" << JoinSeq(", ", GetQueue()) << "}, " + << "Running #" << RunningItems.Size() + << " {" << JoinSeq(", ", GetRunning()) << "}, " + << "Waiting #" << WaitingItems.Size() + << " {" << JoinSeq(", ", GetWaiting()) << "}}"; +} + +} // NOperationQueue +} // NKikimr diff --git a/ydb/core/util/operation_queue_priority_ut.cpp b/ydb/core/util/operation_queue_priority_ut.cpp index 59de557b8b5..1639ef8c9d7 100644 --- a/ydb/core/util/operation_queue_priority_ut.cpp +++ b/ydb/core/util/operation_queue_priority_ut.cpp @@ -1,340 +1,340 @@ -#include "operation_queue.h" - -#include "circular_queue.h" - -#include <library/cpp/testing/unittest/registar.h> - +#include "operation_queue.h" + +#include "circular_queue.h" + +#include <library/cpp/testing/unittest/registar.h> + #include <util/generic/ptr.h> #include <util/generic/xrange.h> - - -namespace NKikimr { -namespace NOperationQueue { - -struct TPriorityItem { - int Id = 0; - int Priority = 0; - - TPriorityItem(int id, int priority) - : Id(id) - , Priority(priority) - { - } - + + +namespace NKikimr { +namespace NOperationQueue { + +struct TPriorityItem { + int Id = 0; + int Priority = 0; + + TPriorityItem(int id, int priority) + : Id(id) + , Priority(priority) + { + } + TPriorityItem(const TPriorityItem&) = default; - bool operator ==(const TPriorityItem& rhs) const { - // note that only identity intentionally checked - return Id == rhs.Id; - } - - TPriorityItem& operator =(const TPriorityItem& rhs) { - // TODO: assert that ID's are the same, because we - // use it as update rather than real assignment - Id = rhs.Id; - Priority = rhs.Priority; - return *this; + bool operator ==(const TPriorityItem& rhs) const { + // note that only identity intentionally checked + return Id == rhs.Id; + } + + TPriorityItem& operator =(const TPriorityItem& rhs) { + // TODO: assert that ID's are the same, because we + // use it as update rather than real assignment + Id = rhs.Id; + Priority = rhs.Priority; + return *this; + } + + size_t Hash() const { + return THash<int>()(Id); + } + + explicit operator size_t() const { + return Hash(); + } + + struct TLessByPriority { + bool operator()(const TPriorityItem& lhs, const TPriorityItem& rhs) const { + // note ">" is intentional + return lhs.Priority > rhs.Priority; + } + }; + + TString ToString() const { + TStringStream ss; + ss << "{" << Id << "," << Priority << "}"; + return ss.Str(); + } +}; + +using TPriorityQueue = TOperationQueue< + TPriorityItem, + TQueueWithPriority< + TPriorityItem, + TPriorityItem::TLessByPriority>>; + +namespace { + +TDuration Timeout = TDuration::Minutes(10); + +class TSimpleTimeProvider : public ITimeProvider { +public: + TInstant Now() override { + return Now_; + } + + void Move(TDuration delta) { + Now_ += delta; + } + + void Move(TInstant now) { + Now_ = now; + } + +private: + TInstant Now_; +}; + + +struct TOperationStarter : public TPriorityQueue::IStarter, public NOperationQueue::ITimer { + TSimpleTimeProvider TimeProvider; + + TVector<TPriorityItem> StartHistory; + TVector<TInstant> WakeupHistory; + + NOperationQueue::EStartStatus StartResult = NOperationQueue::EStartStatus::EOperationRunning; + + NOperationQueue::EStartStatus StartOperation(const TPriorityItem& itemId) override + { + StartHistory.push_back(itemId); + return StartResult; + } + + void SetWakeupTimer(TInstant t) override + { + WakeupHistory.push_back(t); + } + + TInstant Now() override + { + return TimeProvider.Now(); + } +}; + +} // namespace + +Y_UNIT_TEST_SUITE(TPriorityOperationQueueTest) { + Y_UNIT_TEST(ShouldStartEmpty) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Start(); + UNIT_ASSERT(queue.Empty()); + UNIT_ASSERT(starter.StartHistory.empty()); + UNIT_ASSERT(starter.WakeupHistory.empty()); + } + + Y_UNIT_TEST(ShouldNotStartUntilStart) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Enqueue({1, 1}); + queue.Enqueue({2, 2}); + queue.Enqueue({3, 3}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT(starter.StartHistory.empty()); + UNIT_ASSERT(starter.WakeupHistory.empty()); + } + + Y_UNIT_TEST(ShouldStartByPriority) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Enqueue({1, 1}); + queue.Enqueue({3, 3}); + queue.Enqueue({2, 2}); + + queue.Start(); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 3)); + + queue.OnDone({3, 0}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); + + queue.OnDone({2, 0}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); + + // test that circular property works + + queue.OnDone({1, 0}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 4UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 1)); + + queue.OnDone({3, 0}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 1)); + + queue.OnDone({2, 0}); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 6UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); + } + + Y_UNIT_TEST(ShouldStartByPriorityWithRemove) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Enqueue({1, 1}); + queue.Enqueue({3, 3}); + queue.Enqueue({2, 2}); + + queue.Start(); + + UNIT_ASSERT(queue.Remove({2,2})); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + + queue.OnDone({3, 0}); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); } - - size_t Hash() const { - return THash<int>()(Id); - } - - explicit operator size_t() const { - return Hash(); - } - - struct TLessByPriority { - bool operator()(const TPriorityItem& lhs, const TPriorityItem& rhs) const { - // note ">" is intentional - return lhs.Priority > rhs.Priority; - } - }; - - TString ToString() const { - TStringStream ss; - ss << "{" << Id << "," << Priority << "}"; - return ss.Str(); - } -}; - -using TPriorityQueue = TOperationQueue< - TPriorityItem, - TQueueWithPriority< - TPriorityItem, - TPriorityItem::TLessByPriority>>; - -namespace { - -TDuration Timeout = TDuration::Minutes(10); - -class TSimpleTimeProvider : public ITimeProvider { -public: - TInstant Now() override { - return Now_; - } - - void Move(TDuration delta) { - Now_ += delta; - } - - void Move(TInstant now) { - Now_ = now; - } - -private: - TInstant Now_; -}; - - -struct TOperationStarter : public TPriorityQueue::IStarter, public NOperationQueue::ITimer { - TSimpleTimeProvider TimeProvider; - - TVector<TPriorityItem> StartHistory; - TVector<TInstant> WakeupHistory; - - NOperationQueue::EStartStatus StartResult = NOperationQueue::EStartStatus::EOperationRunning; - - NOperationQueue::EStartStatus StartOperation(const TPriorityItem& itemId) override - { - StartHistory.push_back(itemId); - return StartResult; - } - - void SetWakeupTimer(TInstant t) override - { - WakeupHistory.push_back(t); - } - - TInstant Now() override - { - return TimeProvider.Now(); - } -}; - -} // namespace - -Y_UNIT_TEST_SUITE(TPriorityOperationQueueTest) { - Y_UNIT_TEST(ShouldStartEmpty) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Start(); - UNIT_ASSERT(queue.Empty()); - UNIT_ASSERT(starter.StartHistory.empty()); - UNIT_ASSERT(starter.WakeupHistory.empty()); - } - - Y_UNIT_TEST(ShouldNotStartUntilStart) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Enqueue({1, 1}); - queue.Enqueue({2, 2}); - queue.Enqueue({3, 3}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT(starter.StartHistory.empty()); - UNIT_ASSERT(starter.WakeupHistory.empty()); - } - - Y_UNIT_TEST(ShouldStartByPriority) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Enqueue({1, 1}); - queue.Enqueue({3, 3}); - queue.Enqueue({2, 2}); - - queue.Start(); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 3)); - - queue.OnDone({3, 0}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); - - queue.OnDone({2, 0}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); - - // test that circular property works - - queue.OnDone({1, 0}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 4UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 1)); - - queue.OnDone({3, 0}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 1)); - - queue.OnDone({2, 0}); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 6UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); - } - - Y_UNIT_TEST(ShouldStartByPriorityWithRemove) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Enqueue({1, 1}); - queue.Enqueue({3, 3}); - queue.Enqueue({2, 2}); - - queue.Start(); - - UNIT_ASSERT(queue.Remove({2,2})); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - - queue.OnDone({3, 0}); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 1)); - } - - Y_UNIT_TEST(ShouldUpdatePriorityReadyQueue) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Enqueue({1, 1}); - queue.Enqueue({3, 3}); - queue.Enqueue({2, 2}); - - queue.Start(); - - UNIT_ASSERT(queue.Update({1, 100})); - queue.OnDone({3, 0}); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 100)); - - UNIT_ASSERT(queue.Update({3, 100})); - queue.OnDone({1, 0}); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 100)); - - queue.OnDone({3, 0}); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 4UL); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); - } - - Y_UNIT_TEST(ShouldUpdatePriorityWaitingQueue) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - config.MinOperationRepeatDelay = TDuration::Minutes(10); - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Enqueue({1, 1}); - queue.Enqueue({3, 3}); - queue.Enqueue({2, 2}); - - queue.Start(); - - queue.OnDone({3, 0}); - queue.OnDone({2, 0}); - queue.OnDone({1, 0}); - - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - - UNIT_ASSERT(queue.Update({2, 3})); - UNIT_ASSERT(queue.Update({3, 2})); - UNIT_ASSERT(queue.Update({1, 1})); - - starter.TimeProvider.Move(TDuration::Hours(1)); - queue.Wakeup(); - - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 3)); - queue.OnDone({2, 0}); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 2)); - queue.OnDone({3, 0}); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 2)); - } - - Y_UNIT_TEST(ShouldReturnExecTimeWhenUpdateRunningPriority) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - config.MinOperationRepeatDelay = TDuration::Minutes(10); - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - - queue.Enqueue({1, 1}); - queue.Enqueue({2, 2}); - - starter.TimeProvider.Move(TDuration::Seconds(5)); // 01:00:05 - - UNIT_ASSERT(queue.Update({1, 100})); - - starter.TimeProvider.Move(TDuration::Seconds(1)); // 01:00:06 - - auto duration = queue.OnDone({1, 0}); - - UNIT_ASSERT_VALUES_EQUAL(duration, TDuration::Seconds(6)); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); - } - - Y_UNIT_TEST(UpdateNonExistingShouldReturnFalse) { - TPriorityQueue::TConfig config; - config.IsCircular = true; - config.Timeout = Timeout; - config.MinOperationRepeatDelay = TDuration::Minutes(10); - TOperationStarter starter; - - TPriorityQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue({1, 1}); - queue.Enqueue({2, 2}); - - UNIT_ASSERT(!queue.Update({3, 100})); - } -}; - -} // NOperationQueue -} // NKikimr - -using TSomeQueue = NKikimr::NOperationQueue::TPriorityQueue; -template<> -void Out<TSomeQueue::TItemWithTs>(IOutputStream& o, const TSomeQueue::TItemWithTs& item) { - o << "{" << item.Item << "," << item.Timestamp << "}"; -} - -template<> -void Out<NKikimr::NOperationQueue::TPriorityItem>(IOutputStream& o, const NKikimr::NOperationQueue::TPriorityItem& item) { - o << item.ToString(); -} + + Y_UNIT_TEST(ShouldUpdatePriorityReadyQueue) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Enqueue({1, 1}); + queue.Enqueue({3, 3}); + queue.Enqueue({2, 2}); + + queue.Start(); + + UNIT_ASSERT(queue.Update({1, 100})); + queue.OnDone({3, 0}); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 100)); + + UNIT_ASSERT(queue.Update({3, 100})); + queue.OnDone({1, 0}); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 100)); + + queue.OnDone({3, 0}); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 4UL); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); + } + + Y_UNIT_TEST(ShouldUpdatePriorityWaitingQueue) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + config.MinOperationRepeatDelay = TDuration::Minutes(10); + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Enqueue({1, 1}); + queue.Enqueue({3, 3}); + queue.Enqueue({2, 2}); + + queue.Start(); + + queue.OnDone({3, 0}); + queue.OnDone({2, 0}); + queue.OnDone({1, 0}); + + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + + UNIT_ASSERT(queue.Update({2, 3})); + UNIT_ASSERT(queue.Update({3, 2})); + UNIT_ASSERT(queue.Update({1, 1})); + + starter.TimeProvider.Move(TDuration::Hours(1)); + queue.Wakeup(); + + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 3)); + queue.OnDone({2, 0}); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(3, 2)); + queue.OnDone({3, 0}); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(1, 2)); + } + + Y_UNIT_TEST(ShouldReturnExecTimeWhenUpdateRunningPriority) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + config.MinOperationRepeatDelay = TDuration::Minutes(10); + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + + queue.Enqueue({1, 1}); + queue.Enqueue({2, 2}); + + starter.TimeProvider.Move(TDuration::Seconds(5)); // 01:00:05 + + UNIT_ASSERT(queue.Update({1, 100})); + + starter.TimeProvider.Move(TDuration::Seconds(1)); // 01:00:06 + + auto duration = queue.OnDone({1, 0}); + + UNIT_ASSERT_VALUES_EQUAL(duration, TDuration::Seconds(6)); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.back(), TPriorityItem(2, 2)); + } + + Y_UNIT_TEST(UpdateNonExistingShouldReturnFalse) { + TPriorityQueue::TConfig config; + config.IsCircular = true; + config.Timeout = Timeout; + config.MinOperationRepeatDelay = TDuration::Minutes(10); + TOperationStarter starter; + + TPriorityQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue({1, 1}); + queue.Enqueue({2, 2}); + + UNIT_ASSERT(!queue.Update({3, 100})); + } +}; + +} // NOperationQueue +} // NKikimr + +using TSomeQueue = NKikimr::NOperationQueue::TPriorityQueue; +template<> +void Out<TSomeQueue::TItemWithTs>(IOutputStream& o, const TSomeQueue::TItemWithTs& item) { + o << "{" << item.Item << "," << item.Timestamp << "}"; +} + +template<> +void Out<NKikimr::NOperationQueue::TPriorityItem>(IOutputStream& o, const NKikimr::NOperationQueue::TPriorityItem& item) { + o << item.ToString(); +} diff --git a/ydb/core/util/operation_queue_ut.cpp b/ydb/core/util/operation_queue_ut.cpp index e4d6abed3aa..f6093d2fb86 100644 --- a/ydb/core/util/operation_queue_ut.cpp +++ b/ydb/core/util/operation_queue_ut.cpp @@ -1,897 +1,897 @@ -#include "operation_queue.h" - -#include "circular_queue.h" - -#include <library/cpp/testing/unittest/registar.h> - +#include "operation_queue.h" + +#include "circular_queue.h" + +#include <library/cpp/testing/unittest/registar.h> + #include <util/generic/ptr.h> #include <util/generic/xrange.h> - -namespace NKikimr { -namespace NOperationQueue { - -namespace { - -TDuration Timeout = TDuration::Minutes(10); - -class TSimpleTimeProvider : public ITimeProvider { -public: - TInstant Now() override { - return Now_; - } - - void Move(TDuration delta) { - Now_ += delta; - } - - void Move(TInstant now) { - Now_ = now; - } - -private: - TInstant Now_; -}; - -using TQueue = TOperationQueue<int, TFifoQueue<int>>; - -struct TOperationStarter : public TQueue::IStarter, public NOperationQueue::ITimer { - TSimpleTimeProvider TimeProvider; - - TVector<int> StartHistory; - TVector<TInstant> WakeupHistory; - - NOperationQueue::EStartStatus StartResult = NOperationQueue::EStartStatus::EOperationRunning; - - NOperationQueue::EStartStatus StartOperation(const int& itemId) override - { - StartHistory.push_back(itemId); - return StartResult; - } - - void SetWakeupTimer(TInstant t) override - { - WakeupHistory.push_back(t); - } - - TInstant Now() override - { - return TimeProvider.Now(); - } -}; - -void CheckQueue( - const TQueue& queue, - const TOperationStarter& starter, - TVector<TQueue::TItemWithTs> runningGold, - TVector<int> inQueueGold, - TVector<int> startHistory, - TVector<TInstant> wakeupHistory) -{ - auto running = queue.GetRunning(); - auto inQueue = queue.GetQueue(); - UNIT_ASSERT_VALUES_EQUAL(running.size(), runningGold.size()); - UNIT_ASSERT_VALUES_EQUAL(inQueue.size(), inQueueGold.size()); - UNIT_ASSERT_VALUES_EQUAL(running, runningGold); - UNIT_ASSERT_VALUES_EQUAL(inQueue, inQueueGold); - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory, startHistory); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory, wakeupHistory); -} - -void TestStartInflightBeforeStart(int inflight, int pushN = 10) { - TQueue::TConfig config; - config.InflightLimit = inflight; - config.Timeout = Timeout; - TOperationStarter starter; - - auto now = starter.TimeProvider.Now(); - - TQueue queue(config, starter, starter); - - for (int i: xrange(pushN)) { - queue.Enqueue(i); - } - - queue.Start(); - auto running = queue.GetRunning(); - auto startN = Min(inflight, pushN); - UNIT_ASSERT_VALUES_EQUAL(running.size(), startN); - - int firstStarted = 0; - int firstNotStarted = firstStarted + startN; - - TVector<TQueue::TItemWithTs> runningGold; - for (int i: xrange(firstNotStarted)) { - runningGold.push_back({i, now}); - } - - TVector<TInstant> wakeupsGold = - { starter.TimeProvider.Now() + config.Timeout }; - - CheckQueue( - queue, - starter, - runningGold, - xrange(firstNotStarted, pushN), - xrange(firstNotStarted), - wakeupsGold); -} - -void TestInflightWithEnqueue(int inflight, int pushN = 10) { - TQueue::TConfig config; - config.InflightLimit = inflight; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - TVector<TQueue::TItemWithTs> runningGold; - TVector<int> queuedGold; - - TVector<TInstant> wakeupsGold = - { starter.TimeProvider.Now() + TDuration::Seconds(1) + config.Timeout }; - - int lastStarted = 0; - - for (int lastPushed: xrange(pushN)) { - starter.TimeProvider.Move(TDuration::Seconds(1)); - auto now = starter.TimeProvider.Now(); - - queue.Enqueue(lastPushed); - - if (runningGold.size() < (size_t)inflight) { - lastStarted = lastPushed; - runningGold.push_back({lastStarted, now}); - } else { - queuedGold.push_back(lastPushed); - } - - CheckQueue( - queue, - starter, - runningGold, - queuedGold, - xrange(lastStarted + 1), - wakeupsGold); - } -} - -} // namespace - -Y_UNIT_TEST_SUITE(TCircularOperationQueueTest) { - Y_UNIT_TEST(ShouldStartEmpty) { - TQueue::TConfig config; - config.IsCircular = true; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - UNIT_ASSERT(queue.Empty()); - UNIT_ASSERT(starter.StartHistory.empty()); - UNIT_ASSERT(starter.WakeupHistory.empty()); - } - - Y_UNIT_TEST(ShouldNotStartUntilStart) { - TQueue::TConfig config; - config.IsCircular = true; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT(starter.StartHistory.empty()); - UNIT_ASSERT(starter.WakeupHistory.empty()); - } - - Y_UNIT_TEST(ShouldStartInflight1) { - TestStartInflightBeforeStart(1); - } - - Y_UNIT_TEST(ShouldStartInflight2) { - TestStartInflightBeforeStart(2); - } - - Y_UNIT_TEST(ShouldStartInflight3) { - TestStartInflightBeforeStart(3); - } - - Y_UNIT_TEST(ShouldStartInflight10) { - TestStartInflightBeforeStart(10, 10); - } - - Y_UNIT_TEST(ShouldStartInflight100) { - TestStartInflightBeforeStart(100); - } - - Y_UNIT_TEST(ShouldStartInflightEnqueue1) { - TestInflightWithEnqueue(1); - } - - Y_UNIT_TEST(ShouldStartInflightEnqueue2) { - TestInflightWithEnqueue(2); - } - - Y_UNIT_TEST(ShouldStartInflightEnqueue3) { - TestInflightWithEnqueue(3); - } - - Y_UNIT_TEST(ShouldStartInflightEnqueue10) { - TestInflightWithEnqueue(10, 10); - } - - Y_UNIT_TEST(ShouldStartInflightEnqueue100) { - TestInflightWithEnqueue(100); - } - - Y_UNIT_TEST(CheckOnDoneInflight1) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - - queue.OnDone(1); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({3, 4, 1})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); - } - - Y_UNIT_TEST(CheckOnDoneInflight2) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 2; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - queue.OnDone(2); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({4, 5, 2})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[1].Item, 3); - - queue.OnDone(1); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({5, 2, 1})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 3); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[1].Item, 4); - } - - Y_UNIT_TEST(CheckOnDoneNotExisting) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - - queue.OnDone(5); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({2, 3, 4})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); - } - - Y_UNIT_TEST(CheckRemoveNotRunning) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - UNIT_ASSERT(queue.Remove(3)); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({2, 4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); - - UNIT_ASSERT(queue.Remove(2)); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); - } - - Y_UNIT_TEST(CheckRemoveRunning) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - - UNIT_ASSERT(!queue.Remove(1)); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({3, 4})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); - } - - Y_UNIT_TEST(CheckRemoveWaiting) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - config.MinOperationRepeatDelay = TDuration::Minutes(10); - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - - queue.OnDone(1); - - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); - UNIT_ASSERT(queue.Remove(1)); - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); - } - - Y_UNIT_TEST(CheckRemoveNotExisting) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - - UNIT_ASSERT(!queue.Remove(5)); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({2, 3, 4})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); - } - - Y_UNIT_TEST(CheckTimeout) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - auto t1 = starter.TimeProvider.Now(); - auto d1 = t1 + Timeout; // 01:10:00 - queue.Enqueue(1); - - starter.TimeProvider.Move(TDuration::Seconds(1)); - queue.Enqueue(2); - queue.Enqueue(3); - - starter.TimeProvider.Move(TDuration::Seconds(10)); - queue.Enqueue(4); - queue.Enqueue(5); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); - - starter.TimeProvider.Move(d1); - auto t2 = starter.TimeProvider.Now(); - auto d2 = t2 + Timeout; - queue.Wakeup(); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({3, 4, 5, 1})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[1], d2); - - starter.TimeProvider.Move(d2); - auto t3 = starter.TimeProvider.Now(); - auto d3 = t3 + Timeout; - queue.Wakeup(); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({4, 5, 1, 2})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 3); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[2], d3); - } - - Y_UNIT_TEST(CheckTimeoutWhenFirstItemRemoved) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - auto t1 = starter.TimeProvider.Now(); - auto d1 = t1 + Timeout; // 01:10:00 - queue.Enqueue(1); - - starter.TimeProvider.Move(TDuration::Seconds(1)); - queue.Enqueue(2); - queue.Enqueue(3); - - starter.TimeProvider.Move(TDuration::Seconds(10)); - queue.Enqueue(4); - queue.Enqueue(5); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); - - starter.TimeProvider.Move(TDuration::Seconds(5)); - auto t2 = starter.TimeProvider.Now(); - auto d2 = t2 + Timeout; - - queue.Remove(1); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({3, 4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); - - // must still wait for the first wakeup - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); - - starter.TimeProvider.Move(d1); - queue.Wakeup(); - - // check no changes in queue sinse last time except new wakeup scheduled - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({3, 4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); - - // must still wait for the first wakeup - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 2UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[1], d2); - } - - Y_UNIT_TEST(ShouldScheduleWakeupWhenNothingStarted) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - - TOperationStarter starter; - starter.StartResult = NOperationQueue::EStartStatus::EOperationRetry; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - auto t1 = starter.TimeProvider.Now(); - auto d1 = t1 + config.WakeupInterval; - - queue.Enqueue(1); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({1})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); - } - - Y_UNIT_TEST(ShouldScheduleWakeupWhenHasWaitingAndStart) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = TDuration::Zero(); // disable timeout - config.MinOperationRepeatDelay = TDuration::Minutes(10); - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - - queue.Enqueue(1); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - - starter.TimeProvider.Move(TDuration::Minutes(1)); // 01:01:00 - queue.OnDone(1); - auto t1 = starter.TimeProvider.Now(); - auto d1 = t1 + config.MinOperationRepeatDelay; - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); - - // some spurious wakeup - starter.TimeProvider.Move(TDuration::Minutes(1)); - queue.Wakeup(); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - - starter.TimeProvider.Move(d1); - queue.Wakeup(); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); - } - - Y_UNIT_TEST(UseMinOperationRepeatDelayWhenTimeout) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - config.MinOperationRepeatDelay = TDuration::Minutes(10); - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); - - queue.Enqueue(1); - starter.TimeProvider.Move(Timeout + TDuration::Minutes(1)); - queue.Wakeup(); - - auto t1 = starter.TimeProvider.Now(); - auto d1 = t1 + config.MinOperationRepeatDelay; - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); - UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); - - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.back(), d1); - } - - Y_UNIT_TEST(ShouldReturnExecTime) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 - - queue.Enqueue(1); - starter.TimeProvider.Move(TDuration::Seconds(5)); // 01:00:05 - auto duration = queue.OnDone(1); - - UNIT_ASSERT_VALUES_EQUAL(duration, TDuration::Seconds(5)); - } - - Y_UNIT_TEST(ShouldTryToStartAnotherOneWhenStartFails) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 1; - config.Timeout = Timeout; - - TOperationStarter starter; - starter.StartResult = NOperationQueue::EStartStatus::EOperationRetry; - - TQueue queue(config, starter, starter); - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - queue.Start(); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - UNIT_ASSERT_VALUES_EQUAL( - queue.GetQueue(), - TVector<int>({1, 2, 3, 4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - } - - Y_UNIT_TEST(ShouldShuffle) { - TQueue::TConfig config; - config.IsCircular = true; - config.ShuffleOnStart = true; - config.InflightLimit = 5; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - queue.Start(); - - UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); - - UNIT_ASSERT(starter.StartHistory != TVector<int>({1, 2, 3, 4, 5})); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 5UL); - } - - Y_UNIT_TEST(RemoveExistingWhenShuffle) { - TQueue::TConfig config; - config.IsCircular = true; - config.ShuffleOnStart = true; - config.InflightLimit = 5; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - UNIT_ASSERT(queue.Remove(3)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); - - const auto& queueVector = queue.GetQueue(); - UNIT_ASSERT(Find(queueVector.begin(), queueVector.end(), 3) == queueVector.end()); - } - - Y_UNIT_TEST(RemoveNonExistingWhenShuffle) { - TQueue::TConfig config; - config.IsCircular = true; - config.ShuffleOnStart = true; - config.InflightLimit = 5; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - UNIT_ASSERT(!queue.Remove(10)); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - } - - Y_UNIT_TEST(BasicRPSCheck) { - TQueue::TConfig config; - config.IsCircular = true; - config.InflightLimit = 2; - config.Rate = 1.0; - config.Timeout = Timeout; - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - queue.Enqueue(1); - queue.Enqueue(2); - queue.Enqueue(3); - queue.Enqueue(4); - queue.Enqueue(5); - - // initially buckets were full, thus 2 running - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - - queue.OnDone(1); - - // should start another one because RPS smoothing - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - - // some spurious wakeup - starter.TimeProvider.Move(TDuration::MilliSeconds(100)); - queue.Wakeup(); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - - queue.OnDone(2); - - // some spurious wakeup2, note that RPS forbids - // starting more operations - starter.TimeProvider.Move(TDuration::MilliSeconds(100)); - queue.Wakeup(); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); - - // 1 second left, we can start 1 more - starter.TimeProvider.Move(TDuration::MilliSeconds(900)); - queue.Wakeup(); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - - starter.TimeProvider.Move(TDuration::Seconds(1)); - queue.OnDone(2); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); - } - - Y_UNIT_TEST(CheckWakeupAfterStop) { - TQueue::TConfig config; - config.IsCircular = true; - config.ShuffleOnStart = true; - config.InflightLimit = 3; - config.Timeout = Timeout; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - auto now = starter.TimeProvider.Now(); - for (auto i: xrange(1, 6)) { - queue.Enqueue(i); - starter.TimeProvider.Move(TDuration::Seconds(1)); - } - - queue.Stop(); - - auto currentWakeup = now + Timeout; - for (auto i: xrange(1, 4)) { - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), i); - UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[i-1], currentWakeup); - starter.TimeProvider.Move(currentWakeup); - queue.Wakeup(); - currentWakeup += TDuration::Seconds(1); - } - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - } - - Y_UNIT_TEST(CheckStartAfterStop) { - TQueue::TConfig config; - config.IsCircular = true; - config.ShuffleOnStart = true; - config.InflightLimit = 3; - config.Timeout = Timeout; - - TOperationStarter starter; - - TQueue queue(config, starter, starter); - queue.Start(); - - for (auto i: xrange(1, 6)) { - queue.Enqueue(i); - } - - queue.Stop(); - for (auto i: xrange(1, 4)) { - queue.OnDone(i); - } - - starter.TimeProvider.Move(Timeout); - queue.Wakeup(); - - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); - - starter.TimeProvider.Move(Timeout); - - queue.Start(); - UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 3UL); - UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); - UNIT_ASSERT(starter.WakeupHistory.back() > starter.TimeProvider.Now()); - } -}; - -} // NOperationQueue -} // NKikimr - -using TSomeQueue = NKikimr::NOperationQueue::TOperationQueue<int, NKikimr::TFifoQueue<int>>; -template<> -void Out<TSomeQueue::TItemWithTs>(IOutputStream& o, const TSomeQueue::TItemWithTs& item) { - o << "{" << item.Item << "," << item.Timestamp << "}"; -} + +namespace NKikimr { +namespace NOperationQueue { + +namespace { + +TDuration Timeout = TDuration::Minutes(10); + +class TSimpleTimeProvider : public ITimeProvider { +public: + TInstant Now() override { + return Now_; + } + + void Move(TDuration delta) { + Now_ += delta; + } + + void Move(TInstant now) { + Now_ = now; + } + +private: + TInstant Now_; +}; + +using TQueue = TOperationQueue<int, TFifoQueue<int>>; + +struct TOperationStarter : public TQueue::IStarter, public NOperationQueue::ITimer { + TSimpleTimeProvider TimeProvider; + + TVector<int> StartHistory; + TVector<TInstant> WakeupHistory; + + NOperationQueue::EStartStatus StartResult = NOperationQueue::EStartStatus::EOperationRunning; + + NOperationQueue::EStartStatus StartOperation(const int& itemId) override + { + StartHistory.push_back(itemId); + return StartResult; + } + + void SetWakeupTimer(TInstant t) override + { + WakeupHistory.push_back(t); + } + + TInstant Now() override + { + return TimeProvider.Now(); + } +}; + +void CheckQueue( + const TQueue& queue, + const TOperationStarter& starter, + TVector<TQueue::TItemWithTs> runningGold, + TVector<int> inQueueGold, + TVector<int> startHistory, + TVector<TInstant> wakeupHistory) +{ + auto running = queue.GetRunning(); + auto inQueue = queue.GetQueue(); + UNIT_ASSERT_VALUES_EQUAL(running.size(), runningGold.size()); + UNIT_ASSERT_VALUES_EQUAL(inQueue.size(), inQueueGold.size()); + UNIT_ASSERT_VALUES_EQUAL(running, runningGold); + UNIT_ASSERT_VALUES_EQUAL(inQueue, inQueueGold); + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory, startHistory); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory, wakeupHistory); +} + +void TestStartInflightBeforeStart(int inflight, int pushN = 10) { + TQueue::TConfig config; + config.InflightLimit = inflight; + config.Timeout = Timeout; + TOperationStarter starter; + + auto now = starter.TimeProvider.Now(); + + TQueue queue(config, starter, starter); + + for (int i: xrange(pushN)) { + queue.Enqueue(i); + } + + queue.Start(); + auto running = queue.GetRunning(); + auto startN = Min(inflight, pushN); + UNIT_ASSERT_VALUES_EQUAL(running.size(), startN); + + int firstStarted = 0; + int firstNotStarted = firstStarted + startN; + + TVector<TQueue::TItemWithTs> runningGold; + for (int i: xrange(firstNotStarted)) { + runningGold.push_back({i, now}); + } + + TVector<TInstant> wakeupsGold = + { starter.TimeProvider.Now() + config.Timeout }; + + CheckQueue( + queue, + starter, + runningGold, + xrange(firstNotStarted, pushN), + xrange(firstNotStarted), + wakeupsGold); +} + +void TestInflightWithEnqueue(int inflight, int pushN = 10) { + TQueue::TConfig config; + config.InflightLimit = inflight; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + TVector<TQueue::TItemWithTs> runningGold; + TVector<int> queuedGold; + + TVector<TInstant> wakeupsGold = + { starter.TimeProvider.Now() + TDuration::Seconds(1) + config.Timeout }; + + int lastStarted = 0; + + for (int lastPushed: xrange(pushN)) { + starter.TimeProvider.Move(TDuration::Seconds(1)); + auto now = starter.TimeProvider.Now(); + + queue.Enqueue(lastPushed); + + if (runningGold.size() < (size_t)inflight) { + lastStarted = lastPushed; + runningGold.push_back({lastStarted, now}); + } else { + queuedGold.push_back(lastPushed); + } + + CheckQueue( + queue, + starter, + runningGold, + queuedGold, + xrange(lastStarted + 1), + wakeupsGold); + } +} + +} // namespace + +Y_UNIT_TEST_SUITE(TCircularOperationQueueTest) { + Y_UNIT_TEST(ShouldStartEmpty) { + TQueue::TConfig config; + config.IsCircular = true; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + UNIT_ASSERT(queue.Empty()); + UNIT_ASSERT(starter.StartHistory.empty()); + UNIT_ASSERT(starter.WakeupHistory.empty()); + } + + Y_UNIT_TEST(ShouldNotStartUntilStart) { + TQueue::TConfig config; + config.IsCircular = true; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT(starter.StartHistory.empty()); + UNIT_ASSERT(starter.WakeupHistory.empty()); + } + + Y_UNIT_TEST(ShouldStartInflight1) { + TestStartInflightBeforeStart(1); + } + + Y_UNIT_TEST(ShouldStartInflight2) { + TestStartInflightBeforeStart(2); + } + + Y_UNIT_TEST(ShouldStartInflight3) { + TestStartInflightBeforeStart(3); + } + + Y_UNIT_TEST(ShouldStartInflight10) { + TestStartInflightBeforeStart(10, 10); + } + + Y_UNIT_TEST(ShouldStartInflight100) { + TestStartInflightBeforeStart(100); + } + + Y_UNIT_TEST(ShouldStartInflightEnqueue1) { + TestInflightWithEnqueue(1); + } + + Y_UNIT_TEST(ShouldStartInflightEnqueue2) { + TestInflightWithEnqueue(2); + } + + Y_UNIT_TEST(ShouldStartInflightEnqueue3) { + TestInflightWithEnqueue(3); + } + + Y_UNIT_TEST(ShouldStartInflightEnqueue10) { + TestInflightWithEnqueue(10, 10); + } + + Y_UNIT_TEST(ShouldStartInflightEnqueue100) { + TestInflightWithEnqueue(100); + } + + Y_UNIT_TEST(CheckOnDoneInflight1) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + + queue.OnDone(1); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({3, 4, 1})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); + } + + Y_UNIT_TEST(CheckOnDoneInflight2) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 2; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + queue.OnDone(2); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({4, 5, 2})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[1].Item, 3); + + queue.OnDone(1); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({5, 2, 1})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 3); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[1].Item, 4); + } + + Y_UNIT_TEST(CheckOnDoneNotExisting) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + + queue.OnDone(5); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({2, 3, 4})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); + } + + Y_UNIT_TEST(CheckRemoveNotRunning) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + UNIT_ASSERT(queue.Remove(3)); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({2, 4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); + + UNIT_ASSERT(queue.Remove(2)); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); + } + + Y_UNIT_TEST(CheckRemoveRunning) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + + UNIT_ASSERT(!queue.Remove(1)); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({3, 4})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); + } + + Y_UNIT_TEST(CheckRemoveWaiting) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + config.MinOperationRepeatDelay = TDuration::Minutes(10); + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + + queue.OnDone(1); + + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); + UNIT_ASSERT(queue.Remove(1)); + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); + } + + Y_UNIT_TEST(CheckRemoveNotExisting) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + + UNIT_ASSERT(!queue.Remove(5)); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({2, 3, 4})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 1); + } + + Y_UNIT_TEST(CheckTimeout) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + auto t1 = starter.TimeProvider.Now(); + auto d1 = t1 + Timeout; // 01:10:00 + queue.Enqueue(1); + + starter.TimeProvider.Move(TDuration::Seconds(1)); + queue.Enqueue(2); + queue.Enqueue(3); + + starter.TimeProvider.Move(TDuration::Seconds(10)); + queue.Enqueue(4); + queue.Enqueue(5); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); + + starter.TimeProvider.Move(d1); + auto t2 = starter.TimeProvider.Now(); + auto d2 = t2 + Timeout; + queue.Wakeup(); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({3, 4, 5, 1})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[1], d2); + + starter.TimeProvider.Move(d2); + auto t3 = starter.TimeProvider.Now(); + auto d3 = t3 + Timeout; + queue.Wakeup(); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({4, 5, 1, 2})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 3); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[2], d3); + } + + Y_UNIT_TEST(CheckTimeoutWhenFirstItemRemoved) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + auto t1 = starter.TimeProvider.Now(); + auto d1 = t1 + Timeout; // 01:10:00 + queue.Enqueue(1); + + starter.TimeProvider.Move(TDuration::Seconds(1)); + queue.Enqueue(2); + queue.Enqueue(3); + + starter.TimeProvider.Move(TDuration::Seconds(10)); + queue.Enqueue(4); + queue.Enqueue(5); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); + + starter.TimeProvider.Move(TDuration::Seconds(5)); + auto t2 = starter.TimeProvider.Now(); + auto d2 = t2 + Timeout; + + queue.Remove(1); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({3, 4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); + + // must still wait for the first wakeup + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); + + starter.TimeProvider.Move(d1); + queue.Wakeup(); + + // check no changes in queue sinse last time except new wakeup scheduled + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({3, 4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.GetRunning()[0].Item, 2); + + // must still wait for the first wakeup + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 2UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[1], d2); + } + + Y_UNIT_TEST(ShouldScheduleWakeupWhenNothingStarted) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + + TOperationStarter starter; + starter.StartResult = NOperationQueue::EStartStatus::EOperationRetry; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + auto t1 = starter.TimeProvider.Now(); + auto d1 = t1 + config.WakeupInterval; + + queue.Enqueue(1); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({1})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); + } + + Y_UNIT_TEST(ShouldScheduleWakeupWhenHasWaitingAndStart) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = TDuration::Zero(); // disable timeout + config.MinOperationRepeatDelay = TDuration::Minutes(10); + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + + queue.Enqueue(1); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + + starter.TimeProvider.Move(TDuration::Minutes(1)); // 01:01:00 + queue.OnDone(1); + auto t1 = starter.TimeProvider.Now(); + auto d1 = t1 + config.MinOperationRepeatDelay; + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[0], d1); + + // some spurious wakeup + starter.TimeProvider.Move(TDuration::Minutes(1)); + queue.Wakeup(); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + + starter.TimeProvider.Move(d1); + queue.Wakeup(); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); + } + + Y_UNIT_TEST(UseMinOperationRepeatDelayWhenTimeout) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + config.MinOperationRepeatDelay = TDuration::Minutes(10); + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); + + queue.Enqueue(1); + starter.TimeProvider.Move(Timeout + TDuration::Minutes(1)); + queue.Wakeup(); + + auto t1 = starter.TimeProvider.Now(); + auto d1 = t1 + config.MinOperationRepeatDelay; + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 1UL); + UNIT_ASSERT_VALUES_EQUAL(queue.WaitingSize(), 1UL); + + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.back(), d1); + } + + Y_UNIT_TEST(ShouldReturnExecTime) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + starter.TimeProvider.Move(TDuration::Hours(1)); // 01:00:00 + + queue.Enqueue(1); + starter.TimeProvider.Move(TDuration::Seconds(5)); // 01:00:05 + auto duration = queue.OnDone(1); + + UNIT_ASSERT_VALUES_EQUAL(duration, TDuration::Seconds(5)); + } + + Y_UNIT_TEST(ShouldTryToStartAnotherOneWhenStartFails) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 1; + config.Timeout = Timeout; + + TOperationStarter starter; + starter.StartResult = NOperationQueue::EStartStatus::EOperationRetry; + + TQueue queue(config, starter, starter); + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + queue.Start(); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + UNIT_ASSERT_VALUES_EQUAL( + queue.GetQueue(), + TVector<int>({1, 2, 3, 4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + } + + Y_UNIT_TEST(ShouldShuffle) { + TQueue::TConfig config; + config.IsCircular = true; + config.ShuffleOnStart = true; + config.InflightLimit = 5; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + queue.Start(); + + UNIT_ASSERT_VALUES_EQUAL(starter.StartHistory.size(), 5UL); + + UNIT_ASSERT(starter.StartHistory != TVector<int>({1, 2, 3, 4, 5})); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 5UL); + } + + Y_UNIT_TEST(RemoveExistingWhenShuffle) { + TQueue::TConfig config; + config.IsCircular = true; + config.ShuffleOnStart = true; + config.InflightLimit = 5; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + UNIT_ASSERT(queue.Remove(3)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); + + const auto& queueVector = queue.GetQueue(); + UNIT_ASSERT(Find(queueVector.begin(), queueVector.end(), 3) == queueVector.end()); + } + + Y_UNIT_TEST(RemoveNonExistingWhenShuffle) { + TQueue::TConfig config; + config.IsCircular = true; + config.ShuffleOnStart = true; + config.InflightLimit = 5; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + UNIT_ASSERT(!queue.Remove(10)); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + } + + Y_UNIT_TEST(BasicRPSCheck) { + TQueue::TConfig config; + config.IsCircular = true; + config.InflightLimit = 2; + config.Rate = 1.0; + config.Timeout = Timeout; + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + queue.Enqueue(1); + queue.Enqueue(2); + queue.Enqueue(3); + queue.Enqueue(4); + queue.Enqueue(5); + + // initially buckets were full, thus 2 running + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + + queue.OnDone(1); + + // should start another one because RPS smoothing + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + + // some spurious wakeup + starter.TimeProvider.Move(TDuration::MilliSeconds(100)); + queue.Wakeup(); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + + queue.OnDone(2); + + // some spurious wakeup2, note that RPS forbids + // starting more operations + starter.TimeProvider.Move(TDuration::MilliSeconds(100)); + queue.Wakeup(); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 4UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 1UL); + + // 1 second left, we can start 1 more + starter.TimeProvider.Move(TDuration::MilliSeconds(900)); + queue.Wakeup(); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + + starter.TimeProvider.Move(TDuration::Seconds(1)); + queue.OnDone(2); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 2UL); + } + + Y_UNIT_TEST(CheckWakeupAfterStop) { + TQueue::TConfig config; + config.IsCircular = true; + config.ShuffleOnStart = true; + config.InflightLimit = 3; + config.Timeout = Timeout; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + auto now = starter.TimeProvider.Now(); + for (auto i: xrange(1, 6)) { + queue.Enqueue(i); + starter.TimeProvider.Move(TDuration::Seconds(1)); + } + + queue.Stop(); + + auto currentWakeup = now + Timeout; + for (auto i: xrange(1, 4)) { + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory.size(), i); + UNIT_ASSERT_VALUES_EQUAL(starter.WakeupHistory[i-1], currentWakeup); + starter.TimeProvider.Move(currentWakeup); + queue.Wakeup(); + currentWakeup += TDuration::Seconds(1); + } + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + } + + Y_UNIT_TEST(CheckStartAfterStop) { + TQueue::TConfig config; + config.IsCircular = true; + config.ShuffleOnStart = true; + config.InflightLimit = 3; + config.Timeout = Timeout; + + TOperationStarter starter; + + TQueue queue(config, starter, starter); + queue.Start(); + + for (auto i: xrange(1, 6)) { + queue.Enqueue(i); + } + + queue.Stop(); + for (auto i: xrange(1, 4)) { + queue.OnDone(i); + } + + starter.TimeProvider.Move(Timeout); + queue.Wakeup(); + + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 0UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 5UL); + + starter.TimeProvider.Move(Timeout); + + queue.Start(); + UNIT_ASSERT_VALUES_EQUAL(queue.RunningSize(), 3UL); + UNIT_ASSERT_VALUES_EQUAL(queue.Size(), 2UL); + UNIT_ASSERT(starter.WakeupHistory.back() > starter.TimeProvider.Now()); + } +}; + +} // NOperationQueue +} // NKikimr + +using TSomeQueue = NKikimr::NOperationQueue::TOperationQueue<int, NKikimr::TFifoQueue<int>>; +template<> +void Out<TSomeQueue::TItemWithTs>(IOutputStream& o, const TSomeQueue::TItemWithTs& item) { + o << "{" << item.Item << "," << item.Timestamp << "}"; +} diff --git a/ydb/core/util/pb.h b/ydb/core/util/pb.h index ff5d5103786..81bf964f214 100644 --- a/ydb/core/util/pb.h +++ b/ydb/core/util/pb.h @@ -9,15 +9,15 @@ namespace NKikimr { template<typename T> -bool ParsePBFromFile(const TString &path, T *pb, bool allowUnknown = false) { +bool ParsePBFromFile(const TString &path, T *pb, bool allowUnknown = false) { TAutoPtr<TMappedFileInput> fileInput(new TMappedFileInput(path)); const TString content = fileInput->ReadAll(); - if (!allowUnknown) - return ::google::protobuf::TextFormat::ParseFromString(content, pb); - - ::google::protobuf::TextFormat::Parser parser; - parser.AllowUnknownField(true); - return parser.ParseFromString(content, pb); + if (!allowUnknown) + return ::google::protobuf::TextFormat::ParseFromString(content, pb); + + ::google::protobuf::TextFormat::Parser parser; + parser.AllowUnknownField(true); + return parser.ParseFromString(content, pb); } template<typename T> diff --git a/ydb/core/util/testactorsys.cpp b/ydb/core/util/testactorsys.cpp index 7065cfbd5a3..73d27bc9d92 100644 --- a/ydb/core/util/testactorsys.cpp +++ b/ydb/core/util/testactorsys.cpp @@ -109,7 +109,7 @@ void TTestActorSystem::SendToPipe(ui64 tabletId, const TActorId& sender, IEventB }); } -TTabletStorageInfo *TTestActorSystem::CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure, ui32 groupId) { +TTabletStorageInfo *TTestActorSystem::CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure, ui32 groupId) { auto x = std::make_unique<TTabletStorageInfo>(); x->TabletID = tabletId; @@ -127,7 +127,7 @@ TTabletStorageInfo *TTestActorSystem::CreateTestTabletInfo(ui64 tabletId, TTable return x.release(); } -TActorId TTestActorSystem::CreateTestBootstrapper(TTabletStorageInfo *info, std::function<IActor*(TActorId, TTabletStorageInfo*)> op, ui32 nodeId) { +TActorId TTestActorSystem::CreateTestBootstrapper(TTabletStorageInfo *info, std::function<IActor*(TActorId, TTabletStorageInfo*)> op, ui32 nodeId) { auto bi = MakeIntrusive<TBootstrapperInfo>(new TTabletSetupInfo(op, TMailboxType::Simple, 0, TMailboxType::Simple, 0)); return Register(CreateBootstrapper(info, bi.Get()), nodeId); } diff --git a/ydb/core/util/testactorsys.h b/ydb/core/util/testactorsys.h index e4c246d498f..ce6ad7be10d 100644 --- a/ydb/core/util/testactorsys.h +++ b/ydb/core/util/testactorsys.h @@ -660,8 +660,8 @@ public: void SetupTabletRuntime(bool isMirror3dc = false, ui32 stateStorageNodeId = 0, ui32 targetNodeId = 0); static NTabletPipe::TClientConfig GetPipeConfigWithRetries(); void SendToPipe(ui64 tabletId, const TActorId& sender, IEventBase* payload, ui64 cookie, const NKikimr::NTabletPipe::TClientConfig& pipeConfig); - static TTabletStorageInfo *CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure, ui32 groupId); - TActorId CreateTestBootstrapper(TTabletStorageInfo *info, std::function<IActor*(TActorId, TTabletStorageInfo*)> op, ui32 nodeId); + static TTabletStorageInfo *CreateTestTabletInfo(ui64 tabletId, TTabletTypes::EType tabletType, TBlobStorageGroupType::EErasureSpecies erasure, ui32 groupId); + TActorId CreateTestBootstrapper(TTabletStorageInfo *info, std::function<IActor*(TActorId, TTabletStorageInfo*)> op, ui32 nodeId); private: void SetupStateStorage(ui32 nodeId, ui32 stateStorageNodeId); diff --git a/ydb/core/util/token_bucket.h b/ydb/core/util/token_bucket.h index 55d51c435da..060f8c75a6c 100644 --- a/ydb/core/util/token_bucket.h +++ b/ydb/core/util/token_bucket.h @@ -2,8 +2,8 @@ #include <util/datetime/base.h> -#include <cmath> - +#include <cmath> + namespace NKikimr { class TTokenBucket { @@ -26,12 +26,12 @@ public: Capacity = std::numeric_limits<double>::infinity(); // maximum amount of tokens allowed in bucket } - bool IsUnlimited() const { - return Tokens == std::numeric_limits<double>::infinity() && - Rate == 0.0 && - Capacity == std::numeric_limits<double>::infinity(); - } - + bool IsUnlimited() const { + return Tokens == std::numeric_limits<double>::infinity() && + Rate == 0.0 && + Capacity == std::numeric_limits<double>::infinity(); + } + // Reset rate void SetRate(double rate) { Rate = rate; @@ -69,20 +69,20 @@ public: return amount; } - // don't forget to Fill or use FillAndNextAvailableDelay() instead - TDuration NextAvailableDelay() const { - if (IsUnlimited() || Available() >= 0) { - return TDuration::Zero(); - } - - return TDuration::MicroSeconds(std::ceil(Available() * -1000000.0 / Rate)); - } - - TDuration FillAndNextAvailableDelay(TInstant now) { - Fill(now); - return NextAvailableDelay(); - } - + // don't forget to Fill or use FillAndNextAvailableDelay() instead + TDuration NextAvailableDelay() const { + if (IsUnlimited() || Available() >= 0) { + return TDuration::Zero(); + } + + return TDuration::MicroSeconds(std::ceil(Available() * -1000000.0 / Rate)); + } + + TDuration FillAndNextAvailableDelay(TInstant now) { + Fill(now); + return NextAvailableDelay(); + } + // Amount of accumulated tokens double Available() const { return Tokens; diff --git a/ydb/core/util/token_bucket_ut.cpp b/ydb/core/util/token_bucket_ut.cpp index c624bf8e9bc..ef35e78ccd5 100644 --- a/ydb/core/util/token_bucket_ut.cpp +++ b/ydb/core/util/token_bucket_ut.cpp @@ -67,24 +67,24 @@ Y_UNIT_TEST_SUITE(TTokenBucketTest) { tb.SetUnlimited(); UNIT_ASSERT(tb.Available() == std::numeric_limits<double>::infinity()); } - - Y_UNIT_TEST(DelayCalculation) { - TTokenBucket tb; - TInstant now = TInstant::Now(); - tb.SetRate(150); - tb.SetCapacity(1); - tb.Fill(now); - - UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), TDuration::Zero()); - tb.Take(2); - - auto expectedDelay = TDuration::MicroSeconds(std::ceil(1000000.0 / 150)); - UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), expectedDelay); - - now += expectedDelay; - tb.Fill(now); - UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), TDuration::Zero()); - } + + Y_UNIT_TEST(DelayCalculation) { + TTokenBucket tb; + TInstant now = TInstant::Now(); + tb.SetRate(150); + tb.SetCapacity(1); + tb.Fill(now); + + UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), TDuration::Zero()); + tb.Take(2); + + auto expectedDelay = TDuration::MicroSeconds(std::ceil(1000000.0 / 150)); + UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), expectedDelay); + + now += expectedDelay; + tb.Fill(now); + UNIT_ASSERT_VALUES_EQUAL(tb.NextAvailableDelay(), TDuration::Zero()); + } } } // NKikimr diff --git a/ydb/core/util/ut/ya.make b/ydb/core/util/ut/ya.make index 8b3444f725a..315713cad86 100644 --- a/ydb/core/util/ut/ya.make +++ b/ydb/core/util/ut/ya.make @@ -25,7 +25,7 @@ SRCS( btree_cow_ut.cpp btree_ut.cpp cache_ut.cpp - circular_queue_ut.cpp + circular_queue_ut.cpp concurrent_rw_hash_ut.cpp fast_tls_ut.cpp fragmented_buffer_ut.cpp @@ -38,8 +38,8 @@ SRCS( lf_stack_ut.cpp log_priority_mute_checker_ut.cpp lz4_data_generator_ut.cpp - operation_queue_ut.cpp - operation_queue_priority_ut.cpp + operation_queue_ut.cpp + operation_queue_priority_ut.cpp page_map_ut.cpp queue_inplace_ut.cpp queue_oneone_inplace_ut.cpp diff --git a/ydb/core/util/ya.make b/ydb/core/util/ya.make index 0bc8e860e31..4f325d8fcbd 100644 --- a/ydb/core/util/ya.make +++ b/ydb/core/util/ya.make @@ -10,7 +10,7 @@ SRCS( cache.cpp cache.h cache_cache.h - circular_queue.h + circular_queue.h concurrent_rw_hash.cpp concurrent_rw_hash.h console.cpp @@ -35,7 +35,7 @@ SRCS( log_priority_mute_checker.h memory_tracker.cpp memory_tracker.h - operation_queue.h + operation_queue.h page_map.cpp pb.h proto_duration.h diff --git a/ydb/core/viewer/content/v2/tablet_cell.js b/ydb/core/viewer/content/v2/tablet_cell.js index a733f9027b7..4129ba9dd94 100644 --- a/ydb/core/viewer/content/v2/tablet_cell.js +++ b/ydb/core/viewer/content/v2/tablet_cell.js @@ -48,7 +48,7 @@ TabletCell.prototype.buildDomElement = function() { this.domElementCounter = counter[0]; var tooltip = this.Type; if (!this.Leader) { - tooltip += ' (follower)'; + tooltip += ' (follower)'; } tablet.attr('data-original-title', tooltip); tablet.tooltip({html: true}); diff --git a/ydb/core/viewer/json_hiveinfo.h b/ydb/core/viewer/json_hiveinfo.h index f411b7bfa4c..f4d04ddfaf6 100644 --- a/ydb/core/viewer/json_hiveinfo.h +++ b/ydb/core/viewer/json_hiveinfo.h @@ -49,8 +49,8 @@ public: if (params.Has("tablet_type")) { request->Record.SetTabletType(static_cast<TTabletTypes::EType>(FromStringWithDefault<ui32>(params.Get("tablet_type"), 0))); } - if (FromStringWithDefault(params.Get("followers"), false)) { - request->Record.SetReturnFollowers(true); + if (FromStringWithDefault(params.Get("followers"), false)) { + request->Record.SetReturnFollowers(true); } if (FromStringWithDefault(params.Get("metrics"), false)) { request->Record.SetReturnMetrics(true); diff --git a/ydb/core/viewer/json_hivestats.h b/ydb/core/viewer/json_hivestats.h index 1918d878496..7f24693d635 100644 --- a/ydb/core/viewer/json_hivestats.h +++ b/ydb/core/viewer/json_hivestats.h @@ -41,7 +41,7 @@ public: InitConfig(params); if (hiveId != 0 ) { THolder<TEvHive::TEvRequestHiveDomainStats> request = MakeHolder<TEvHive::TEvRequestHiveDomainStats>(); - request->Record.SetReturnFollowers(FromStringWithDefault(params.Get("followers"), false)); + request->Record.SetReturnFollowers(FromStringWithDefault(params.Get("followers"), false)); request->Record.SetReturnMetrics(FromStringWithDefault(params.Get("metrics"), true)); SendRequestToPipe(ConnectTabletPipe(hiveId), request.Release()); Become(&TThis::StateRequestedInfo, TDuration::MilliSeconds(Timeout), new TEvents::TEvWakeup()); diff --git a/ydb/core/viewer/json_pipe_req.h b/ydb/core/viewer/json_pipe_req.h index b6bea47bc0e..d41b2a93d4f 100644 --- a/ydb/core/viewer/json_pipe_req.h +++ b/ydb/core/viewer/json_pipe_req.h @@ -20,7 +20,7 @@ template <typename TDerived> class TViewerPipeClient : public TActorBootstrapped<TDerived> { protected: using TBase = TActorBootstrapped<TDerived>; - bool Followers = true; + bool Followers = true; bool Metrics = true; bool WithRetry = true; ui32 Requests = 0; @@ -90,7 +90,7 @@ protected: void RequestHiveDomainStats(TTabletId hiveId) { TActorId pipeClient = ConnectTabletPipe(hiveId); THolder<TEvHive::TEvRequestHiveDomainStats> request = MakeHolder<TEvHive::TEvRequestHiveDomainStats>(); - request->Record.SetReturnFollowers(Followers); + request->Record.SetReturnFollowers(Followers); request->Record.SetReturnMetrics(Metrics); SendRequestToPipe(pipeClient, request.Release(), hiveId); } @@ -175,7 +175,7 @@ protected: } void InitConfig(const TCgiParameters& params) { - Followers = FromStringWithDefault(params.Get("followers"), Followers); + Followers = FromStringWithDefault(params.Get("followers"), Followers); Metrics = FromStringWithDefault(params.Get("metrics"), Metrics); WithRetry = FromStringWithDefault(params.Get("with_retry"), WithRetry); } diff --git a/ydb/core/viewer/json_tabletinfo.h b/ydb/core/viewer/json_tabletinfo.h index 539f8c1bc2a..32546865a15 100644 --- a/ydb/core/viewer/json_tabletinfo.h +++ b/ydb/core/viewer/json_tabletinfo.h @@ -26,11 +26,11 @@ struct TWhiteboardInfo<TEvWhiteboard::TEvTabletStateResponse> { } static std::pair<ui64, ui32> GetElementKey(const TElementType& type) { - return std::pair<ui64, ui32>(type.GetTabletId(), type.GetFollowerId()); + return std::pair<ui64, ui32>(type.GetTabletId(), type.GetFollowerId()); } static TString GetDefaultMergeField() { - return "TabletId,FollowerId"; + return "TabletId,FollowerId"; } static THolder<TResponseType> MergeResponses(TMap<ui32, THolder<TResponseType>>& responses, const TString& fields = GetDefaultMergeField()) { diff --git a/ydb/core/viewer/json_tenantinfo.h b/ydb/core/viewer/json_tenantinfo.h index 27ba2d1b352..749422ba396 100644 --- a/ydb/core/viewer/json_tenantinfo.h +++ b/ydb/core/viewer/json_tenantinfo.h @@ -62,7 +62,7 @@ public: const auto& params(Event->Get()->Request.GetParams()); JsonSettings.EnumAsNumbers = !FromStringWithDefault<bool>(params.Get("enums"), true); JsonSettings.UI64AsString = !FromStringWithDefault<bool>(params.Get("ui64"), false); - Followers = false; + Followers = false; Metrics = true; InitConfig(params); Timeout = FromStringWithDefault<ui32>(params.Get("timeout"), 10000); diff --git a/ydb/core/viewer/viewer.cpp b/ydb/core/viewer/viewer.cpp index e1d5645556b..f1124115bf7 100644 --- a/ydb/core/viewer/viewer.cpp +++ b/ydb/core/viewer/viewer.cpp @@ -541,7 +541,7 @@ NKikimrViewer::EFlag GetFlagFromTabletState(NKikimrWhiteboard::TTabletStateInfo: case NKikimrWhiteboard::TTabletStateInfo::RebuildGraph: flag = NKikimrViewer::EFlag::Orange; break; - case NKikimrWhiteboard::TTabletStateInfo::ResolveLeader: + case NKikimrWhiteboard::TTabletStateInfo::ResolveLeader: flag = NKikimrViewer::EFlag::Yellow; break; case NKikimrWhiteboard::TTabletStateInfo::Deleted: diff --git a/ydb/core/viewer/viewer_ut.cpp b/ydb/core/viewer/viewer_ut.cpp index 904fc0b2944..020239e8a5f 100644 --- a/ydb/core/viewer/viewer_ut.cpp +++ b/ydb/core/viewer/viewer_ut.cpp @@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(Viewer) { for (ui32 tabletId = 1; tabletId <= 10000; ++tabletId) { NKikimrWhiteboard::TTabletStateInfo* tabletData = nodeData->Record.AddTabletStateInfo(); tabletData->SetTabletId(tabletId); - tabletData->SetLeader(true); + tabletData->SetLeader(true); tabletData->SetGeneration(13); tabletData->SetChangeTime(TInstant::Now().MilliSeconds()); } diff --git a/ydb/core/ydb_convert/table_description.cpp b/ydb/core/ydb_convert/table_description.cpp index 1dcf37e3227..0d10bb8450b 100644 --- a/ydb/core/ydb_convert/table_description.cpp +++ b/ydb/core/ydb_convert/table_description.cpp @@ -664,25 +664,25 @@ void FillReadReplicasSettingsImpl(TYdbProto& out, } const auto& partConfig = in.GetPartitionConfig(); - if (!partConfig.FollowerGroupsSize() && !partConfig.HasCrossDataCenterFollowerCount() && !partConfig.HasFollowerCount()) { + if (!partConfig.FollowerGroupsSize() && !partConfig.HasCrossDataCenterFollowerCount() && !partConfig.HasFollowerCount()) { return; } - if (partConfig.FollowerGroupsSize()) { - if (partConfig.FollowerGroupsSize() > 1) { + if (partConfig.FollowerGroupsSize()) { + if (partConfig.FollowerGroupsSize() > 1) { // Not supported yet return; } - const auto& followerGroup = partConfig.GetFollowerGroups(0); - if (followerGroup.GetFollowerCountPerDataCenter()) { - out.mutable_read_replicas_settings()->set_per_az_read_replicas_count(followerGroup.GetFollowerCount()); + const auto& followerGroup = partConfig.GetFollowerGroups(0); + if (followerGroup.GetFollowerCountPerDataCenter()) { + out.mutable_read_replicas_settings()->set_per_az_read_replicas_count(followerGroup.GetFollowerCount()); } else { - out.mutable_read_replicas_settings()->set_any_az_read_replicas_count(followerGroup.GetFollowerCount()); + out.mutable_read_replicas_settings()->set_any_az_read_replicas_count(followerGroup.GetFollowerCount()); } - } else if (partConfig.HasCrossDataCenterFollowerCount()) { - out.mutable_read_replicas_settings()->set_per_az_read_replicas_count(partConfig.GetCrossDataCenterFollowerCount()); - } else if (partConfig.HasFollowerCount()) { - out.mutable_read_replicas_settings()->set_any_az_read_replicas_count(partConfig.GetFollowerCount()); + } else if (partConfig.HasCrossDataCenterFollowerCount()) { + out.mutable_read_replicas_settings()->set_per_az_read_replicas_count(partConfig.GetCrossDataCenterFollowerCount()); + } else if (partConfig.HasFollowerCount()) { + out.mutable_read_replicas_settings()->set_any_az_read_replicas_count(partConfig.GetFollowerCount()); } } diff --git a/ydb/core/ydb_convert/table_settings.cpp b/ydb/core/ydb_convert/table_settings.cpp index b49f1123425..3f3547f1f5e 100644 --- a/ydb/core/ydb_convert/table_settings.cpp +++ b/ydb/core/ydb_convert/table_settings.cpp @@ -161,26 +161,26 @@ bool FillCreateTableSettingsDesc(NKikimrSchemeOp::TTableDescription& tableDesc, if (proto.has_read_replicas_settings()) { if (tableProfileSet) { MEWarning("ReadReplicasSettings", warnings); - partitionConfig.ClearFollowerCount(); - partitionConfig.ClearCrossDataCenterFollowerCount(); - partitionConfig.ClearAllowFollowerPromotion(); - partitionConfig.ClearFollowerGroups(); + partitionConfig.ClearFollowerCount(); + partitionConfig.ClearCrossDataCenterFollowerCount(); + partitionConfig.ClearAllowFollowerPromotion(); + partitionConfig.ClearFollowerGroups(); } auto& readReplicasSettings = proto.read_replicas_settings(); switch (readReplicasSettings.settings_case()) { case Ydb::Table::ReadReplicasSettings::kPerAzReadReplicasCount: { - auto& followerGroup = *partitionConfig.AddFollowerGroups(); - followerGroup.SetFollowerCount(readReplicasSettings.per_az_read_replicas_count()); - followerGroup.SetRequireAllDataCenters(true); - followerGroup.SetFollowerCountPerDataCenter(true); + auto& followerGroup = *partitionConfig.AddFollowerGroups(); + followerGroup.SetFollowerCount(readReplicasSettings.per_az_read_replicas_count()); + followerGroup.SetRequireAllDataCenters(true); + followerGroup.SetFollowerCountPerDataCenter(true); break; } case Ydb::Table::ReadReplicasSettings::kAnyAzReadReplicasCount: { - auto& followerGroup = *partitionConfig.AddFollowerGroups(); - followerGroup.SetFollowerCount(readReplicasSettings.any_az_read_replicas_count()); - followerGroup.SetRequireAllDataCenters(false); + auto& followerGroup = *partitionConfig.AddFollowerGroups(); + followerGroup.SetFollowerCount(readReplicasSettings.any_az_read_replicas_count()); + followerGroup.SetRequireAllDataCenters(false); break; } default: @@ -317,17 +317,17 @@ bool FillAlterTableSettingsDesc(NKikimrSchemeOp::TTableDescription& tableDesc, switch (readReplicasSettings.settings_case()) { case Ydb::Table::ReadReplicasSettings::kPerAzReadReplicasCount: { - auto& followerGroup = *partitionConfig.AddFollowerGroups(); - followerGroup.SetFollowerCount(readReplicasSettings.per_az_read_replicas_count()); - followerGroup.SetRequireAllDataCenters(true); - followerGroup.SetFollowerCountPerDataCenter(true); + auto& followerGroup = *partitionConfig.AddFollowerGroups(); + followerGroup.SetFollowerCount(readReplicasSettings.per_az_read_replicas_count()); + followerGroup.SetRequireAllDataCenters(true); + followerGroup.SetFollowerCountPerDataCenter(true); break; } case Ydb::Table::ReadReplicasSettings::kAnyAzReadReplicasCount: { - auto& followerGroup = *partitionConfig.AddFollowerGroups(); - followerGroup.SetFollowerCount(readReplicasSettings.any_az_read_replicas_count()); - followerGroup.SetRequireAllDataCenters(false); + auto& followerGroup = *partitionConfig.AddFollowerGroups(); + followerGroup.SetFollowerCount(readReplicasSettings.any_az_read_replicas_count()); + followerGroup.SetRequireAllDataCenters(false); break; } default: diff --git a/ydb/core/ymq/actor/action.h b/ydb/core/ymq/actor/action.h index 7967eafcad2..1801c98d68f 100644 --- a/ydb/core/ymq/actor/action.h +++ b/ydb/core/ymq/actor/action.h @@ -93,7 +93,7 @@ public: configurationFlags |= TSqsEvents::TEvGetConfiguration::EFlags::NeedQueueAttributes; } if (TProxyActor::NeedCreateProxyActor(Action_)) { - configurationFlags |= TSqsEvents::TEvGetConfiguration::EFlags::NeedQueueLeader; + configurationFlags |= TSqsEvents::TEvGetConfiguration::EFlags::NeedQueueLeader; } this->Send(MakeSqsServiceID(this->SelfId().NodeId()), MakeHolder<TSqsEvents::TEvGetConfiguration>( @@ -303,7 +303,7 @@ protected: void PassAway() { if (TProxyActor::NeedCreateProxyActor(Action_)) { if (TString queueName = GetQueueName()) { - this->Send(MakeSqsServiceID(this->SelfId().NodeId()), new TSqsEvents::TEvQueueLeaderDecRef()); + this->Send(MakeSqsServiceID(this->SelfId().NodeId()), new TSqsEvents::TEvQueueLeaderDecRef()); } } if (StartRequestWasCalled_ != FinishRequestWasCalled_) { @@ -508,7 +508,7 @@ private: SqsCoreCounters_ = std::move(ev->Get()->SqsCoreCounters); QueueCounters_ = std::move(ev->Get()->QueueCounters); UserCounters_ = std::move(ev->Get()->UserCounters); - QueueLeader_ = ev->Get()->QueueLeader; + QueueLeader_ = ev->Get()->QueueLeader; QuoterResources_ = std::move(ev->Get()->QuoterResources); Y_VERIFY(SchemeCache_); @@ -762,7 +762,7 @@ protected: TMaybe<TSqsEvents::TQueueAttributes> QueueAttributes_; NKikimrClient::TSqsResponse Response_; TActorId SchemeCache_; - TActorId QueueLeader_; + TActorId QueueLeader_; bool StartRequestWasCalled_ = false; bool FinishRequestWasCalled_ = false; TInstant QuotaRequestTs_; diff --git a/ydb/core/ymq/actor/actor.cpp b/ydb/core/ymq/actor/actor.cpp index 09051f0f888..d2ebd7cf50f 100644 --- a/ydb/core/ymq/actor/actor.cpp +++ b/ydb/core/ymq/actor/actor.cpp @@ -77,8 +77,8 @@ IActor* CreateActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyC Y_FAIL(); } -IActor* CreateProxyActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyCallback> cb, bool enableQueueLeader) { - if (enableQueueLeader && TProxyActor::NeedCreateProxyActor(req)) { +IActor* CreateProxyActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyCallback> cb, bool enableQueueLeader) { + if (enableQueueLeader && TProxyActor::NeedCreateProxyActor(req)) { return new TProxyActor(req, std::move(cb)); } else { return CreateActionActor(req, std::move(cb)); diff --git a/ydb/core/ymq/actor/actor.h b/ydb/core/ymq/actor/actor.h index 87b8d184d49..d6a825d2f82 100644 --- a/ydb/core/ymq/actor/actor.h +++ b/ydb/core/ymq/actor/actor.h @@ -21,12 +21,12 @@ public: }; // Create actor that would process request. -// Called from leader node. +// Called from leader node. IActor* CreateActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyCallback> cb); -// Create actor that would proxy request to leader -// or process it if leader is not required for given operation type. -IActor* CreateProxyActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyCallback> cb, bool enableQueueLeader); +// Create actor that would proxy request to leader +// or process it if leader is not required for given operation type. +IActor* CreateProxyActionActor(const NKikimrClient::TSqsRequest& req, THolder<IReplyCallback> cb, bool enableQueueLeader); IActor* CreatePingActor(THolder<IPingReplyCallback> cb, const TString& requestId); diff --git a/ydb/core/ymq/actor/cfg.cpp b/ydb/core/ymq/actor/cfg.cpp index d6c6620d56b..10361b92b2b 100644 --- a/ydb/core/ymq/actor/cfg.cpp +++ b/ydb/core/ymq/actor/cfg.cpp @@ -8,12 +8,12 @@ const NKikimrConfig::TSqsConfig& Cfg() { return AppData()->SqsConfig; } -ui32 GetLeadersDescriberUpdateTimeMs() { - const auto& config = AppData()->SqsConfig; - if (config.HasMastersDescriberUpdateTimeMs()) { - return config.GetMastersDescriberUpdateTimeMs(); - } - return config.GetLeadersDescriberUpdateTimeMs(); -} - +ui32 GetLeadersDescriberUpdateTimeMs() { + const auto& config = AppData()->SqsConfig; + if (config.HasMastersDescriberUpdateTimeMs()) { + return config.GetMastersDescriberUpdateTimeMs(); + } + return config.GetLeadersDescriberUpdateTimeMs(); +} + } // namespace NKikimr::NSQS diff --git a/ydb/core/ymq/actor/cfg.h b/ydb/core/ymq/actor/cfg.h index 61a34556086..8d7fcac91b6 100644 --- a/ydb/core/ymq/actor/cfg.h +++ b/ydb/core/ymq/actor/cfg.h @@ -6,6 +6,6 @@ namespace NKikimr::NSQS { const NKikimrConfig::TSqsConfig& Cfg(); -ui32 GetLeadersDescriberUpdateTimeMs(); +ui32 GetLeadersDescriberUpdateTimeMs(); } // namespace NKikimr::NSQS diff --git a/ydb/core/ymq/actor/change_visibility.cpp b/ydb/core/ymq/actor/change_visibility.cpp index 8fef2242aa4..5c3140bcc8b 100644 --- a/ydb/core/ymq/actor/change_visibility.cpp +++ b/ydb/core/ymq/actor/change_visibility.cpp @@ -62,7 +62,7 @@ protected: auto& shardInfo = ShardInfo_[receipt.GetShard()]; // Create request if (!shardInfo.Request_) { - ++RequestsToLeader_; + ++RequestsToLeader_; shardInfo.Request_ = MakeHolder<TSqsEvents::TEvChangeMessageVisibilityBatch>(); shardInfo.Request_->Shard = receipt.GetShard(); shardInfo.Request_->RequestId = RequestId_; @@ -143,11 +143,11 @@ protected: AppendEntry(Request(), Response_.MutableChangeMessageVisibility(), 0); } - if (RequestsToLeader_) { - Y_VERIFY(RequestsToLeader_ <= Shards_); + if (RequestsToLeader_) { + Y_VERIFY(RequestsToLeader_ <= Shards_); for (auto& shardInfo : ShardInfo_) { if (shardInfo.Request_) { - Send(QueueLeader_, shardInfo.Request_.Release()); + Send(QueueLeader_, shardInfo.Request_.Release()); } } } else { @@ -178,13 +178,13 @@ private: ProcessAnswer(Response_.MutableChangeMessageVisibilityBatch()->MutableEntries(entryIndex), ev->Get()->Statuses[i]); } } else { - Y_VERIFY(RequestsToLeader_ == 1); + Y_VERIFY(RequestsToLeader_ == 1); Y_VERIFY(ev->Get()->Statuses.size() == 1); ProcessAnswer(Response_.MutableChangeMessageVisibility(), ev->Get()->Statuses[0]); } - --RequestsToLeader_; - if (RequestsToLeader_ == 0) { + --RequestsToLeader_; + if (RequestsToLeader_ == 0) { SendReplyAndDie(); } } @@ -204,7 +204,7 @@ private: std::vector<size_t> RequestToReplyIndexMapping_; THolder<TSqsEvents::TEvChangeMessageVisibilityBatch> Request_; // actual when processing initial request, then nullptr }; - size_t RequestsToLeader_ = 0; + size_t RequestsToLeader_ = 0; std::vector<TShardInfo> ShardInfo_; TInstant NowTimestamp_; }; diff --git a/ydb/core/ymq/actor/delete_message.cpp b/ydb/core/ymq/actor/delete_message.cpp index dbd355923b4..50b59ddcfb0 100644 --- a/ydb/core/ymq/actor/delete_message.cpp +++ b/ydb/core/ymq/actor/delete_message.cpp @@ -71,7 +71,7 @@ private: auto& shardInfo = ShardInfo_[receipt.GetShard()]; // Create request if (!shardInfo.Request_) { - ++RequestsToLeader_; + ++RequestsToLeader_; shardInfo.Request_ = MakeHolder<TSqsEvents::TEvDeleteMessageBatch>(); shardInfo.Request_->Shard = receipt.GetShard(); shardInfo.Request_->RequestId = RequestId_; @@ -137,11 +137,11 @@ private: AppendEntry(Request(), Response_.MutableDeleteMessage(), 0); } - if (RequestsToLeader_) { - Y_VERIFY(RequestsToLeader_ <= Shards_); + if (RequestsToLeader_) { + Y_VERIFY(RequestsToLeader_ <= Shards_); for (auto& shardInfo : ShardInfo_) { if (shardInfo.Request_) { - Send(QueueLeader_, shardInfo.Request_.Release()); + Send(QueueLeader_, shardInfo.Request_.Release()); } } } else { @@ -171,13 +171,13 @@ private: ProcessAnswer(Response_.MutableDeleteMessageBatch()->MutableEntries(entryIndex), ev->Get()->Statuses[i]); } } else { - Y_VERIFY(RequestsToLeader_ == 1); + Y_VERIFY(RequestsToLeader_ == 1); Y_VERIFY(ev->Get()->Statuses.size() == 1); ProcessAnswer(Response_.MutableDeleteMessage(), ev->Get()->Statuses[0]); } - --RequestsToLeader_; - if (RequestsToLeader_ == 0) { + --RequestsToLeader_; + if (RequestsToLeader_ == 0) { SendReplyAndDie(); } } @@ -197,7 +197,7 @@ private: std::vector<size_t> RequestToReplyIndexMapping_; THolder<TSqsEvents::TEvDeleteMessageBatch> Request_; // actual when processing initial request, then nullptr }; - size_t RequestsToLeader_ = 0; + size_t RequestsToLeader_ = 0; std::vector<TShardInfo> ShardInfo_; }; diff --git a/ydb/core/ymq/actor/events.h b/ydb/core/ymq/actor/events.h index 8d45c2445bb..9fff62c7cf8 100644 --- a/ydb/core/ymq/actor/events.h +++ b/ydb/core/ymq/actor/events.h @@ -72,10 +72,10 @@ struct TSqsEvents { EvAtomicCounterIncrementResult, /// Request for finding leader node for the given queue - EvGetLeaderNodeForQueueRequest, - EvGetLeaderNodeForQueueResponse, + EvGetLeaderNodeForQueueRequest, + EvGetLeaderNodeForQueueResponse, - EvQueueLeaderDecRef, + EvQueueLeaderDecRef, EvGetQueueId, EvQueueId, @@ -86,7 +86,7 @@ struct TSqsEvents { EvCountQueues, EvCountQueuesResponse, - // Send/Receive/Delete requests. Action actor sends these requests to queue leader + // Send/Receive/Delete requests. Action actor sends these requests to queue leader EvSendMessageBatch, EvSendMessageBatchResponse, @@ -150,8 +150,8 @@ struct TSqsEvents { ui64 Flags = 0; enum EFlags { - NeedQueueLeader = 1, - NeedQueueAttributes = NeedQueueLeader | 2, // attributes are stored in leader actor, so, when you need attributes, you need leader + NeedQueueLeader = 1, + NeedQueueAttributes = NeedQueueLeader | 2, // attributes are stored in leader actor, so, when you need attributes, you need leader }; TEvGetConfiguration() = default; @@ -199,7 +199,7 @@ struct TSqsEvents { // Common info TString RootUrl; TActorId SchemeCache; - TActorId QueueLeader; + TActorId QueueLeader; }; struct TEvClearQueueAttributesCache : public NActors::TEventLocal<TEvClearQueueAttributesCache, EvClearQueueAttributesCache> { @@ -382,7 +382,7 @@ struct TSqsEvents { } }; - // Request that is sent from proxy to sqs service actor on other (leader) node + // Request that is sent from proxy to sqs service actor on other (leader) node struct TEvSqsRequest : public NActors::TEventPB<TEvSqsRequest, NKikimrClient::TSqsRequest, EvSqsRequest> { using TEventPB::TEventPB; }; @@ -392,11 +392,11 @@ struct TSqsEvents { using TEventPB::TEventPB; }; - // Request for proxying request to sqs service actor on other (leader) node + // Request for proxying request to sqs service actor on other (leader) node struct TEvProxySqsRequest : public NActors::TEventLocal<TEvProxySqsRequest, EvProxySqsRequest> { NKikimrClient::TSqsRequest Record; - // Information to identify leader node + // Information to identify leader node TString UserName; TString QueueName; @@ -425,7 +425,7 @@ struct TSqsEvents { struct TEvProxySqsResponse : public NActors::TEventLocal<TEvProxySqsResponse, EvProxySqsResponse> { enum class EProxyStatus { // can be written to text stream OK, - LeaderResolvingError, + LeaderResolvingError, SessionError, QueueDoesNotExist, UserDoesNotExist, @@ -449,12 +449,12 @@ struct TSqsEvents { } }; - struct TEvGetLeaderNodeForQueueRequest : public NActors::TEventLocal<TEvGetLeaderNodeForQueueRequest, EvGetLeaderNodeForQueueRequest> { + struct TEvGetLeaderNodeForQueueRequest : public NActors::TEventLocal<TEvGetLeaderNodeForQueueRequest, EvGetLeaderNodeForQueueRequest> { TString RequestId; TString UserName; TString QueueName; - TEvGetLeaderNodeForQueueRequest(TString requestId, TString user, TString queue) + TEvGetLeaderNodeForQueueRequest(TString requestId, TString user, TString queue) : RequestId(std::move(requestId)) , UserName(std::move(user)) , QueueName(std::move(queue)) @@ -462,12 +462,12 @@ struct TSqsEvents { } }; - struct TEvGetLeaderNodeForQueueResponse : public NActors::TEventLocal<TEvGetLeaderNodeForQueueResponse, EvGetLeaderNodeForQueueResponse> { + struct TEvGetLeaderNodeForQueueResponse : public NActors::TEventLocal<TEvGetLeaderNodeForQueueResponse, EvGetLeaderNodeForQueueResponse> { enum class EStatus { OK, NoUser, NoQueue, - FailedToConnectToLeader, + FailedToConnectToLeader, Error, }; @@ -477,7 +477,7 @@ struct TSqsEvents { ui64 NodeId = 0; EStatus Status = EStatus::OK; - TEvGetLeaderNodeForQueueResponse(TString requestId, TString user, TString queue, ui64 nodeId) + TEvGetLeaderNodeForQueueResponse(TString requestId, TString user, TString queue, ui64 nodeId) : RequestId(std::move(requestId)) , UserName(std::move(user)) , QueueName(std::move(queue)) @@ -485,7 +485,7 @@ struct TSqsEvents { { } - TEvGetLeaderNodeForQueueResponse(TString requestId, TString user, TString queue, EStatus error) + TEvGetLeaderNodeForQueueResponse(TString requestId, TString user, TString queue, EStatus error) : RequestId(std::move(requestId)) , UserName(std::move(user)) , QueueName(std::move(queue)) @@ -494,7 +494,7 @@ struct TSqsEvents { } }; - struct TEvQueueLeaderDecRef : public NActors::TEventLocal<TEvQueueLeaderDecRef, EvQueueLeaderDecRef> { + struct TEvQueueLeaderDecRef : public NActors::TEventLocal<TEvQueueLeaderDecRef, EvQueueLeaderDecRef> { }; struct TEvGetQueueId : public NActors::TEventLocal<TEvGetQueueId, EvGetQueueId> { @@ -624,7 +624,7 @@ struct TSqsEvents { }; // Request to try to receive message batch. - // While processing this request leader doesn't perform long polling. + // While processing this request leader doesn't perform long polling. struct TEvReceiveMessageBatch : public NActors::TEventLocal<TEvReceiveMessageBatch, EvReceiveMessageBatch> { TString RequestId; size_t MaxMessagesCount = 0; @@ -756,16 +756,16 @@ struct TSqsEvents { }; struct TEvInsertQueueCounters : public NActors::TEventLocal<TEvInsertQueueCounters, EvInsertQueueCounters> { - TEvInsertQueueCounters(const TString& user, const TString& queue, ui64 leaderTabletId) + TEvInsertQueueCounters(const TString& user, const TString& queue, ui64 leaderTabletId) : User(user) , Queue(queue) - , LeaderTabletId(leaderTabletId) + , LeaderTabletId(leaderTabletId) { } TString User; TString Queue; - ui64 LeaderTabletId; + ui64 LeaderTabletId; }; struct TEvUserSettingsChanged : public NActors::TEventLocal<TEvUserSettingsChanged, EvUserSettingsChanged> { @@ -789,7 +789,7 @@ struct TSqsEvents { struct TQueueRecord { TString UserName; TString QueueName; - ui64 LeaderTabletId = 0; + ui64 LeaderTabletId = 0; TString CustomName; TString FolderId; TString DlqName; @@ -811,7 +811,7 @@ struct TSqsEvents { } }; - // Used by service to notify dead letter queue leader + // Used by service to notify dead letter queue leader struct TEvDeadLetterQueueNotification : public NActors::TEventLocal<TEvDeadLetterQueueNotification, EvDeadLetterQueueNotification> { }; diff --git a/ydb/core/ymq/actor/executor.cpp b/ydb/core/ymq/actor/executor.cpp index 9789552588c..e17dc68fe95 100644 --- a/ydb/core/ymq/actor/executor.cpp +++ b/ydb/core/ymq/actor/executor.cpp @@ -46,7 +46,7 @@ TExecutorBuilder::TExecutorBuilder(TActorId parent, const TString& requestId) void TExecutorBuilder::Start() { if (HasQueryId() && QueueName_) { - SendToQueueLeader(); + SendToQueueLeader(); } else { StartExecutorActor(); } @@ -95,8 +95,8 @@ void TExecutorBuilder::StartExecutorActor() { TActivationContext::Register(actor.Release()); } -void TExecutorBuilder::SendToQueueLeader() { - Y_VERIFY(QueueLeaderActor_); +void TExecutorBuilder::SendToQueueLeader() { + Y_VERIFY(QueueLeaderActor_); auto ev = MakeHolder<TSqsEvents::TEvExecute>(Parent_, RequestId_, TQueuePath(Cfg().GetRoot(), UserName_, QueueName_, QueueVersion_), QueryId_, Shard_); ev->RetryOnTimeout = RetryOnTimeout_; @@ -104,9 +104,9 @@ void TExecutorBuilder::SendToQueueLeader() { Params(); // create params if not yet exist ev->Params = std::move(*Request().Record.MutableTransaction()->MutableMiniKQLTransaction()->MutableParams()->MutableProto()); - RLOG_SQS_DEBUG("Sending execute request for query(idx=" << QueryId_ << ") to queue leader"); + RLOG_SQS_DEBUG("Sending execute request for query(idx=" << QueryId_ << ") to queue leader"); - TActivationContext::Send(new IEventHandle(QueueLeaderActor_, Parent_, ev.Release())); + TActivationContext::Send(new IEventHandle(QueueLeaderActor_, Parent_, ev.Release())); } const char* TExecutorBuilder::GetQueryById(size_t idx) { diff --git a/ydb/core/ymq/actor/executor.h b/ydb/core/ymq/actor/executor.h index 93a36eca3c8..5dd51c6da23 100644 --- a/ydb/core/ymq/actor/executor.h +++ b/ydb/core/ymq/actor/executor.h @@ -19,7 +19,7 @@ namespace NKikimr::NSQS { // Builds transaction request and properly executes it -// Can either send TEvExecute to queue leader or create execution actor. +// Can either send TEvExecute to queue leader or create execution actor. class TExecutorBuilder { public: explicit TExecutorBuilder(TActorId parent, const TString& requestId); @@ -40,8 +40,8 @@ public: QueueVersion_ = version; return *this; } - TExecutorBuilder& QueueLeader(const TActorId& queueLeaderActor) { - QueueLeaderActor_ = queueLeaderActor; + TExecutorBuilder& QueueLeader(const TActorId& queueLeaderActor) { + QueueLeaderActor_ = queueLeaderActor; return *this; } TExecutorBuilder& Text(const TString& text, bool miniKql = true) { @@ -120,7 +120,7 @@ public: void StartExecutorActor(); // explicilty choose a way to start actor private: - void SendToQueueLeader(); // make transaction throught leader to use cached compiled query + void SendToQueueLeader(); // make transaction throught leader to use cached compiled query bool HasQueryId() const { return QueryId_ != EQueryId::QUERY_VECTOR_SIZE; @@ -139,7 +139,7 @@ private: TString QueueName_; ui64 Shard_ = 0; ui64 QueueVersion_ = 0; - TActorId QueueLeaderActor_; + TActorId QueueLeaderActor_; TSqsEvents::TExecutedCallback Callback_; EQueryId QueryId_ = EQueryId::QUERY_VECTOR_SIZE; TIntrusivePtr<TTransactionCounters> TransactionCounters_; diff --git a/ydb/core/ymq/actor/fifo_cleanup.cpp b/ydb/core/ymq/actor/fifo_cleanup.cpp index 450e2a742a6..218deb0fcc0 100644 --- a/ydb/core/ymq/actor/fifo_cleanup.cpp +++ b/ydb/core/ymq/actor/fifo_cleanup.cpp @@ -13,10 +13,10 @@ namespace NKikimr::NSQS { -TCleanupActor::TCleanupActor(const TQueuePath& queuePath, const TActorId& queueLeader, ECleanupType cleanupType) +TCleanupActor::TCleanupActor(const TQueuePath& queuePath, const TActorId& queueLeader, ECleanupType cleanupType) : QueuePath_(queuePath) , RequestId_(CreateGuidAsString()) - , QueueLeader_(queueLeader) + , QueueLeader_(queueLeader) , CleanupType(cleanupType) { DebugInfo->QueueCleanupActors.emplace(TStringBuilder() << TLogQueueName(QueuePath_), this); @@ -76,7 +76,7 @@ void TCleanupActor::RunCleanupQuery() { builder .User(QueuePath_.UserName) .Queue(QueuePath_.QueueName) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(GetCleanupQueryId()) .RetryOnTimeout() .Params() diff --git a/ydb/core/ymq/actor/fifo_cleanup.h b/ydb/core/ymq/actor/fifo_cleanup.h index 929678518d0..edf6040eec5 100644 --- a/ydb/core/ymq/actor/fifo_cleanup.h +++ b/ydb/core/ymq/actor/fifo_cleanup.h @@ -14,7 +14,7 @@ public: Reads, }; - TCleanupActor(const TQueuePath& queuePath, const TActorId& queueLeader, ECleanupType cleanupType); + TCleanupActor(const TQueuePath& queuePath, const TActorId& queueLeader, ECleanupType cleanupType); ~TCleanupActor(); void Bootstrap(); @@ -40,7 +40,7 @@ private: private: const TQueuePath QueuePath_; const TString RequestId_; - const TActorId QueueLeader_; + const TActorId QueueLeader_; const ECleanupType CleanupType; TString KeyRangeStart; }; diff --git a/ydb/core/ymq/actor/get_queue_attributes.cpp b/ydb/core/ymq/actor/get_queue_attributes.cpp index 960b5fd4f8b..28dc67b14f5 100644 --- a/ydb/core/ymq/actor/get_queue_attributes.cpp +++ b/ydb/core/ymq/actor/get_queue_attributes.cpp @@ -138,7 +138,7 @@ private: builder .User(UserName_) .Queue(GetQueueName()) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(INTERNAL_GET_QUEUE_ATTRIBUTES_ID) .Counters(QueueCounters_) .RetryOnTimeout() @@ -147,7 +147,7 @@ private: } if (NeedRuntimeAttributes_) { - Send(QueueLeader_, MakeHolder<TSqsEvents::TEvGetRuntimeQueueAttributes>(RequestId_)); + Send(QueueLeader_, MakeHolder<TSqsEvents::TEvGetRuntimeQueueAttributes>(RequestId_)); ++WaitCount_; } diff --git a/ydb/core/ymq/actor/list_dead_letter_source_queues.cpp b/ydb/core/ymq/actor/list_dead_letter_source_queues.cpp index 24d0fe402d3..fd4866fd49f 100644 --- a/ydb/core/ymq/actor/list_dead_letter_source_queues.cpp +++ b/ydb/core/ymq/actor/list_dead_letter_source_queues.cpp @@ -63,7 +63,7 @@ private: builder .User(UserName_) .Queue(GetQueueName()) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(LIST_DEAD_LETTER_SOURCE_QUEUES_ID) .Counters(QueueCounters_) .RetryOnTimeout() diff --git a/ydb/core/ymq/actor/migration.cpp b/ydb/core/ymq/actor/migration.cpp index 4adbd8fe494..e547e975581 100644 --- a/ydb/core/ymq/actor/migration.cpp +++ b/ydb/core/ymq/actor/migration.cpp @@ -200,10 +200,10 @@ void TAddColumnActor::OnTableAltered(const TSqsEvents::TEvExecuted::TRecord& ev) } -TQueueMigrationActor::TQueueMigrationActor(const TString& userName, const TString& queueName, const TActorId& queueLeader, const TActorId& schemeCache, TIntrusivePtr<TQueueCounters> counters, TDuration waitBeforeMigration) +TQueueMigrationActor::TQueueMigrationActor(const TString& userName, const TString& queueName, const TActorId& queueLeader, const TActorId& schemeCache, TIntrusivePtr<TQueueCounters> counters, TDuration waitBeforeMigration) : UserName(userName) , QueueName(queueName) - , QueueLeader(queueLeader) + , QueueLeader(queueLeader) , SchemeCache(schemeCache) , Counters(std::move(counters)) , WaitBeforeMigration(waitBeforeMigration) @@ -247,7 +247,7 @@ void TQueueMigrationActor::SendReplyAndDie(bool ok) { LOG_SQS_DEBUG("Queue " << TLogQueueName(UserName, QueueName) << " migration. Migration failed"); } - Send(QueueLeader, new TSqsEvents::TEvMigrationDone(ok)); + Send(QueueLeader, new TSqsEvents::TEvMigrationDone(ok)); PassAway(); } diff --git a/ydb/core/ymq/actor/migration.h b/ydb/core/ymq/actor/migration.h index a245dd33a75..501ec050f3f 100644 --- a/ydb/core/ymq/actor/migration.h +++ b/ydb/core/ymq/actor/migration.h @@ -10,7 +10,7 @@ namespace NKikimr::NSQS { class TQueueMigrationActor : public TActorBootstrapped<TQueueMigrationActor> { public: - TQueueMigrationActor(const TString& userName, const TString& queueName, const TActorId& queueLeader, const TActorId& schemeCache, TIntrusivePtr<TQueueCounters> counters, TDuration waitBeforeMigration = TDuration::Zero()); + TQueueMigrationActor(const TString& userName, const TString& queueName, const TActorId& queueLeader, const TActorId& schemeCache, TIntrusivePtr<TQueueCounters> counters, TDuration waitBeforeMigration = TDuration::Zero()); ~TQueueMigrationActor(); void Bootstrap(); @@ -43,7 +43,7 @@ private: private: const TString UserName; const TString QueueName; - const TActorId QueueLeader; + const TActorId QueueLeader; const TActorId SchemeCache; TIntrusivePtr<TQueueCounters> Counters; TDuration WaitBeforeMigration; diff --git a/ydb/core/ymq/actor/proxy_actor.cpp b/ydb/core/ymq/actor/proxy_actor.cpp index d759db687f0..98d85210a53 100644 --- a/ydb/core/ymq/actor/proxy_actor.cpp +++ b/ydb/core/ymq/actor/proxy_actor.cpp @@ -166,10 +166,10 @@ void TProxyActor::HandleWakeup(TEvWakeup::TPtr&) { const TErrorClass& TProxyActor::GetErrorClass(TSqsEvents::TEvProxySqsResponse::EProxyStatus proxyStatus) { using EProxyStatus = TSqsEvents::TEvProxySqsResponse::EProxyStatus; switch (proxyStatus) { - case EProxyStatus::LeaderResolvingError: - return NErrors::LEADER_RESOLVING_ERROR; + case EProxyStatus::LeaderResolvingError: + return NErrors::LEADER_RESOLVING_ERROR; case EProxyStatus::SessionError: - return NErrors::LEADER_SESSION_ERROR; + return NErrors::LEADER_SESSION_ERROR; case EProxyStatus::QueueDoesNotExist: case EProxyStatus::UserDoesNotExist: return NErrors::NON_EXISTENT_QUEUE; diff --git a/ydb/core/ymq/actor/proxy_actor.h b/ydb/core/ymq/actor/proxy_actor.h index 204cfbe49e1..b553716bf06 100644 --- a/ydb/core/ymq/actor/proxy_actor.h +++ b/ydb/core/ymq/actor/proxy_actor.h @@ -54,7 +54,7 @@ public: return NKikimrServices::TActivity::SQS_PROXY_ACTOR; } - // Watches request type and returns true if this type assumes proxying request to other queue leader node. + // Watches request type and returns true if this type assumes proxying request to other queue leader node. // So, TProxyActor must be created only if this function returns true. static bool NeedCreateProxyActor(const NKikimrClient::TSqsRequest& req); static bool NeedCreateProxyActor(EAction action); diff --git a/ydb/core/ymq/actor/proxy_service.cpp b/ydb/core/ymq/actor/proxy_service.cpp index 4e21673801d..1eecd851031 100644 --- a/ydb/core/ymq/actor/proxy_service.cpp +++ b/ydb/core/ymq/actor/proxy_service.cpp @@ -2,7 +2,7 @@ #include "executor.h" #include "log.h" #include "service.h" -#include "queue_leader.h" +#include "queue_leader.h" #include "params.h" #include "proxy_service.h" #include "serviceid.h" @@ -78,28 +78,28 @@ void TSqsProxyService::HandleSqsRequest(TSqsEvents::TEvSqsRequest::TPtr& ev) { void TSqsProxyService::HandleProxySqsRequest(TSqsEvents::TEvProxySqsRequest::TPtr& ev) { TProxyRequestInfoRef request = new TProxyRequestInfo(std::move(ev)); RequestsToProxy_.emplace(request->RequestId, request); - Send(MakeSqsServiceID(SelfId().NodeId()), new TSqsEvents::TEvGetLeaderNodeForQueueRequest(request->RequestId, request->ProxyRequest->Get()->UserName, request->ProxyRequest->Get()->QueueName)); - RLOG_SQS_REQ_DEBUG(request->RequestId, "Send get leader node request to sqs service"); + Send(MakeSqsServiceID(SelfId().NodeId()), new TSqsEvents::TEvGetLeaderNodeForQueueRequest(request->RequestId, request->ProxyRequest->Get()->UserName, request->ProxyRequest->Get()->QueueName)); + RLOG_SQS_REQ_DEBUG(request->RequestId, "Send get leader node request to sqs service"); } -static TSqsEvents::TEvProxySqsResponse::EProxyStatus GetLeaderNodeForQueueStatusToProxyStatus(TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus status) { +static TSqsEvents::TEvProxySqsResponse::EProxyStatus GetLeaderNodeForQueueStatusToProxyStatus(TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus status) { switch (status) { - case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::OK: + case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::OK: return TSqsEvents::TEvProxySqsResponse::EProxyStatus::OK; - case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser: + case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser: return TSqsEvents::TEvProxySqsResponse::EProxyStatus::UserDoesNotExist; - case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue: + case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue: return TSqsEvents::TEvProxySqsResponse::EProxyStatus::QueueDoesNotExist; - case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::FailedToConnectToLeader: + case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::FailedToConnectToLeader: return TSqsEvents::TEvProxySqsResponse::EProxyStatus::SessionError; - case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::Error: + case TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::Error: default: - return TSqsEvents::TEvProxySqsResponse::EProxyStatus::LeaderResolvingError; + return TSqsEvents::TEvProxySqsResponse::EProxyStatus::LeaderResolvingError; } } -void TSqsProxyService::HandleGetLeaderNodeForQueueResponse(TSqsEvents::TEvGetLeaderNodeForQueueResponse::TPtr& ev) { - RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Got leader node for queue response. Node id: " << ev->Get()->NodeId << ". Status: " << static_cast<int>(ev->Get()->Status)); +void TSqsProxyService::HandleGetLeaderNodeForQueueResponse(TSqsEvents::TEvGetLeaderNodeForQueueResponse::TPtr& ev) { + RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Got leader node for queue response. Node id: " << ev->Get()->NodeId << ". Status: " << static_cast<int>(ev->Get()->Status)); const auto requestIt = RequestsToProxy_.find(ev->Get()->RequestId); if (requestIt == RequestsToProxy_.end()) { RLOG_SQS_REQ_ERROR(ev->Get()->RequestId, "Request was not found in requests to proxy map"); @@ -108,11 +108,11 @@ void TSqsProxyService::HandleGetLeaderNodeForQueueResponse(TSqsEvents::TEvGetLea TProxyRequestInfoRef request = requestIt->second; RequestsToProxy_.erase(requestIt); - if (ev->Get()->Status == TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::OK) { + if (ev->Get()->Status == TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::OK) { TNodeInfoRef nodeInfo = GetNodeInfo(ev->Get()->NodeId); SendProxyRequestToNode(*nodeInfo, request); } else { - SendProxyError(request, GetLeaderNodeForQueueStatusToProxyStatus(ev->Get()->Status)); + SendProxyError(request, GetLeaderNodeForQueueStatusToProxyStatus(ev->Get()->Status)); } } @@ -162,20 +162,20 @@ void TSqsProxyService::HandleUndelivered(TEvents::TEvUndelivered::TPtr& ev) { STATEFN(TSqsProxyService::StateFunc) { switch (ev->GetTypeRewrite()) { hFunc(TSqsEvents::TEvExecuted, HandleExecuted); - hFunc(TSqsEvents::TEvSqsRequest, HandleSqsRequest); // request to queue leader node (proxied) // creates request worker and calls it - hFunc(TSqsEvents::TEvProxySqsRequest, HandleProxySqsRequest); // request from proxy on our node // proxies request to queue leader node (TEvSqsRequest) + hFunc(TSqsEvents::TEvSqsRequest, HandleSqsRequest); // request to queue leader node (proxied) // creates request worker and calls it + hFunc(TSqsEvents::TEvProxySqsRequest, HandleProxySqsRequest); // request from proxy on our node // proxies request to queue leader node (TEvSqsRequest) hFunc(TSqsEvents::TEvSqsResponse, HandleSqsResponse); // response from other node on TEvSqsRequest // sends response to source proxy on our node hFunc(TEvInterconnect::TEvNodeDisconnected, HandleDisconnect); hFunc(TEvInterconnect::TEvNodeConnected, HandleConnect); hFunc(TEvents::TEvUndelivered, HandleUndelivered); - hFunc(TSqsEvents::TEvGetLeaderNodeForQueueResponse, HandleGetLeaderNodeForQueueResponse); + hFunc(TSqsEvents::TEvGetLeaderNodeForQueueResponse, HandleGetLeaderNodeForQueueResponse); default: LOG_SQS_ERROR("Unknown type of event came to SQS service actor: " << ev->Type << " (" << ev->GetBase()->ToString() << "), sender: " << ev->Sender); } } void TSqsProxyService::SendProxyRequestToNode(TNodeInfo& nodeInfo, TProxyRequestInfoRef request) { - RLOG_SQS_REQ_TRACE(request->RequestId, "Sending request from proxy to leader node " << nodeInfo.NodeId << ": " << SecureShortUtf8DebugString(request->ProxyRequest->Get()->Record)); + RLOG_SQS_REQ_TRACE(request->RequestId, "Sending request from proxy to leader node " << nodeInfo.NodeId << ": " << SecureShortUtf8DebugString(request->ProxyRequest->Get()->Record)); Send(MakeSqsProxyServiceID(nodeInfo.NodeId), new TSqsEvents::TEvSqsRequest(std::move(request->ProxyRequest->Get()->Record)), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession); nodeInfo.Requests.emplace(request->RequestId, std::move(request)); diff --git a/ydb/core/ymq/actor/proxy_service.h b/ydb/core/ymq/actor/proxy_service.h index f53ff16c15f..a3c991105fe 100644 --- a/ydb/core/ymq/actor/proxy_service.h +++ b/ydb/core/ymq/actor/proxy_service.h @@ -82,7 +82,7 @@ private: void HandleConnect(TEvInterconnect::TEvNodeConnected::TPtr& ev); void HandleUndelivered(TEvents::TEvUndelivered::TPtr& ev); void HandleDisconnect(ui32 nodeId); - void HandleGetLeaderNodeForQueueResponse(TSqsEvents::TEvGetLeaderNodeForQueueResponse::TPtr& ev); + void HandleGetLeaderNodeForQueueResponse(TSqsEvents::TEvGetLeaderNodeForQueueResponse::TPtr& ev); private: TIntrusivePtr<NMonitoring::TDynamicCounters> SqsCounters_; diff --git a/ydb/core/ymq/actor/purge.cpp b/ydb/core/ymq/actor/purge.cpp index 62df7634dce..aff713d7844 100644 --- a/ydb/core/ymq/actor/purge.cpp +++ b/ydb/core/ymq/actor/purge.cpp @@ -13,11 +13,11 @@ using NKikimr::NClient::TValue; namespace NKikimr::NSQS { -TPurgeActor::TPurgeActor(const TQueuePath& queuePath, TIntrusivePtr<TQueueCounters> counters, const TActorId& queueLeader, bool isFifo) +TPurgeActor::TPurgeActor(const TQueuePath& queuePath, TIntrusivePtr<TQueueCounters> counters, const TActorId& queueLeader, bool isFifo) : QueuePath_(queuePath) , RequestId_(CreateGuidAsString()) , Counters_(std::move(counters)) - , QueueLeader_(queueLeader) + , QueueLeader_(queueLeader) , IsFifo_(isFifo) { DebugInfo->QueuePurgeActors.emplace(TStringBuilder() << TLogQueueName(QueuePath_), this); @@ -62,7 +62,7 @@ void TPurgeActor::MakeGetRetentionOffsetRequest(const ui64 shardId, TShard* shar .User(QueuePath_.UserName) .Queue(QueuePath_.QueueName) .Shard(shardId) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(GET_RETENTION_OFFSET_ID) .Counters(Counters_) .RetryOnTimeout() @@ -106,7 +106,7 @@ void TPurgeActor::MakeStage1Request(const ui64 shardId, TShard* shard, const std .User(QueuePath_.UserName) .Queue(QueuePath_.QueueName) .Shard(shardId) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(PURGE_QUEUE_ID) .Counters(Counters_) .RetryOnTimeout() @@ -158,7 +158,7 @@ void TPurgeActor::MakeStage2Request(ui64 cleanupVersion, const TValue& messages, auto notification = MakeHolder<TSqsEvents::TEvQueuePurgedNotification>(); notification->Shard = shardId; notification->NewMessagesCount = static_cast<ui64>(newMessagesCount); - Send(QueueLeader_, std::move(notification)); + Send(QueueLeader_, std::move(notification)); } shard->BoundaryPurged = shard->CurrentLastMessage.SentTimestamp; @@ -179,7 +179,7 @@ void TPurgeActor::MakeStage2Request(ui64 cleanupVersion, const TValue& messages, .User(QueuePath_.UserName) .Queue(QueuePath_.QueueName) .Shard(shardId) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(PURGE_QUEUE_STAGE2_ID) .Counters(Counters_) .RetryOnTimeout() @@ -197,7 +197,7 @@ void TPurgeActor::MakeStage2Request(ui64 cleanupVersion, const TValue& messages, notification->Shard = shardId; FillMessagesParam(messagesParam, *inflyMessages, shard->CurrentLastMessage.Offset, shard->CurrentLastMessage.SentTimestamp, notification.Get()); if (!notification->Offsets.empty()) { - Send(QueueLeader_, std::move(notification)); + Send(QueueLeader_, std::move(notification)); } } diff --git a/ydb/core/ymq/actor/purge.h b/ydb/core/ymq/actor/purge.h index b41ef50b73e..2a16a5aa247 100644 --- a/ydb/core/ymq/actor/purge.h +++ b/ydb/core/ymq/actor/purge.h @@ -27,7 +27,7 @@ class TPurgeActor : public TActorBootstrapped<TPurgeActor> { }; public: - TPurgeActor(const TQueuePath& queuePath, TIntrusivePtr<TQueueCounters> counters, const TActorId& queueLeader, bool isFifo); + TPurgeActor(const TQueuePath& queuePath, TIntrusivePtr<TQueueCounters> counters, const TActorId& queueLeader, bool isFifo); ~TPurgeActor(); void Bootstrap(); @@ -61,7 +61,7 @@ private: const TString RequestId_; TIntrusivePtr<TQueueCounters> Counters_; TIntrusivePtr<NMonitoring::TCounterForPtr> PurgedMessagesCounter_; - const TActorId QueueLeader_; + const TActorId QueueLeader_; const bool IsFifo_; }; diff --git a/ydb/core/ymq/actor/purge_queue.cpp b/ydb/core/ymq/actor/purge_queue.cpp index 1b48fa79f36..72830bdd4a7 100644 --- a/ydb/core/ymq/actor/purge_queue.cpp +++ b/ydb/core/ymq/actor/purge_queue.cpp @@ -45,7 +45,7 @@ private: TExecutorBuilder(SelfId(), RequestId_) .User(UserName_) .Queue(GetQueueName()) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(SET_RETENTION_ID) .Counters(QueueCounters_) .RetryOnTimeout() @@ -83,7 +83,7 @@ private: RLOG_SQS_INFO("Purging queue. Set retention boundary for queue [" << req->QueuePath << "/" << req->Shard << "] to " << req->Boundary.MilliSeconds() << " (" << req->Boundary << ")"); - Send(QueueLeader_, std::move(req)); + Send(QueueLeader_, std::move(req)); } } else { RLOG_SQS_ERROR("Failed to set retention boundary for queue [" << GetQueuePath() << "] while purging"); diff --git a/ydb/core/ymq/actor/queue_leader.cpp b/ydb/core/ymq/actor/queue_leader.cpp index 74f9ccc053a..2c6e81d8275 100644 --- a/ydb/core/ymq/actor/queue_leader.cpp +++ b/ydb/core/ymq/actor/queue_leader.cpp @@ -1,4 +1,4 @@ -#include "queue_leader.h" +#include "queue_leader.h" #include "fifo_cleanup.h" #include "executor.h" #include "log.h" @@ -38,7 +38,7 @@ const TString INFLY_INVALIDATION_REASON_VERSION_CHANGED = "InflyVersionChanged"; const TString INFLY_INVALIDATION_REASON_DEADLINE_CHANGED = "MessageDeadlineChanged"; const TString INFLY_INVALIDATION_REASON_DELETED = "MessageDeleted"; -TQueueLeader::TQueueLeader(TString userName, TString queueName, TString folderId, TString rootUrl, TIntrusivePtr<TQueueCounters> counters, TIntrusivePtr<TUserCounters> userCounters, const TActorId& schemeCache, const TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions>& quoterResourcesForUser) +TQueueLeader::TQueueLeader(TString userName, TString queueName, TString folderId, TString rootUrl, TIntrusivePtr<TQueueCounters> counters, TIntrusivePtr<TUserCounters> userCounters, const TActorId& schemeCache, const TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions>& quoterResourcesForUser) : UserName_(std::move(userName)) , QueueName_(std::move(queueName)) , FolderId_(std::move(folderId)) @@ -47,23 +47,23 @@ TQueueLeader::TQueueLeader(TString userName, TString queueName, TString folderId , Counters_(std::move(counters)) , UserCounters_(std::move(userCounters)) { - DebugInfo->QueueLeaders.emplace(TStringBuilder() << TLogQueueName(UserName_, QueueName_), this); + DebugInfo->QueueLeaders.emplace(TStringBuilder() << TLogQueueName(UserName_, QueueName_), this); if (quoterResourcesForUser) { QuoterResources_ = new TSqsEvents::TQuoterResourcesForActions(*quoterResourcesForUser); } } -TQueueLeader::~TQueueLeader() { - DebugInfo->QueueLeaders.EraseKeyValue(TStringBuilder() << TLogQueueName(UserName_, QueueName_), this); +TQueueLeader::~TQueueLeader() { + DebugInfo->QueueLeaders.EraseKeyValue(TStringBuilder() << TLogQueueName(UserName_, QueueName_), this); } -void TQueueLeader::Bootstrap() { - Become(&TQueueLeader::StateInit); +void TQueueLeader::Bootstrap() { + Become(&TQueueLeader::StateInit); Register(new TQueueMigrationActor(UserName_, QueueName_, SelfId(), SchemeCache_, Counters_)); } -void TQueueLeader::BecomeWorking() { - Become(&TQueueLeader::StateWorking); +void TQueueLeader::BecomeWorking() { + Become(&TQueueLeader::StateWorking); const auto& cfg = Cfg(); const ui64 randomTimeToWait = RandomNumber<ui64>(cfg.GetBackgroundMetricsUpdateTimeMs() / 4); // Don't start all such operations at one moment Schedule(TDuration::MilliSeconds(randomTimeToWait), new TEvWakeup(UPDATE_COUNTERS_TAG)); @@ -93,7 +93,7 @@ void TQueueLeader::BecomeWorking() { } } -STATEFN(TQueueLeader::StateInit) { +STATEFN(TQueueLeader::StateInit) { switch (ev->GetTypeRewrite()) { // interface cFunc(TEvPoisonPill::EventType, PassAway); // from service @@ -114,11 +114,11 @@ STATEFN(TQueueLeader::StateInit) { hFunc(TEvWakeup, HandleWakeup); hFunc(TSqsEvents::TEvMigrationDone, HandleMigrationDone); // from migration actor default: - LOG_SQS_ERROR("Unknown type of event came to SQS background queue " << TLogQueueName(UserName_, QueueName_) << " leader actor: " << ev->Type << " (" << ev->GetBase()->ToString() << "), sender: " << ev->Sender); + LOG_SQS_ERROR("Unknown type of event came to SQS background queue " << TLogQueueName(UserName_, QueueName_) << " leader actor: " << ev->Type << " (" << ev->GetBase()->ToString() << "), sender: " << ev->Sender); } } -STATEFN(TQueueLeader::StateWorking) { +STATEFN(TQueueLeader::StateWorking) { switch (ev->GetTypeRewrite()) { // interface cFunc(TEvPoisonPill::EventType, PassAway); // from service @@ -140,12 +140,12 @@ STATEFN(TQueueLeader::StateWorking) { hFunc(TSqsEvents::TEvInflyIsPurgingNotification, HandleInflyIsPurgingNotification); hFunc(TSqsEvents::TEvQueuePurgedNotification, HandleQueuePurgedNotification); default: - LOG_SQS_ERROR("Unknown type of event came to SQS background queue " << TLogQueueName(UserName_, QueueName_) << " leader actor: " << ev->Type << " (" << ev->GetBase()->ToString() << "), sender: " << ev->Sender); + LOG_SQS_ERROR("Unknown type of event came to SQS background queue " << TLogQueueName(UserName_, QueueName_) << " leader actor: " << ev->Type << " (" << ev->GetBase()->ToString() << "), sender: " << ev->Sender); } } -void TQueueLeader::PassAway() { - LOG_SQS_INFO("Queue " << TLogQueueName(UserName_, QueueName_) << " leader is dying"); +void TQueueLeader::PassAway() { + LOG_SQS_INFO("Queue " << TLogQueueName(UserName_, QueueName_) << " leader is dying"); for (auto& req : GetConfigurationRequests_) { AnswerFailed(req); @@ -175,7 +175,7 @@ void TQueueLeader::PassAway() { TActorBootstrapped::PassAway(); } -void TQueueLeader::HandleWakeup(TEvWakeup::TPtr& ev) { +void TQueueLeader::HandleWakeup(TEvWakeup::TPtr& ev) { if (ev->Get()->Tag >= RELOAD_INFLY_TAG && ev->Get()->Tag < RELOAD_INFLY_TAG + MAX_SHARDS_COUNT) { StartLoadingInfly(ev->Get()->Tag - RELOAD_INFLY_TAG, true); // reload infly after failure while loading infly return; @@ -201,24 +201,24 @@ void TQueueLeader::HandleWakeup(TEvWakeup::TPtr& ev) { } } -void TQueueLeader::HandleMigrationDone(TSqsEvents::TEvMigrationDone::TPtr& ev) { +void TQueueLeader::HandleMigrationDone(TSqsEvents::TEvMigrationDone::TPtr& ev) { if (ev->Get()->Success) { const auto& cfg = Cfg(); QueueAttributesCacheTime_ = TDuration::MilliSeconds(cfg.GetQueueAttributesCacheTimeMs()); RequestConfiguration(); } else { INC_COUNTER(Counters_, QueueMasterStartProblems); - INC_COUNTER(Counters_, QueueLeaderStartProblems); + INC_COUNTER(Counters_, QueueLeaderStartProblems); Register(new TQueueMigrationActor(UserName_, QueueName_, SelfId(), SchemeCache_, Counters_, TDuration::MilliSeconds(500))); FailRequestsDuringStartProblems(); } } -void TQueueLeader::HandleGetConfigurationWhileIniting(TSqsEvents::TEvGetConfiguration::TPtr& ev) { +void TQueueLeader::HandleGetConfigurationWhileIniting(TSqsEvents::TEvGetConfiguration::TPtr& ev) { GetConfigurationRequests_.emplace_back(ev); } -void TQueueLeader::HandleGetConfigurationWhileWorking(TSqsEvents::TEvGetConfiguration::TPtr& ev) { +void TQueueLeader::HandleGetConfigurationWhileWorking(TSqsEvents::TEvGetConfiguration::TPtr& ev) { if (ev->Get()->NeedQueueAttributes && TActivationContext::Now() <= AttributesUpdateTime_ + QueueAttributesCacheTime_ && QueueAttributes_) { AnswerGetConfiguration(ev); } else { @@ -228,16 +228,16 @@ void TQueueLeader::HandleGetConfigurationWhileWorking(TSqsEvents::TEvGetConfigur } } -void TQueueLeader::HandleClearQueueAttributesCache([[maybe_unused]] TSqsEvents::TEvClearQueueAttributesCache::TPtr& ev) { +void TQueueLeader::HandleClearQueueAttributesCache([[maybe_unused]] TSqsEvents::TEvClearQueueAttributesCache::TPtr& ev) { AttributesUpdateTime_ = TInstant::Zero(); QueueAttributes_ = Nothing(); } -void TQueueLeader::HandleExecuteWhileIniting(TSqsEvents::TEvExecute::TPtr& ev) { +void TQueueLeader::HandleExecuteWhileIniting(TSqsEvents::TEvExecute::TPtr& ev) { ExecuteRequests_.emplace_back(ev); } -void TQueueLeader::HandleExecuteWhileWorking(TSqsEvents::TEvExecute::TPtr& ev) { +void TQueueLeader::HandleExecuteWhileWorking(TSqsEvents::TEvExecute::TPtr& ev) { Y_VERIFY(ev->Get()->QueryIdx < QUERY_VECTOR_SIZE); Y_VERIFY(ev->Get()->Shard < ShardsCount_); auto& query = Shards_[ev->Get()->Shard].Queries[ev->Get()->QueryIdx]; @@ -257,7 +257,7 @@ void TQueueLeader::HandleExecuteWhileWorking(TSqsEvents::TEvExecute::TPtr& ev) { } } -void TQueueLeader::Prepare(TSqsEvents::TEvExecute::TPtr& ev) { +void TQueueLeader::Prepare(TSqsEvents::TEvExecute::TPtr& ev) { const TSqsEvents::TEvExecute& req = *ev->Get(); RLOG_SQS_REQ_DEBUG(req.RequestId, "Preparing query(idx=" << req.QueryIdx << ")"); @@ -275,7 +275,7 @@ void TQueueLeader::Prepare(TSqsEvents::TEvExecute::TPtr& ev) { .StartExecutorActor(); } -void TQueueLeader::OnQueryPrepared(TSqsEvents::TEvExecute::TPtr& ev, const TSqsEvents::TEvExecuted::TRecord& record) { +void TQueueLeader::OnQueryPrepared(TSqsEvents::TEvExecute::TPtr& ev, const TSqsEvents::TEvExecuted::TRecord& record) { const TSqsEvents::TEvExecute& req = *ev->Get(); auto status = TEvTxUserProxy::TEvProposeTransactionStatus::EStatus(record.GetStatus()); auto& query = Shards_[req.Shard].Queries[req.QueryIdx]; @@ -313,7 +313,7 @@ void TQueueLeader::OnQueryPrepared(TSqsEvents::TEvExecute::TPtr& ev, const TSqsE } } -void TQueueLeader::RemoveCachedRequest(size_t shard, size_t idx) { +void TQueueLeader::RemoveCachedRequest(size_t shard, size_t idx) { TQuery& query = Shards_[shard].Queries[idx]; if (query.State == EQueryState::Cached) { LOG_SQS_INFO("Remove cached compiled query(idx=" << idx << ") for queue " << TLogQueueName(UserName_, QueueName_, shard)); @@ -329,7 +329,7 @@ void TQueueLeader::RemoveCachedRequest(size_t shard, size_t idx) { } } -void TQueueLeader::ExecuteRequest(TSqsEvents::TEvExecute::TPtr& ev, const TString& compiled) { +void TQueueLeader::ExecuteRequest(TSqsEvents::TEvExecute::TPtr& ev, const TString& compiled) { const TSqsEvents::TEvExecute& req = *ev->Get(); RLOG_SQS_REQ_DEBUG(req.RequestId, "Executing compiled query(idx=" << req.QueryIdx << ")"); TExecutorBuilder builder(SelfId(), req.RequestId); @@ -349,7 +349,7 @@ void TQueueLeader::ExecuteRequest(TSqsEvents::TEvExecute::TPtr& ev, const TStrin builder.StartExecutorActor(); } -void TQueueLeader::OnQueryExecuted(TSqsEvents::TEvExecute::TPtr& ev, const TSqsEvents::TEvExecuted::TRecord& record) { +void TQueueLeader::OnQueryExecuted(TSqsEvents::TEvExecute::TPtr& ev, const TSqsEvents::TEvExecuted::TRecord& record) { const TSqsEvents::TEvExecute& req = *ev->Get(); bool retried = false; auto status = TEvTxUserProxy::TEvProposeTransactionStatus::EStatus(record.GetStatus()); @@ -377,19 +377,19 @@ void TQueueLeader::OnQueryExecuted(TSqsEvents::TEvExecute::TPtr& ev, const TSqsE } } -void TQueueLeader::HandleSendMessageBatchWhileIniting(TSqsEvents::TEvSendMessageBatch::TPtr& ev) { +void TQueueLeader::HandleSendMessageBatchWhileIniting(TSqsEvents::TEvSendMessageBatch::TPtr& ev) { TString reqId = ev->Get()->RequestId; Y_VERIFY(SendMessageRequests_.emplace(std::move(reqId), std::move(ev)).second); } -void TQueueLeader::HandleSendMessageBatchWhileWorking(TSqsEvents::TEvSendMessageBatch::TPtr& ev) { +void TQueueLeader::HandleSendMessageBatchWhileWorking(TSqsEvents::TEvSendMessageBatch::TPtr& ev) { TString reqId = ev->Get()->RequestId; auto [reqIter, inserted] = SendMessageRequests_.emplace(std::move(reqId), std::move(ev)); Y_VERIFY(inserted); ProcessSendMessageBatch(reqIter->second); } -void TQueueLeader::ProcessSendMessageBatch(TSendMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::ProcessSendMessageBatch(TSendMessageBatchRequestProcessing& reqInfo) { reqInfo.Init(ShardsCount_); // init if not inited if (!IncActiveMessageRequests(reqInfo.Shard, reqInfo.Event->Get()->RequestId)) { return; @@ -400,7 +400,7 @@ void TQueueLeader::ProcessSendMessageBatch(TSendMessageBatchRequestProcessing& r shardInfo.SendBatchingState.TryExecute(this); } -void TQueueLeader::OnMessageSent(const TString& requestId, size_t index, const TSqsEvents::TEvExecuted::TRecord& reply, const NKikimr::NClient::TValue* messageRecord) { +void TQueueLeader::OnMessageSent(const TString& requestId, size_t index, const TSqsEvents::TEvExecuted::TRecord& reply, const NKikimr::NClient::TValue* messageRecord) { auto reqInfoIt = SendMessageRequests_.find(requestId); Y_VERIFY(reqInfoIt != SendMessageRequests_.end()); auto& reqInfo = reqInfoIt->second; @@ -438,7 +438,7 @@ void TQueueLeader::OnMessageSent(const TString& requestId, size_t index, const T } } -void TQueueLeader::OnSendBatchExecuted(ui64 shard, ui64 batchId, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnSendBatchExecuted(ui64 shard, ui64 batchId, const TSqsEvents::TEvExecuted::TRecord& reply) { auto& shardInfo = Shards_[shard]; auto& batchingState = shardInfo.SendBatchingState; auto batchIt = batchingState.BatchesExecuting.find(batchId); @@ -478,19 +478,19 @@ void TQueueLeader::OnSendBatchExecuted(ui64 shard, ui64 batchId, const TSqsEvent batchingState.TryExecute(this); } -void TQueueLeader::HandleReceiveMessageBatchWhileIniting(TSqsEvents::TEvReceiveMessageBatch::TPtr& ev) { +void TQueueLeader::HandleReceiveMessageBatchWhileIniting(TSqsEvents::TEvReceiveMessageBatch::TPtr& ev) { TString reqId = ev->Get()->RequestId; Y_VERIFY(ReceiveMessageRequests_.emplace(std::move(reqId), std::move(ev)).second); } -void TQueueLeader::HandleReceiveMessageBatchWhileWorking(TSqsEvents::TEvReceiveMessageBatch::TPtr& ev) { +void TQueueLeader::HandleReceiveMessageBatchWhileWorking(TSqsEvents::TEvReceiveMessageBatch::TPtr& ev) { TString reqId = ev->Get()->RequestId; auto [reqIter, inserted] = ReceiveMessageRequests_.emplace(std::move(reqId), std::move(ev)); Y_VERIFY(inserted); ProcessReceiveMessageBatch(reqIter->second); } -void TQueueLeader::ProcessReceiveMessageBatch(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::ProcessReceiveMessageBatch(TReceiveMessageBatchRequestProcessing& reqInfo) { reqInfo.Init(ShardsCount_); // init if not inited if (reqInfo.WaitingAddMessagesToInfly) { @@ -508,7 +508,7 @@ void TQueueLeader::ProcessReceiveMessageBatch(TReceiveMessageBatchRequestProcess } } -void TQueueLeader::LockFifoGroup(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::LockFifoGroup(TReceiveMessageBatchRequestProcessing& reqInfo) { reqInfo.LockSendTs = TActivationContext::Now(); auto onExecuted = [this, requestId = reqInfo.Event->Get()->RequestId] (const TSqsEvents::TEvExecuted::TRecord& ev) { OnFifoGroupLocked(requestId, ev); @@ -519,7 +519,7 @@ void TQueueLeader::LockFifoGroup(TReceiveMessageBatchRequestProcessing& reqInfo) .Queue(QueueName_) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(LOCK_GROUP_ID) .Counters(Counters_) .RetryOnTimeout() @@ -535,7 +535,7 @@ void TQueueLeader::LockFifoGroup(TReceiveMessageBatchRequestProcessing& reqInfo) .ParentBuilder().Start(); } -void TQueueLeader::OnFifoGroupLocked(const TString& requestId, const TSqsEvents::TEvExecuted::TRecord& ev) { +void TQueueLeader::OnFifoGroupLocked(const TString& requestId, const TSqsEvents::TEvExecuted::TRecord& ev) { auto reqInfoIt = ReceiveMessageRequests_.find(requestId); Y_VERIFY(reqInfoIt != ReceiveMessageRequests_.end()); auto& reqInfo = reqInfoIt->second; @@ -578,7 +578,7 @@ void TQueueLeader::OnFifoGroupLocked(const TString& requestId, const TSqsEvents: } } -void TQueueLeader::ReadFifoMessages(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::ReadFifoMessages(TReceiveMessageBatchRequestProcessing& reqInfo) { ui32 maxReceiveCount = 0; // not set if (Cfg().GetEnableDeadLetterQueues() && DlqInfo_) { const auto& dlqInfo(*DlqInfo_); @@ -594,7 +594,7 @@ void TQueueLeader::ReadFifoMessages(TReceiveMessageBatchRequestProcessing& reqIn .Queue(QueueName_) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .Counters(Counters_) .RetryOnTimeout(); @@ -647,7 +647,7 @@ void TQueueLeader::ReadFifoMessages(TReceiveMessageBatchRequestProcessing& reqIn builder.Start(); } -void TQueueLeader::OnFifoMessagesRead(const TString& requestId, const TSqsEvents::TEvExecuted::TRecord& ev, const bool usedDLQ) { +void TQueueLeader::OnFifoMessagesRead(const TString& requestId, const TSqsEvents::TEvExecuted::TRecord& ev, const bool usedDLQ) { auto reqInfoIt = ReceiveMessageRequests_.find(requestId); Y_VERIFY(reqInfoIt != ReceiveMessageRequests_.end()); auto& reqInfo = reqInfoIt->second; @@ -715,7 +715,7 @@ void TQueueLeader::OnFifoMessagesRead(const TString& requestId, const TSqsEvents Reply(reqInfo); } -void TQueueLeader::GetMessagesFromInfly(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::GetMessagesFromInfly(TReceiveMessageBatchRequestProcessing& reqInfo) { reqInfo.LockSendTs = TActivationContext::Now(); Y_VERIFY(reqInfo.GetCurrentShard() < Shards_.size()); const ui64 shard = reqInfo.GetCurrentShard(); @@ -735,7 +735,7 @@ void TQueueLeader::GetMessagesFromInfly(TReceiveMessageBatchRequestProcessing& r } } -void TQueueLeader::LoadStdMessages(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::LoadStdMessages(TReceiveMessageBatchRequestProcessing& reqInfo) { const ui64 shard = reqInfo.GetCurrentShard(); auto& shardInfo = Shards_[shard]; RLOG_SQS_REQ_DEBUG(reqInfo.Event->Get()->RequestId, "Reading messages. Shard: " << shard); @@ -746,7 +746,7 @@ void TQueueLeader::LoadStdMessages(TReceiveMessageBatchRequestProcessing& reqInf } } -void TQueueLeader::OnLoadStdMessageResult(const TString& requestId, const ui64 offset, const TSqsEvents::TEvExecuted::TRecord& ev, const NKikimr::NClient::TValue* messageRecord, const bool ignoreMessageLoadingErrors) { +void TQueueLeader::OnLoadStdMessageResult(const TString& requestId, const ui64 offset, const TSqsEvents::TEvExecuted::TRecord& ev, const NKikimr::NClient::TValue* messageRecord, const bool ignoreMessageLoadingErrors) { auto reqInfoIt = ReceiveMessageRequests_.find(requestId); Y_VERIFY(reqInfoIt != ReceiveMessageRequests_.end()); auto& reqInfo = reqInfoIt->second; @@ -795,7 +795,7 @@ void TQueueLeader::OnLoadStdMessageResult(const TString& requestId, const ui64 o } } else { deadlineChanged = true; - RLOG_SQS_REQ_WARN(requestId, "Attempted to receive message that was received by another leader's request. Shard: " << reqInfo.GetCurrentShard() + RLOG_SQS_REQ_WARN(requestId, "Attempted to receive message that was received by another leader's request. Shard: " << reqInfo.GetCurrentShard() << ". Offset: " << offset << ". Visibility deadline: " << visibilityDeadline); } } else { @@ -809,7 +809,7 @@ void TQueueLeader::OnLoadStdMessageResult(const TString& requestId, const ui64 o RLOG_SQS_REQ_WARN(requestId, "Attempted to receive message that was deleted. Shard: " << reqInfo.GetCurrentShard() << ". Offset: " << offset); deleted = true; } - } // else there was concurrent delete (purge) by this leader, => OK + } // else there was concurrent delete (purge) by this leader, => OK } const bool invalidated = deleted || deadlineChanged; if (invalidated) { @@ -831,7 +831,7 @@ void TQueueLeader::OnLoadStdMessageResult(const TString& requestId, const ui64 o } } -void TQueueLeader::OnLoadStdMessagesBatchExecuted(ui64 shard, ui64 batchId, const bool usedDLQ, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnLoadStdMessagesBatchExecuted(ui64 shard, ui64 batchId, const bool usedDLQ, const TSqsEvents::TEvExecuted::TRecord& reply) { auto& shardInfo = Shards_[shard]; auto& batchingState = shardInfo.LoadBatchingState; auto batchIt = batchingState.BatchesExecuting.find(batchId); @@ -888,7 +888,7 @@ void TQueueLeader::OnLoadStdMessagesBatchExecuted(ui64 shard, ui64 batchId, cons batchingState.TryExecute(this); } -void TQueueLeader::TryReceiveAnotherShard(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::TryReceiveAnotherShard(TReceiveMessageBatchRequestProcessing& reqInfo) { const TString& requestId = reqInfo.Event->Get()->RequestId; const TInstant waitDeadline = reqInfo.Event->Get()->WaitDeadline; const TInstant now = TActivationContext::Now(); @@ -909,7 +909,7 @@ void TQueueLeader::TryReceiveAnotherShard(TReceiveMessageBatchRequestProcessing& Reply(reqInfo); } -void TQueueLeader::WaitAddMessagesToInflyOrTryAnotherShard(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::WaitAddMessagesToInflyOrTryAnotherShard(TReceiveMessageBatchRequestProcessing& reqInfo) { const ui64 shard = reqInfo.GetCurrentShard(); auto& shardInfo = Shards_[shard]; const TString& requestId = reqInfo.Event->Get()->RequestId; @@ -947,26 +947,26 @@ void TQueueLeader::WaitAddMessagesToInflyOrTryAnotherShard(TReceiveMessageBatchR } } -void TQueueLeader::Reply(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::Reply(TReceiveMessageBatchRequestProcessing& reqInfo) { const ui64 shard = reqInfo.GetCurrentShard(); Send(reqInfo.Event->Sender, std::move(reqInfo.Answer)); ReceiveMessageRequests_.erase(reqInfo.Event->Get()->RequestId); DecActiveMessageRequests(shard); } -void TQueueLeader::HandleDeleteMessageBatchWhileIniting(TSqsEvents::TEvDeleteMessageBatch::TPtr& ev) { +void TQueueLeader::HandleDeleteMessageBatchWhileIniting(TSqsEvents::TEvDeleteMessageBatch::TPtr& ev) { auto key = std::make_pair(ev->Get()->RequestId, ev->Get()->Shard); Y_VERIFY(DeleteMessageRequests_.emplace(std::move(key), std::move(ev)).second); } -void TQueueLeader::HandleDeleteMessageBatchWhileWorking(TSqsEvents::TEvDeleteMessageBatch::TPtr& ev) { +void TQueueLeader::HandleDeleteMessageBatchWhileWorking(TSqsEvents::TEvDeleteMessageBatch::TPtr& ev) { auto key = std::make_pair(ev->Get()->RequestId, ev->Get()->Shard); auto [reqIter, inserted] = DeleteMessageRequests_.emplace(std::move(key), std::move(ev)); Y_VERIFY(inserted); ProcessDeleteMessageBatch(reqIter->second); } -void TQueueLeader::ProcessDeleteMessageBatch(TDeleteMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::ProcessDeleteMessageBatch(TDeleteMessageBatchRequestProcessing& reqInfo) { auto& req = reqInfo.Event; if (!IncActiveMessageRequests(req->Get()->Shard, req->Get()->RequestId)) { return; @@ -989,7 +989,7 @@ void TQueueLeader::ProcessDeleteMessageBatch(TDeleteMessageBatchRequestProcessin shardInfo.DeleteBatchingState.TryExecute(this); } -void TQueueLeader::OnMessageDeleted(const TString& requestId, ui64 shard, size_t index, const TSqsEvents::TEvExecuted::TRecord& reply, const NKikimr::NClient::TValue* messageRecord) { +void TQueueLeader::OnMessageDeleted(const TString& requestId, ui64 shard, size_t index, const TSqsEvents::TEvExecuted::TRecord& reply, const NKikimr::NClient::TValue* messageRecord) { auto key = std::make_pair(requestId, shard); auto reqIt = DeleteMessageRequests_.find(key); Y_VERIFY(reqIt != DeleteMessageRequests_.end()); @@ -1046,7 +1046,7 @@ void TQueueLeader::OnMessageDeleted(const TString& requestId, ui64 shard, size_t } } -void TQueueLeader::OnDeleteBatchExecuted(ui64 shard, ui64 batchId, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnDeleteBatchExecuted(ui64 shard, ui64 batchId, const TSqsEvents::TEvExecuted::TRecord& reply) { auto& shardInfo = Shards_[shard]; auto& batchingState = shardInfo.DeleteBatchingState; auto batchIt = batchingState.BatchesExecuting.find(batchId); @@ -1094,19 +1094,19 @@ void TQueueLeader::OnDeleteBatchExecuted(ui64 shard, ui64 batchId, const TSqsEve batchingState.TryExecute(this); } -void TQueueLeader::HandleChangeMessageVisibilityBatchWhileIniting(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr& ev) { +void TQueueLeader::HandleChangeMessageVisibilityBatchWhileIniting(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr& ev) { auto key = std::make_pair(ev->Get()->RequestId, ev->Get()->Shard); Y_VERIFY(ChangeMessageVisibilityRequests_.emplace(std::move(key), std::move(ev)).second); } -void TQueueLeader::HandleChangeMessageVisibilityBatchWhileWorking(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr& ev) { +void TQueueLeader::HandleChangeMessageVisibilityBatchWhileWorking(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr& ev) { auto key = std::make_pair(ev->Get()->RequestId, ev->Get()->Shard); auto [reqIter, inserted] = ChangeMessageVisibilityRequests_.emplace(std::move(key), std::move(ev)); Y_VERIFY(inserted); ProcessChangeMessageVisibilityBatch(reqIter->second); } -void TQueueLeader::ProcessChangeMessageVisibilityBatch(TChangeMessageVisibilityBatchRequestProcessing& reqInfo) { +void TQueueLeader::ProcessChangeMessageVisibilityBatch(TChangeMessageVisibilityBatchRequestProcessing& reqInfo) { auto& req = *reqInfo.Event->Get(); if (!IncActiveMessageRequests(req.Shard, req.RequestId)) { return; @@ -1118,7 +1118,7 @@ void TQueueLeader::ProcessChangeMessageVisibilityBatch(TChangeMessageVisibilityB .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) .Shard(req.Shard) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(CHANGE_VISIBILITY_ID) .Counters(Counters_) .RetryOnTimeout() @@ -1151,7 +1151,7 @@ void TQueueLeader::ProcessChangeMessageVisibilityBatch(TChangeMessageVisibilityB builder.Start(); } -void TQueueLeader::OnVisibilityChanged(const TString& requestId, ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnVisibilityChanged(const TString& requestId, ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { auto key = std::make_pair(requestId, shard); auto reqIt = ChangeMessageVisibilityRequests_.find(key); Y_VERIFY(reqIt != ChangeMessageVisibilityRequests_.end()); @@ -1210,7 +1210,7 @@ void TQueueLeader::OnVisibilityChanged(const TString& requestId, ui64 shard, con DecActiveMessageRequests(shard); } -void TQueueLeader::AnswerGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& req) { +void TQueueLeader::AnswerGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& req) { auto resp = MakeHolder<TSqsEvents::TEvConfiguration>(); resp->RootUrl = RootUrl_; @@ -1222,7 +1222,7 @@ void TQueueLeader::AnswerGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& resp->QueueExists = true; resp->Fifo = IsFifoQueue_; resp->SchemeCache = SchemeCache_; - resp->QueueLeader = SelfId(); + resp->QueueLeader = SelfId(); resp->QuoterResources = QuoterResources_; if (req->Get()->NeedQueueAttributes) { @@ -1233,7 +1233,7 @@ void TQueueLeader::AnswerGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& Send(req->Sender, std::move(resp)); } -void TQueueLeader::AnswerFailed(TSqsEvents::TEvGetConfiguration::TPtr& ev) { +void TQueueLeader::AnswerFailed(TSqsEvents::TEvGetConfiguration::TPtr& ev) { auto answer = MakeHolder<TSqsEvents::TEvConfiguration>(); answer->RootUrl = RootUrl_; answer->SqsCoreCounters = Counters_->RootCounters.SqsCounters; @@ -1245,7 +1245,7 @@ void TQueueLeader::AnswerFailed(TSqsEvents::TEvGetConfiguration::TPtr& ev) { Send(ev->Sender, answer.Release()); } -void TQueueLeader::RequestConfiguration() { +void TQueueLeader::RequestConfiguration() { TExecutorBuilder(SelfId(), "") .User(UserName_) .Queue(QueueName_) @@ -1259,7 +1259,7 @@ void TQueueLeader::RequestConfiguration() { .ParentBuilder().StartExecutorActor(); } -void TQueueLeader::OnQueueConfiguration(const TSqsEvents::TEvExecuted::TRecord& ev) { +void TQueueLeader::OnQueueConfiguration(const TSqsEvents::TEvExecuted::TRecord& ev) { if (ev.GetStatus() == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete) { using NKikimr::NClient::TValue; const TValue val(TValue::Create(ev.GetExecutionEngineEvaluatedResponse())); @@ -1315,7 +1315,7 @@ void TQueueLeader::OnQueueConfiguration(const TSqsEvents::TEvExecuted::TRecord& BecomeWorking(); } else { INC_COUNTER(Counters_, QueueMasterStartProblems); - INC_COUNTER(Counters_, QueueLeaderStartProblems); + INC_COUNTER(Counters_, QueueLeaderStartProblems); for (auto& req : GetConfigurationRequests_) { RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Queue [" << req->Get()->QueueName << "] was not found in Queues table for user [" << req->Get()->UserName << "]"); @@ -1337,30 +1337,30 @@ void TQueueLeader::OnQueueConfiguration(const TSqsEvents::TEvExecuted::TRecord& } } else { INC_COUNTER(Counters_, QueueMasterStartProblems); - INC_COUNTER(Counters_, QueueLeaderStartProblems); + INC_COUNTER(Counters_, QueueLeaderStartProblems); FailRequestsDuringStartProblems(); ScheduleGetConfigurationRetry(); } } -void TQueueLeader::FailRequestsDuringStartProblems() { +void TQueueLeader::FailRequestsDuringStartProblems() { for (auto& req : GetConfigurationRequests_) { AnswerFailed(req); } GetConfigurationRequests_.clear(); } -void TQueueLeader::ScheduleGetConfigurationRetry() { +void TQueueLeader::ScheduleGetConfigurationRetry() { Schedule(TDuration::MilliSeconds(100 + RandomNumber<ui32>(300)), new TEvWakeup(REQUEST_CONFIGURATION_TAG)); } -void TQueueLeader::AskQueueAttributes() { +void TQueueLeader::AskQueueAttributes() { const TString reqId = CreateGuidAsString(); LOG_SQS_DEBUG("Executing queue " << TLogQueueName(UserName_, QueueName_) << " attributes cache request. Req id: " << reqId); TExecutorBuilder(SelfId(), reqId) .User(UserName_) .Queue(QueueName_) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(INTERNAL_GET_QUEUE_ATTRIBUTES_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1370,7 +1370,7 @@ void TQueueLeader::AskQueueAttributes() { .Start(); } -void TQueueLeader::OnQueueAttributes(const TSqsEvents::TEvExecuted::TRecord& ev) { +void TQueueLeader::OnQueueAttributes(const TSqsEvents::TEvExecuted::TRecord& ev) { const ui32 status = ev.GetStatus(); if (status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete) { using NKikimr::NClient::TValue; @@ -1422,7 +1422,7 @@ void TQueueLeader::OnQueueAttributes(const TSqsEvents::TEvExecuted::TRecord& ev) } } -void TQueueLeader::HandleQueueId(TSqsEvents::TEvQueueId::TPtr& ev) { +void TQueueLeader::HandleQueueId(TSqsEvents::TEvQueueId::TPtr& ev) { if (!DlqInfo_) { return; } @@ -1443,16 +1443,16 @@ void TQueueLeader::HandleQueueId(TSqsEvents::TEvQueueId::TPtr& ev) { DlqInfo_.Clear(); // something is off } -void TQueueLeader::HandleExecuted(TSqsEvents::TEvExecuted::TPtr& ev) { +void TQueueLeader::HandleExecuted(TSqsEvents::TEvExecuted::TPtr& ev) { ev->Get()->Call(); } -void TQueueLeader::HandlePurgeQueue(TSqsEvents::TEvPurgeQueue::TPtr& ev) { +void TQueueLeader::HandlePurgeQueue(TSqsEvents::TEvPurgeQueue::TPtr& ev) { CreateBackgroundActors(); Send(PurgeActor_, MakeHolder<TSqsEvents::TEvPurgeQueue>(*ev->Get())); } -void TQueueLeader::StartGatheringMetrics() { +void TQueueLeader::StartGatheringMetrics() { if (!IsFifoQueue_ && (TActivationContext::Now() - LatestDlqNotificationTs_ >= TDuration::MilliSeconds(Cfg().GetDlqNotificationGracePeriodMs()))) { if (IsDlqQueue_) { LOG_SQS_INFO("Stopped periodic message counting for queue " << TLogQueueName(UserName_, QueueName_) @@ -1470,7 +1470,7 @@ void TQueueLeader::StartGatheringMetrics() { } } -void TQueueLeader::RequestMessagesCountMetrics(ui64 shard) { +void TQueueLeader::RequestMessagesCountMetrics(ui64 shard) { if (Shards_[shard].MessagesCountIsRequesting) { LOG_SQS_DEBUG("Messages count for " << TLogQueueName(UserName_, QueueName_, shard) << " is already requesting"); return; @@ -1478,7 +1478,7 @@ void TQueueLeader::RequestMessagesCountMetrics(ui64 shard) { TExecutorBuilder(SelfId(), "") .User(UserName_) .Queue(QueueName_) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(GET_MESSAGE_COUNT_METRIC_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1493,7 +1493,7 @@ void TQueueLeader::RequestMessagesCountMetrics(ui64 shard) { Shards_[shard].MessagesCountIsRequesting = true; } -void TQueueLeader::RequestOldestTimestampMetrics(ui64 shard) { +void TQueueLeader::RequestOldestTimestampMetrics(ui64 shard) { if (Shards_[shard].OldestMessageAgeIsRequesting) { LOG_SQS_DEBUG("Oldest message timestamp " << TLogQueueName(UserName_, QueueName_, shard) << " is already requesting"); return; @@ -1502,7 +1502,7 @@ void TQueueLeader::RequestOldestTimestampMetrics(ui64 shard) { .User(UserName_) .Queue(QueueName_) .Shard(shard) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(GET_OLDEST_MESSAGE_TIMESTAMP_METRIC_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1517,7 +1517,7 @@ void TQueueLeader::RequestOldestTimestampMetrics(ui64 shard) { Shards_[shard].OldestMessageAgeIsRequesting = true; } -void TQueueLeader::ReceiveMessagesCountMetrics(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::ReceiveMessagesCountMetrics(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { LOG_SQS_DEBUG("Handle message count metrics for " << TLogQueueName(UserName_, QueueName_, shard)); Y_VERIFY(MetricsQueriesInfly_ > 0); --MetricsQueriesInfly_; @@ -1552,7 +1552,7 @@ void TQueueLeader::ReceiveMessagesCountMetrics(ui64 shard, const TSqsEvents::TEv ReportMessagesCountMetricsIfReady(); } -void TQueueLeader::ReceiveOldestTimestampMetrics(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::ReceiveOldestTimestampMetrics(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { LOG_SQS_DEBUG("Handle oldest timestamp metrics for " << TLogQueueName(UserName_, QueueName_, shard)); Y_VERIFY(MetricsQueriesInfly_ > 0); --MetricsQueriesInfly_; @@ -1577,13 +1577,13 @@ void TQueueLeader::ReceiveOldestTimestampMetrics(ui64 shard, const TSqsEvents::T ReportOldestTimestampMetricsIfReady(); } -void TQueueLeader::ScheduleMetricsRequest() { +void TQueueLeader::ScheduleMetricsRequest() { const ui64 updateTime = Cfg().GetBackgroundMetricsUpdateTimeMs(); const ui64 randomTimeToWait = RandomNumber<ui32>(updateTime / 4); Schedule(TDuration::MilliSeconds(updateTime + randomTimeToWait), new TEvWakeup(UPDATE_COUNTERS_TAG)); } -void TQueueLeader::ReportMessagesCountMetricsIfReady() { +void TQueueLeader::ReportMessagesCountMetricsIfReady() { ui64 messagesCount = 0; ui64 inflyMessagesCount = 0; const TInstant now = TActivationContext::Now(); @@ -1609,7 +1609,7 @@ void TQueueLeader::ReportMessagesCountMetricsIfReady() { } } -void TQueueLeader::ReportOldestTimestampMetricsIfReady() { +void TQueueLeader::ReportOldestTimestampMetricsIfReady() { ui64 oldestMessagesTimestamp = Max(); for (const auto& shardInfo : Shards_) { if (shardInfo.OldestMessageAgeIsRequesting) { @@ -1627,7 +1627,7 @@ void TQueueLeader::ReportOldestTimestampMetricsIfReady() { } } -void TQueueLeader::CreateBackgroundActors() { +void TQueueLeader::CreateBackgroundActors() { if ((!IsFifoQueue_ || DeduplicationCleanupActor_) && (!IsFifoQueue_ || ReadsCleanupActor_) && RetentionActor_ && PurgeActor_) { return; } @@ -1652,7 +1652,7 @@ void TQueueLeader::CreateBackgroundActors() { } } -void TQueueLeader::MarkInflyReloading(ui64 shard, size_t invalidatedCount, const TString& invalidationReason) { +void TQueueLeader::MarkInflyReloading(ui64 shard, size_t invalidatedCount, const TString& invalidationReason) { LWPROBE(InflyInvalidation, UserName_, QueueName_, shard, invalidatedCount, invalidationReason); auto& shardInfo = Shards_[shard]; if (!shardInfo.NeedInflyReload) { @@ -1661,13 +1661,13 @@ void TQueueLeader::MarkInflyReloading(ui64 shard, size_t invalidatedCount, const } } -void TQueueLeader::StartLoadingInfly() { +void TQueueLeader::StartLoadingInfly() { for (ui64 shard = 0; shard < Shards_.size(); ++shard) { StartLoadingInfly(shard); } } -void TQueueLeader::StartLoadingInfly(ui64 shard, bool afterFailure) { +void TQueueLeader::StartLoadingInfly(ui64 shard, bool afterFailure) { auto& shardInfo = Shards_[shard]; if (shardInfo.InflyLoadState == TShardInfo::EInflyLoadState::Fifo || shardInfo.InflyLoadState == TShardInfo::EInflyLoadState::WaitingForActiveRequests && shardInfo.ActiveMessageRequests > 0 @@ -1696,7 +1696,7 @@ void TQueueLeader::StartLoadingInfly(ui64 shard, bool afterFailure) { .User(UserName_) .Queue(QueueName_) .Shard(shard) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(LOAD_INFLY_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1711,7 +1711,7 @@ void TQueueLeader::StartLoadingInfly(ui64 shard, bool afterFailure) { .User(UserName_) .Queue(QueueName_) .Shard(shard) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(GET_STATE_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1723,7 +1723,7 @@ void TQueueLeader::StartLoadingInfly(ui64 shard, bool afterFailure) { .ParentBuilder().Start(); } -void TQueueLeader::OnInflyLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnInflyLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { LOG_SQS_TRACE("Infly load reply for shard " << TLogQueueName(UserName_, QueueName_, shard) << ": " << reply); auto& shardInfo = Shards_[shard]; Y_VERIFY(shardInfo.LoadInflyRequests > 0); @@ -1785,7 +1785,7 @@ void TQueueLeader::OnInflyLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRec } } -void TQueueLeader::OnStateLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnStateLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { auto& shardInfo = Shards_[shard]; Y_VERIFY(shardInfo.LoadInflyRequests > 0); --shardInfo.LoadInflyRequests; @@ -1823,7 +1823,7 @@ void TQueueLeader::OnStateLoaded(ui64 shard, const TSqsEvents::TEvExecuted::TRec } } -bool TQueueLeader::AddMessagesToInfly(ui64 shard) { +bool TQueueLeader::AddMessagesToInfly(ui64 shard) { auto& shardInfo = Shards_[shard]; LOG_SQS_INFO("Adding messages to infly for queue " << TLogQueueName(UserName_, QueueName_, shard)); shardInfo.AddingMessagesToInfly = true; @@ -1833,7 +1833,7 @@ bool TQueueLeader::AddMessagesToInfly(ui64 shard) { .User(UserName_) .Queue(QueueName_) .Shard(shard) - .QueueLeader(SelfId()) + .QueueLeader(SelfId()) .QueryId(ADD_MESSAGES_TO_INFLY_ID) .QueueVersion(QueueVersion_) .Fifo(IsFifoQueue_) @@ -1848,7 +1848,7 @@ bool TQueueLeader::AddMessagesToInfly(ui64 shard) { return true; } -void TQueueLeader::OnAddedMessagesToInfly(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { +void TQueueLeader::OnAddedMessagesToInfly(ui64 shard, const TSqsEvents::TEvExecuted::TRecord& reply) { auto& shardInfo = Shards_[shard]; Y_VERIFY(shardInfo.AddingMessagesToInfly); shardInfo.AddingMessagesToInfly = false; @@ -1896,7 +1896,7 @@ void TQueueLeader::OnAddedMessagesToInfly(ui64 shard, const TSqsEvents::TEvExecu } } -void TQueueLeader::ProcessReceivesAfterAddedMessagesToInfly(ui64 shard) { +void TQueueLeader::ProcessReceivesAfterAddedMessagesToInfly(ui64 shard) { std::vector<TReceiveMessageBatchRequestProcessing*> requestsToContinue; requestsToContinue.reserve(ReceiveMessageRequests_.size()); for (auto&& [reqId, req] : ReceiveMessageRequests_) { @@ -1910,7 +1910,7 @@ void TQueueLeader::ProcessReceivesAfterAddedMessagesToInfly(ui64 shard) { } } -void TQueueLeader::FailMessageRequestsAfterInflyLoadFailure(ui64 shard) { +void TQueueLeader::FailMessageRequestsAfterInflyLoadFailure(ui64 shard) { std::vector<TString> requestsToDelete; requestsToDelete.reserve(Max(ReceiveMessageRequests_.size(), SendMessageRequests_.size())); for (auto&& [reqId, req] : ReceiveMessageRequests_) { @@ -1991,7 +1991,7 @@ void TQueueLeader::FailMessageRequestsAfterInflyLoadFailure(ui64 shard) { } } -void TQueueLeader::StartMessageRequestsAfterInflyLoaded(ui64 shard) { +void TQueueLeader::StartMessageRequestsAfterInflyLoaded(ui64 shard) { { std::vector<TReceiveMessageBatchRequestProcessing*> receiveRequests; receiveRequests.reserve(ReceiveMessageRequests_.size()); @@ -2045,7 +2045,7 @@ void TQueueLeader::StartMessageRequestsAfterInflyLoaded(ui64 shard) { } } -bool TQueueLeader::IncActiveMessageRequests(ui64 shard, const TString& requestId) { +bool TQueueLeader::IncActiveMessageRequests(ui64 shard, const TString& requestId) { if (!IsFifoQueue_) { auto& shardInfo = Shards_[shard]; if (shardInfo.InflyLoadState != TShardInfo::EInflyLoadState::Loaded) { @@ -2058,7 +2058,7 @@ bool TQueueLeader::IncActiveMessageRequests(ui64 shard, const TString& requestId return true; } -void TQueueLeader::DecActiveMessageRequests(ui64 shard) { +void TQueueLeader::DecActiveMessageRequests(ui64 shard) { if (!IsFifoQueue_) { auto& shardInfo = Shards_[shard]; Y_VERIFY(shardInfo.ActiveMessageRequests > 0); @@ -2070,13 +2070,13 @@ void TQueueLeader::DecActiveMessageRequests(ui64 shard) { } } -void TQueueLeader::ScheduleInflyLoadAfterFailure(ui64 shard) { +void TQueueLeader::ScheduleInflyLoadAfterFailure(ui64 shard) { const ui32 randomMs = 100 + RandomNumber<ui32>(300); LOG_SQS_INFO("Scheduling retry after infly " << TLogQueueName(UserName_, QueueName_, shard) << " load failure in " << randomMs << "ms"); Schedule(TDuration::MilliSeconds(randomMs), new TEvWakeup(RELOAD_INFLY_TAG + shard)); } -void TQueueLeader::HandleInflyIsPurgingNotification(TSqsEvents::TEvInflyIsPurgingNotification::TPtr& ev) { +void TQueueLeader::HandleInflyIsPurgingNotification(TSqsEvents::TEvInflyIsPurgingNotification::TPtr& ev) { LOG_SQS_TRACE("Handle infly purged notification for " << TLogQueueName(UserName_, QueueName_, ev->Get()->Shard) << ". Messages: " << ev->Get()->Offsets.size()); if (!IsFifoQueue_) { auto& shardInfo = Shards_[ev->Get()->Shard]; @@ -2100,23 +2100,23 @@ void TQueueLeader::HandleInflyIsPurgingNotification(TSqsEvents::TEvInflyIsPurgin } } -void TQueueLeader::HandleQueuePurgedNotification(TSqsEvents::TEvQueuePurgedNotification::TPtr& ev) { +void TQueueLeader::HandleQueuePurgedNotification(TSqsEvents::TEvQueuePurgedNotification::TPtr& ev) { auto& shardInfo = Shards_[ev->Get()->Shard]; shardInfo.MessagesCount = ev->Get()->NewMessagesCount; } -void TQueueLeader::HandleGetRuntimeQueueAttributesWhileIniting(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr& ev) { +void TQueueLeader::HandleGetRuntimeQueueAttributesWhileIniting(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr& ev) { auto&& [reqInfoIt, inserted] = GetRuntimeQueueAttributesRequests_.emplace(ev->Get()->RequestId, std::move(ev)); Y_VERIFY(inserted); } -void TQueueLeader::HandleGetRuntimeQueueAttributesWhileWorking(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr& ev) { +void TQueueLeader::HandleGetRuntimeQueueAttributesWhileWorking(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr& ev) { auto&& [reqInfoIt, inserted] = GetRuntimeQueueAttributesRequests_.emplace(ev->Get()->RequestId, std::move(ev)); Y_VERIFY(inserted); ProcessGetRuntimeQueueAttributes(reqInfoIt->second); } -void TQueueLeader::HandleDeadLetterQueueNotification(TSqsEvents::TEvDeadLetterQueueNotification::TPtr&) { +void TQueueLeader::HandleDeadLetterQueueNotification(TSqsEvents::TEvDeadLetterQueueNotification::TPtr&) { LatestDlqNotificationTs_ = TActivationContext::Now(); if (!IsFifoQueue_ && !IsDlqQueue_) { @@ -2129,7 +2129,7 @@ void TQueueLeader::HandleDeadLetterQueueNotification(TSqsEvents::TEvDeadLetterQu } } -void TQueueLeader::ProcessGetRuntimeQueueAttributes(TGetRuntimeQueueAttributesRequestProcessing& reqInfo) { +void TQueueLeader::ProcessGetRuntimeQueueAttributes(TGetRuntimeQueueAttributesRequestProcessing& reqInfo) { if (reqInfo.ShardProcessFlags.empty()) { Y_VERIFY(ShardsCount_ > 0); reqInfo.ShardProcessFlags.resize(ShardsCount_); @@ -2140,7 +2140,7 @@ void TQueueLeader::ProcessGetRuntimeQueueAttributes(TGetRuntimeQueueAttributesRe } } -void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard, TGetRuntimeQueueAttributesRequestProcessing& reqInfo) { +void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard, TGetRuntimeQueueAttributesRequestProcessing& reqInfo) { Y_VERIFY(shard < reqInfo.ShardProcessFlags.size()); if (reqInfo.ShardProcessFlags[shard]) { return; @@ -2175,7 +2175,7 @@ void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard, TGetRuntimeQueue } } -void TQueueLeader::FailGetRuntimeQueueAttributesForShard(ui64 shard) { +void TQueueLeader::FailGetRuntimeQueueAttributesForShard(ui64 shard) { std::vector<TString> reqIds; reqIds.reserve(GetRuntimeQueueAttributesRequests_.size()); for (auto& [reqId, reqInfo] : GetRuntimeQueueAttributesRequests_) { @@ -2193,7 +2193,7 @@ void TQueueLeader::FailGetRuntimeQueueAttributesForShard(ui64 shard) { } } -void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard) { +void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard) { std::vector<TGetRuntimeQueueAttributesRequestProcessing*> requestsToProcess; requestsToProcess.reserve(GetRuntimeQueueAttributesRequests_.size()); for (auto& [reqId, reqInfo] : GetRuntimeQueueAttributesRequests_) { @@ -2204,7 +2204,7 @@ void TQueueLeader::ProcessGetRuntimeQueueAttributes(ui64 shard) { } } -void TQueueLeader::InitQuoterResources() { +void TQueueLeader::InitQuoterResources() { const auto& cfg = Cfg().GetQuotingConfig(); if (cfg.GetEnableQuoting()) { Y_VERIFY(cfg.HasLocalRateLimiterConfig() != cfg.HasKesusQuoterConfig()); // exactly one must be set @@ -2240,29 +2240,29 @@ void TQueueLeader::InitQuoterResources() { } } -TQueueLeader::TShardInfo::~TShardInfo() = default; +TQueueLeader::TShardInfo::~TShardInfo() = default; -TQueueLeader::TSendMessageBatchRequestProcessing::TSendMessageBatchRequestProcessing(TSqsEvents::TEvSendMessageBatch::TPtr&& ev) +TQueueLeader::TSendMessageBatchRequestProcessing::TSendMessageBatchRequestProcessing(TSqsEvents::TEvSendMessageBatch::TPtr&& ev) : Event(std::move(ev)) { Statuses.resize(Event->Get()->Messages.size()); } -void TQueueLeader::TSendMessageBatchRequestProcessing::Init(ui64 shardsCount) { +void TQueueLeader::TSendMessageBatchRequestProcessing::Init(ui64 shardsCount) { if (!Inited) { Shard = RandomNumber<ui64>() % shardsCount; Inited = true; } } -TQueueLeader::TReceiveMessageBatchRequestProcessing::TReceiveMessageBatchRequestProcessing(TSqsEvents::TEvReceiveMessageBatch::TPtr&& ev) +TQueueLeader::TReceiveMessageBatchRequestProcessing::TReceiveMessageBatchRequestProcessing(TSqsEvents::TEvReceiveMessageBatch::TPtr&& ev) : Event(std::move(ev)) , Answer(MakeHolder<TSqsEvents::TEvReceiveMessageBatchResponse>()) { Answer->Messages.reserve(Event->Get()->MaxMessagesCount); } -void TQueueLeader::TReceiveMessageBatchRequestProcessing::Init(ui64 shardsCount) { +void TQueueLeader::TReceiveMessageBatchRequestProcessing::Init(ui64 shardsCount) { if (!Inited) { Shards.resize(shardsCount); for (ui64 i = 0; i < shardsCount; ++i) { @@ -2275,7 +2275,7 @@ void TQueueLeader::TReceiveMessageBatchRequestProcessing::Init(ui64 shardsCount) } } -TQueueLeader::TDeleteMessageBatchRequestProcessing::TDeleteMessageBatchRequestProcessing(TSqsEvents::TEvDeleteMessageBatch::TPtr&& ev) +TQueueLeader::TDeleteMessageBatchRequestProcessing::TDeleteMessageBatchRequestProcessing(TSqsEvents::TEvDeleteMessageBatch::TPtr&& ev) : Event(std::move(ev)) , Answer(MakeHolder<TSqsEvents::TEvDeleteMessageBatchResponse>()) { @@ -2284,7 +2284,7 @@ TQueueLeader::TDeleteMessageBatchRequestProcessing::TDeleteMessageBatchRequestPr InflyMessages.reserve(Event->Get()->Messages.size()); } -TQueueLeader::TChangeMessageVisibilityBatchRequestProcessing::TChangeMessageVisibilityBatchRequestProcessing(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr&& ev) +TQueueLeader::TChangeMessageVisibilityBatchRequestProcessing::TChangeMessageVisibilityBatchRequestProcessing(TSqsEvents::TEvChangeMessageVisibilityBatch::TPtr&& ev) : Event(std::move(ev)) , Answer(MakeHolder<TSqsEvents::TEvChangeMessageVisibilityBatchResponse>()) { @@ -2292,7 +2292,7 @@ TQueueLeader::TChangeMessageVisibilityBatchRequestProcessing::TChangeMessageVisi Answer->Shard = Event->Get()->Shard; } -TQueueLeader::TGetRuntimeQueueAttributesRequestProcessing::TGetRuntimeQueueAttributesRequestProcessing(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr&& ev) +TQueueLeader::TGetRuntimeQueueAttributesRequestProcessing::TGetRuntimeQueueAttributesRequestProcessing(TSqsEvents::TEvGetRuntimeQueueAttributes::TPtr&& ev) : Event(std::move(ev)) , Answer(MakeHolder<TSqsEvents::TEvGetRuntimeQueueAttributesResponse>()) { @@ -2300,17 +2300,17 @@ TQueueLeader::TGetRuntimeQueueAttributesRequestProcessing::TGetRuntimeQueueAttri } template <class TBatch> -TQueueLeader::TBatchingState<TBatch>::~TBatchingState() = default; +TQueueLeader::TBatchingState<TBatch>::~TBatchingState() = default; template <class TBatch> -void TQueueLeader::TBatchingState<TBatch>::Init(const NKikimrConfig::TSqsConfig::TBatchingPolicy& policy, ui64 shard, bool isFifo) { +void TQueueLeader::TBatchingState<TBatch>::Init(const NKikimrConfig::TSqsConfig::TBatchingPolicy& policy, ui64 shard, bool isFifo) { Policy = policy; Shard = shard; IsFifoQueue = isFifo; } template <class TBatch> -void TQueueLeader::TBatchingState<TBatch>::TryExecute(TQueueLeader* leader) { +void TQueueLeader::TBatchingState<TBatch>::TryExecute(TQueueLeader* leader) { while (BatchesExecuting.size() < Policy.GetTransactionsMaxInflyPerShard() && !BatchesIniting.empty()) { auto& batchPtr = BatchesIniting.front(); if (!BatchesExecuting.empty() && !CanExecute(*batchPtr)) { @@ -2318,13 +2318,13 @@ void TQueueLeader::TBatchingState<TBatch>::TryExecute(TQueueLeader* leader) { } BatchesExecuting[batchPtr->BatchId] = batchPtr; - batchPtr->Execute(leader); + batchPtr->Execute(leader); BatchesIniting.pop_front(); } } template <class TBatch> -TBatch& TQueueLeader::TBatchingState<TBatch>::NewBatch() { +TBatch& TQueueLeader::TBatchingState<TBatch>::NewBatch() { auto newBatch = MakeIntrusive<TBatch>(Shard, Policy.GetBatchSize(), IsFifoQueue); newBatch->BatchId = NextBatchId++; BatchesIniting.push_back(newBatch); @@ -2332,14 +2332,14 @@ TBatch& TQueueLeader::TBatchingState<TBatch>::NewBatch() { } template <class TBatch> -void TQueueLeader::TBatchingState<TBatch>::CancelRequestsAfterInflyLoadFailure() { +void TQueueLeader::TBatchingState<TBatch>::CancelRequestsAfterInflyLoadFailure() { Y_VERIFY(BatchesExecuting.empty()); BatchesIniting.clear(); } template <class TBatch> template <class TRequestProcessing> -void TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::AddRequest(TRequestProcessing& reqInfo) { +void TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::AddRequest(TRequestProcessing& reqInfo) { const auto& msgs = reqInfo.Event->Get()->Messages; if (this->IsFifoQueue) { for (size_t i = 0; i < msgs.size(); ++i) { @@ -2372,7 +2372,7 @@ void TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::AddRequest(TReq } template <class TBatch> -bool TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::CanExecute(const TBatch& batch) const { +bool TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::CanExecute(const TBatch& batch) const { using TBatchingState = TBatchingState<TBatch>; if (this->IsFifoQueue) { // find whether groups from batch are already executing @@ -2395,7 +2395,7 @@ bool TQueueLeader::TBatchingStateWithGroupsRestrictions<TBatch>::CanExecute(cons } } -void TQueueLeader::TSendBatch::AddEntry(TSendMessageBatchRequestProcessing& reqInfo, size_t i) { +void TQueueLeader::TSendBatch::AddEntry(TSendMessageBatchRequestProcessing& reqInfo, size_t i) { RLOG_SQS_REQ_DEBUG(reqInfo.Event->Get()->RequestId, "Add message[" << i << "] to send batch. BatchId: " << BatchId); Entries.emplace_back(reqInfo.Event->Get()->RequestId, reqInfo.Event->Get()->SenderId, reqInfo.Event->Get()->Messages[i], i); if (IsFifoQueue) { @@ -2403,21 +2403,21 @@ void TQueueLeader::TSendBatch::AddEntry(TSendMessageBatchRequestProcessing& reqI } } -void TQueueLeader::TSendBatch::Execute(TQueueLeader* leader) { - RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing send batch. BatchId: " << BatchId << ". Size: " << Size()); +void TQueueLeader::TSendBatch::Execute(TQueueLeader* leader) { + RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing send batch. BatchId: " << BatchId << ". Size: " << Size()); TransactionStartedTime = TActivationContext::Now(); TExecutorBuilder builder(SelfId(), RequestId_); builder - .User(leader->UserName_) - .Queue(leader->QueueName_) + .User(leader->UserName_) + .Queue(leader->QueueName_) .Shard(Shard) - .QueueVersion(leader->QueueVersion_) - .QueueLeader(SelfId()) + .QueueVersion(leader->QueueVersion_) + .QueueLeader(SelfId()) .QueryId(WRITE_MESSAGE_ID) .Fifo(IsFifoQueue) - .Counters(leader->Counters_) + .Counters(leader->Counters_) .RetryOnTimeout(IsFifoQueue) // Fifo queues have deduplication, so we can retry even on unknown transaction state - .OnExecuted([leader, shard = Shard, batchId = BatchId](const TSqsEvents::TEvExecuted::TRecord& ev) { leader->OnSendBatchExecuted(shard, batchId, ev); }) + .OnExecuted([leader, shard = Shard, batchId = BatchId](const TSqsEvents::TEvExecuted::TRecord& ev) { leader->OnSendBatchExecuted(shard, batchId, ev); }) .Params() .Uint64("RANDOM_ID", RandomNumber<ui64>()) .Uint64("TIMESTAMP", TransactionStartedTime.MilliSeconds()) @@ -2449,7 +2449,7 @@ void TQueueLeader::TSendBatch::Execute(TQueueLeader* leader) { builder.Start(); } -void TQueueLeader::TDeleteBatch::AddEntry(TDeleteMessageBatchRequestProcessing& reqInfo, size_t i) { +void TQueueLeader::TDeleteBatch::AddEntry(TDeleteMessageBatchRequestProcessing& reqInfo, size_t i) { RLOG_SQS_REQ_DEBUG(reqInfo.Event->Get()->RequestId, "Add message[" << i << "] to delete batch. BatchId: " << BatchId); Entries.emplace_back(reqInfo.Event->Get()->RequestId, reqInfo.Event->Get()->Messages[i], i); if (IsFifoQueue) { @@ -2457,20 +2457,20 @@ void TQueueLeader::TDeleteBatch::AddEntry(TDeleteMessageBatchRequestProcessing& } } -void TQueueLeader::TDeleteBatch::Execute(TQueueLeader* leader) { - RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing delete batch. BatchId: " << BatchId << ". Size: " << Size()); +void TQueueLeader::TDeleteBatch::Execute(TQueueLeader* leader) { + RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing delete batch. BatchId: " << BatchId << ". Size: " << Size()); TExecutorBuilder builder(SelfId(), RequestId_); builder - .User(leader->UserName_) - .Queue(leader->QueueName_) + .User(leader->UserName_) + .Queue(leader->QueueName_) .Shard(Shard) - .QueueVersion(leader->QueueVersion_) - .QueueLeader(SelfId()) + .QueueVersion(leader->QueueVersion_) + .QueueLeader(SelfId()) .Fifo(IsFifoQueue) .QueryId(DELETE_MESSAGE_ID) - .Counters(leader->Counters_) + .Counters(leader->Counters_) .RetryOnTimeout() - .OnExecuted([leader, shard = Shard, batchId = BatchId](const TSqsEvents::TEvExecuted::TRecord& ev) { leader->OnDeleteBatchExecuted(shard, batchId, ev); }) + .OnExecuted([leader, shard = Shard, batchId = BatchId](const TSqsEvents::TEvExecuted::TRecord& ev) { leader->OnDeleteBatchExecuted(shard, batchId, ev); }) .Params() .Uint64("NOW", TActivationContext::Now().MilliSeconds()) .Uint64("SHARD", Shard) @@ -2503,7 +2503,7 @@ void TQueueLeader::TDeleteBatch::Execute(TQueueLeader* leader) { builder.Start(); } -void TQueueLeader::TLoadBatchingState::AddRequest(TReceiveMessageBatchRequestProcessing& reqInfo) { +void TQueueLeader::TLoadBatchingState::AddRequest(TReceiveMessageBatchRequestProcessing& reqInfo) { auto msg = reqInfo.ReceiveCandidates.Begin(); const auto end = reqInfo.ReceiveCandidates.End(); while (msg != end) { @@ -2519,19 +2519,19 @@ void TQueueLeader::TLoadBatchingState::AddRequest(TReceiveMessageBatchRequestPro } } -void TQueueLeader::TLoadBatch::Execute(TQueueLeader* leader) { - RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing load batch. BatchId: " << BatchId << ". Size: " << Size()); +void TQueueLeader::TLoadBatch::Execute(TQueueLeader* leader) { + RLOG_SQS_DEBUG(TLogQueueName(leader->UserName_, leader->QueueName_, Shard) << " Executing load batch. BatchId: " << BatchId << ". Size: " << Size()); TExecutorBuilder builder(SelfId(), RequestId_); const auto now = TActivationContext::Now(); builder - .User(leader->UserName_) - .Queue(leader->QueueName_) + .User(leader->UserName_) + .Queue(leader->QueueName_) .Shard(Shard) - .QueueVersion(leader->QueueVersion_) + .QueueVersion(leader->QueueVersion_) .Fifo(IsFifoQueue) - .QueueLeader(SelfId()) - .Counters(leader->Counters_) + .QueueLeader(SelfId()) + .Counters(leader->Counters_) .RetryOnTimeout() .Params() .Uint64("NOW", now.MilliSeconds()) @@ -2539,8 +2539,8 @@ void TQueueLeader::TLoadBatch::Execute(TQueueLeader* leader) { .Uint64("SHARD", Shard); ui32 maxReceiveCount = 0; // not set - if (Cfg().GetEnableDeadLetterQueues() && leader->DlqInfo_) { - const auto& dlqInfo(*leader->DlqInfo_); + if (Cfg().GetEnableDeadLetterQueues() && leader->DlqInfo_) { + const auto& dlqInfo(*leader->DlqInfo_); if (dlqInfo.DlqName && dlqInfo.QueueId) { // dlq is set and resolved maxReceiveCount = dlqInfo.MaxReceiveCount; @@ -2576,11 +2576,11 @@ void TQueueLeader::TLoadBatch::Execute(TQueueLeader* leader) { if (deadLettersCounter) { // perform heavy read and move transaction (DLQ) - Y_VERIFY(leader->DlqInfo_); - const auto& dlqInfo(*leader->DlqInfo_); + Y_VERIFY(leader->DlqInfo_); + const auto& dlqInfo(*leader->DlqInfo_); - const TQueuePath currentQueuePath = { Cfg().GetRoot(), leader->UserName_, leader->QueueName_, leader->QueueVersion_ }; - const TQueuePath deadLetterQueuePath = { Cfg().GetRoot(), leader->UserName_, dlqInfo.QueueId, dlqInfo.QueueVersion }; + const TQueuePath currentQueuePath = { Cfg().GetRoot(), leader->UserName_, leader->QueueName_, leader->QueueVersion_ }; + const TQueuePath deadLetterQueuePath = { Cfg().GetRoot(), leader->UserName_, dlqInfo.QueueId, dlqInfo.QueueVersion }; const TString transactionText = Sprintf(GetStdQueryById(LOAD_OR_REDRIVE_MESSAGE_ID), currentQueuePath.GetVersionedQueuePath().c_str(), Shard, @@ -2595,18 +2595,18 @@ void TQueueLeader::TLoadBatch::Execute(TQueueLeader* leader) { } const bool usedDLQ = deadLettersCounter; - builder.OnExecuted([leader, shard = Shard, batchId = BatchId, usedDLQ] (const TSqsEvents::TEvExecuted::TRecord& ev) { - leader->OnLoadStdMessagesBatchExecuted(shard, batchId, usedDLQ, ev); + builder.OnExecuted([leader, shard = Shard, batchId = BatchId, usedDLQ] (const TSqsEvents::TEvExecuted::TRecord& ev) { + leader->OnLoadStdMessagesBatchExecuted(shard, batchId, usedDLQ, ev); }); builder.Start(); } -bool TQueueLeader::TShardInfo::HasMessagesToAddToInfly() const { +bool TQueueLeader::TShardInfo::HasMessagesToAddToInfly() const { return Infly ? Infly->GetCapacity() < MessagesCount : MessagesCount > 0; } -bool TQueueLeader::TShardInfo::NeedAddMessagesToInflyCheckInDatabase() const { +bool TQueueLeader::TShardInfo::NeedAddMessagesToInflyCheckInDatabase() const { const NKikimrConfig::TSqsConfig& cfg = Cfg(); if (AddMessagesToInflyCheckAttempts < cfg.GetAddMessagesToInflyMinCheckAttempts()) { return false; diff --git a/ydb/core/ymq/actor/queue_leader.h b/ydb/core/ymq/actor/queue_leader.h index 3e0b1b26c36..3504e4ddb1a 100644 --- a/ydb/core/ymq/actor/queue_leader.h +++ b/ydb/core/ymq/actor/queue_leader.h @@ -22,7 +22,7 @@ namespace NKikimr::NSQS { -class TQueueLeader : public TActorBootstrapped<TQueueLeader> { +class TQueueLeader : public TActorBootstrapped<TQueueLeader> { struct TSendMessageBatchRequestProcessing; struct TReceiveMessageBatchRequestProcessing; struct TDeleteMessageBatchRequestProcessing; @@ -30,13 +30,13 @@ class TQueueLeader : public TActorBootstrapped<TQueueLeader> { struct TGetRuntimeQueueAttributesRequestProcessing; public: - TQueueLeader(TString userName, TString queueName, TString folderId, TString rootUrl, TIntrusivePtr<TQueueCounters> counters, TIntrusivePtr<TUserCounters> userCounters, const TActorId& schemeCache, const TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions>& quoterResourcesForUser); - ~TQueueLeader(); + TQueueLeader(TString userName, TString queueName, TString folderId, TString rootUrl, TIntrusivePtr<TQueueCounters> counters, TIntrusivePtr<TUserCounters> userCounters, const TActorId& schemeCache, const TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions>& quoterResourcesForUser); + ~TQueueLeader(); void Bootstrap(); static constexpr NKikimrServices::TActivity::EType ActorActivityType() { - return NKikimrServices::TActivity::SQS_QUEUE_LEADER_ACTOR; + return NKikimrServices::TActivity::SQS_QUEUE_LEADER_ACTOR; } private: @@ -220,7 +220,7 @@ private: virtual ~TBatchBase() = default; - void Execute(TQueueLeader*) { + void Execute(TQueueLeader*) { } size_t Size() const { @@ -247,7 +247,7 @@ private: struct TBatchingState { virtual ~TBatchingState(); void Init(const NKikimrConfig::TSqsConfig::TBatchingPolicy& policy, ui64 shard, bool isFifo); - void TryExecute(TQueueLeader* leader); + void TryExecute(TQueueLeader* leader); virtual bool CanExecute(const TBatch& batch) const { // Called for next batches when we have some batches in flight. return batch.IsFull(); } @@ -327,7 +327,7 @@ private: using TBatchWithGroupInfo<TSendBatchEntry>::TBatchWithGroupInfo; void AddEntry(TSendMessageBatchRequestProcessing& reqInfo, size_t i); - void Execute(TQueueLeader* leader); + void Execute(TQueueLeader* leader); TInstant TransactionStartedTime; }; @@ -336,7 +336,7 @@ private: using TBatchWithGroupInfo<TDeleteBatchEntry>::TBatchWithGroupInfo; void AddEntry(TDeleteMessageBatchRequestProcessing& reqInfo, size_t i); - void Execute(TQueueLeader* leader); + void Execute(TQueueLeader* leader); THashMultiMap<ui64, size_t> Offset2Entry; }; @@ -344,7 +344,7 @@ private: struct TLoadBatch : public TBatchBase<TLoadBatchEntry> { using TBatchBase<TLoadBatchEntry>::TBatchBase; - void Execute(TQueueLeader* leader); + void Execute(TQueueLeader* leader); }; template <class TBatch> @@ -488,7 +488,7 @@ private: // requests std::vector<TSqsEvents::TEvGetConfiguration::TPtr> GetConfigurationRequests_; - std::vector<TSqsEvents::TEvExecute::TPtr> ExecuteRequests_; // execute requests that wait for queue leader init + std::vector<TSqsEvents::TEvExecute::TPtr> ExecuteRequests_; // execute requests that wait for queue leader init THashMap<TString, TSendMessageBatchRequestProcessing> SendMessageRequests_; // request id -> request THashMap<TString, TReceiveMessageBatchRequestProcessing> ReceiveMessageRequests_; // request id -> request THashMap<std::pair<TString, ui64>, TDeleteMessageBatchRequestProcessing> DeleteMessageRequests_; // (request id, shard) -> request diff --git a/ydb/core/ymq/actor/queue_schema.cpp b/ydb/core/ymq/actor/queue_schema.cpp index 243fc59f13f..91d3c5d3df4 100644 --- a/ydb/core/ymq/actor/queue_schema.cpp +++ b/ydb/core/ymq/actor/queue_schema.cpp @@ -456,11 +456,11 @@ void TCreateQueueSchemaActorV2::RegisterMakeDirActor(const TString& workingDir, Register(new TMiniKqlExecutionActor(SelfId(), RequestId_, std::move(ev), false, QueuePath_, GetTransactionCounters(UserCounters_))); } -void TCreateQueueSchemaActorV2::RequestLeaderTabletId() { - RLOG_SQS_TRACE("Requesting leader tablet id for path id " << TableWithLeaderPathId_.second); +void TCreateQueueSchemaActorV2::RequestLeaderTabletId() { + RLOG_SQS_TRACE("Requesting leader tablet id for path id " << TableWithLeaderPathId_.second); THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate()); - request->Record.MutableDescribePath()->SetSchemeshardId(TableWithLeaderPathId_.first); - request->Record.MutableDescribePath()->SetPathId(TableWithLeaderPathId_.second); + request->Record.MutableDescribePath()->SetSchemeshardId(TableWithLeaderPathId_.first); + request->Record.MutableDescribePath()->SetPathId(TableWithLeaderPathId_.second); Send(MakeTxProxyID(), std::move(request)); } @@ -493,8 +493,8 @@ void TCreateQueueSchemaActorV2::CreateComponents() { const TActorId actorId = Register(new TMiniKqlExecutionActor( SelfId(), RequestId_, std::move(ev), false, QueuePath_, GetTransactionCounters(UserCounters_))); - if (table.HasLeaderTablet && !CreateTableWithLeaderTabletActorId_) { - CreateTableWithLeaderTabletActorId_ = actorId; + if (table.HasLeaderTablet && !CreateTableWithLeaderTabletActorId_) { + CreateTableWithLeaderTabletActorId_ = actorId; } } @@ -504,8 +504,8 @@ void TCreateQueueSchemaActorV2::CreateComponents() { SendDescribeTable(); break; } - case ECreateComponentsStep::DiscoverLeaderTabletId: { - RequestLeaderTabletId(); + case ECreateComponentsStep::DiscoverLeaderTabletId: { + RequestLeaderTabletId(); break; } case ECreateComponentsStep::AddQuoterResource: { @@ -562,8 +562,8 @@ void TCreateQueueSchemaActorV2::Step() { return; // do not progress } - Y_VERIFY(TableWithLeaderPathId_.first && TableWithLeaderPathId_.second); - CurrentCreationStep_ = ECreateComponentsStep::DiscoverLeaderTabletId; + Y_VERIFY(TableWithLeaderPathId_.first && TableWithLeaderPathId_.second); + CurrentCreationStep_ = ECreateComponentsStep::DiscoverLeaderTabletId; break; } case ECreateComponentsStep::DescribeTableForSetSchemeShardId: { @@ -572,7 +572,7 @@ void TCreateQueueSchemaActorV2::Step() { CurrentCreationStep_ = ECreateComponentsStep::DiscoverLeaderTabletId; break; } - case ECreateComponentsStep::DiscoverLeaderTabletId: { + case ECreateComponentsStep::DiscoverLeaderTabletId: { Y_VERIFY(Cfg().GetQuotingConfig().GetEnableQuoting() && Cfg().GetQuotingConfig().HasKesusQuoterConfig()); CurrentCreationStep_ = ECreateComponentsStep::AddQuoterResource; break; @@ -591,10 +591,10 @@ void TCreateQueueSchemaActorV2::OnExecuted(TSqsEvents::TEvExecuted::TPtr& ev) { const auto status = record.GetStatus(); RLOG_SQS_TRACE("OnExecuted: " << ev->Get()->Record); - if (ev->Sender == CreateTableWithLeaderTabletActorId_) { - CreateTableWithLeaderTabletTxId_ = record.GetTxId(); - TableWithLeaderPathId_ = std::make_pair(record.GetSchemeShardTabletId(), record.GetPathId()); - RLOG_SQS_TRACE("Handle executed transaction with leader tablet: " << record); + if (ev->Sender == CreateTableWithLeaderTabletActorId_) { + CreateTableWithLeaderTabletTxId_ = record.GetTxId(); + TableWithLeaderPathId_ = std::make_pair(record.GetSchemeShardTabletId(), record.GetPathId()); + RLOG_SQS_TRACE("Handle executed transaction with leader tablet: " << record); } // Note: @@ -643,14 +643,14 @@ void TCreateQueueSchemaActorV2::OnExecuted(TSqsEvents::TEvExecuted::TPtr& ev) { } void TCreateQueueSchemaActorV2::OnDescribeSchemeResult(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev) { - RLOG_SQS_TRACE("OnDescribeSchemeResult for leader tablet: " << ev->Get()->GetRecord()); + RLOG_SQS_TRACE("OnDescribeSchemeResult for leader tablet: " << ev->Get()->GetRecord()); const auto& pathDescription = ev->Get()->GetRecord().GetPathDescription(); if (ev->Get()->GetRecord().GetStatus() != NKikimrScheme::StatusSuccess || pathDescription.TablePartitionsSize() == 0 || !pathDescription.GetTablePartitions(0).GetDatashardId()) { // fail auto resp = MakeErrorResponse(NErrors::INTERNAL_FAILURE); resp->State = EQueueState::Creating; - resp->Error = "Failed to discover leader."; + resp->Error = "Failed to discover leader."; Send(Sender_, std::move(resp)); @@ -658,7 +658,7 @@ void TCreateQueueSchemaActorV2::OnDescribeSchemeResult(NSchemeShard::TEvSchemeSh return; } - LeaderTabletId_ = pathDescription.GetTablePartitions(0).GetDatashardId(); + LeaderTabletId_ = pathDescription.GetTablePartitions(0).GetDatashardId(); if (Cfg().GetQuotingConfig().GetEnableQuoting() && Cfg().GetQuotingConfig().HasKesusQuoterConfig()) { Step(); @@ -729,7 +729,7 @@ static const char* const CommitQueueParamsQuery = R"__( (let now (Parameter 'NOW (DataType 'Uint64))) (let shards (Parameter 'SHARDS (DataType 'Uint64))) (let partitions (Parameter 'PARTITIONS (DataType 'Uint64))) - (let masterTabletId (Parameter 'MASTER_TABLET_ID (DataType 'Uint64))) + (let masterTabletId (Parameter 'MASTER_TABLET_ID (DataType 'Uint64))) (let tablesFormat (Parameter 'TABLES_FORMAT (DataType 'Uint32))) (let version (Parameter 'VERSION (DataType 'Uint64))) (let queueIdNumberHash (Parameter 'QUEUE_ID_NUMBER_HASH (DataType 'Uint64))) @@ -966,7 +966,7 @@ void TCreateQueueSchemaActorV2::CommitNewVersion() { auto ev = MakeExecuteEvent(query); auto* trans = ev->Record.MutableTransaction()->MutableMiniKQLTransaction(); - Y_VERIFY(LeaderTabletId_ != 0); + Y_VERIFY(LeaderTabletId_ != 0); TParameters(trans->MutableParams()->MutableProto()) .Utf8("NAME", QueuePath_.QueueName) .Utf8("CUSTOMNAME", CustomQueueName_) @@ -977,7 +977,7 @@ void TCreateQueueSchemaActorV2::CommitNewVersion() { .Uint64("NOW", QueueCreationTimestamp_.MilliSeconds()) .Uint64("SHARDS", RequiredShardsCount_) .Uint64("PARTITIONS", Request_.GetPartitions()) - .Uint64("MASTER_TABLET_ID", LeaderTabletId_) + .Uint64("MASTER_TABLET_ID", LeaderTabletId_) .Uint32("TABLES_FORMAT", TablesFormat_) .Uint64("VERSION", Version_) .Uint64("QUEUE_ID_NUMBER_HASH", GetHash(Version_)) @@ -1209,7 +1209,7 @@ void TCreateQueueSchemaActorV2::OnAttributesMatch(TSqsEvents::TEvExecuted::TPtr& resp->ErrorClass = &NErrors::VALIDATION_ERROR; } - if (CurrentCreationStep_ == ECreateComponentsStep::DiscoverLeaderTabletId) { + if (CurrentCreationStep_ == ECreateComponentsStep::DiscoverLeaderTabletId) { // call the special version of cleanup actor RLOG_SQS_WARN("Removing redundant queue version: " << Version_ << " for queue " << QueuePath_.GetQueuePath() << ". Shards: " << RequiredShardsCount_ << " IsFifo: " << IsFifo_); diff --git a/ydb/core/ymq/actor/queue_schema.h b/ydb/core/ymq/actor/queue_schema.h index da9355d5bb9..793ba1c06ad 100644 --- a/ydb/core/ymq/actor/queue_schema.h +++ b/ydb/core/ymq/actor/queue_schema.h @@ -50,7 +50,7 @@ public: void RequestTablesFormatSettings(const TString& accountName); void RegisterMakeDirActor(const TString& workingDir, const TString& dirName); - void RequestLeaderTabletId(); + void RequestLeaderTabletId(); void CreateComponents(); @@ -98,7 +98,7 @@ private: MakeShards, MakeTables, DescribeTableForSetSchemeShardId, - DiscoverLeaderTabletId, + DiscoverLeaderTabletId, AddQuoterResource, }; @@ -129,10 +129,10 @@ private: ui64 CreatedTablesCount_ = 0; TQueueAttributes ValidatedAttributes_; - ui64 LeaderTabletId_ = 0; - TActorId CreateTableWithLeaderTabletActorId_; - ui64 CreateTableWithLeaderTabletTxId_ = 0; - std::pair<ui64, ui64> TableWithLeaderPathId_ = std::make_pair(0, 0); // (scheme shard, path id) are required for describing table + ui64 LeaderTabletId_ = 0; + TActorId CreateTableWithLeaderTabletActorId_; + ui64 CreateTableWithLeaderTabletTxId_ = 0; + std::pair<ui64, ui64> TableWithLeaderPathId_ = std::make_pair(0, 0); // (scheme shard, path id) are required for describing table ECreateComponentsStep CurrentCreationStep_ = ECreateComponentsStep::GetTablesFormatSetting; diff --git a/ydb/core/ymq/actor/queues_list_reader.cpp b/ydb/core/ymq/actor/queues_list_reader.cpp index b176ef8bd6e..37b8b734263 100644 --- a/ydb/core/ymq/actor/queues_list_reader.cpp +++ b/ydb/core/ymq/actor/queues_list_reader.cpp @@ -104,9 +104,9 @@ void TQueuesListReader::OnQueuesList(const TSqsEvents::TEvExecuted::TRecord& rec continue; } - const TValue leaderTabletId = row["MasterTabletId"]; - if (!leaderTabletId.HaveValue()) { - LOG_SQS_ERROR("Queue [" << user << "/" << queue << "] without leader tablet id detected"); + const TValue leaderTabletId = row["MasterTabletId"]; + if (!leaderTabletId.HaveValue()) { + LOG_SQS_ERROR("Queue [" << user << "/" << queue << "] without leader tablet id detected"); continue; } @@ -114,7 +114,7 @@ void TQueuesListReader::OnQueuesList(const TSqsEvents::TEvExecuted::TRecord& rec auto& rec = Result->SortedQueues.back(); rec.UserName = std::move(user); rec.QueueName = std::move(queue); - rec.LeaderTabletId = leaderTabletId; + rec.LeaderTabletId = leaderTabletId; if (cloudMode) { rec.CustomName = row["CustomQueueName"]; } else { diff --git a/ydb/core/ymq/actor/receive_message.cpp b/ydb/core/ymq/actor/receive_message.cpp index 395a19b6a6c..2b5bf0e5174 100644 --- a/ydb/core/ymq/actor/receive_message.cpp +++ b/ydb/core/ymq/actor/receive_message.cpp @@ -138,7 +138,7 @@ private: receiveRequest->WaitDeadline = WaitDeadline(); } - Send(QueueLeader_, std::move(receiveRequest)); + Send(QueueLeader_, std::move(receiveRequest)); } TString DoGetQueueName() const override { diff --git a/ydb/core/ymq/actor/retention.cpp b/ydb/core/ymq/actor/retention.cpp index 3b95aa1b1da..9e610e8ed29 100644 --- a/ydb/core/ymq/actor/retention.cpp +++ b/ydb/core/ymq/actor/retention.cpp @@ -12,10 +12,10 @@ namespace NKikimr::NSQS { -TRetentionActor::TRetentionActor(const TQueuePath& queuePath, const TActorId& queueLeader) +TRetentionActor::TRetentionActor(const TQueuePath& queuePath, const TActorId& queueLeader) : QueuePath_(queuePath) , RequestId_(CreateGuidAsString()) - , QueueLeader_(queueLeader) + , QueueLeader_(queueLeader) { DebugInfo->QueueRetentionActors.emplace(TStringBuilder() << TLogQueueName(QueuePath_), this); } @@ -53,7 +53,7 @@ void TRetentionActor::SetRetentionBoundary() { RLOG_SQS_INFO("Set retention boundary for queue " << TLogQueueName(QueuePath_, req->Shard) << " to " << req->Boundary.MilliSeconds() << " (" << req->Boundary << ")"); - Send(QueueLeader_, std::move(req)); + Send(QueueLeader_, std::move(req)); } } else { RLOG_SQS_ERROR("Failed to set retention boundary for queue " << TLogQueueName(QueuePath_)); @@ -65,7 +65,7 @@ void TRetentionActor::SetRetentionBoundary() { TExecutorBuilder(SelfId(), RequestId_) .User(QueuePath_.UserName) .Queue(QueuePath_.QueueName) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(SET_RETENTION_ID) .RetryOnTimeout() .OnExecuted(onExecuted) diff --git a/ydb/core/ymq/actor/retention.h b/ydb/core/ymq/actor/retention.h index 4281a36eb2f..724baddff3f 100644 --- a/ydb/core/ymq/actor/retention.h +++ b/ydb/core/ymq/actor/retention.h @@ -9,7 +9,7 @@ namespace NKikimr::NSQS { class TRetentionActor : public TActorBootstrapped<TRetentionActor> { public: - TRetentionActor(const TQueuePath& queuePath, const TActorId& queueLeader); + TRetentionActor(const TQueuePath& queuePath, const TActorId& queueLeader); ~TRetentionActor(); void Bootstrap(); @@ -33,7 +33,7 @@ private: private: const TQueuePath QueuePath_; const TString RequestId_; - const TActorId QueueLeader_; + const TActorId QueueLeader_; }; } // namespace NKikimr::NSQS diff --git a/ydb/core/ymq/actor/send_message.cpp b/ydb/core/ymq/actor/send_message.cpp index db97f02e2f0..e596b8f2e33 100644 --- a/ydb/core/ymq/actor/send_message.cpp +++ b/ydb/core/ymq/actor/send_message.cpp @@ -222,7 +222,7 @@ private: } if (req) { - Send(QueueLeader_, req.Release()); + Send(QueueLeader_, req.Release()); } else { SendReplyAndDie(); } diff --git a/ydb/core/ymq/actor/service.cpp b/ydb/core/ymq/actor/service.cpp index 385795ed1c2..34c9a4ae46b 100644 --- a/ydb/core/ymq/actor/service.cpp +++ b/ydb/core/ymq/actor/service.cpp @@ -7,7 +7,7 @@ #include "local_rate_limiter_allocator.h" #include "params.h" #include "proxy_service.h" -#include "queue_leader.h" +#include "queue_leader.h" #include "queues_list_reader.h" #include "user_settings_names.h" #include "user_settings_reader.h" @@ -40,10 +40,10 @@ LWTRACE_USING(SQS_PROVIDER); template <> -struct THash<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> : THash<const NActors::TEventHandle<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest>*> { - using TParent = THash<const NActors::TEventHandle<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest>*>; +struct THash<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> : THash<const NActors::TEventHandle<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest>*> { + using TParent = THash<const NActors::TEventHandle<NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest>*>; using TParent::operator(); - size_t operator()(const NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ptr) const { + size_t operator()(const NKikimr::NSQS::TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ptr) const { return TParent::operator()(ptr.Get()); } }; @@ -52,10 +52,10 @@ namespace NKikimr::NSQS { using NKikimr::NClient::TValue; -const TString LEADER_CREATE_REASON_USER_REQUEST = "UserRequestOnNode"; -const TString LEADER_CREATE_REASON_LOCAL_TABLET = "LocalTablet"; -const TString LEADER_DESTROY_REASON_LAST_REF = "LastReference"; -const TString LEADER_DESTROY_REASON_TABLET_PIPE_CLOSED = "TabletPipeClosed"; +const TString LEADER_CREATE_REASON_USER_REQUEST = "UserRequestOnNode"; +const TString LEADER_CREATE_REASON_LOCAL_TABLET = "LocalTablet"; +const TString LEADER_DESTROY_REASON_LAST_REF = "LastReference"; +const TString LEADER_DESTROY_REASON_TABLET_PIPE_CLOSED = "TabletPipeClosed"; constexpr ui64 LIST_USERS_WAKEUP_TAG = 1; constexpr ui64 LIST_QUEUES_WAKEUP_TAG = 2; @@ -69,7 +69,7 @@ bool IsInternalFolder(const TString& folder) { struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { TQueueInfo( - TString userName, TString queueName, TString rootUrl, ui64 leaderTabletId, TString customName, + TString userName, TString queueName, TString rootUrl, ui64 leaderTabletId, TString customName, TString folderId, ui64 version, ui64 shardsCount, const TIntrusivePtr<TUserCounters>& userCounters, const TActorId& schemeCache, TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions> quoterResourcesForUser, bool insertCounters @@ -81,7 +81,7 @@ struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { , Version_(version) , ShardsCount_(shardsCount) , RootUrl_(std::move(rootUrl)) - , LeaderTabletId_(leaderTabletId) + , LeaderTabletId_(leaderTabletId) , Counters_(userCounters->CreateQueueCounters(QueueName_, FolderId_, insertCounters)) , UserCounters_(userCounters) , SchemeCache_(schemeCache) @@ -89,45 +89,45 @@ struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { { } - void ConnectToLeaderTablet(bool firstTime = true) { - if (ConnectingToLeaderTablet_) { + void ConnectToLeaderTablet(bool firstTime = true) { + if (ConnectingToLeaderTablet_) { return; } - ClosePipeToLeaderTablet(); - ConnectingToLeaderTablet_ = true; + ClosePipeToLeaderTablet(); + ConnectingToLeaderTablet_ = true; NTabletPipe::TClientConfig cfg; - cfg.AllowFollower = false; + cfg.AllowFollower = false; cfg.CheckAliveness = true; cfg.RetryPolicy = {.RetryLimitCount = 3, .MinRetryTime = TDuration::MilliSeconds(100), .DoFirstRetryInstantly = firstTime}; - PipeClient_ = TActivationContext::Register(NTabletPipe::CreateClient(SelfId(), LeaderTabletId_, cfg)); - LOG_SQS_DEBUG("Connect to leader tablet [" << LeaderTabletId_ << "] for queue [" << UserName_ << "/" << QueueName_ << "]. Pipe client actor: " << PipeClient_); + PipeClient_ = TActivationContext::Register(NTabletPipe::CreateClient(SelfId(), LeaderTabletId_, cfg)); + LOG_SQS_DEBUG("Connect to leader tablet [" << LeaderTabletId_ << "] for queue [" << UserName_ << "/" << QueueName_ << "]. Pipe client actor: " << PipeClient_); } - void SetLeaderPipeServer(const TActorId& pipeServer) { - LeaderPipeServer_ = pipeServer; + void SetLeaderPipeServer(const TActorId& pipeServer) { + LeaderPipeServer_ = pipeServer; - const ui64 nodeId = LeaderPipeServer_.NodeId(); + const ui64 nodeId = LeaderPipeServer_.NodeId(); if (nodeId == SelfId().NodeId()) { - IncLocalLeaderRef(LEADER_CREATE_REASON_LOCAL_TABLET); // ref for service + IncLocalLeaderRef(LEADER_CREATE_REASON_LOCAL_TABLET); // ref for service } } - void ClosePipeToLeaderTablet() { - if (LeaderPipeServer_.NodeId() == SelfId().NodeId()) { - DecLocalLeaderRef(LEADER_DESTROY_REASON_TABLET_PIPE_CLOSED); // ref for service + void ClosePipeToLeaderTablet() { + if (LeaderPipeServer_.NodeId() == SelfId().NodeId()) { + DecLocalLeaderRef(LEADER_DESTROY_REASON_TABLET_PIPE_CLOSED); // ref for service } if (PipeClient_) { NTabletPipe::CloseClient(SelfId(), PipeClient_); - PipeClient_ = LeaderPipeServer_ = TActorId(); + PipeClient_ = LeaderPipeServer_ = TActorId(); } } - void StartLocalLeader(const TString& reason) { - if (!LocalLeader_) { - Counters_ = Counters_->GetCountersForLeaderNode(); - LWPROBE(CreateLeader, UserName_, QueueName_, reason); - LocalLeader_ = TActivationContext::Register(new TQueueLeader(UserName_, QueueName_, FolderId_, RootUrl_, Counters_, UserCounters_, SchemeCache_, QuoterResourcesForUser_)); - LOG_SQS_INFO("Start local leader [" << UserName_ << "/" << QueueName_ << "] actor " << LocalLeader_); + void StartLocalLeader(const TString& reason) { + if (!LocalLeader_) { + Counters_ = Counters_->GetCountersForLeaderNode(); + LWPROBE(CreateLeader, UserName_, QueueName_, reason); + LocalLeader_ = TActivationContext::Register(new TQueueLeader(UserName_, QueueName_, FolderId_, RootUrl_, Counters_, UserCounters_, SchemeCache_, QuoterResourcesForUser_)); + LOG_SQS_INFO("Start local leader [" << UserName_ << "/" << QueueName_ << "] actor " << LocalLeader_); // ToDo: Should better make TFolderCounters struct and move it there. // Will have to refactor TQueueCounters a bit, since it directly works with TUserCounters @@ -141,13 +141,13 @@ struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { } } - void StopLocalLeader(const TString& reason) { - if (LocalLeader_) { - Counters_ = Counters_->GetCountersForNotLeaderNode(); - LWPROBE(DestroyLeader, UserName_, QueueName_, reason); - LOG_SQS_INFO("Stop local leader [" << UserName_ << "/" << QueueName_ << "] actor " << LocalLeader_); - TActivationContext::Send(new IEventHandle(LocalLeader_, SelfId(), new TEvPoisonPill())); - LocalLeader_ = TActorId(); + void StopLocalLeader(const TString& reason) { + if (LocalLeader_) { + Counters_ = Counters_->GetCountersForNotLeaderNode(); + LWPROBE(DestroyLeader, UserName_, QueueName_, reason); + LOG_SQS_INFO("Stop local leader [" << UserName_ << "/" << QueueName_ << "] actor " << LocalLeader_); + TActivationContext::Send(new IEventHandle(LocalLeader_, SelfId(), new TEvPoisonPill())); + LocalLeader_ = TActorId(); if (FolderId_) { auto folderCounters = GetFolderCounters(UserCounters_->UserCounters, FolderId_); if (folderCounters.YmqCounters) { @@ -161,16 +161,16 @@ struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { } } - void IncLocalLeaderRef(const TString& reason) { - StartLocalLeader(reason); - ++LocalLeaderRefCount_; + void IncLocalLeaderRef(const TString& reason) { + StartLocalLeader(reason); + ++LocalLeaderRefCount_; } - void DecLocalLeaderRef(const TString& reason) { - Y_VERIFY(LocalLeaderRefCount_ > 0); - --LocalLeaderRefCount_; - if (LocalLeaderRefCount_ == 0) { - StopLocalLeader(reason); + void DecLocalLeaderRef(const TString& reason) { + Y_VERIFY(LocalLeaderRefCount_ > 0); + --LocalLeaderRefCount_; + if (LocalLeaderRefCount_ == 0) { + StopLocalLeader(reason); } } @@ -185,20 +185,20 @@ struct TSqsService::TQueueInfo : public TAtomicRefCount<TQueueInfo> { ui64 Version_; ui64 ShardsCount_; TString RootUrl_; - ui64 LeaderTabletId_ = 0; + ui64 LeaderTabletId_ = 0; TIntrusivePtr<TQueueCounters> Counters_; TIntrusivePtr<TUserCounters> UserCounters_; TActorId PipeClient_; - TActorId LeaderPipeServer_; - TActorId LocalLeader_; + TActorId LeaderPipeServer_; + TActorId LocalLeader_; TActorId SchemeCache_; - ui64 LocalLeaderRefCount_ = 0; + ui64 LocalLeaderRefCount_ = 0; TIntrusivePtr<TSqsEvents::TQuoterResourcesForActions> QuoterResourcesForUser_; // State machine - bool ConnectingToLeaderTablet_ = false; + bool ConnectingToLeaderTablet_ = false; TInstant DisconnectedFrom_ = TInstant::Now(); - THashSet<TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; + THashSet<TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; }; struct TSqsService::TUserInfo : public TAtomicRefCount<TUserInfo> { @@ -259,7 +259,7 @@ struct TSqsService::TUserInfo : public TAtomicRefCount<TUserInfo> { i64 EarlyRequestQueuesListBudget_ = EARLY_REQUEST_QUEUES_LIST_MAX_BUDGET; // Defence from continuously requesting queues list. // State machine - THashMultiMap<TString, TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; // queue name -> request + THashMultiMap<TString, TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; // queue name -> request THashMultiMap<TString, TSqsEvents::TEvGetConfiguration::TPtr> GetConfigurationRequests_; // queue name -> request THashMultiMap<std::pair<TString, TString>, TSqsEvents::TEvGetQueueId::TPtr> GetQueueIdRequests_; // <queue custom name, folder id> -> request THashMultiMap<TString, TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr> GetQueueFolderIdAndCustomNameRequests_; // queue name -> request @@ -342,8 +342,8 @@ void TSqsService::Bootstrap() { STATEFN(TSqsService::StateFunc) { switch (ev->GetTypeRewrite()) { // Interface events - hFunc(TSqsEvents::TEvGetLeaderNodeForQueueRequest, HandleGetLeaderNodeForQueueRequest); - hFunc(TSqsEvents::TEvQueueLeaderDecRef, HandleQueueLeaderDecRef); + hFunc(TSqsEvents::TEvGetLeaderNodeForQueueRequest, HandleGetLeaderNodeForQueueRequest); + hFunc(TSqsEvents::TEvQueueLeaderDecRef, HandleQueueLeaderDecRef); hFunc(TSqsEvents::TEvGetQueueId, HandleGetQueueId); hFunc(TSqsEvents::TEvGetQueueFolderIdAndCustomName, HandleGetQueueFolderIdAndCustomName); hFunc(TSqsEvents::TEvCountQueues, HandleCountQueues); @@ -375,7 +375,7 @@ void TSqsService::ScheduleRequestSqsUsersList() { if (!ScheduledRequestingUsersList_) { ScheduledRequestingUsersList_ = true; const TInstant now = TActivationContext::Now(); - const TInstant whenToRequest = Max(LastRequestUsersListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs()), now); + const TInstant whenToRequest = Max(LastRequestUsersListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs()), now); Schedule(whenToRequest - now, new TEvWakeup(LIST_USERS_WAKEUP_TAG)); } } @@ -396,7 +396,7 @@ void TSqsService::ScheduleRequestSqsQueuesList() { if (!ScheduledRequestingQueuesList_) { ScheduledRequestingQueuesList_ = true; const TInstant now = TActivationContext::Now(); - const TInstant whenToRequest = Max(LastRequestQueuesListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs()), now); + const TInstant whenToRequest = Max(LastRequestQueuesListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs()), now); Schedule(whenToRequest - now, new TEvWakeup(LIST_QUEUES_WAKEUP_TAG)); } } @@ -425,7 +425,7 @@ Y_WARN_UNUSED_RESULT bool TSqsService::RequestQueueListForUser(const TUserInfoPt return true; } -void TSqsService::HandleGetLeaderNodeForQueueRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev) { +void TSqsService::HandleGetLeaderNodeForQueueRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev) { TUserInfoPtr user = GetUserOrWait(ev); if (!user) { return; @@ -440,24 +440,24 @@ void TSqsService::HandleGetLeaderNodeForQueueRequest(TSqsEvents::TEvGetLeaderNod LWPROBE(QueueRequestCacheMiss, userName, queueName, reqId, ev->Get()->ToStringHeader()); if (RequestQueueListForUser(user, reqId)) { RLOG_SQS_REQ_DEBUG(reqId, "Queue [" << userName << "/" << queueName << "] was not found in sqs service list. Requesting queues list"); - user->GetLeaderNodeRequests_.emplace(queueName, std::move(ev)); + user->GetLeaderNodeRequests_.emplace(queueName, std::move(ev)); } else { - Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(reqId, userName, queueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue)); + Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(reqId, userName, queueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue)); } return; } - if (!queueIt->second->LeaderPipeServer_) { + if (!queueIt->second->LeaderPipeServer_) { LWPROBE(QueueRequestCacheMiss, userName, queueName, reqId, ev->Get()->ToStringHeader()); - RLOG_SQS_REQ_DEBUG(reqId, "Queue [" << userName << "/" << queueName << "] is waiting for connection to leader tablet."); + RLOG_SQS_REQ_DEBUG(reqId, "Queue [" << userName << "/" << queueName << "] is waiting for connection to leader tablet."); auto& queue = queueIt->second; - queue->GetLeaderNodeRequests_.emplace(std::move(ev)); + queue->GetLeaderNodeRequests_.emplace(std::move(ev)); return; } - const ui64 nodeId = queueIt->second->LeaderPipeServer_.NodeId(); - RLOG_SQS_REQ_DEBUG(reqId, "Leader node for queue [" << userName << "/" << queueName << "] is " << nodeId); - Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(reqId, userName, queueName, nodeId)); + const ui64 nodeId = queueIt->second->LeaderPipeServer_.NodeId(); + RLOG_SQS_REQ_DEBUG(reqId, "Leader node for queue [" << userName << "/" << queueName << "] is " << nodeId); + Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(reqId, userName, queueName, nodeId)); } void TSqsService::HandleGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev) { @@ -506,15 +506,15 @@ void TSqsService::AnswerNotExists(TSqsEvents::TEvGetConfiguration::TPtr& ev, con Send(ev->Sender, answer.Release()); } -void TSqsService::AnswerNotExists(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo) { - const TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus status = userInfo ? TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue : TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser; - if (status == TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser) { +void TSqsService::AnswerNotExists(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo) { + const TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus status = userInfo ? TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue : TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser; + if (status == TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoUser) { RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "No user [" << ev->Get()->UserName << "] found"); } else { RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "No queue [" << ev->Get()->QueueName << "] found for user [" << ev->Get()->UserName << "]"); } Send(ev->Sender, - new TSqsEvents::TEvGetLeaderNodeForQueueResponse(ev->Get()->RequestId, + new TSqsEvents::TEvGetLeaderNodeForQueueResponse(ev->Get()->RequestId, ev->Get()->UserName, ev->Get()->QueueName, status)); @@ -543,8 +543,8 @@ void TSqsService::AnswerNotExists(TSqsEvents::TEvCountQueues::TPtr& ev, const TU Send(ev->Sender, new TSqsEvents::TEvCountQueuesResponse(false)); } -void TSqsService::AnswerFailed(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr&) { - Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(ev->Get()->RequestId, ev->Get()->UserName, ev->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::Error)); +void TSqsService::AnswerFailed(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr&) { + Send(ev->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(ev->Get()->RequestId, ev->Get()->UserName, ev->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::Error)); } void TSqsService::AnswerFailed(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo) { @@ -574,7 +574,7 @@ void TSqsService::Answer(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr& ev, Send(ev->Sender, new TSqsEvents::TEvQueueFolderIdAndCustomName(queueInfo->FolderId_, queueInfo->CustomName_)); } -void TSqsService::AnswerLeaderlessConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo) { +void TSqsService::AnswerLeaderlessConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo) { auto answer = MakeHolder<TSqsEvents::TEvConfiguration>(); answer->UserExists = true; answer->QueueExists = true; @@ -589,13 +589,13 @@ void TSqsService::AnswerLeaderlessConfiguration(TSqsEvents::TEvGetConfiguration: } void TSqsService::ProcessConfigurationRequestForQueue(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo) { - if (ev->Get()->Flags & TSqsEvents::TEvGetConfiguration::EFlags::NeedQueueLeader) { - IncLocalLeaderRef(ev->Sender, queueInfo, LEADER_CREATE_REASON_USER_REQUEST); - RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Forward configuration request to queue [" << queueInfo->UserName_ << "/" << queueInfo->QueueName_ << "] leader"); - TActivationContext::Send(ev->Forward(queueInfo->LocalLeader_)); + if (ev->Get()->Flags & TSqsEvents::TEvGetConfiguration::EFlags::NeedQueueLeader) { + IncLocalLeaderRef(ev->Sender, queueInfo, LEADER_CREATE_REASON_USER_REQUEST); + RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Forward configuration request to queue [" << queueInfo->UserName_ << "/" << queueInfo->QueueName_ << "] leader"); + TActivationContext::Send(ev->Forward(queueInfo->LocalLeader_)); } else { - RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Answer configuration for queue [" << queueInfo->UserName_ << "/" << queueInfo->QueueName_ << "] without leader"); - AnswerLeaderlessConfiguration(ev, userInfo, queueInfo); + RLOG_SQS_REQ_DEBUG(ev->Get()->RequestId, "Answer configuration for queue [" << queueInfo->UserName_ << "/" << queueInfo->QueueName_ << "] without leader"); + AnswerLeaderlessConfiguration(ev, userInfo, queueInfo); } } @@ -643,8 +643,8 @@ void TSqsService::HandleDescribeSchemeResult(NSchemeShard::TEvSchemeShard::TEvDe ScheduleRequestSqsUsersList(); } -void TSqsService::HandleQueueLeaderDecRef(TSqsEvents::TEvQueueLeaderDecRef::TPtr& ev) { - DecLocalLeaderRef(ev->Sender, LEADER_DESTROY_REASON_LAST_REF); +void TSqsService::HandleQueueLeaderDecRef(TSqsEvents::TEvQueueLeaderDecRef::TPtr& ev) { + DecLocalLeaderRef(ev->Sender, LEADER_DESTROY_REASON_LAST_REF); } void TSqsService::HandleGetQueueId(TSqsEvents::TEvGetQueueId::TPtr& ev) { @@ -739,48 +739,48 @@ TSqsService::TUserInfoPtr TSqsService::GetUserOrWait(TAutoPtr<TEvent>& ev) { } void TSqsService::HandlePipeClientConnected(TEvTabletPipe::TEvClientConnected::TPtr& ev) { - auto queueIt = LeaderTabletIdToQueue_.find(ev->Get()->TabletId); - if (queueIt == LeaderTabletIdToQueue_.end()) { - LOG_SQS_WARN("Connected to unknown queue leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); + auto queueIt = LeaderTabletIdToQueue_.find(ev->Get()->TabletId); + if (queueIt == LeaderTabletIdToQueue_.end()) { + LOG_SQS_WARN("Connected to unknown queue leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); return; } const auto& queue = queueIt->second; - queue->ConnectingToLeaderTablet_ = false; + queue->ConnectingToLeaderTablet_ = false; if (ev->Get()->Status != NKikimrProto::OK) { - LOG_SQS_WARN("Failed to connect to queue [" << queue->UserName_ << "/" << queue->QueueName_ << "] leader tablet. Tablet id: [" << ev->Get()->TabletId << "]. Status: " << NKikimrProto::EReplyStatus_Name(ev->Get()->Status)); + LOG_SQS_WARN("Failed to connect to queue [" << queue->UserName_ << "/" << queue->QueueName_ << "] leader tablet. Tablet id: [" << ev->Get()->TabletId << "]. Status: " << NKikimrProto::EReplyStatus_Name(ev->Get()->Status)); const TInstant now = TActivationContext::Now(); const TDuration timeDisconnecned = now - queue->DisconnectedFrom_; const TDuration leaderConnectTimeout = TDuration::MilliSeconds(Cfg().GetLeaderConnectTimeoutMs()); - if (timeDisconnecned >= leaderConnectTimeout) { - for (auto& req : queue->GetLeaderNodeRequests_) { - RLOG_SQS_REQ_WARN(req->Get()->RequestId, "Can't connect to leader tablet for " << timeDisconnecned); - Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::FailedToConnectToLeader)); + if (timeDisconnecned >= leaderConnectTimeout) { + for (auto& req : queue->GetLeaderNodeRequests_) { + RLOG_SQS_REQ_WARN(req->Get()->RequestId, "Can't connect to leader tablet for " << timeDisconnecned); + Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::FailedToConnectToLeader)); } - queue->GetLeaderNodeRequests_.clear(); + queue->GetLeaderNodeRequests_.clear(); } - queue->ConnectToLeaderTablet(false); + queue->ConnectToLeaderTablet(false); return; } - LOG_SQS_DEBUG("Connected to queue [" << queueIt->second->UserName_ << "/" << queueIt->second->QueueName_ << "] leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); - queue->SetLeaderPipeServer(ev->Get()->ServerId); - for (auto& req : queue->GetLeaderNodeRequests_) { - RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Connected to leader tablet. Node id: " << queue->LeaderPipeServer_.NodeId()); - Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, queue->LeaderPipeServer_.NodeId())); + LOG_SQS_DEBUG("Connected to queue [" << queueIt->second->UserName_ << "/" << queueIt->second->QueueName_ << "] leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); + queue->SetLeaderPipeServer(ev->Get()->ServerId); + for (auto& req : queue->GetLeaderNodeRequests_) { + RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Connected to leader tablet. Node id: " << queue->LeaderPipeServer_.NodeId()); + Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, queue->LeaderPipeServer_.NodeId())); } - queue->GetLeaderNodeRequests_.clear(); + queue->GetLeaderNodeRequests_.clear(); } void TSqsService::HandlePipeClientDisconnected(TEvTabletPipe::TEvClientDestroyed::TPtr& ev) { - auto queueIt = LeaderTabletIdToQueue_.find(ev->Get()->TabletId); - if (queueIt != LeaderTabletIdToQueue_.end()) { - queueIt->second->ConnectingToLeaderTablet_ = false; + auto queueIt = LeaderTabletIdToQueue_.find(ev->Get()->TabletId); + if (queueIt != LeaderTabletIdToQueue_.end()) { + queueIt->second->ConnectingToLeaderTablet_ = false; queueIt->second->DisconnectedFrom_ = TActivationContext::Now(); - LOG_SQS_DEBUG("Disconnected from queue [" << queueIt->second->UserName_ << "/" << queueIt->second->QueueName_ << "] leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); - queueIt->second->ConnectToLeaderTablet(false); + LOG_SQS_DEBUG("Disconnected from queue [" << queueIt->second->UserName_ << "/" << queueIt->second->QueueName_ << "] leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); + queueIt->second->ConnectToLeaderTablet(false); } else { - LOG_SQS_WARN("Disconnected from unknown queue leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); + LOG_SQS_WARN("Disconnected from unknown queue leader. Tablet id: [" << ev->Get()->TabletId << "]. Client pipe actor: " << ev->Get()->ClientId << ". Server pipe actor: " << ev->Get()->ServerId); } } @@ -799,23 +799,23 @@ void TSqsService::HandleQueuesList(TSqsEvents::TEvQueuesList::TPtr& ev) { auto oldListIt = user->Queues_.begin(); while (oldListIt != user->Queues_.end() && newListIt != ev->Get()->SortedQueues.end() && newListIt->UserName == user->UserName_) { if (oldListIt->first == newListIt->QueueName) { // the same queue - if (oldListIt->second->LeaderTabletId_ != newListIt->LeaderTabletId) { - LOG_SQS_WARN("Leader tablet id for queue " << oldListIt->first << " has been changed from " - << oldListIt->second->LeaderTabletId_ << " to " << newListIt->LeaderTabletId << " (queue was recreated)"); - THashSet<TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> oldQueueRequests; - oldQueueRequests.swap(oldListIt->second->GetLeaderNodeRequests_); + if (oldListIt->second->LeaderTabletId_ != newListIt->LeaderTabletId) { + LOG_SQS_WARN("Leader tablet id for queue " << oldListIt->first << " has been changed from " + << oldListIt->second->LeaderTabletId_ << " to " << newListIt->LeaderTabletId << " (queue was recreated)"); + THashSet<TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> oldQueueRequests; + oldQueueRequests.swap(oldListIt->second->GetLeaderNodeRequests_); RemoveQueue(user->UserName_, newListIt->QueueName); oldListIt = AddQueue(user->UserName_, newListIt->QueueName, - newListIt->LeaderTabletId, + newListIt->LeaderTabletId, newListIt->CustomName, newListIt->FolderId, newListIt->Version, newListIt->ShardsCount, newListIt->CreatedTimestamp); - Y_VERIFY(oldListIt->second->ConnectingToLeaderTablet_); - oldQueueRequests.swap(oldListIt->second->GetLeaderNodeRequests_); + Y_VERIFY(oldListIt->second->ConnectingToLeaderTablet_); + oldQueueRequests.swap(oldListIt->second->GetLeaderNodeRequests_); } ++oldListIt; ++newListIt; @@ -826,7 +826,7 @@ void TSqsService::HandleQueuesList(TSqsEvents::TEvQueuesList::TPtr& ev) { } else { oldListIt = AddQueue(user->UserName_, newListIt->QueueName, - newListIt->LeaderTabletId, + newListIt->LeaderTabletId, newListIt->CustomName, newListIt->FolderId, newListIt->Version, @@ -844,7 +844,7 @@ void TSqsService::HandleQueuesList(TSqsEvents::TEvQueuesList::TPtr& ev) { while (newListIt != ev->Get()->SortedQueues.end() && newListIt->UserName == user->UserName_) { AddQueue(user->UserName_, newListIt->QueueName, - newListIt->LeaderTabletId, + newListIt->LeaderTabletId, newListIt->CustomName, newListIt->FolderId, newListIt->Version, @@ -862,7 +862,7 @@ void TSqsService::HandleQueuesList(TSqsEvents::TEvQueuesList::TPtr& ev) { } } - NotifyLocalDeadLetterQueuesLeaders(ev->Get()->SortedQueues); + NotifyLocalDeadLetterQueuesLeaders(ev->Get()->SortedQueues); } else { for (const auto& [userName, user] : Users_) { AnswerErrorToRequests(user); @@ -870,7 +870,7 @@ void TSqsService::HandleQueuesList(TSqsEvents::TEvQueuesList::TPtr& ev) { } } -void TSqsService::NotifyLocalDeadLetterQueuesLeaders(const std::vector<TSqsEvents::TEvQueuesList::TQueueRecord>& sortedQueues) const { +void TSqsService::NotifyLocalDeadLetterQueuesLeaders(const std::vector<TSqsEvents::TEvQueuesList::TQueueRecord>& sortedQueues) const { using TKnownDeadLetterQueues = THashMap<TString, THashSet<std::pair<TString, TString>>>; TKnownDeadLetterQueues knownDlqs; @@ -887,8 +887,8 @@ void TSqsService::NotifyLocalDeadLetterQueuesLeaders(const std::vector<TSqsEvent auto queueInfoIt = accountIt->second->QueueByNameAndFolder_.find(customNameAndFolderPair); if (queueInfoIt != accountIt->second->QueueByNameAndFolder_.end()) { const auto& queueInfo = *queueInfoIt->second; - if (queueInfo.LocalLeader_) { - Send(queueInfo.LocalLeader_, new TSqsEvents::TEvDeadLetterQueueNotification); + if (queueInfo.LocalLeader_) { + Send(queueInfo.LocalLeader_, new TSqsEvents::TEvDeadLetterQueueNotification); } } } @@ -965,7 +965,7 @@ TSqsService::TUsersMap::iterator TSqsService::MutableUserIter(const TString& use if (moveUserRequestsToUserRecord) { // move user's requests to user info size_t moved = 0; - moved += MoveUserRequests(user, GetLeaderNodeRequests_); + moved += MoveUserRequests(user, GetLeaderNodeRequests_); moved += MoveUserRequests(user, GetConfigurationRequests_); moved += MoveUserRequests(user, GetQueueIdRequests_); moved += MoveUserRequests(user, GetQueueFolderIdAndCustomNameRequests_); @@ -1016,13 +1016,13 @@ void TSqsService::RemoveQueue(const TString& userName, const TString& queue) { } auto queuePtr = queueIt->second; - queuePtr->ClosePipeToLeaderTablet(); - for (auto& req : queuePtr->GetLeaderNodeRequests_) { + queuePtr->ClosePipeToLeaderTablet(); + for (auto& req : queuePtr->GetLeaderNodeRequests_) { RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Removing queue [" << req->Get()->UserName << "/" << req->Get()->QueueName << "] from sqs service info"); - Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue)); + Send(req->Sender, new TSqsEvents::TEvGetLeaderNodeForQueueResponse(req->Get()->RequestId, req->Get()->UserName, req->Get()->QueueName, TSqsEvents::TEvGetLeaderNodeForQueueResponse::EStatus::NoQueue)); } - queuePtr->GetLeaderNodeRequests_.clear(); - LeaderTabletIdToQueue_.erase(queuePtr->LeaderTabletId_); + queuePtr->GetLeaderNodeRequests_.clear(); + LeaderTabletIdToQueue_.erase(queuePtr->LeaderTabletId_); userIt->second->QueueByNameAndFolder_.erase(std::make_pair(queuePtr->CustomName_, queuePtr->FolderId_)); userIt->second->Queues_.erase(queueIt); @@ -1031,7 +1031,7 @@ void TSqsService::RemoveQueue(const TString& userName, const TString& queue) { std::map<TString, TSqsService::TQueueInfoPtr>::iterator TSqsService::AddQueue(const TString& userName, const TString& queue, - ui64 leaderTabletId, + ui64 leaderTabletId, const TString& customName, const TString& folderId, const ui64 version, @@ -1041,23 +1041,23 @@ std::map<TString, TSqsService::TQueueInfoPtr>::iterator TSqsService::AddQueue(co const TInstant now = TActivationContext::Now(); const TInstant timeToInsertCounters = createdTimestamp + TDuration::MilliSeconds(Cfg().GetQueueCountersExportDelayMs()); const bool insertCounters = now >= timeToInsertCounters; - auto ret = user->Queues_.insert(std::make_pair(queue, TQueueInfoPtr(new TQueueInfo(userName, queue, RootUrl_, leaderTabletId, customName, folderId, version, shardsCount, user->Counters_, SchemeCache_, user->QuoterResources_, insertCounters)))).first; + auto ret = user->Queues_.insert(std::make_pair(queue, TQueueInfoPtr(new TQueueInfo(userName, queue, RootUrl_, leaderTabletId, customName, folderId, version, shardsCount, user->Counters_, SchemeCache_, user->QuoterResources_, insertCounters)))).first; auto queueInfo = ret->second; - LeaderTabletIdToQueue_[leaderTabletId] = queueInfo; + LeaderTabletIdToQueue_[leaderTabletId] = queueInfo; user->QueueByNameAndFolder_.emplace(std::make_pair(customName, folderId), queueInfo); if (!insertCounters) { - Schedule(timeToInsertCounters - now, new TSqsEvents::TEvInsertQueueCounters(userName, queue, leaderTabletId)); + Schedule(timeToInsertCounters - now, new TSqsEvents::TEvInsertQueueCounters(userName, queue, leaderTabletId)); } { - auto requests = user->GetLeaderNodeRequests_.equal_range(queue); + auto requests = user->GetLeaderNodeRequests_.equal_range(queue); for (auto i = requests.first; i != requests.second; ++i) { auto& req = i->second; - RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Adding queue [" << req->Get()->UserName << "/" << req->Get()->QueueName << "] to sqs service. Move get leader node request to queue info"); - queueInfo->GetLeaderNodeRequests_.emplace(std::move(req)); + RLOG_SQS_REQ_DEBUG(req->Get()->RequestId, "Adding queue [" << req->Get()->UserName << "/" << req->Get()->QueueName << "] to sqs service. Move get leader node request to queue info"); + queueInfo->GetLeaderNodeRequests_.emplace(std::move(req)); } - user->GetLeaderNodeRequests_.erase(requests.first, requests.second); + user->GetLeaderNodeRequests_.erase(requests.first, requests.second); } { @@ -1087,13 +1087,13 @@ std::map<TString, TSqsService::TQueueInfoPtr>::iterator TSqsService::AddQueue(co user->GetQueueFolderIdAndCustomNameRequests_.erase(requests.first, requests.second); } - queueInfo->ConnectToLeaderTablet(); - LOG_SQS_DEBUG("Created queue record. Queue: [" << queue << "]. Leader tablet id: [" << leaderTabletId << "]. Pipe client actor: " << queueInfo->PipeClient_); + queueInfo->ConnectToLeaderTablet(); + LOG_SQS_DEBUG("Created queue record. Queue: [" << queue << "]. Leader tablet id: [" << leaderTabletId << "]. Pipe client actor: " << queueInfo->PipeClient_); return ret; } void TSqsService::AnswerNoUserToRequests() { - AnswerNoUserToRequests(GetLeaderNodeRequests_); + AnswerNoUserToRequests(GetLeaderNodeRequests_); AnswerNoUserToRequests(GetConfigurationRequests_); AnswerNoUserToRequests(GetQueueIdRequests_); AnswerNoUserToRequests(GetQueueFolderIdAndCustomNameRequests_); @@ -1101,14 +1101,14 @@ void TSqsService::AnswerNoUserToRequests() { } void TSqsService::AnswerNoQueueToRequests(const TUserInfoPtr& user) { - AnswerNoQueueToRequests(user, user->GetLeaderNodeRequests_); + AnswerNoQueueToRequests(user, user->GetLeaderNodeRequests_); AnswerNoQueueToRequests(user, user->GetConfigurationRequests_); AnswerNoQueueToRequests(user, user->GetQueueIdRequests_); AnswerNoQueueToRequests(user, user->GetQueueFolderIdAndCustomNameRequests_); } void TSqsService::AnswerErrorToRequests() { - AnswerErrorToRequests(nullptr, GetLeaderNodeRequests_); + AnswerErrorToRequests(nullptr, GetLeaderNodeRequests_); AnswerErrorToRequests(nullptr, GetConfigurationRequests_); AnswerErrorToRequests(nullptr, GetQueueIdRequests_); AnswerErrorToRequests(nullptr, GetQueueFolderIdAndCustomNameRequests_); @@ -1116,7 +1116,7 @@ void TSqsService::AnswerErrorToRequests() { } void TSqsService::AnswerErrorToRequests(const TUserInfoPtr& user) { - AnswerErrorToRequests(user, user->GetLeaderNodeRequests_); + AnswerErrorToRequests(user, user->GetLeaderNodeRequests_); AnswerErrorToRequests(user, user->GetConfigurationRequests_); AnswerErrorToRequests(user, user->GetQueueIdRequests_); AnswerErrorToRequests(user, user->GetQueueFolderIdAndCustomNameRequests_); @@ -1128,7 +1128,7 @@ void TSqsService::HandleWakeup(TEvWakeup::TPtr& ev) { switch (ev->Get()->Tag) { case LIST_USERS_WAKEUP_TAG: ScheduledRequestingUsersList_ = false; - if (TActivationContext::Now() < LastRequestUsersListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs())) { + if (TActivationContext::Now() < LastRequestUsersListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs())) { ScheduleRequestSqsUsersList(); } else { EarlyRequestUsersListBudget_ = Min(EarlyRequestUsersListBudget_ + 1, EARLY_REQUEST_USERS_LIST_MAX_BUDGET); @@ -1137,7 +1137,7 @@ void TSqsService::HandleWakeup(TEvWakeup::TPtr& ev) { break; case LIST_QUEUES_WAKEUP_TAG: ScheduledRequestingQueuesList_ = false; - if (TActivationContext::Now() < LastRequestQueuesListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs())) { + if (TActivationContext::Now() < LastRequestQueuesListTime_ + TDuration::MilliSeconds(GetLeadersDescriberUpdateTimeMs())) { ScheduleRequestSqsQueuesList(); } else { --EarlyRequestQueuesListMinBudget_; @@ -1171,37 +1171,37 @@ void TSqsService::HandleInsertQueueCounters(TSqsEvents::TEvInsertQueueCounters:: return; } const auto& queue = queueIt->second; - if (queue->LeaderTabletId_ != ev->Get()->LeaderTabletId) { - LOG_SQS_WARN("Don't insert queue [" << ev->Get()->Queue << "] counters: leader tablet is not as expected. Expected: " - << ev->Get()->LeaderTabletId << ". Real: " << queue->LeaderTabletId_); + if (queue->LeaderTabletId_ != ev->Get()->LeaderTabletId) { + LOG_SQS_WARN("Don't insert queue [" << ev->Get()->Queue << "] counters: leader tablet is not as expected. Expected: " + << ev->Get()->LeaderTabletId << ". Real: " << queue->LeaderTabletId_); return; } queue->Counters_->InsertCounters(); } -void TSqsService::IncLocalLeaderRef(const TActorId& referer, const TQueueInfoPtr& queueInfo, const TString& reason) { - LWPROBE(IncLeaderRef, queueInfo->UserName_, queueInfo->QueueName_, referer.ToString()); - const auto [iter, inserted] = LocalLeaderRefs_.emplace(referer, queueInfo); +void TSqsService::IncLocalLeaderRef(const TActorId& referer, const TQueueInfoPtr& queueInfo, const TString& reason) { + LWPROBE(IncLeaderRef, queueInfo->UserName_, queueInfo->QueueName_, referer.ToString()); + const auto [iter, inserted] = LocalLeaderRefs_.emplace(referer, queueInfo); if (inserted) { - LOG_SQS_TRACE("Inc local leader ref for actor " << referer); - queueInfo->IncLocalLeaderRef(reason); + LOG_SQS_TRACE("Inc local leader ref for actor " << referer); + queueInfo->IncLocalLeaderRef(reason); } else { - LWPROBE(IncLeaderRefAlreadyHasRef, queueInfo->UserName_, queueInfo->QueueName_, referer.ToString()); - LOG_SQS_WARN("Inc local leader ref for actor " << referer << ". Ignore because this actor already presents in referers set"); + LWPROBE(IncLeaderRefAlreadyHasRef, queueInfo->UserName_, queueInfo->QueueName_, referer.ToString()); + LOG_SQS_WARN("Inc local leader ref for actor " << referer << ". Ignore because this actor already presents in referers set"); } } -void TSqsService::DecLocalLeaderRef(const TActorId& referer, const TString& reason) { - LWPROBE(DecLeaderRef, referer.ToString()); - const auto iter = LocalLeaderRefs_.find(referer); - LOG_SQS_TRACE("Dec local leader ref for actor " << referer << ". Found: " << (iter != LocalLeaderRefs_.end())); - if (iter != LocalLeaderRefs_.end()) { +void TSqsService::DecLocalLeaderRef(const TActorId& referer, const TString& reason) { + LWPROBE(DecLeaderRef, referer.ToString()); + const auto iter = LocalLeaderRefs_.find(referer); + LOG_SQS_TRACE("Dec local leader ref for actor " << referer << ". Found: " << (iter != LocalLeaderRefs_.end())); + if (iter != LocalLeaderRefs_.end()) { auto queueInfo = iter->second; - queueInfo->DecLocalLeaderRef(reason); - LocalLeaderRefs_.erase(iter); + queueInfo->DecLocalLeaderRef(reason); + LocalLeaderRefs_.erase(iter); } else { - LWPROBE(DecLeaderRefNotInRefSet, referer.ToString()); + LWPROBE(DecLeaderRefNotInRefSet, referer.ToString()); } } @@ -1217,8 +1217,8 @@ void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetConfiguration::TPtr&& e GetConfigurationRequests_.emplace(ev->Get()->UserName, std::move(ev)); } -void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev) { - GetLeaderNodeRequests_.emplace(ev->Get()->UserName, std::move(ev)); +void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev) { + GetLeaderNodeRequests_.emplace(ev->Get()->UserName, std::move(ev)); } void TSqsService::InsertWaitingRequest(TSqsEvents::TEvCountQueues::TPtr&& ev) { @@ -1237,8 +1237,8 @@ void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetConfiguration::TPtr&& e userInfo->GetConfigurationRequests_.emplace(ev->Get()->QueueName, std::move(ev)); } -void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev, const TUserInfoPtr& userInfo) { - userInfo->GetLeaderNodeRequests_.emplace(ev->Get()->QueueName, std::move(ev)); +void TSqsService::InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev, const TUserInfoPtr& userInfo) { + userInfo->GetLeaderNodeRequests_.emplace(ev->Get()->QueueName, std::move(ev)); } void TSqsService::InsertWaitingRequest(TSqsEvents::TEvCountQueues::TPtr&& ev, const TUserInfoPtr& userInfo) { diff --git a/ydb/core/ymq/actor/service.h b/ydb/core/ymq/actor/service.h index cba59c004bf..caf091c24b8 100644 --- a/ydb/core/ymq/actor/service.h +++ b/ydb/core/ymq/actor/service.h @@ -49,10 +49,10 @@ private: void HandleExecuted(TSqsEvents::TEvExecuted::TPtr& ev); void HandlePipeClientConnected(TEvTabletPipe::TEvClientConnected::TPtr& ev); void HandlePipeClientDisconnected(TEvTabletPipe::TEvClientDestroyed::TPtr& ev); - void HandleGetLeaderNodeForQueueRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev); + void HandleGetLeaderNodeForQueueRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev); void HandleGetConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev); void HandleSqsRequest(TSqsEvents::TEvSqsRequest::TPtr& ev); // request from nodes with old version - void HandleQueueLeaderDecRef(TSqsEvents::TEvQueueLeaderDecRef::TPtr& ev); + void HandleQueueLeaderDecRef(TSqsEvents::TEvQueueLeaderDecRef::TPtr& ev); void HandleGetQueueId(TSqsEvents::TEvGetQueueId::TPtr& ev); void HandleGetQueueFolderIdAndCustomName(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr& ev); void HandleCountQueues(TSqsEvents::TEvCountQueues::TPtr& ev); @@ -71,7 +71,7 @@ private: TUsersMap::iterator MutableUserIter(const TString& userName, bool moveUserRequestsToUserRecord = true, bool* requestsWereMoved = nullptr); TUserInfoPtr MutableUser(const TString& userName, bool moveUserRequestsToUserRecord = true, bool* requestsWereMoved = nullptr); void RemoveUser(const TString& userName); - std::map<TString, TQueueInfoPtr>::iterator AddQueue(const TString& userName, const TString& queue, ui64 leaderTabletId, + std::map<TString, TQueueInfoPtr>::iterator AddQueue(const TString& userName, const TString& queue, ui64 leaderTabletId, const TString& customName, const TString& folderId, const ui64 version, const ui64 shardsCount, const TInstant createdTimestamp); @@ -81,11 +81,11 @@ private: void AnswerErrorToRequests(); void AnswerErrorToRequests(const TUserInfoPtr& user); - void AnswerLeaderlessConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo); + void AnswerLeaderlessConfiguration(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo); void ProcessConfigurationRequestForQueue(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo, const TQueueInfoPtr& queueInfo); - void IncLocalLeaderRef(const TActorId& referer, const TQueueInfoPtr& queueInfo, const TString& reason); - void DecLocalLeaderRef(const TActorId& referer, const TString& reason); + void IncLocalLeaderRef(const TActorId& referer, const TQueueInfoPtr& queueInfo, const TString& reason); + void DecLocalLeaderRef(const TActorId& referer, const TString& reason); template <class TEvent> TUserInfoPtr GetUserOrWait(TAutoPtr<TEvent>& ev); @@ -93,13 +93,13 @@ private: void InsertWaitingRequest(TSqsEvents::TEvGetQueueId::TPtr&& ev); void InsertWaitingRequest(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr&& ev); void InsertWaitingRequest(TSqsEvents::TEvGetConfiguration::TPtr&& ev); - void InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev); + void InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev); void InsertWaitingRequest(TSqsEvents::TEvCountQueues::TPtr&& ev); void InsertWaitingRequest(TSqsEvents::TEvGetQueueId::TPtr&& ev, const TUserInfoPtr& userInfo); void InsertWaitingRequest(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr&& ev, const TUserInfoPtr& userInfo); void InsertWaitingRequest(TSqsEvents::TEvGetConfiguration::TPtr&& ev, const TUserInfoPtr& userInfo); - void InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev, const TUserInfoPtr& userInfo); + void InsertWaitingRequest(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr&& ev, const TUserInfoPtr& userInfo); void InsertWaitingRequest(TSqsEvents::TEvCountQueues::TPtr&& ev, const TUserInfoPtr& userInfo); template <class TMultimap> @@ -111,13 +111,13 @@ private: template <class TMultimap> void AnswerErrorToRequests(const TUserInfoPtr& user, TMultimap& map); - void AnswerNotExists(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo); + void AnswerNotExists(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerNotExists(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerNotExists(TSqsEvents::TEvGetQueueId::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerNotExists(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerNotExists(TSqsEvents::TEvCountQueues::TPtr& ev, const TUserInfoPtr& userInfo); - void AnswerFailed(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo); + void AnswerFailed(TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerFailed(TSqsEvents::TEvGetConfiguration::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerFailed(TSqsEvents::TEvGetQueueId::TPtr& ev, const TUserInfoPtr& userInfo); void AnswerFailed(TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr& ev, const TUserInfoPtr& userInfo); @@ -127,7 +127,7 @@ private: void AnswerCountQueuesRequests(const TUserInfoPtr& user); - void NotifyLocalDeadLetterQueuesLeaders(const std::vector<TSqsEvents::TEvQueuesList::TQueueRecord>& sortedQueues) const; + void NotifyLocalDeadLetterQueuesLeaders(const std::vector<TSqsEvents::TEvQueuesList::TQueueRecord>& sortedQueues) const; void MakeAndRegisterYcEventsProcessor(); @@ -138,8 +138,8 @@ private: std::shared_ptr<TAlignedPagePoolCounters> AllocPoolCounters_; TIntrusivePtr<TUserCounters> AggregatedUserCounters_; TUsersMap Users_; - THashMap<ui64, TQueueInfoPtr> LeaderTabletIdToQueue_; - THashMap<TActorId, TQueueInfoPtr> LocalLeaderRefs_; // referer -> queue info + THashMap<ui64, TQueueInfoPtr> LeaderTabletIdToQueue_; + THashMap<TActorId, TQueueInfoPtr> LocalLeaderRefs_; // referer -> queue info TActorId SchemeCache_; TActorId QueuesListReader_; @@ -153,7 +153,7 @@ private: bool ScheduledRequestingQueuesList_ = false; i64 EarlyRequestQueuesListMinBudget_ = 0; // Defence from continuously requesting queues list. TInstant LastRequestQueuesListTime_; - THashMultiMap<TString, TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; // user name -> request + THashMultiMap<TString, TSqsEvents::TEvGetLeaderNodeForQueueRequest::TPtr> GetLeaderNodeRequests_; // user name -> request THashMultiMap<TString, TSqsEvents::TEvGetConfiguration::TPtr> GetConfigurationRequests_; // user name -> request THashMultiMap<TString, TSqsEvents::TEvGetQueueId::TPtr> GetQueueIdRequests_; // user name -> request THashMultiMap<TString, TSqsEvents::TEvGetQueueFolderIdAndCustomName::TPtr> GetQueueFolderIdAndCustomNameRequests_; // user name -> request diff --git a/ydb/core/ymq/actor/set_queue_attributes.cpp b/ydb/core/ymq/actor/set_queue_attributes.cpp index 185d28c5f80..df33ad99e6a 100644 --- a/ydb/core/ymq/actor/set_queue_attributes.cpp +++ b/ydb/core/ymq/actor/set_queue_attributes.cpp @@ -70,7 +70,7 @@ private: builder .User(UserName_) .Queue(GetQueueName()) - .QueueLeader(QueueLeader_) + .QueueLeader(QueueLeader_) .QueryId(SET_QUEUE_ATTRIBUTES_ID) .Counters(QueueCounters_) .RetryOnTimeout(); @@ -144,7 +144,7 @@ private: if (status == TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecComplete) { // OK RLOG_SQS_DEBUG("Sending clear attributes cache event for queue [" << UserName_ << "/" << GetQueueName() << "]"); - Send(QueueLeader_, MakeHolder<TSqsEvents::TEvClearQueueAttributesCache>()); + Send(QueueLeader_, MakeHolder<TSqsEvents::TEvClearQueueAttributesCache>()); } else { RLOG_SQS_WARN("Request failed: " << record); MakeError(result, NErrors::INTERNAL_FAILURE); diff --git a/ydb/core/ymq/actor/ya.make b/ydb/core/ymq/actor/ya.make index 627946e1653..070653bb577 100644 --- a/ydb/core/ymq/actor/ya.make +++ b/ydb/core/ymq/actor/ya.make @@ -38,7 +38,7 @@ SRCS( proxy_actor.cpp purge.cpp purge_queue.cpp - queue_leader.cpp + queue_leader.cpp receive_message.cpp retention.cpp schema.cpp diff --git a/ydb/core/ymq/base/counters.cpp b/ydb/core/ymq/base/counters.cpp index 92f65b5e4de..90a9f5000f8 100644 --- a/ydb/core/ymq/base/counters.cpp +++ b/ydb/core/ymq/base/counters.cpp @@ -266,7 +266,7 @@ static const auto QueueCountersDescriptor = TMemberCountersDescriptor(&TQueueCounters::RequestTimeouts, &TQueueCounters::RequestsThrottled, &TQueueCounters::QueueMasterStartProblems, - &TQueueCounters::QueueLeaderStartProblems, + &TQueueCounters::QueueLeaderStartProblems, &TQueueCounters::MessagesPurged, &TQueueCounters::MessageReceiveAttempts, &TQueueCounters::ClientMessageProcessing_Duration, @@ -537,7 +537,7 @@ TQueueCounters::TQueueCounters(const NKikimrConfig::TSqsConfig& cfg, InitCounters(); } -void TQueueCounters::InitCounters(bool forLeaderNode) { +void TQueueCounters::InitCounters(bool forLeaderNode) { if (!RequestTimeouts) { INIT_COUNTERS_COUPLE( QueueCounters, @@ -548,11 +548,11 @@ void TQueueCounters::InitCounters(bool forLeaderNode) { } - if (forLeaderNode) { + if (forLeaderNode) { INIT_COUNTER(QueueCounters.SqsCounters, RequestsThrottled, ELifetime::Expiring, EValueType::Derivative, ELaziness::OnStart); INIT_COUNTER(QueueCounters.SqsCounters, QueueMasterStartProblems, ELifetime::Persistent, EValueType::Derivative, ELaziness::OnStart); - INIT_COUNTER(QueueCounters.SqsCounters, QueueLeaderStartProblems, ELifetime::Persistent, EValueType::Derivative, ELaziness::OnStart); + INIT_COUNTER(QueueCounters.SqsCounters, QueueLeaderStartProblems, ELifetime::Persistent, EValueType::Derivative, ELaziness::OnStart); INIT_COUNTERS_COUPLE( QueueCounters, @@ -649,21 +649,21 @@ void TQueueCounters::InitCounters(bool forLeaderNode) { for (EAction action = static_cast<EAction>(EAction::Unknown + 1); action < EAction::ActionsArraySize; action = static_cast<EAction>(action + 1)) { if (IsActionForQueue(action)) { - if (forLeaderNode && IsProxyAction(action) || !forLeaderNode && !IsProxyAction(action)) { - SqsActionCounters[action].Init(*Cfg, QueueCounters.SqsCounters, action, forLeaderNode ? ELifetime::Expiring : ELifetime::Persistent); + if (forLeaderNode && IsProxyAction(action) || !forLeaderNode && !IsProxyAction(action)) { + SqsActionCounters[action].Init(*Cfg, QueueCounters.SqsCounters, action, forLeaderNode ? ELifetime::Expiring : ELifetime::Persistent); } } if (IsActionForQueueYMQ(action) && QueueCounters.YmqCounters && !AggregatedCounters) { - if (forLeaderNode && IsProxyAction(action) || !forLeaderNode && !IsProxyAction(action)) { + if (forLeaderNode && IsProxyAction(action) || !forLeaderNode && !IsProxyAction(action)) { YmqActionCounters[action].Init( *Cfg, QueueCounters.YmqCounters, action, METHOD_LABLE, ACTION_CNTR_PREFIX, - forLeaderNode ? ELifetime::Expiring : ELifetime::Persistent + forLeaderNode ? ELifetime::Expiring : ELifetime::Persistent ); } } } - DetailedCounters.Init(QueueCounters.SqsCounters, AllocPoolCounters, forLeaderNode); + DetailedCounters.Init(QueueCounters.SqsCounters, AllocPoolCounters, forLeaderNode); } void TQueueCounters::TDetailedCounters::Init(const TIntrusivePtr<NMonitoring::TDynamicCounters>& queueCounters, @@ -672,7 +672,7 @@ void TQueueCounters::TDetailedCounters::Init(const TIntrusivePtr<NMonitoring::TD INIT_HISTOGRAM_COUNTER(queueCounters, GetConfiguration_Duration, ELifetime::Expiring, DurationBucketsMs, ELaziness::OnDemand); } - if (forLeaderNode) { + if (forLeaderNode) { TransactionCounters = new TTransactionCounters(); TransactionCounters->Init(queueCounters, allocPoolCounters, true); @@ -724,9 +724,9 @@ void TQueueCounters::RemoveCounters() { couple.YmqCounters->RemoveSubgroup(QUEUE_LABEL, QueueName); } -TIntrusivePtr<TQueueCounters> TQueueCounters::GetCountersForLeaderNode() { +TIntrusivePtr<TQueueCounters> TQueueCounters::GetCountersForLeaderNode() { TIntrusivePtr<TQueueCounters> counters = new TQueueCounters(*this); - counters->NotLeaderNodeCounters = this; + counters->NotLeaderNodeCounters = this; counters->InitCounters(true); if (AggregatedParent) { counters->SetAggregatedParent(AggregatedParent); @@ -734,8 +734,8 @@ TIntrusivePtr<TQueueCounters> TQueueCounters::GetCountersForLeaderNode() { return counters; } -TIntrusivePtr<TQueueCounters> TQueueCounters::GetCountersForNotLeaderNode() { - return NotLeaderNodeCounters; +TIntrusivePtr<TQueueCounters> TQueueCounters::GetCountersForNotLeaderNode() { + return NotLeaderNodeCounters; } void TUserCounters::InitCounters(const TString& userName, const std::shared_ptr<TAlignedPagePoolCounters>& allocPoolCounters) { @@ -759,7 +759,7 @@ void TUserCounters::InitCounters(const TString& userName, const std::shared_ptr< // ToDo. Errors codes here. Will probably need this in Ymq counters further DetailedCounters.Init(UserCounters, allocPoolCounters, *Cfg); - AggregatedQueueCounters = CreateQueueCountersImpl(TOTAL_COUNTER_LABEL, Cfg->GetYandexCloudMode() ? TOTAL_COUNTER_LABEL : TString(), true, true)->GetCountersForLeaderNode(); + AggregatedQueueCounters = CreateQueueCountersImpl(TOTAL_COUNTER_LABEL, Cfg->GetYandexCloudMode() ? TOTAL_COUNTER_LABEL : TString(), true, true)->GetCountersForLeaderNode(); if (AggregatedParent) { AggregatedQueueCounters->SetAggregatedParent(AggregatedParent->AggregatedQueueCounters); diff --git a/ydb/core/ymq/base/counters.h b/ydb/core/ymq/base/counters.h index c26da5211d2..3c2667b2410 100644 --- a/ydb/core/ymq/base/counters.h +++ b/ydb/core/ymq/base/counters.h @@ -563,8 +563,8 @@ struct TQueueCounters : public TAtomicRefCount<TQueueCounters> { TLazyCachedCounter RequestTimeouts; // Requests that weren't processed in 10 minutes. They are almost sure hanged. TLazyCachedCounter request_timeouts_count_per_second; // Requests that weren't processed in 10 minutes. They are almost sure hanged. TLazyCachedCounter RequestsThrottled; // Request that ended with ThrottlingException - TLazyCachedCounter QueueMasterStartProblems; // TODO: remove after migration - TLazyCachedCounter QueueLeaderStartProblems; // Critical problems during leader start. + TLazyCachedCounter QueueMasterStartProblems; // TODO: remove after migration + TLazyCachedCounter QueueLeaderStartProblems; // Critical problems during leader start. TLazyCachedCounter MessagesPurged; TLazyCachedCounter purged_count_per_second; @@ -633,7 +633,7 @@ struct TQueueCounters : public TAtomicRefCount<TQueueCounters> { TIntrusivePtrCntrCouple FolderCounters; // Folder subtree in user tree (only for Yandex Cloud). TIntrusivePtrCntrCouple QueueCounters; // Queue subtree in user (or folder) tree. - // Creates counters for not leader node. + // Creates counters for not leader node. TQueueCounters(const NKikimrConfig::TSqsConfig& cfg, const TIntrusivePtrCntrCouple& sqsCoreCounters, const TUserCounters* userCounters, @@ -647,8 +647,8 @@ struct TQueueCounters : public TAtomicRefCount<TQueueCounters> { void InsertCounters(); void RemoveCounters(); - TIntrusivePtr<TQueueCounters> GetCountersForLeaderNode(); - TIntrusivePtr<TQueueCounters> GetCountersForNotLeaderNode(); + TIntrusivePtr<TQueueCounters> GetCountersForLeaderNode(); + TIntrusivePtr<TQueueCounters> GetCountersForNotLeaderNode(); void ShowDetailedCounters(TInstant deadline) { Y_ASSERT(ShowDetailedCountersDeadline); @@ -675,13 +675,13 @@ struct TQueueCounters : public TAtomicRefCount<TQueueCounters> { void SetAggregatedParent(const TIntrusivePtr<TQueueCounters>& parent); private: - void InitCounters(bool forLeaderNode = false); + void InitCounters(bool forLeaderNode = false); private: const NKikimrConfig::TSqsConfig* Cfg = nullptr; const TString QueueName; bool AggregatedCounters = false; - TIntrusivePtr<TQueueCounters> NotLeaderNodeCounters; + TIntrusivePtr<TQueueCounters> NotLeaderNodeCounters; std::shared_ptr<std::atomic<ui64>> ShowDetailedCountersDeadline = std::make_shared<std::atomic<ui64>>(0ul); // TInstant value std::shared_ptr<std::atomic<ui64>> UserShowDetailedCountersDeadline; TDetailedCounters DetailedCounters; diff --git a/ydb/core/ymq/base/debug_info.h b/ydb/core/ymq/base/debug_info.h index 44c89bbe866..8ead82ebed5 100644 --- a/ydb/core/ymq/base/debug_info.h +++ b/ydb/core/ymq/base/debug_info.h @@ -51,7 +51,7 @@ struct TDebugInfo { NDebug::TMultimapWithKeyValueErase<TString, class TMiniKqlExecutionActor*> ExecutorActors; // Queue activities by [username/queuename] - NDebug::TMultimapWithKeyValueErase<TString, class TQueueLeader*> QueueLeaders; + NDebug::TMultimapWithKeyValueErase<TString, class TQueueLeader*> QueueLeaders; NDebug::TMultimapWithKeyValueErase<TString, class TPurgeActor*> QueuePurgeActors; NDebug::TMultimapWithKeyValueErase<TString, class TRetentionActor*> QueueRetentionActors; NDebug::TMultimapWithKeyValueErase<TString, class TCleanupActor*> QueueCleanupActors; diff --git a/ydb/core/ymq/base/probes.h b/ydb/core/ymq/base/probes.h index aa299aa3ece..0fa0a46ffc2 100644 --- a/ydb/core/ymq/base/probes.h +++ b/ydb/core/ymq/base/probes.h @@ -3,22 +3,22 @@ #include <library/cpp/lwtrace/all.h> #define SQS_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ - PROBE(CreateLeader, GROUPS("SqsLeadersLifeTime"), \ + PROBE(CreateLeader, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString, TString, TString), \ NAMES("user", "queue", "reason")) \ - PROBE(DestroyLeader, GROUPS("SqsLeadersLifeTime"), \ + PROBE(DestroyLeader, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString, TString, TString), \ NAMES("user", "queue", "reason")) \ - PROBE(IncLeaderRef, GROUPS("SqsLeadersLifeTime"), \ + PROBE(IncLeaderRef, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString, TString, TString), \ NAMES("user", "queue", "referer")) \ - PROBE(DecLeaderRef, GROUPS("SqsLeadersLifeTime"), \ + PROBE(DecLeaderRef, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString), \ NAMES("rerefer")) \ - PROBE(IncLeaderRefAlreadyHasRef, GROUPS("SqsLeadersLifeTime"), \ + PROBE(IncLeaderRefAlreadyHasRef, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString, TString, TString), \ NAMES("user", "queue", "referer")) \ - PROBE(DecLeaderRefNotInRefSet, GROUPS("SqsLeadersLifeTime"), \ + PROBE(DecLeaderRefNotInRefSet, GROUPS("SqsLeadersLifeTime"), \ TYPES(TString), \ NAMES("rerefer")) \ \ diff --git a/ydb/core/ymq/base/table_info.h b/ydb/core/ymq/base/table_info.h index b352fc650aa..2ea37f8f0ed 100644 --- a/ydb/core/ymq/base/table_info.h +++ b/ydb/core/ymq/base/table_info.h @@ -31,7 +31,7 @@ struct TTable { bool Small = false; bool OnePartitionPerShard = false; // <queue_name>/State table - has one datashard per SQS-shard i64 Shard = 0; - bool HasLeaderTablet = false; + bool HasLeaderTablet = false; bool EnableAutosplit = false; ui64 SizeToSplit = 0; @@ -71,8 +71,8 @@ struct TTable { return *this; } - TTable& SetHasLeaderTablet(bool value = true) { - HasLeaderTablet = value; + TTable& SetHasLeaderTablet(bool value = true) { + HasLeaderTablet = value; return *this; } diff --git a/ydb/core/ymq/base/ut/counters_ut.cpp b/ydb/core/ymq/base/ut/counters_ut.cpp index f32d5ad2e4f..5ff3d26e36e 100644 --- a/ydb/core/ymq/base/ut/counters_ut.cpp +++ b/ydb/core/ymq/base/ut/counters_ut.cpp @@ -372,34 +372,34 @@ Y_UNIT_TEST_SUITE(QueueCountersTest) { ASSERT_STR_COUPLE_CONTAINS(CountersString(core), CountersString(ymqCounters), "my_queue"); } - void RemoveQueueCountersTest(bool leader, const TString& folderId) { + void RemoveQueueCountersTest(bool leader, const TString& folderId) { NKikimrConfig::TSqsConfig cfg; cfg.SetCreateLazyCounters(false); TIntrusivePtr<NMonitoring::TDynamicCounters> core = new NMonitoring::TDynamicCounters(); TIntrusivePtr<NMonitoring::TDynamicCounters> ymqCounters = new NMonitoring::TDynamicCounters(); TIntrusivePtr<TUserCounters> user = new TUserCounters(cfg, core, ymqCounters, nullptr, "my_user", nullptr); TIntrusivePtr<TQueueCounters> queue = user->CreateQueueCounters("my_queue", folderId, true); - if (leader) { - queue = queue->GetCountersForLeaderNode(); + if (leader) { + queue = queue->GetCountersForLeaderNode(); } ASSERT_STR_COUPLE_CONTAINS(CountersString(core), CountersString(ymqCounters), "queue=my_queue"); queue->RemoveCounters(); ASSERT_STR_COUPLE_DONT_CONTAIN(CountersString(core), CountersString(ymqCounters), "queue=my_queue"); } - Y_UNIT_TEST(RemoveQueueCountersNonLeaderWithoutFolderTest) { + Y_UNIT_TEST(RemoveQueueCountersNonLeaderWithoutFolderTest) { RemoveQueueCountersTest(false, ""); } - Y_UNIT_TEST(RemoveQueueCountersLeaderWithoutFolderTest) { + Y_UNIT_TEST(RemoveQueueCountersLeaderWithoutFolderTest) { RemoveQueueCountersTest(true, ""); } - Y_UNIT_TEST(RemoveQueueCountersNonLeaderWithFolderTest) { + Y_UNIT_TEST(RemoveQueueCountersNonLeaderWithFolderTest) { RemoveQueueCountersTest(false, "my_folder"); } - Y_UNIT_TEST(RemoveQueueCountersLeaderWithFolderTest) { + Y_UNIT_TEST(RemoveQueueCountersLeaderWithFolderTest) { RemoveQueueCountersTest(true, "my_folder"); } @@ -412,7 +412,7 @@ Y_UNIT_TEST_SUITE(QueueCountersTest) { TIntrusivePtr<TUserCounters> total = new TUserCounters(cfg, core, ymqCounters, nullptr, TOTAL_COUNTER_LABEL, nullptr); total->ShowDetailedCounters(TInstant::Max()); TIntrusivePtr<TUserCounters> user = new TUserCounters(cfg, core, ymqCounters, nullptr, "my_user", total); - TIntrusivePtr<TQueueCounters> queue = user->CreateQueueCounters("my_queue", cloudMode ? "my_folder" : "", true)->GetCountersForLeaderNode(); + TIntrusivePtr<TQueueCounters> queue = user->CreateQueueCounters("my_queue", cloudMode ? "my_folder" : "", true)->GetCountersForLeaderNode(); UNIT_ASSERT_STRING_CONTAINS(CountersString(core), "queue=my_queue"); queue->ShowDetailedCounters(TInstant::Max()); diff --git a/ydb/core/ymq/http/http.cpp b/ydb/core/ymq/http/http.cpp index 763b28ab093..5d0963bfb2e 100644 --- a/ydb/core/ymq/http/http.cpp +++ b/ydb/core/ymq/http/http.cpp @@ -551,7 +551,7 @@ bool THttpRequest::SetupRequest() { const bool enableQueueLeader = Parent_->Config.HasEnableQueueMaster() ? Parent_->Config.GetEnableQueueMaster() : Parent_->Config.GetEnableQueueLeader(); - + auto httpCallback = MakeHolder<THttpCallback>(this, *requestHolder); TAuthActorData data { diff --git a/ydb/core/ymq/queues/fifo/schema.cpp b/ydb/core/ymq/queues/fifo/schema.cpp index c892fc2b8cc..49e04d773b1 100644 --- a/ydb/core/ymq/queues/fifo/schema.cpp +++ b/ydb/core/ymq/queues/fifo/schema.cpp @@ -82,7 +82,7 @@ TVector<TTable> GetFifoTables() { list.push_back(TTable("Attributes") .SetColumns(AttributesColumns) .SetShard(-1) - .SetHasLeaderTablet()); + .SetHasLeaderTablet()); list.push_back(TTable("Data") .SetColumns(DataColumns) .SetShard(-1)); diff --git a/ydb/core/ymq/queues/std/schema.cpp b/ydb/core/ymq/queues/std/schema.cpp index ea963e2ada2..4ba75d17a23 100644 --- a/ydb/core/ymq/queues/std/schema.cpp +++ b/ydb/core/ymq/queues/std/schema.cpp @@ -69,7 +69,7 @@ TVector<TTable> GetStandardTables(ui64 shards, ui64 partitions, bool enableAutos .SetSmall(true) .SetInMemory(true) .SetShard(-1) - .SetHasLeaderTablet()); + .SetHasLeaderTablet()); list.push_back(TTable("State") .SetColumns(StateColumns) .SetSmall(true) diff --git a/ydb/core/yq/libs/actors/logging/log.h b/ydb/core/yq/libs/actors/logging/log.h index 7340b1fec5f..a5a938f0149 100644 --- a/ydb/core/yq/libs/actors/logging/log.h +++ b/ydb/core/yq/libs/actors/logging/log.h @@ -6,9 +6,9 @@ #define LOG_STREAMS_IMPL(level, component, logRecordStream) \ LOG_LOG_S(::NActors::TActivationContext::AsActorContext(), ::NActors::NLog:: Y_CAT(PRI_, level), ::NKikimrServices::component, logRecordStream); -#define LOG_STREAMS_IMPL_AS(actorSystem, level, component, logRecordStream) \ - LOG_LOG_S(actorSystem, ::NActors::NLog:: Y_CAT(PRI_, level), ::NKikimrServices::component, logRecordStream); - +#define LOG_STREAMS_IMPL_AS(actorSystem, level, component, logRecordStream) \ + LOG_LOG_S(actorSystem, ::NActors::NLog:: Y_CAT(PRI_, level), ::NKikimrServices::component, logRecordStream); + // Component: STREAMS. #define LOG_STREAMS_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS, logRecordStream) #define LOG_STREAMS_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS, logRecordStream) @@ -42,8 +42,8 @@ #define LOG_STREAMS_STORAGE_SERVICE_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_STORAGE_SERVICE, logRecordStream) #define LOG_STREAMS_STORAGE_SERVICE_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_STORAGE_SERVICE, logRecordStream) -#define LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(actorSystem, logRecordStream) LOG_STREAMS_IMPL_AS(actorSystem, DEBUG, STREAMS_STORAGE_SERVICE, logRecordStream) - +#define LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(actorSystem, logRecordStream) LOG_STREAMS_IMPL_AS(actorSystem, DEBUG, STREAMS_STORAGE_SERVICE, logRecordStream) + // Component: STREAMS_SCHEDULER_SERVICE. #define LOG_STREAMS_SCHEDULER_SERVICE_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_SCHEDULER_SERVICE, logRecordStream) #define LOG_STREAMS_SCHEDULER_SERVICE_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS_SCHEDULER_SERVICE, logRecordStream) @@ -88,16 +88,16 @@ #define LOG_STREAMS_CONTROL_PLANE_SERVICE_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_CONTROL_PLANE_SERVICE, logRecordStream) #define LOG_STREAMS_CONTROL_PLANE_SERVICE_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_CONTROL_PLANE_SERVICE, logRecordStream) -// Component: STREAMS_GRAND_LEADER_SERVICE. -#define LOG_STREAMS_GRAND_LEADER_SERVICE_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_CRIT(logRecordStream) LOG_STREAMS_IMPL(CRIT, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_ERROR(logRecordStream) LOG_STREAMS_IMPL(ERROR, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_WARN(logRecordStream) LOG_STREAMS_IMPL(WARN, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_NOTICE(logRecordStream) LOG_STREAMS_IMPL(NOTICE, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_INFO(logRecordStream) LOG_STREAMS_IMPL(INFO, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) -#define LOG_STREAMS_GRAND_LEADER_SERVICE_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +// Component: STREAMS_GRAND_LEADER_SERVICE. +#define LOG_STREAMS_GRAND_LEADER_SERVICE_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_CRIT(logRecordStream) LOG_STREAMS_IMPL(CRIT, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_ERROR(logRecordStream) LOG_STREAMS_IMPL(ERROR, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_WARN(logRecordStream) LOG_STREAMS_IMPL(WARN, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_NOTICE(logRecordStream) LOG_STREAMS_IMPL(NOTICE, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_INFO(logRecordStream) LOG_STREAMS_IMPL(INFO, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) +#define LOG_STREAMS_GRAND_LEADER_SERVICE_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_GRAND_LEADER_SERVICE, logRecordStream) // Component: STREAMS_META_STORAGE_SERVICE. #define LOG_STREAMS_META_STORAGE_SERVICE_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_META_STORAGE_SERVICE, logRecordStream) @@ -110,16 +110,16 @@ #define LOG_STREAMS_META_STORAGE_SERVICE_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_META_STORAGE_SERVICE, logRecordStream) #define LOG_STREAMS_META_STORAGE_SERVICE_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_META_STORAGE_SERVICE, logRecordStream) -// Component: STREAMS_GRAPH_LEADER. -#define LOG_STREAMS_GRAPH_LEADER_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_CRIT(logRecordStream) LOG_STREAMS_IMPL(CRIT, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_ERROR(logRecordStream) LOG_STREAMS_IMPL(ERROR, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_WARN(logRecordStream) LOG_STREAMS_IMPL(WARN, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_NOTICE(logRecordStream) LOG_STREAMS_IMPL(NOTICE, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_INFO(logRecordStream) LOG_STREAMS_IMPL(INFO, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_GRAPH_LEADER, logRecordStream) -#define LOG_STREAMS_GRAPH_LEADER_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_GRAPH_LEADER, logRecordStream) +// Component: STREAMS_GRAPH_LEADER. +#define LOG_STREAMS_GRAPH_LEADER_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_ALERT(logRecordStream) LOG_STREAMS_IMPL(ALERT, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_CRIT(logRecordStream) LOG_STREAMS_IMPL(CRIT, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_ERROR(logRecordStream) LOG_STREAMS_IMPL(ERROR, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_WARN(logRecordStream) LOG_STREAMS_IMPL(WARN, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_NOTICE(logRecordStream) LOG_STREAMS_IMPL(NOTICE, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_INFO(logRecordStream) LOG_STREAMS_IMPL(INFO, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_DEBUG(logRecordStream) LOG_STREAMS_IMPL(DEBUG, STREAMS_GRAPH_LEADER, logRecordStream) +#define LOG_STREAMS_GRAPH_LEADER_TRACE(logRecordStream) LOG_STREAMS_IMPL(TRACE, STREAMS_GRAPH_LEADER, logRecordStream) // Component: YQ_CONTROL_PLANE_STORAGE. #define LOG_YQ_CONTROL_PLANE_STORAGE_EMERG(logRecordStream) LOG_STREAMS_IMPL(EMERG, YQ_CONTROL_PLANE_STORAGE, logRecordStream) diff --git a/ydb/core/yq/libs/checkpoint_storage/checkpoint_storage.h b/ydb/core/yq/libs/checkpoint_storage/checkpoint_storage.h index e7ebce84b69..74923fc8169 100644 --- a/ydb/core/yq/libs/checkpoint_storage/checkpoint_storage.h +++ b/ydb/core/yq/libs/checkpoint_storage/checkpoint_storage.h @@ -1,84 +1,84 @@ -#pragma once - +#pragma once + #include <ydb/core/yq/libs/checkpointing_common/defs.h> #include <ydb/core/yq/libs/checkpoint_storage/proto/graph_description.pb.h> - + #include <ydb/library/yql/public/issue/yql_issue.h> - -#include <library/cpp/threading/future/core/future.h> - -#include <util/generic/ptr.h> - + +#include <library/cpp/threading/future/core/future.h> + +#include <util/generic/ptr.h> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -class ICheckpointStorage : public virtual TThrRefBase { -public: - using TGetCheckpointsResult = std::pair<TCheckpoints, NYql::TIssues>; - using TGetCoordinatorsResult = std::pair<TCoordinators, NYql::TIssues>; + +//////////////////////////////////////////////////////////////////////////////// + +class ICheckpointStorage : public virtual TThrRefBase { +public: + using TGetCheckpointsResult = std::pair<TCheckpoints, NYql::TIssues>; + using TGetCoordinatorsResult = std::pair<TCoordinators, NYql::TIssues>; using TAddToStateSizeResult = std::pair<ui64, NYql::TIssues>; using TGetTotalCheckpointsStateSizeResult = std::pair<ui64, NYql::TIssues>; using TCreateCheckpointResult = std::pair<TString, NYql::TIssues>; // graphDescId for subsequent usage. - - virtual NThreading::TFuture<NYql::TIssues> Init() = 0; - - virtual NThreading::TFuture<NYql::TIssues> RegisterGraphCoordinator( - const TCoordinatorId& coordinator) = 0; - - virtual NThreading::TFuture<TGetCoordinatorsResult> GetCoordinators() = 0; - + + virtual NThreading::TFuture<NYql::TIssues> Init() = 0; + + virtual NThreading::TFuture<NYql::TIssues> RegisterGraphCoordinator( + const TCoordinatorId& coordinator) = 0; + + virtual NThreading::TFuture<TGetCoordinatorsResult> GetCoordinators() = 0; + virtual NThreading::TFuture<TCreateCheckpointResult> CreateCheckpoint( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, const TString& graphDescId, - ECheckpointStatus status) = 0; - + ECheckpointStatus status) = 0; + virtual NThreading::TFuture<TCreateCheckpointResult> CreateCheckpoint( const TCoordinatorId& coordinator, const TCheckpointId& checkpointId, const NProto::TCheckpointGraphDescription& graphDesc, ECheckpointStatus status) = 0; - virtual NThreading::TFuture<NYql::TIssues> UpdateCheckpointStatus( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, - ECheckpointStatus newStatus, - ECheckpointStatus prevStatus) = 0; - - virtual NThreading::TFuture<NYql::TIssues> AbortCheckpoint( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId) = 0; - + virtual NThreading::TFuture<NYql::TIssues> UpdateCheckpointStatus( + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, + ECheckpointStatus newStatus, + ECheckpointStatus prevStatus) = 0; + + virtual NThreading::TFuture<NYql::TIssues> AbortCheckpoint( + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId) = 0; + virtual NThreading::TFuture<TGetCheckpointsResult> GetCheckpoints(const TString& graph) = 0; - virtual NThreading::TFuture<TGetCheckpointsResult> GetCheckpoints( + virtual NThreading::TFuture<TGetCheckpointsResult> GetCheckpoints( const TString& graph, const TVector<ECheckpointStatus>& statuses, ui64 limit, bool loadGraphDescription = false) = 0; - - // GC interface - // Note that no coordinator check required - // Also there is no check of current checkpoint state, it's - // up to caller to check at first - - virtual NThreading::TFuture<NYql::TIssues> DeleteGraph( - const TString& graphId) = 0; - - virtual NThreading::TFuture<NYql::TIssues> MarkCheckpointsGC( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) = 0; - - // will only delete checkpoints marked as GC - virtual NThreading::TFuture<NYql::TIssues> DeleteMarkedCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) = 0; - + + // GC interface + // Note that no coordinator check required + // Also there is no check of current checkpoint state, it's + // up to caller to check at first + + virtual NThreading::TFuture<NYql::TIssues> DeleteGraph( + const TString& graphId) = 0; + + virtual NThreading::TFuture<NYql::TIssues> MarkCheckpointsGC( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) = 0; + + // will only delete checkpoints marked as GC + virtual NThreading::TFuture<NYql::TIssues> DeleteMarkedCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) = 0; + virtual NThreading::TFuture<ICheckpointStorage::TAddToStateSizeResult> AddToStateSize( const TString& graphId, const TCheckpointId& checkpoint, ui64 size) = 0; virtual NThreading::TFuture<ICheckpointStorage::TGetTotalCheckpointsStateSizeResult> GetTotalCheckpointsStateSize(const TString& graphId) = 0; -}; - -using TCheckpointStoragePtr = TIntrusivePtr<ICheckpointStorage>; - +}; + +using TCheckpointStoragePtr = TIntrusivePtr<ICheckpointStorage>; + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/gc.cpp b/ydb/core/yq/libs/checkpoint_storage/gc.cpp index 709e10acdce..2a0e73ecb4f 100644 --- a/ydb/core/yq/libs/checkpoint_storage/gc.cpp +++ b/ydb/core/yq/libs/checkpoint_storage/gc.cpp @@ -1,182 +1,182 @@ -#include "gc.h" - +#include "gc.h" + #include <ydb/core/yq/libs/checkpointing_common/defs.h> #include <ydb/core/yq/libs/checkpoint_storage/events/events.h> #include <ydb/core/yq/libs/actors/logging/log.h> - -#include <library/cpp/actors/core/actor_bootstrapped.h> -#include <library/cpp/actors/core/hfunc.h> - + +#include <library/cpp/actors/core/actor_bootstrapped.h> +#include <library/cpp/actors/core/hfunc.h> + namespace NYq { - -using namespace NActors; -using namespace NThreading; - -using NYql::TIssues; - -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -struct TContext : public TThrRefBase { - enum EStage { - StageOk, - StageFailed, - }; - - TActorSystem* ActorSystem; - TCheckpointStoragePtr CheckpointStorage; - TStateStoragePtr StateStorage; - - TString GraphId; - TCheckpointId UpperBound; - - EStage Stage = StageOk; - - TContext(TActorSystem* actorSystem, - const TCheckpointStoragePtr& checkpointStorage, - const TStateStoragePtr& stateStorage, - const TString& graphId, - const TCheckpointId& upperBound) - : ActorSystem(actorSystem) - , CheckpointStorage(checkpointStorage) - , StateStorage(stateStorage) - , GraphId(graphId) - , UpperBound(upperBound) - { - } -}; - -using TContextPtr = TIntrusivePtr<TContext>; - -//////////////////////////////////////////////////////////////////////////////// - -class TActorGC : public TActorBootstrapped<TActorGC> { - TCheckpointStoragePtr CheckpointStorage; - TStateStoragePtr StateStorage; - -public: - TActorGC(const TCheckpointStoragePtr& checkpointStorage, const TStateStoragePtr& stateStorage); - - void Bootstrap(const TActorContext& ctx); - + +using namespace NActors; +using namespace NThreading; + +using NYql::TIssues; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +struct TContext : public TThrRefBase { + enum EStage { + StageOk, + StageFailed, + }; + + TActorSystem* ActorSystem; + TCheckpointStoragePtr CheckpointStorage; + TStateStoragePtr StateStorage; + + TString GraphId; + TCheckpointId UpperBound; + + EStage Stage = StageOk; + + TContext(TActorSystem* actorSystem, + const TCheckpointStoragePtr& checkpointStorage, + const TStateStoragePtr& stateStorage, + const TString& graphId, + const TCheckpointId& upperBound) + : ActorSystem(actorSystem) + , CheckpointStorage(checkpointStorage) + , StateStorage(stateStorage) + , GraphId(graphId) + , UpperBound(upperBound) + { + } +}; + +using TContextPtr = TIntrusivePtr<TContext>; + +//////////////////////////////////////////////////////////////////////////////// + +class TActorGC : public TActorBootstrapped<TActorGC> { + TCheckpointStoragePtr CheckpointStorage; + TStateStoragePtr StateStorage; + +public: + TActorGC(const TCheckpointStoragePtr& checkpointStorage, const TStateStoragePtr& stateStorage); + + void Bootstrap(const TActorContext& ctx); + static constexpr char ActorName[] = "YQ_GC_ACTOR"; -private: - STRICT_STFUNC(StateFunc, +private: + STRICT_STFUNC(StateFunc, HFunc(TEvCheckpointStorage::TEvNewCheckpointSucceeded, Handle); - ) - + ) + void Handle(TEvCheckpointStorage::TEvNewCheckpointSucceeded::TPtr& ev, const NActors::TActorContext& ctx); -}; - -TActorGC::TActorGC(const TCheckpointStoragePtr& checkpointStorage, const TStateStoragePtr& stateStorage) - : CheckpointStorage(checkpointStorage) - , StateStorage(stateStorage) -{ -} - -void TActorGC::Bootstrap(const TActorContext&) -{ - Become(&TActorGC::StateFunc); - - LOG_STREAMS_STORAGE_SERVICE_INFO("Successfully bootstrapped storage GC " << SelfId()); -} - +}; + +TActorGC::TActorGC(const TCheckpointStoragePtr& checkpointStorage, const TStateStoragePtr& stateStorage) + : CheckpointStorage(checkpointStorage) + , StateStorage(stateStorage) +{ +} + +void TActorGC::Bootstrap(const TActorContext&) +{ + Become(&TActorGC::StateFunc); + + LOG_STREAMS_STORAGE_SERVICE_INFO("Successfully bootstrapped storage GC " << SelfId()); +} + void TActorGC::Handle(TEvCheckpointStorage::TEvNewCheckpointSucceeded::TPtr& ev, const NActors::TActorContext& ctx) -{ - const auto* event = ev->Get(); - const auto& graphId = event->CoordinatorId.GraphId; - const auto& checkpointUpperBound = event->CheckpointId; - - LOG_STREAMS_STORAGE_SERVICE_DEBUG("GC received upperbound checkpoint " << checkpointUpperBound - << " for graph '" << graphId << "'"); - - // we need to: - // 1. Mark checkpoints as GC and continue only if succeeded - // 2. Delete states of marked checkpoints and continue only if succeeded - // 3. Delete marked checkpoints - - auto context = MakeIntrusive<TContext>( - ctx.ActorSystem(), - CheckpointStorage, - StateStorage, - graphId, - checkpointUpperBound); - - // 1-2. - auto future = CheckpointStorage->MarkCheckpointsGC(graphId, checkpointUpperBound).Apply( - [context] (const TFuture<TIssues>& future) { - auto issues = future.GetValue(); - if (!issues.Empty()) { - TStringStream ss; - ss << "GC failed to mark checkpoints of graph '" << context->GraphId - << "' up to " << context->UpperBound << ", issues:"; - issues.PrintTo(ss); - LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); - context->Stage = TContext::StageFailed; - return future; - } - - return context->StateStorage->DeleteCheckpoints(context->GraphId, context->UpperBound); - }); - - // 2-3. check StateStorage->DeleteCheckpoints and if OK DeleteMarkedCheckpoints - future.Apply( - [context] (const TFuture<TIssues>& future) { - if (context->Stage == TContext::StageFailed) { - return future; - } - - auto issues = future.GetValue(); - if (!issues.Empty()) { - TStringStream ss; - ss << "GC failed to delete states of checkpoints of graph '" << context->GraphId - << "' up to " << context->UpperBound << ", issues:"; - issues.PrintTo(ss); - LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); - context->Stage = TContext::StageFailed; - return future; - } - - return context->CheckpointStorage->DeleteMarkedCheckpoints(context->GraphId, context->UpperBound); - }); - - // this one just to debug log result - future.Apply( - [context] (const TFuture<TIssues>& future) { - if (context->Stage == TContext::StageFailed) { - return future; - } - - auto issues = future.GetValue(); - if (!issues.Empty()) { - TStringStream ss; - ss << "GC failed to delete marked checkpoints of graph '" << context->GraphId - << "' up to " << context->UpperBound << ", issues:"; - issues.PrintTo(ss); - LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); - context->Stage = TContext::StageFailed; - return future; - } - TStringStream ss; - ss << "GC deleted checkpoints of graph '" << context->GraphId - << "' up to " << context->UpperBound; - LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); - return future; - }); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - -std::unique_ptr<NActors::IActor> NewGC( - const NConfig::TCheckpointGcConfig&, - const TCheckpointStoragePtr& checkpointStorage, - const TStateStoragePtr& stateStorage) -{ - return std::unique_ptr<NActors::IActor>(new TActorGC(checkpointStorage, stateStorage)); -} - +{ + const auto* event = ev->Get(); + const auto& graphId = event->CoordinatorId.GraphId; + const auto& checkpointUpperBound = event->CheckpointId; + + LOG_STREAMS_STORAGE_SERVICE_DEBUG("GC received upperbound checkpoint " << checkpointUpperBound + << " for graph '" << graphId << "'"); + + // we need to: + // 1. Mark checkpoints as GC and continue only if succeeded + // 2. Delete states of marked checkpoints and continue only if succeeded + // 3. Delete marked checkpoints + + auto context = MakeIntrusive<TContext>( + ctx.ActorSystem(), + CheckpointStorage, + StateStorage, + graphId, + checkpointUpperBound); + + // 1-2. + auto future = CheckpointStorage->MarkCheckpointsGC(graphId, checkpointUpperBound).Apply( + [context] (const TFuture<TIssues>& future) { + auto issues = future.GetValue(); + if (!issues.Empty()) { + TStringStream ss; + ss << "GC failed to mark checkpoints of graph '" << context->GraphId + << "' up to " << context->UpperBound << ", issues:"; + issues.PrintTo(ss); + LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); + context->Stage = TContext::StageFailed; + return future; + } + + return context->StateStorage->DeleteCheckpoints(context->GraphId, context->UpperBound); + }); + + // 2-3. check StateStorage->DeleteCheckpoints and if OK DeleteMarkedCheckpoints + future.Apply( + [context] (const TFuture<TIssues>& future) { + if (context->Stage == TContext::StageFailed) { + return future; + } + + auto issues = future.GetValue(); + if (!issues.Empty()) { + TStringStream ss; + ss << "GC failed to delete states of checkpoints of graph '" << context->GraphId + << "' up to " << context->UpperBound << ", issues:"; + issues.PrintTo(ss); + LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); + context->Stage = TContext::StageFailed; + return future; + } + + return context->CheckpointStorage->DeleteMarkedCheckpoints(context->GraphId, context->UpperBound); + }); + + // this one just to debug log result + future.Apply( + [context] (const TFuture<TIssues>& future) { + if (context->Stage == TContext::StageFailed) { + return future; + } + + auto issues = future.GetValue(); + if (!issues.Empty()) { + TStringStream ss; + ss << "GC failed to delete marked checkpoints of graph '" << context->GraphId + << "' up to " << context->UpperBound << ", issues:"; + issues.PrintTo(ss); + LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); + context->Stage = TContext::StageFailed; + return future; + } + TStringStream ss; + ss << "GC deleted checkpoints of graph '" << context->GraphId + << "' up to " << context->UpperBound; + LOG_STREAMS_STORAGE_SERVICE_AS_DEBUG(*context->ActorSystem, ss.Str()); + return future; + }); +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + +std::unique_ptr<NActors::IActor> NewGC( + const NConfig::TCheckpointGcConfig&, + const TCheckpointStoragePtr& checkpointStorage, + const TStateStoragePtr& stateStorage) +{ + return std::unique_ptr<NActors::IActor>(new TActorGC(checkpointStorage, stateStorage)); +} + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/gc.h b/ydb/core/yq/libs/checkpoint_storage/gc.h index 9e04f6d3755..57063ed1bb9 100644 --- a/ydb/core/yq/libs/checkpoint_storage/gc.h +++ b/ydb/core/yq/libs/checkpoint_storage/gc.h @@ -1,21 +1,21 @@ -#pragma once - -#include "checkpoint_storage.h" -#include "state_storage.h" - +#pragma once + +#include "checkpoint_storage.h" +#include "state_storage.h" + #include <ydb/core/yq/libs/config/protos/checkpoint_coordinator.pb.h> - -#include <library/cpp/actors/core/actor.h> - -#include <memory> - + +#include <library/cpp/actors/core/actor.h> + +#include <memory> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -std::unique_ptr<NActors::IActor> NewGC( - const NConfig::TCheckpointGcConfig& config, - const TCheckpointStoragePtr& checkpointStorage, - const TStateStoragePtr& stateStorage); - + +//////////////////////////////////////////////////////////////////////////////// + +std::unique_ptr<NActors::IActor> NewGC( + const NConfig::TCheckpointGcConfig& config, + const TCheckpointStoragePtr& checkpointStorage, + const TStateStoragePtr& stateStorage); + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/state_storage.h b/ydb/core/yq/libs/checkpoint_storage/state_storage.h index 31af8a616d1..d1d89703de3 100644 --- a/ydb/core/yq/libs/checkpoint_storage/state_storage.h +++ b/ydb/core/yq/libs/checkpoint_storage/state_storage.h @@ -1,50 +1,50 @@ -#pragma once - +#pragma once + #include <ydb/core/yq/libs/checkpointing_common/defs.h> - + #include <ydb/library/yql/dq/proto/dq_checkpoint.pb.h> #include <ydb/library/yql/public/issue/yql_issue.h> - -#include <library/cpp/threading/future/core/future.h> - -#include <util/generic/ptr.h> - + +#include <library/cpp/threading/future/core/future.h> + +#include <util/generic/ptr.h> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -class IStateStorage : public virtual TThrRefBase { -public: + +//////////////////////////////////////////////////////////////////////////////// + +class IStateStorage : public virtual TThrRefBase { +public: using TGetStateResult = std::pair<std::vector<NYql::NDqProto::TComputeActorState>, NYql::TIssues>; - using TCountStatesResult = std::pair<size_t, NYql::TIssues>; - - virtual NThreading::TFuture<NYql::TIssues> Init() = 0; - - virtual NThreading::TFuture<NYql::TIssues> SaveState( - ui64 taskId, - const TString& graphId, - const TCheckpointId& checkpointId, + using TCountStatesResult = std::pair<size_t, NYql::TIssues>; + + virtual NThreading::TFuture<NYql::TIssues> Init() = 0; + + virtual NThreading::TFuture<NYql::TIssues> SaveState( + ui64 taskId, + const TString& graphId, + const TCheckpointId& checkpointId, const NYql::NDqProto::TComputeActorState& state) = 0; - - virtual NThreading::TFuture<TGetStateResult> GetState( + + virtual NThreading::TFuture<TGetStateResult> GetState( const std::vector<ui64>& taskIds, - const TString& graphId, - const TCheckpointId& checkpointId) = 0; - - virtual NThreading::TFuture<TCountStatesResult> CountStates( - const TString& graphId, - const TCheckpointId& checkpointId) = 0; - - // GC interface - - virtual NThreading::TFuture<NYql::TIssues> DeleteGraph( - const TString& graphId) = 0; - - virtual NThreading::TFuture<NYql::TIssues> DeleteCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointId) = 0; -}; - -using TStateStoragePtr = TIntrusivePtr<IStateStorage>; - + const TString& graphId, + const TCheckpointId& checkpointId) = 0; + + virtual NThreading::TFuture<TCountStatesResult> CountStates( + const TString& graphId, + const TCheckpointId& checkpointId) = 0; + + // GC interface + + virtual NThreading::TFuture<NYql::TIssues> DeleteGraph( + const TString& graphId) = 0; + + virtual NThreading::TFuture<NYql::TIssues> DeleteCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointId) = 0; +}; + +using TStateStoragePtr = TIntrusivePtr<IStateStorage>; + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/storage_proxy.cpp b/ydb/core/yq/libs/checkpoint_storage/storage_proxy.cpp index 653731d222b..07c8d5101a0 100644 --- a/ydb/core/yq/libs/checkpoint_storage/storage_proxy.cpp +++ b/ydb/core/yq/libs/checkpoint_storage/storage_proxy.cpp @@ -1,22 +1,22 @@ -#include "storage_proxy.h" - -#include "gc.h" +#include "storage_proxy.h" + +#include "gc.h" #include <ydb/core/yq/libs/config/protos/storage.pb.h> #include <ydb/core/yq/libs/control_plane_storage/util.h> -#include "ydb_checkpoint_storage.h" -#include "ydb_state_storage.h" - +#include "ydb_checkpoint_storage.h" +#include "ydb_state_storage.h" + #include <ydb/core/yq/libs/checkpointing_common/defs.h> #include <ydb/core/yq/libs/checkpoint_storage/events/events.h> #include <ydb/core/yq/libs/actors/logging/log.h> #include <ydb/core/yq/libs/ydb/util.h> - + #include <ydb/library/yql/dq/actors/compute/dq_compute_actor.h> -#include <library/cpp/actors/core/actor_bootstrapped.h> -#include <library/cpp/actors/core/hfunc.h> - +#include <library/cpp/actors/core/actor_bootstrapped.h> +#include <library/cpp/actors/core/hfunc.h> + #include <util/stream/file.h> #include <util/string/join.h> #include <util/string/strip.h> @@ -26,58 +26,58 @@ #define LOG_STORAGE_ASYNC_WARN(actorContext, stream) LOG_LOG_S(actorContext, ::NActors::NLog::PRI_WARN, ::NKikimrServices::STREAMS_STORAGE_SERVICE, stream); namespace NYq { - -using namespace NActors; - -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -class TStorageProxy : public TActorBootstrapped<TStorageProxy> { + +using namespace NActors; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +class TStorageProxy : public TActorBootstrapped<TStorageProxy> { NConfig::TCheckpointCoordinatorConfig Config; NConfig::TCommonConfig CommonConfig; NConfig::TYdbStorageConfig StorageConfig; - TCheckpointStoragePtr CheckpointStorage; - TStateStoragePtr StateStorage; - TActorId ActorGC; + TCheckpointStoragePtr CheckpointStorage; + TStateStoragePtr StateStorage; + TActorId ActorGC; NKikimr::TYdbCredentialsProviderFactory CredentialsProviderFactory; - -public: + +public: explicit TStorageProxy( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory); - + void Bootstrap(); - + static constexpr char ActorName[] = "YQ_STORAGE_PROXY"; -private: - STRICT_STFUNC(StateFunc, +private: + STRICT_STFUNC(StateFunc, hFunc(TEvCheckpointStorage::TEvRegisterCoordinatorRequest, Handle); hFunc(TEvCheckpointStorage::TEvCreateCheckpointRequest, Handle); hFunc(TEvCheckpointStorage::TEvSetCheckpointPendingCommitStatusRequest, Handle); hFunc(TEvCheckpointStorage::TEvCompleteCheckpointRequest, Handle); hFunc(TEvCheckpointStorage::TEvAbortCheckpointRequest, Handle); hFunc(TEvCheckpointStorage::TEvGetCheckpointsMetadataRequest, Handle); - + hFunc(NYql::NDq::TEvDqCompute::TEvSaveTaskState, Handle); hFunc(NYql::NDq::TEvDqCompute::TEvGetTaskState, Handle); - ) - + ) + void Handle(TEvCheckpointStorage::TEvRegisterCoordinatorRequest::TPtr& ev); - + void Handle(TEvCheckpointStorage::TEvCreateCheckpointRequest::TPtr& ev); void Handle(TEvCheckpointStorage::TEvSetCheckpointPendingCommitStatusRequest::TPtr& ev); void Handle(TEvCheckpointStorage::TEvCompleteCheckpointRequest::TPtr& ev); void Handle(TEvCheckpointStorage::TEvAbortCheckpointRequest::TPtr& ev); - + void Handle(TEvCheckpointStorage::TEvGetCheckpointsMetadataRequest::TPtr& ev); - + void Handle(NYql::NDq::TEvDqCompute::TEvSaveTaskState::TPtr& ev); void Handle(NYql::NDq::TEvDqCompute::TEvGetTaskState::TPtr& ev); -}; - +}; + static void FillDefaultParameters(NConfig::TCheckpointCoordinatorConfig& checkpointCoordinatorConfig, NConfig::TYdbStorageConfig& ydbStorageConfig) { auto& limits = *checkpointCoordinatorConfig.MutableStateStorageLimits(); if (!limits.GetMaxGraphCheckpointsSizeBytes()) { @@ -101,42 +101,42 @@ TStorageProxy::TStorageProxy( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) - : Config(config) + : Config(config) , CommonConfig(commonConfig) , StorageConfig(Config.GetStorage()) , CredentialsProviderFactory(credentialsProviderFactory) { FillDefaultParameters(Config, StorageConfig); -} - +} + void TStorageProxy::Bootstrap() { CheckpointStorage = NewYdbCheckpointStorage(StorageConfig, CredentialsProviderFactory, CreateEntityIdGenerator(CommonConfig.GetIdsPrefix())); auto issues = CheckpointStorage->Init().GetValueSync(); if (!issues.Empty()) { LOG_STREAMS_STORAGE_SERVICE_ERROR("Failed to init checkpoint storage: " << issues.ToOneLineString()); } - + StateStorage = NewYdbStateStorage(StorageConfig, CredentialsProviderFactory); issues = StateStorage->Init().GetValueSync(); if (!issues.Empty()) { LOG_STREAMS_STORAGE_SERVICE_ERROR("Failed to init checkpoint state storage: " << issues.ToOneLineString()); } - + if (Config.GetCheckpointGarbageConfig().GetEnabled()) { const auto& gcConfig = Config.GetCheckpointGarbageConfig(); - ActorGC = Register(NewGC(gcConfig, CheckpointStorage, StateStorage).release()); - } - - Become(&TStorageProxy::StateFunc); - - LOG_STREAMS_STORAGE_SERVICE_INFO("Successfully bootstrapped TStorageProxy " << SelfId() << " with connection to " + ActorGC = Register(NewGC(gcConfig, CheckpointStorage, StateStorage).release()); + } + + Become(&TStorageProxy::StateFunc); + + LOG_STREAMS_STORAGE_SERVICE_INFO("Successfully bootstrapped TStorageProxy " << SelfId() << " with connection to " << StorageConfig.GetEndpoint().data() << ":" << StorageConfig.GetDatabase().data()) -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvRegisterCoordinatorRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->CoordinatorId << "] Got TEvRegisterCoordinatorRequest") - + CheckpointStorage->RegisterGraphCoordinator(event->CoordinatorId) .Apply([coordinatorId = event->CoordinatorId, cookie = ev->Cookie, @@ -152,12 +152,12 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvRegisterCoordinatorRequest:: LOG_STORAGE_ASYNC_DEBUG(context, "[" << coordinatorId << "] Send TEvRegisterCoordinatorResponse") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvCreateCheckpointRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->CoordinatorId << "] [" << event->CheckpointId << "] Got TEvCreateCheckpointRequest") - + CheckpointStorage->GetTotalCheckpointsStateSize(event->CoordinatorId.GraphId) .Apply([checkpointId = event->CheckpointId, coordinatorId = event->CoordinatorId, @@ -225,10 +225,10 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvCreateCheckpointRequest::TPt LOG_STORAGE_ASYNC_DEBUG(context, "[" << coordinatorId << "] [" << checkpointId << "] Send TEvCreateCheckpointResponse"); context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvSetCheckpointPendingCommitStatusRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->CoordinatorId << "] [" << event->CheckpointId << "] Got TEvSetCheckpointPendingCommitStatusRequest") CheckpointStorage->UpdateCheckpointStatus(event->CoordinatorId, event->CheckpointId, ECheckpointStatus::PendingCommit, ECheckpointStatus::Pending) .Apply([checkpointId = event->CheckpointId, @@ -247,10 +247,10 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvSetCheckpointPendingCommitSt LOG_STORAGE_ASYNC_DEBUG(context, "[" << coordinatorId << "] [" << checkpointId << "] Send TEvSetCheckpointPendingCommitStatusResponse") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvCompleteCheckpointRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->CoordinatorId << "] [" << event->CheckpointId << "] Got TEvCompleteCheckpointRequest") CheckpointStorage->UpdateCheckpointStatus(event->CoordinatorId, event->CheckpointId, ECheckpointStatus::Completed, ECheckpointStatus::PendingCommit) .Apply([checkpointId = event->CheckpointId, @@ -276,10 +276,10 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvCompleteCheckpointRequest::T LOG_STORAGE_ASYNC_DEBUG(context, "[" << coordinatorId << "] [" << checkpointId << "] Send TEvCompleteCheckpointResponse") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvAbortCheckpointRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->CoordinatorId << "] [" << event->CheckpointId << "] Got TEvAbortCheckpointRequest") CheckpointStorage->AbortCheckpoint(event->CoordinatorId,event->CheckpointId) .Apply([checkpointId = event->CheckpointId, @@ -297,10 +297,10 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvAbortCheckpointRequest::TPtr LOG_STORAGE_ASYNC_DEBUG(context, "[" << coordinatorId << "] [" << checkpointId << "] Send TEvAbortCheckpointResponse") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(TEvCheckpointStorage::TEvGetCheckpointsMetadataRequest::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << event->GraphId << "] Got TEvGetCheckpointsMetadataRequest") CheckpointStorage->GetCheckpoints(event->GraphId, event->Statuses, event->Limit, event->LoadGraphDescription) .Apply([graphId = event->GraphId, @@ -315,10 +315,10 @@ void TStorageProxy::Handle(TEvCheckpointStorage::TEvGetCheckpointsMetadataReques LOG_STORAGE_ASYNC_DEBUG(context, "[" << graphId << "] Send TEvGetCheckpointsMetadataResponse") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(NYql::NDq::TEvDqCompute::TEvSaveTaskState::TPtr& ev) { - auto* event = ev->Get(); + auto* event = ev->Get(); const auto checkpointId = TCheckpointId(event->Checkpoint.GetGeneration(), event->Checkpoint.GetId()); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << checkpointId << "] Got TEvSaveTaskState: task " << event->TaskId); @@ -360,10 +360,10 @@ void TStorageProxy::Handle(NYql::NDq::TEvDqCompute::TEvSaveTaskState::TPtr& ev) LOG_STORAGE_ASYNC_DEBUG(context, "[" << checkpointId << "] Send TEvSaveTaskStateResult") context.Send(sender, response.release(), 0, cookie); }); -} - +} + void TStorageProxy::Handle(NYql::NDq::TEvDqCompute::TEvGetTaskState::TPtr& ev) { - const auto* event = ev->Get(); + const auto* event = ev->Get(); const auto checkpointId = TCheckpointId(event->Checkpoint.GetGeneration(), event->Checkpoint.GetId()); LOG_STREAMS_STORAGE_SERVICE_DEBUG("[" << checkpointId << "] Got TEvGetTaskState: tasks {" << JoinSeq(", ", event->TaskIds) << "}"); @@ -375,7 +375,7 @@ void TStorageProxy::Handle(NYql::NDq::TEvDqCompute::TEvGetTaskState::TPtr& ev) { sender = ev->Sender, context = TActivationContext::AsActorContext()](const NThreading::TFuture<IStateStorage::TGetStateResult>& resultFuture) { auto result = resultFuture.GetValue(); - + auto response = std::make_unique<NYql::NDq::TEvDqCompute::TEvGetTaskStateResult>(checkpointId, result.second, generation); std::swap(response->States, result.first); if (response->Issues) { @@ -384,18 +384,18 @@ void TStorageProxy::Handle(NYql::NDq::TEvDqCompute::TEvGetTaskState::TPtr& ev) { LOG_STORAGE_ASYNC_DEBUG(context, "[" << checkpointId << "] Send TEvGetTaskStateResult"); context.Send(sender, response.release(), 0, cookie); }); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + std::unique_ptr<NActors::IActor> NewStorageProxy( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) { return std::unique_ptr<NActors::IActor>(new TStorageProxy(config, commonConfig, credentialsProviderFactory)); -} - +} + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/storage_proxy.h b/ydb/core/yq/libs/checkpoint_storage/storage_proxy.h index 52efec04de7..c67d928a151 100644 --- a/ydb/core/yq/libs/checkpoint_storage/storage_proxy.h +++ b/ydb/core/yq/libs/checkpoint_storage/storage_proxy.h @@ -1,19 +1,19 @@ -#pragma once - +#pragma once + #include <ydb/core/yq/libs/config/protos/checkpoint_coordinator.pb.h> #include <ydb/core/yq/libs/config/protos/common.pb.h> - + #include <ydb/library/security/ydb_credentials_provider_factory.h> -#include <library/cpp/actors/core/actor.h> - -#include <memory> - +#include <library/cpp/actors/core/actor.h> + +#include <memory> + namespace NYq { - + std::unique_ptr<NActors::IActor> NewStorageProxy( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory); - + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/storage_service.cpp b/ydb/core/yq/libs/checkpoint_storage/storage_service.cpp index af93cdfb2cc..421c19d7fdb 100644 --- a/ydb/core/yq/libs/checkpoint_storage/storage_service.cpp +++ b/ydb/core/yq/libs/checkpoint_storage/storage_service.cpp @@ -1,19 +1,19 @@ -#include "storage_service.h" - -#include "storage_proxy.h" - +#include "storage_service.h" + +#include "storage_proxy.h" + namespace NYq { - -using namespace NActors; - -//////////////////////////////////////////////////////////////////////////////// - + +using namespace NActors; + +//////////////////////////////////////////////////////////////////////////////// + std::unique_ptr<NActors::IActor> NewCheckpointStorageService( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) { return NewStorageProxy(config, commonConfig, credentialsProviderFactory); -} - +} + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/storage_service.h b/ydb/core/yq/libs/checkpoint_storage/storage_service.h index b5d1d8d69db..5eab844545a 100644 --- a/ydb/core/yq/libs/checkpoint_storage/storage_service.h +++ b/ydb/core/yq/libs/checkpoint_storage/storage_service.h @@ -1,19 +1,19 @@ -#pragma once - +#pragma once + #include <ydb/core/yq/libs/config/protos/checkpoint_coordinator.pb.h> #include <ydb/core/yq/libs/config/protos/common.pb.h> - + #include <ydb/library/security/ydb_credentials_provider_factory.h> -#include <library/cpp/actors/core/actor.h> - -#include <memory> - +#include <library/cpp/actors/core/actor.h> + +#include <memory> + namespace NYq { - + std::unique_ptr<NActors::IActor> NewCheckpointStorageService( const NConfig::TCheckpointCoordinatorConfig& config, const NConfig::TCommonConfig& commonConfig, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory); - + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/ya.make b/ydb/core/yq/libs/checkpoint_storage/ya.make index 992e8bbbb1a..fc2f449e371 100644 --- a/ydb/core/yq/libs/checkpoint_storage/ya.make +++ b/ydb/core/yq/libs/checkpoint_storage/ya.make @@ -1,16 +1,16 @@ OWNER(g:yq) - -LIBRARY() - -SRCS( - gc.cpp - storage_proxy.cpp - storage_service.cpp - ydb_checkpoint_storage.cpp - ydb_state_storage.cpp -) - -PEERDIR( + +LIBRARY() + +SRCS( + gc.cpp + storage_proxy.cpp + storage_service.cpp + ydb_checkpoint_storage.cpp + ydb_state_storage.cpp +) + +PEERDIR( contrib/libs/fmt library/cpp/actors/core ydb/core/yq/libs/actors/logging @@ -24,12 +24,12 @@ PEERDIR( ydb/public/sdk/cpp/client/ydb_table ydb/library/yql/dq/actors/compute ydb/library/yql/dq/proto -) - +) + YQL_LAST_ABI_VERSION() -END() - +END() + RECURSE( events proto diff --git a/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.cpp b/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.cpp index be3e8bd7e47..7799b52daaf 100644 --- a/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.cpp +++ b/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.cpp @@ -1,34 +1,34 @@ -#include "ydb_checkpoint_storage.h" - +#include "ydb_checkpoint_storage.h" + #include <ydb/core/yq/libs/ydb/util.h> #include <ydb/core/yq/libs/ydb/ydb.h> - + #include <ydb/public/sdk/cpp/client/ydb_scheme/scheme.h> - -#include <util/stream/str.h> + +#include <util/stream/str.h> #include <util/string/builder.h> #include <util/string/printf.h> - + #include <fmt/format.h> namespace NYq { - -using namespace NThreading; -using namespace NYdb; -using namespace NYdb::NTable; - -using NYql::TIssues; - -namespace { - -//////////////////////////////////////////////////////////////////////////////// - + +using namespace NThreading; +using namespace NYdb; +using namespace NYdb::NTable; + +using NYql::TIssues; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + const char* const CoordinatorsSyncTable = "coordinators_sync"; const char* const CheckpointsMetadataTable = "checkpoints_metadata"; const char* const CheckpointsGraphsDescriptionTable = "checkpoints_graphs_description"; - -//////////////////////////////////////////////////////////////////////////////// - + +//////////////////////////////////////////////////////////////////////////////// + struct TCheckpointGraphDescriptionContext : public TThrRefBase { TString GraphDescId; const TMaybe<NProto::TCheckpointGraphDescription> NewGraphDescription; @@ -48,45 +48,45 @@ using TCheckpointGraphDescriptionContextPtr = TIntrusivePtr<TCheckpointGraphDesc //////////////////////////////////////////////////////////////////////////////// -struct TCheckpointContext : public TThrRefBase { - const TCheckpointId CheckpointId; - const ECheckpointStatus Status; // optional new status - const ECheckpointStatus ExpectedStatus; // optional expecrted current status, used only in some operations - - TGenerationContextPtr GenerationContext; +struct TCheckpointContext : public TThrRefBase { + const TCheckpointId CheckpointId; + const ECheckpointStatus Status; // optional new status + const ECheckpointStatus ExpectedStatus; // optional expecrted current status, used only in some operations + + TGenerationContextPtr GenerationContext; TCheckpointGraphDescriptionContextPtr CheckpointGraphDescriptionContext; IEntityIdGenerator::TPtr EntityIdGenerator; - - TCheckpointContext(const TCheckpointId& id, - ECheckpointStatus status, - ECheckpointStatus expected = ECheckpointStatus::Pending) - : CheckpointId(id) - , Status(status) - , ExpectedStatus(expected) - { - } -}; - -using TCheckpointContextPtr = TIntrusivePtr<TCheckpointContext>; - -//////////////////////////////////////////////////////////////////////////////// - -struct TGetCheckpointsContext : public TThrRefBase { - TCheckpoints Checkpoints; -}; - -using TGetCheckpointsContextPtr = TIntrusivePtr<TGetCheckpointsContext>; - -//////////////////////////////////////////////////////////////////////////////// - -struct TGetCoordinatorsContext : public TThrRefBase { - TCoordinators Coordinators; -}; - -using TGetCoordinatorsContextPtr = TIntrusivePtr<TGetCoordinatorsContext>; - -//////////////////////////////////////////////////////////////////////////////// - + + TCheckpointContext(const TCheckpointId& id, + ECheckpointStatus status, + ECheckpointStatus expected = ECheckpointStatus::Pending) + : CheckpointId(id) + , Status(status) + , ExpectedStatus(expected) + { + } +}; + +using TCheckpointContextPtr = TIntrusivePtr<TCheckpointContext>; + +//////////////////////////////////////////////////////////////////////////////// + +struct TGetCheckpointsContext : public TThrRefBase { + TCheckpoints Checkpoints; +}; + +using TGetCheckpointsContextPtr = TIntrusivePtr<TGetCheckpointsContext>; + +//////////////////////////////////////////////////////////////////////////////// + +struct TGetCoordinatorsContext : public TThrRefBase { + TCoordinators Coordinators; +}; + +using TGetCoordinatorsContextPtr = TIntrusivePtr<TGetCoordinatorsContext>; + +//////////////////////////////////////////////////////////////////////////////// + struct TAddToStateSizeContext : public TThrRefBase { ui64 Size = 0; }; @@ -99,53 +99,53 @@ struct TGetTotalCheckpointsStateSizeContext : public TThrRefBase { //////////////////////////////////////////////////////////////////////////////// -TFuture<TDataQueryResult> SelectGraphCoordinators(const TGenerationContextPtr& context) -{ - // TODO: use prepared queries - - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - - SELECT * - FROM %s; - )", context->TablePathPrefix.c_str(), CoordinatorsSyncTable); - - return context->Session.ExecuteDataQuery( - query, - TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); -} - -TFuture<TStatus> ProcessCoordinators( - const TDataQueryResult& selectResult, - const TGenerationContextPtr&, - const TGetCoordinatorsContextPtr& getContext) -{ - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - TResultSetParser parser(selectResult.GetResultSet(0)); - - while (parser.TryNextRow()) { - getContext->Coordinators.emplace_back( - *parser.ColumnParser("graph_id").GetOptionalString(), - *parser.ColumnParser("generation").GetOptionalUint64()); - } - - return MakeFuture<TStatus>(selectResult); -} - -TFuture<TStatus> CreateCheckpoint(const TCheckpointContextPtr& context) { - // TODO: use prepared query - - const auto& generationContext = context->GenerationContext; +TFuture<TDataQueryResult> SelectGraphCoordinators(const TGenerationContextPtr& context) +{ + // TODO: use prepared queries + + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + + SELECT * + FROM %s; + )", context->TablePathPrefix.c_str(), CoordinatorsSyncTable); + + return context->Session.ExecuteDataQuery( + query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); +} + +TFuture<TStatus> ProcessCoordinators( + const TDataQueryResult& selectResult, + const TGenerationContextPtr&, + const TGetCoordinatorsContextPtr& getContext) +{ + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + TResultSetParser parser(selectResult.GetResultSet(0)); + + while (parser.TryNextRow()) { + getContext->Coordinators.emplace_back( + *parser.ColumnParser("graph_id").GetOptionalString(), + *parser.ColumnParser("generation").GetOptionalUint64()); + } + + return MakeFuture<TStatus>(selectResult); +} + +TFuture<TStatus> CreateCheckpoint(const TCheckpointContextPtr& context) { + // TODO: use prepared query + + const auto& generationContext = context->GenerationContext; const auto& graphDescContext = context->CheckpointGraphDescriptionContext; - + TStringBuilder query; using namespace fmt::literals; const TString firstPart = fmt::format(R"sql( - --!syntax_v1 + --!syntax_v1 PRAGMA TablePathPrefix("{table_path_prefix}"); DECLARE $ts AS Timestamp; DECLARE $graph_id AS String; @@ -162,9 +162,9 @@ TFuture<TStatus> CreateCheckpoint(const TCheckpointContextPtr& context) { "checkpoints_metadata_table_name"_a = CheckpointsMetadataTable, "optional_graph_description_declaration"_a = graphDescContext->NewGraphDescription ? "DECLARE $graph_description AS String;" : "" ); - + query << firstPart; - + NYdb::TParamsBuilder params; params .AddParam("$graph_id") @@ -220,43 +220,43 @@ TFuture<TStatus> CreateCheckpoint(const TCheckpointContextPtr& context) { query << graphDescriptionPart; } - auto ttxControl = TTxControl::Tx(*generationContext->Transaction).CommitTx(); + auto ttxControl = TTxControl::Tx(*generationContext->Transaction).CommitTx(); return generationContext->Session.ExecuteDataQuery(query, ttxControl, params.Build()).Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); -} - -TFuture<TStatus> UpdateCheckpoint(const TCheckpointContextPtr& context) { - const auto& generationContext = context->GenerationContext; - - // TODO: use prepared query - - // TODO: UPSERT VS UPDATE (especially with WHERE status = X) - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - $ts = cast(%lu as Timestamp); - + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); +} + +TFuture<TStatus> UpdateCheckpoint(const TCheckpointContextPtr& context) { + const auto& generationContext = context->GenerationContext; + + // TODO: use prepared query + + // TODO: UPSERT VS UPDATE (especially with WHERE status = X) + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + $ts = cast(%lu as Timestamp); + UPSERT INTO %s (graph_id, coordinator_generation, seq_no, status, modified_by) VALUES - ("%s", %lu, %lu, %u, $ts); - )", generationContext->TablePathPrefix.c_str(), - TInstant::Now().MicroSeconds(), - CheckpointsMetadataTable, - generationContext->PrimaryKey.c_str(), + ("%s", %lu, %lu, %u, $ts); + )", generationContext->TablePathPrefix.c_str(), + TInstant::Now().MicroSeconds(), + CheckpointsMetadataTable, + generationContext->PrimaryKey.c_str(), context->CheckpointId.CoordinatorGeneration, context->CheckpointId.SeqNo, - (ui32)context->Status); - - auto ttxControl = TTxControl::Tx(*generationContext->Transaction).CommitTx(); - return generationContext->Session.ExecuteDataQuery(query, ttxControl).Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); -} - + (ui32)context->Status); + + auto ttxControl = TTxControl::Tx(*generationContext->Transaction).CommitTx(); + return generationContext->Session.ExecuteDataQuery(query, ttxControl).Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); +} + TFuture<TDataQueryResult> SelectGraphDescId(const TCheckpointContextPtr& context) { const auto& generationContext = context->GenerationContext; const auto& graphDescContext = context->CheckpointGraphDescriptionContext; @@ -301,17 +301,17 @@ TFuture<TStatus> GenerateGraphDescId(const TCheckpointContextPtr& context) { }); } -TFuture<TStatus> CreateCheckpointWrapper( - const TFuture<TStatus>& generationFuture, - const TCheckpointContextPtr& context) -{ - return generationFuture.Apply( - [context] (const TFuture<TStatus>& generationFuture) { - auto generationSelect = generationFuture.GetValue(); - if (!generationSelect.IsSuccess()) { - return MakeFuture(generationSelect); - } - +TFuture<TStatus> CreateCheckpointWrapper( + const TFuture<TStatus>& generationFuture, + const TCheckpointContextPtr& context) +{ + return generationFuture.Apply( + [context] (const TFuture<TStatus>& generationFuture) { + auto generationSelect = generationFuture.GetValue(); + if (!generationSelect.IsSuccess()) { + return MakeFuture(generationSelect); + } + return GenerateGraphDescId(context) .Apply( [context](const TFuture<TStatus>& result) { @@ -320,11 +320,11 @@ TFuture<TStatus> CreateCheckpointWrapper( } return CreateCheckpoint(context); }); - }); -} - + }); +} + TFuture<TDataQueryResult> SelectGraphCheckpoints(const TGenerationContextPtr& context, const TVector<ECheckpointStatus>& statuses, ui64 limit, TExecDataQuerySettings settings, bool loadGraphDescription) -{ +{ NYdb::TParamsBuilder paramsBuilder; if (statuses) { auto& statusesParam = paramsBuilder.AddParam("$statuses").BeginList(); @@ -333,7 +333,7 @@ TFuture<TDataQueryResult> SelectGraphCheckpoints(const TGenerationContextPtr& co } statusesParam.EndList().Build(); } - + paramsBuilder.AddParam("$graph_id").String(context->PrimaryKey).Build(); if (limit < std::numeric_limits<ui64>::max()) { paramsBuilder.AddParam("$limit").Uint64(limit).Build(); @@ -353,10 +353,10 @@ TFuture<TDataQueryResult> SelectGraphCheckpoints(const TGenerationContextPtr& co } const TString query = fmt::format(R"sql( - --!syntax_v1 + --!syntax_v1 PRAGMA TablePathPrefix("{table_path_prefix}"); PRAGMA AnsiInForEmptyOrNullableItemsCollections; - + DECLARE $graph_id AS String; {optional_statuses_declaration} {optional_limit_declaration} @@ -384,35 +384,35 @@ TFuture<TDataQueryResult> SelectGraphCheckpoints(const TGenerationContextPtr& co "graph_description_field"_a = loadGraphDescription ? "desc.graph_description AS graph_description," : "", "join"_a = join ); - - return context->Session.ExecuteDataQuery( - query, + + return context->Session.ExecuteDataQuery( + query, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params, settings); -} - -TFuture<TStatus> ProcessCheckpoints( - const TDataQueryResult& selectResult, - const TGenerationContextPtr& context, +} + +TFuture<TStatus> ProcessCheckpoints( + const TDataQueryResult& selectResult, + const TGenerationContextPtr& context, const TGetCheckpointsContextPtr& getContext, bool loadGraphDescription) -{ - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - TResultSetParser parser(selectResult.GetResultSet(0)); - - while (parser.TryNextRow()) { - TCheckpointId checkpointId( +{ + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + TResultSetParser parser(selectResult.GetResultSet(0)); + + while (parser.TryNextRow()) { + TCheckpointId checkpointId( *parser.ColumnParser("coordinator_generation").GetOptionalUint64(), *parser.ColumnParser("seq_no").GetOptionalUint64()); - - getContext->Checkpoints.emplace_back( - context->PrimaryKey, - checkpointId, - ECheckpointStatus(*parser.ColumnParser("status").GetOptionalUint8()), + + getContext->Checkpoints.emplace_back( + context->PrimaryKey, + checkpointId, + ECheckpointStatus(*parser.ColumnParser("status").GetOptionalUint8()), *parser.ColumnParser("created_by").GetOptionalTimestamp(), *parser.ColumnParser("modified_by").GetOptionalTimestamp()); @@ -429,180 +429,180 @@ TFuture<TStatus> ProcessCheckpoints( graphParams.Swap(graphDesc.MutableGraph()); } } - } - - return MakeFuture<TStatus>(selectResult); -} - -TFuture<TDataQueryResult> SelectCheckpoint(const TCheckpointContextPtr& context) -{ - // TODO: use prepared queries - - const auto& generationContext = context->GenerationContext; - - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - - SELECT status - FROM %s + } + + return MakeFuture<TStatus>(selectResult); +} + +TFuture<TDataQueryResult> SelectCheckpoint(const TCheckpointContextPtr& context) +{ + // TODO: use prepared queries + + const auto& generationContext = context->GenerationContext; + + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + + SELECT status + FROM %s WHERE graph_id = "%s" AND coordinator_generation = %lu AND seq_no = %lu; - )", generationContext->TablePathPrefix.c_str(), - CheckpointsMetadataTable, + )", generationContext->TablePathPrefix.c_str(), + CheckpointsMetadataTable, generationContext->PrimaryKey.c_str(), context->CheckpointId.CoordinatorGeneration, context->CheckpointId.SeqNo); - - return generationContext->Session.ExecuteDataQuery( - query, - TTxControl::Tx(*generationContext->Transaction)); -} - -TFuture<TStatus> CheckCheckpoint( - const TDataQueryResult& selectResult, - const TCheckpointContextPtr& context) -{ - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - TResultSetParser parser(selectResult.GetResultSet(0)); - - ECheckpointStatus statusRead; - if (parser.TryNextRow()) { - statusRead = static_cast<ECheckpointStatus>(*parser.ColumnParser("status").GetOptionalUint8()); - } else { - TIssues issues; - TStringStream ss; - ss << "Failed to select checkpoint '" << context->CheckpointId << "'"; - - const auto& stats = selectResult.GetStats(); - if (stats) { - ss << ", stats: " << stats->ToString(); - } - - // TODO: print status, etc - - // we use GENERIC_ERROR, because not sure if NOT_FOUND non-retrieable - // also severity is error, because user expects checkpoint to be existed - - return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); - } - - if (statusRead == ECheckpointStatus::GC) { - TIssues issues; - TStringStream ss; - ss << "Selected checkpoint '" << context->CheckpointId - << "' is owned by GC"; - - return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); - } - - bool isAbort = context->Status == ECheckpointStatus::Aborted; - if (!isAbort && statusRead != context->ExpectedStatus) { - TIssues issues; - TStringStream ss; - ss << "Selected checkpoint '" << context->CheckpointId - << "' with status " << statusRead - << ", while expected " << context->ExpectedStatus; - - return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); - } - - return MakeFuture<TStatus>(selectResult); -} - -TFuture<TStatus> SelectCheckpointWithCheck(const TCheckpointContextPtr& context) -{ - auto future = SelectCheckpoint(context); - return future.Apply( - [context] (const TFuture<TDataQueryResult>& future) { - return CheckCheckpoint(future.GetValue(), context); - }); -} - -TFuture<TStatus> UpdateCheckpointWithCheckWrapper( - const TFuture<TStatus>& generationFuture, - const TCheckpointContextPtr& context) -{ - return generationFuture.Apply( - [context] (const TFuture<TStatus>& generationFuture) { - auto generationSelect = generationFuture.GetValue(); - if (!generationSelect.IsSuccess()) { - return MakeFuture(generationSelect); - } - - auto future = SelectCheckpointWithCheck(context); - return future.Apply( - [context] (const TFuture<TStatus>& selectFuture) { - auto selectResult = selectFuture.GetValue(); - if (!selectResult.IsSuccess()) { - return MakeFuture(selectResult); - } - - return UpdateCheckpoint(context); - }); - }); -} - -//////////////////////////////////////////////////////////////////////////////// - -class TCheckpointStorage : public ICheckpointStorage { - TYdbConnectionPtr YdbConnection; + + return generationContext->Session.ExecuteDataQuery( + query, + TTxControl::Tx(*generationContext->Transaction)); +} + +TFuture<TStatus> CheckCheckpoint( + const TDataQueryResult& selectResult, + const TCheckpointContextPtr& context) +{ + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + TResultSetParser parser(selectResult.GetResultSet(0)); + + ECheckpointStatus statusRead; + if (parser.TryNextRow()) { + statusRead = static_cast<ECheckpointStatus>(*parser.ColumnParser("status").GetOptionalUint8()); + } else { + TIssues issues; + TStringStream ss; + ss << "Failed to select checkpoint '" << context->CheckpointId << "'"; + + const auto& stats = selectResult.GetStats(); + if (stats) { + ss << ", stats: " << stats->ToString(); + } + + // TODO: print status, etc + + // we use GENERIC_ERROR, because not sure if NOT_FOUND non-retrieable + // also severity is error, because user expects checkpoint to be existed + + return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); + } + + if (statusRead == ECheckpointStatus::GC) { + TIssues issues; + TStringStream ss; + ss << "Selected checkpoint '" << context->CheckpointId + << "' is owned by GC"; + + return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); + } + + bool isAbort = context->Status == ECheckpointStatus::Aborted; + if (!isAbort && statusRead != context->ExpectedStatus) { + TIssues issues; + TStringStream ss; + ss << "Selected checkpoint '" << context->CheckpointId + << "' with status " << statusRead + << ", while expected " << context->ExpectedStatus; + + return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); + } + + return MakeFuture<TStatus>(selectResult); +} + +TFuture<TStatus> SelectCheckpointWithCheck(const TCheckpointContextPtr& context) +{ + auto future = SelectCheckpoint(context); + return future.Apply( + [context] (const TFuture<TDataQueryResult>& future) { + return CheckCheckpoint(future.GetValue(), context); + }); +} + +TFuture<TStatus> UpdateCheckpointWithCheckWrapper( + const TFuture<TStatus>& generationFuture, + const TCheckpointContextPtr& context) +{ + return generationFuture.Apply( + [context] (const TFuture<TStatus>& generationFuture) { + auto generationSelect = generationFuture.GetValue(); + if (!generationSelect.IsSuccess()) { + return MakeFuture(generationSelect); + } + + auto future = SelectCheckpointWithCheck(context); + return future.Apply( + [context] (const TFuture<TStatus>& selectFuture) { + auto selectResult = selectFuture.GetValue(); + if (!selectResult.IsSuccess()) { + return MakeFuture(selectResult); + } + + return UpdateCheckpoint(context); + }); + }); +} + +//////////////////////////////////////////////////////////////////////////////// + +class TCheckpointStorage : public ICheckpointStorage { + TYdbConnectionPtr YdbConnection; const NConfig::TYdbStorageConfig Config; - -public: + +public: explicit TCheckpointStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory, const IEntityIdGenerator::TPtr& entityIdGenerator); - ~TCheckpointStorage() = default; - - TFuture<TIssues> Init() override; - - TFuture<TIssues> RegisterGraphCoordinator(const TCoordinatorId& coordinator) override; - - TFuture<TGetCoordinatorsResult> GetCoordinators() override; - + ~TCheckpointStorage() = default; + + TFuture<TIssues> Init() override; + + TFuture<TIssues> RegisterGraphCoordinator(const TCoordinatorId& coordinator) override; + + TFuture<TGetCoordinatorsResult> GetCoordinators() override; + TFuture<TCreateCheckpointResult> CreateCheckpoint( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, const TString& graphDescId, - ECheckpointStatus status) override; - + ECheckpointStatus status) override; + TFuture<TCreateCheckpointResult> CreateCheckpoint( const TCoordinatorId& coordinator, const TCheckpointId& checkpointId, const NProto::TCheckpointGraphDescription& graphDesc, ECheckpointStatus status) override; - TFuture<TIssues> UpdateCheckpointStatus( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, - ECheckpointStatus newStatus, - ECheckpointStatus prevStatus) override; - - TFuture<TIssues> AbortCheckpoint( - const TCoordinatorId& coordinator, + TFuture<TIssues> UpdateCheckpointStatus( + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, + ECheckpointStatus newStatus, + ECheckpointStatus prevStatus) override; + + TFuture<TIssues> AbortCheckpoint( + const TCoordinatorId& coordinator, const TCheckpointId& checkpointId) override; - - TFuture<TGetCheckpointsResult> GetCheckpoints( - const TString& graph) override; - + + TFuture<TGetCheckpointsResult> GetCheckpoints( + const TString& graph) override; + TFuture<TGetCheckpointsResult> GetCheckpoints( const TString& graph, const TVector<ECheckpointStatus>& statuses, ui64 limit, bool loadGraphDescription) override; - TFuture<TIssues> DeleteGraph( - const TString& graphId) override; - - TFuture<TIssues> MarkCheckpointsGC( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) override; - - TFuture<TIssues> DeleteMarkedCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) override; + TFuture<TIssues> DeleteGraph( + const TString& graphId) override; + + TFuture<TIssues> MarkCheckpointsGC( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) override; + + TFuture<TIssues> DeleteMarkedCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) override; TFuture<ICheckpointStorage::TAddToStateSizeResult> AddToStateSize( const TString& graphId, @@ -617,10 +617,10 @@ private: private: IEntityIdGenerator::TPtr EntityIdGenerator; -}; - -//////////////////////////////////////////////////////////////////////////////// - +}; + +//////////////////////////////////////////////////////////////////////////////// + TCheckpointStorage::TCheckpointStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory, @@ -628,31 +628,31 @@ TCheckpointStorage::TCheckpointStorage( : YdbConnection(NewYdbConnection(config, credentialsProviderFactory)) , Config(config) , EntityIdGenerator(entityIdGenerator) -{ -} - -TFuture<TIssues> TCheckpointStorage::Init() -{ - TIssues issues; - - // TODO: list at first? - if (YdbConnection->DB != YdbConnection->TablePathPrefix) { - auto schemeClient = NScheme::TSchemeClient(YdbConnection->Driver); - auto status = schemeClient.MakeDirectory(YdbConnection->TablePathPrefix).GetValueSync(); - if (!status.IsSuccess() && status.GetStatus() != EStatus::ALREADY_EXISTS) { - issues = status.GetIssues(); - - TStringStream ss; - ss << "Failed to create path '" << YdbConnection->TablePathPrefix << "': " << status.GetStatus(); - if (issues) { - ss << ", issues: "; - issues.PrintTo(ss); - } - - return MakeFuture(std::move(issues)); - } - } - +{ +} + +TFuture<TIssues> TCheckpointStorage::Init() +{ + TIssues issues; + + // TODO: list at first? + if (YdbConnection->DB != YdbConnection->TablePathPrefix) { + auto schemeClient = NScheme::TSchemeClient(YdbConnection->Driver); + auto status = schemeClient.MakeDirectory(YdbConnection->TablePathPrefix).GetValueSync(); + if (!status.IsSuccess() && status.GetStatus() != EStatus::ALREADY_EXISTS) { + issues = status.GetIssues(); + + TStringStream ss; + ss << "Failed to create path '" << YdbConnection->TablePathPrefix << "': " << status.GetStatus(); + if (issues) { + ss << ", issues: "; + issues.PrintTo(ss); + } + + return MakeFuture(std::move(issues)); + } + } + #define RUN_CREATE_TABLE(tableName, desc) \ { \ auto status = CreateTable(YdbConnection, \ @@ -673,103 +673,103 @@ TFuture<TIssues> TCheckpointStorage::Init() } \ } - auto graphDesc = TTableBuilder() - .AddNullableColumn("graph_id", EPrimitiveType::String) - .AddNullableColumn("generation", EPrimitiveType::Uint64) - .SetPrimaryKeyColumn("graph_id") - .Build(); - + auto graphDesc = TTableBuilder() + .AddNullableColumn("graph_id", EPrimitiveType::String) + .AddNullableColumn("generation", EPrimitiveType::Uint64) + .SetPrimaryKeyColumn("graph_id") + .Build(); + RUN_CREATE_TABLE(CoordinatorsSyncTable, graphDesc); - - // TODO: graph_id could be just secondary index, but API forbids it, - // so we set it primary key column to have index - auto checkpointDesc = TTableBuilder() - .AddNullableColumn("graph_id", EPrimitiveType::String) + + // TODO: graph_id could be just secondary index, but API forbids it, + // so we set it primary key column to have index + auto checkpointDesc = TTableBuilder() + .AddNullableColumn("graph_id", EPrimitiveType::String) .AddNullableColumn("coordinator_generation", EPrimitiveType::Uint64) .AddNullableColumn("seq_no", EPrimitiveType::Uint64) - .AddNullableColumn("status", EPrimitiveType::Uint8) + .AddNullableColumn("status", EPrimitiveType::Uint8) .AddNullableColumn("created_by", EPrimitiveType::Timestamp) .AddNullableColumn("modified_by", EPrimitiveType::Timestamp) .AddNullableColumn("state_size", EPrimitiveType::Uint64) .AddNullableColumn("graph_description_id", EPrimitiveType::String) .SetPrimaryKeyColumns({"graph_id", "coordinator_generation", "seq_no"}) - .Build(); - + .Build(); + RUN_CREATE_TABLE(CheckpointsMetadataTable, checkpointDesc); - + auto checkpointGraphsDescDesc = TTableBuilder() .AddNullableColumn("id", EPrimitiveType::String) .AddNullableColumn("ref_count", EPrimitiveType::Uint64) .AddNullableColumn("graph_description", EPrimitiveType::String) .SetPrimaryKeyColumn("id") .Build(); - + RUN_CREATE_TABLE(CheckpointsGraphsDescriptionTable, checkpointGraphsDescDesc); #undef RUN_CREATE_TABLE - return MakeFuture(std::move(issues)); -} - -TFuture<TIssues> TCheckpointStorage::RegisterGraphCoordinator(const TCoordinatorId& coordinator) -{ - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, coordinator] (TSession session) { - auto context = MakeIntrusive<TGenerationContext>( - session, - true, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - coordinator.GraphId, - coordinator.Generation); - + return MakeFuture(std::move(issues)); +} + +TFuture<TIssues> TCheckpointStorage::RegisterGraphCoordinator(const TCoordinatorId& coordinator) +{ + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, coordinator] (TSession session) { + auto context = MakeIntrusive<TGenerationContext>( + session, + true, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + coordinator.GraphId, + coordinator.Generation); + return RegisterCheckGeneration(context); - }); - - return StatusToIssues(future); -} - -TFuture<ICheckpointStorage::TGetCoordinatorsResult> TCheckpointStorage::GetCoordinators() { - auto getContext = MakeIntrusive<TGetCoordinatorsContext>(); - - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, getContext] (TSession session) { - auto generationContext = MakeIntrusive<TGenerationContext>( - session, - false, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - "", - 0UL); - - auto future = SelectGraphCoordinators(generationContext); - return future.Apply( - [generationContext, getContext] (const TFuture<TDataQueryResult>& future) { - return ProcessCoordinators(future.GetValue(), generationContext, getContext); - }); - }); - - return StatusToIssues(future).Apply( - [getContext] (const TFuture<TIssues>& future) { - auto result = TGetCoordinatorsResult( - std::move(getContext->Coordinators), - std::move(future.GetValue())); - return MakeFuture(result); - }); -} - + }); + + return StatusToIssues(future); +} + +TFuture<ICheckpointStorage::TGetCoordinatorsResult> TCheckpointStorage::GetCoordinators() { + auto getContext = MakeIntrusive<TGetCoordinatorsContext>(); + + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, getContext] (TSession session) { + auto generationContext = MakeIntrusive<TGenerationContext>( + session, + false, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + "", + 0UL); + + auto future = SelectGraphCoordinators(generationContext); + return future.Apply( + [generationContext, getContext] (const TFuture<TDataQueryResult>& future) { + return ProcessCoordinators(future.GetValue(), generationContext, getContext); + }); + }); + + return StatusToIssues(future).Apply( + [getContext] (const TFuture<TIssues>& future) { + auto result = TGetCoordinatorsResult( + std::move(getContext->Coordinators), + std::move(future.GetValue())); + return MakeFuture(result); + }); +} + TFuture<ICheckpointStorage::TCreateCheckpointResult> TCheckpointStorage::CreateCheckpoint( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, const TString& graphDescId, - ECheckpointStatus status) -{ + ECheckpointStatus status) +{ Y_VERIFY(graphDescId); - auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, status); + auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, status); checkpointContext->CheckpointGraphDescriptionContext = MakeIntrusive<TCheckpointGraphDescriptionContext>(graphDescId); return CreateCheckpointImpl(coordinator, checkpointContext); } @@ -788,24 +788,24 @@ TFuture<ICheckpointStorage::TCreateCheckpointResult> TCheckpointStorage::CreateC TFuture<ICheckpointStorage::TCreateCheckpointResult> TCheckpointStorage::CreateCheckpointImpl(const TCoordinatorId& coordinator, const TCheckpointContextPtr& checkpointContext) { Y_VERIFY(checkpointContext->CheckpointGraphDescriptionContext->GraphDescId || checkpointContext->EntityIdGenerator); - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { - auto generationContext = MakeIntrusive<TGenerationContext>( - session, - false, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - coordinator.GraphId, - coordinator.Generation); - - checkpointContext->GenerationContext = generationContext; - - auto future = CheckGeneration(generationContext); - return CreateCheckpointWrapper(future, checkpointContext); - }); - + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { + auto generationContext = MakeIntrusive<TGenerationContext>( + session, + false, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + coordinator.GraphId, + coordinator.Generation); + + checkpointContext->GenerationContext = generationContext; + + auto future = CheckGeneration(generationContext); + return CreateCheckpointWrapper(future, checkpointContext); + }); + return future.Apply( [checkpointContext](const TFuture<NYdb::TStatus>& future) { if (NYql::TIssues issues = StatusToIssues(future.GetValue())) { @@ -814,187 +814,187 @@ TFuture<ICheckpointStorage::TCreateCheckpointResult> TCheckpointStorage::CreateC return TCreateCheckpointResult(checkpointContext->CheckpointGraphDescriptionContext->GraphDescId, NYql::TIssues()); } }); -} - -TFuture<TIssues> TCheckpointStorage::UpdateCheckpointStatus( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId, - ECheckpointStatus newStatus, - ECheckpointStatus prevStatus) -{ - auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, newStatus, prevStatus); - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { - auto generationContext = MakeIntrusive<TGenerationContext>( - session, - false, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - coordinator.GraphId, - coordinator.Generation); - - checkpointContext->GenerationContext = generationContext; - - auto future = CheckGeneration(generationContext); - return UpdateCheckpointWithCheckWrapper(future, checkpointContext); - }); - - return StatusToIssues(future); -} - -TFuture<TIssues> TCheckpointStorage::AbortCheckpoint( - const TCoordinatorId& coordinator, - const TCheckpointId& checkpointId) -{ - auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, ECheckpointStatus::Aborted); - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { - auto generationContext = MakeIntrusive<TGenerationContext>( - session, - false, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - coordinator.GraphId, - coordinator.Generation); - - checkpointContext->GenerationContext = generationContext; - - auto future = CheckGeneration(generationContext); - return UpdateCheckpointWithCheckWrapper(future, checkpointContext); - }); - - return StatusToIssues(future); -} - +} + +TFuture<TIssues> TCheckpointStorage::UpdateCheckpointStatus( + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId, + ECheckpointStatus newStatus, + ECheckpointStatus prevStatus) +{ + auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, newStatus, prevStatus); + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { + auto generationContext = MakeIntrusive<TGenerationContext>( + session, + false, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + coordinator.GraphId, + coordinator.Generation); + + checkpointContext->GenerationContext = generationContext; + + auto future = CheckGeneration(generationContext); + return UpdateCheckpointWithCheckWrapper(future, checkpointContext); + }); + + return StatusToIssues(future); +} + +TFuture<TIssues> TCheckpointStorage::AbortCheckpoint( + const TCoordinatorId& coordinator, + const TCheckpointId& checkpointId) +{ + auto checkpointContext = MakeIntrusive<TCheckpointContext>(checkpointId, ECheckpointStatus::Aborted); + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, coordinator, checkpointContext] (TSession session) { + auto generationContext = MakeIntrusive<TGenerationContext>( + session, + false, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + coordinator.GraphId, + coordinator.Generation); + + checkpointContext->GenerationContext = generationContext; + + auto future = CheckGeneration(generationContext); + return UpdateCheckpointWithCheckWrapper(future, checkpointContext); + }); + + return StatusToIssues(future); +} + TFuture<ICheckpointStorage::TGetCheckpointsResult> TCheckpointStorage::GetCheckpoints(const TString& graph) { return GetCheckpoints(graph, TVector<ECheckpointStatus>(), std::numeric_limits<ui64>::max(), true); } -TFuture<ICheckpointStorage::TGetCheckpointsResult> TCheckpointStorage::GetCheckpoints( +TFuture<ICheckpointStorage::TGetCheckpointsResult> TCheckpointStorage::GetCheckpoints( const TString& graph, const TVector<ECheckpointStatus>& statuses, ui64 limit, bool loadGraphDescription) -{ - auto getContext = MakeIntrusive<TGetCheckpointsContext>(); - - auto future = YdbConnection->Client.RetryOperation( +{ + auto getContext = MakeIntrusive<TGetCheckpointsContext>(); + + auto future = YdbConnection->Client.RetryOperation( [prefix = YdbConnection->TablePathPrefix, graph, getContext, statuses, limit, loadGraphDescription, settings = DefaultExecDataQuerySettings()] (TSession session) { - auto generationContext = MakeIntrusive<TGenerationContext>( - session, - false, - prefix, - CoordinatorsSyncTable, - "graph_id", - "generation", - graph, - 0UL); - + auto generationContext = MakeIntrusive<TGenerationContext>( + session, + false, + prefix, + CoordinatorsSyncTable, + "graph_id", + "generation", + graph, + 0UL); + auto future = SelectGraphCheckpoints(generationContext, statuses, limit, settings, loadGraphDescription); - return future.Apply( + return future.Apply( [generationContext, getContext, loadGraphDescription] (const TFuture<TDataQueryResult>& future) { return ProcessCheckpoints(future.GetValue(), generationContext, getContext, loadGraphDescription); - }); - }); - - return StatusToIssues(future).Apply( - [getContext] (const TFuture<TIssues>& future) { - auto result = TGetCheckpointsResult(std::move(getContext->Checkpoints), std::move(future.GetValue())); - return MakeFuture(result); - }); -} - -TFuture<TIssues> TCheckpointStorage::DeleteGraph(const TString& graphId) { - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, graphId] (TSession session) { - // TODO: use prepared queries - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - - DELETE - FROM %s - WHERE graph_id = "%s"; - - DELETE - FROM %s - WHERE graph_id = "%s"; - )", prefix.c_str(), - CoordinatorsSyncTable, - graphId.c_str(), - CheckpointsMetadataTable, - graphId.c_str()); - - auto future = session.ExecuteDataQuery( - query, - TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); - - return future.Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); - }); - - return StatusToIssues(future); -} - -TFuture<TIssues> TCheckpointStorage::MarkCheckpointsGC( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) -{ - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, graphId, checkpointUpperBound] (TSession session) { - // TODO: use prepared queries - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - $ts = cast(%lu as Timestamp); - - UPDATE %s + }); + }); + + return StatusToIssues(future).Apply( + [getContext] (const TFuture<TIssues>& future) { + auto result = TGetCheckpointsResult(std::move(getContext->Checkpoints), std::move(future.GetValue())); + return MakeFuture(result); + }); +} + +TFuture<TIssues> TCheckpointStorage::DeleteGraph(const TString& graphId) { + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, graphId] (TSession session) { + // TODO: use prepared queries + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + + DELETE + FROM %s + WHERE graph_id = "%s"; + + DELETE + FROM %s + WHERE graph_id = "%s"; + )", prefix.c_str(), + CoordinatorsSyncTable, + graphId.c_str(), + CheckpointsMetadataTable, + graphId.c_str()); + + auto future = session.ExecuteDataQuery( + query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); + + return future.Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); + }); + + return StatusToIssues(future); +} + +TFuture<TIssues> TCheckpointStorage::MarkCheckpointsGC( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) +{ + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, graphId, checkpointUpperBound] (TSession session) { + // TODO: use prepared queries + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + $ts = cast(%lu as Timestamp); + + UPDATE %s SET status = %u, modified_by = $ts - WHERE graph_id = "%s" AND + WHERE graph_id = "%s" AND (coordinator_generation < %lu OR (coordinator_generation = %lu AND seq_no < %lu)); - )", prefix.c_str(), - TInstant::Now().MicroSeconds(), - CheckpointsMetadataTable, - (ui32)ECheckpointStatus::GC, - graphId.c_str(), + )", prefix.c_str(), + TInstant::Now().MicroSeconds(), + CheckpointsMetadataTable, + (ui32)ECheckpointStatus::GC, + graphId.c_str(), checkpointUpperBound.CoordinatorGeneration, checkpointUpperBound.CoordinatorGeneration, checkpointUpperBound.SeqNo); - - auto future = session.ExecuteDataQuery( - query, - TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); - - return future.Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); - }); - - return StatusToIssues(future); -} - -TFuture<TIssues> TCheckpointStorage::DeleteMarkedCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) -{ - auto future = YdbConnection->Client.RetryOperation( - [prefix = YdbConnection->TablePathPrefix, graphId, checkpointUpperBound] (TSession session) { - // TODO: use prepared queries + + auto future = session.ExecuteDataQuery( + query, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()); + + return future.Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); + }); + + return StatusToIssues(future); +} + +TFuture<TIssues> TCheckpointStorage::DeleteMarkedCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) +{ + auto future = YdbConnection->Client.RetryOperation( + [prefix = YdbConnection->TablePathPrefix, graphId, checkpointUpperBound] (TSession session) { + // TODO: use prepared queries using namespace fmt::literals; const TString query = fmt::format(R"sql( - --!syntax_v1 + --!syntax_v1 PRAGMA TablePathPrefix("{table_path_prefix}"); DECLARE $graph_id AS String; DECLARE $coordinator_generation AS Uint64; DECLARE $seq_no AS Uint64; - + $refs = SELECT COUNT(*) AS refs, graph_description_id @@ -1004,7 +1004,7 @@ TFuture<TIssues> TCheckpointStorage::DeleteMarkedCheckpoints( (coordinator_generation = $coordinator_generation AND seq_no < $seq_no)) AND graph_description_id != "" -- legacy condition (excludes old records without graph description) GROUP BY graph_description_id; - + $update = SELECT checkpoints_graphs_description.id AS id, @@ -1012,7 +1012,7 @@ TFuture<TIssues> TCheckpointStorage::DeleteMarkedCheckpoints( FROM {checkpoints_graphs_description_table_name} INNER JOIN (SELECT * FROM $refs) AS refs ON refs.graph_description_id = checkpoints_graphs_description.id; - + UPDATE {checkpoints_graphs_description_table_name} ON SELECT * FROM $update WHERE ref_count > 0; @@ -1042,19 +1042,19 @@ TFuture<TIssues> TCheckpointStorage::DeleteMarkedCheckpoints( .Uint64(checkpointUpperBound.SeqNo) .Build(); - auto future = session.ExecuteDataQuery( - query, + auto future = session.ExecuteDataQuery( + query, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params.Build()); - - return future.Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); - }); - - return StatusToIssues(future); -} + + return future.Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); + }); + + return StatusToIssues(future); +} TFuture<ICheckpointStorage::TAddToStateSizeResult> NYq::TCheckpointStorage::AddToStateSize(const TString& graphId, const TCheckpointId& checkpointId, ui64 size) { auto result = MakeIntrusive<TAddToStateSizeContext>(); auto future = YdbConnection->Client.RetryOperation( @@ -1065,7 +1065,7 @@ TFuture<ICheckpointStorage::TAddToStateSizeResult> NYq::TCheckpointStorage::AddT paramsBuilder.AddParam("$seq_no").Uint64(checkpointId.SeqNo).Build(); paramsBuilder.AddParam("$task_state_size").Uint64(size).Build(); auto params = paramsBuilder.Build(); - + auto query = Sprintf(R"( --!syntax_v1 PRAGMA TablePathPrefix("%s"); @@ -1177,17 +1177,17 @@ TExecDataQuerySettings NYq::TCheckpointStorage::DefaultExecDataQuerySettings() { .CancelAfter(TDuration::Seconds(Config.GetCancelAfterSec())); } -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + TCheckpointStoragePtr NewYdbCheckpointStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory, const IEntityIdGenerator::TPtr& entityIdGenerator) -{ +{ Y_VERIFY(entityIdGenerator); return new TCheckpointStorage(config, credentialsProviderFactory, entityIdGenerator); -} - +} + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.h b/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.h index 43eb0acc5ab..c52b006f916 100644 --- a/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.h +++ b/ydb/core/yq/libs/checkpoint_storage/ydb_checkpoint_storage.h @@ -1,18 +1,18 @@ -#pragma once - -#include "checkpoint_storage.h" - +#pragma once + +#include "checkpoint_storage.h" + #include <ydb/library/security/ydb_credentials_provider_factory.h> #include <ydb/core/yq/libs/common/entity_id.h> #include <ydb/core/yq/libs/config/protos/storage.pb.h> - + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - + +//////////////////////////////////////////////////////////////////////////////// + TCheckpointStoragePtr NewYdbCheckpointStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory, const IEntityIdGenerator::TPtr& entityIdGenerator); - + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.cpp b/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.cpp index 135f50efe07..ab209ec1e89 100644 --- a/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.cpp +++ b/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.cpp @@ -1,52 +1,52 @@ -#include "ydb_state_storage.h" - +#include "ydb_state_storage.h" + #include <ydb/core/yq/libs/actors/logging/log.h> #include <ydb/core/yq/libs/ydb/util.h> #include <ydb/core/yq/libs/ydb/ydb.h> - + #include <ydb/public/sdk/cpp/client/ydb_scheme/scheme.h> - -#include <util/stream/str.h> + +#include <util/stream/str.h> #include <util/string/join.h> - + namespace NYq { - -using namespace NThreading; -using namespace NYdb; -using namespace NYdb::NTable; - -using NYql::TIssues; - -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -const char* StatesTable = "states"; - -//////////////////////////////////////////////////////////////////////////////// - -struct TContext : public TThrRefBase { - const TString TablePathPrefix; + +using namespace NThreading; +using namespace NYdb; +using namespace NYdb::NTable; + +using NYql::TIssues; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +const char* StatesTable = "states"; + +//////////////////////////////////////////////////////////////////////////////// + +struct TContext : public TThrRefBase { + const TString TablePathPrefix; const std::vector<ui64> TaskIds; - const TString GraphId; - const TCheckpointId CheckpointId; + const TString GraphId; + const TCheckpointId CheckpointId; std::vector<NYql::NDqProto::TComputeActorState> States; TMaybe<TSession> Session; - - TContext(const TString& tablePathPrefix, + + TContext(const TString& tablePathPrefix, const std::vector<ui64>& taskIds, - TString graphId, - const TCheckpointId& checkpointId, + TString graphId, + const TCheckpointId& checkpointId, std::vector<NYql::NDqProto::TComputeActorState> states = {}, TMaybe<TSession> session = {}) - : TablePathPrefix(tablePathPrefix) + : TablePathPrefix(tablePathPrefix) , TaskIds(taskIds) - , GraphId(std::move(graphId)) - , CheckpointId(checkpointId) + , GraphId(std::move(graphId)) + , CheckpointId(checkpointId) , States(std::move(states)) - , Session(session) - { - } + , Session(session) + { + } TContext(const TString& tablePathPrefix, ui64 taskId, @@ -57,20 +57,20 @@ struct TContext : public TThrRefBase { : TContext(tablePathPrefix, std::vector{taskId}, std::move(graphId), checkpointId, std::vector{std::move(state)}, std::move(session)) { } -}; - -using TContextPtr = TIntrusivePtr<TContext>; - -//////////////////////////////////////////////////////////////////////////////// - -struct TCountStateContext : public TThrRefBase { - size_t Count = 0; -}; - -using TCountStateContextPtr = TIntrusivePtr<TCountStateContext>; - -//////////////////////////////////////////////////////////////////////////////// - +}; + +using TContextPtr = TIntrusivePtr<TContext>; + +//////////////////////////////////////////////////////////////////////////////// + +struct TCountStateContext : public TThrRefBase { + size_t Count = 0; +}; + +using TCountStateContextPtr = TIntrusivePtr<TCountStateContext>; + +//////////////////////////////////////////////////////////////////////////////// + static void LoadState(NYql::NDqProto::TComputeActorState& state, const TString& serializedState) { if (!state.ParseFromString(serializedState)) { // backward compatibility with YQL serialization state.Clear(); @@ -78,15 +78,15 @@ static void LoadState(NYql::NDqProto::TComputeActorState& state, const TString& } } -TFuture<TStatus> ProcessState( - const TDataQueryResult& selectResult, +TFuture<TStatus> ProcessState( + const TDataQueryResult& selectResult, const TContextPtr& context) -{ - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - TResultSetParser parser(selectResult.GetResultSet(0)); +{ + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + TResultSetParser parser(selectResult.GetResultSet(0)); TStringBuilder errorMessage; if (parser.RowsCount() == context->TaskIds.size()) { context->States.resize(context->TaskIds.size()); @@ -116,161 +116,161 @@ TFuture<TStatus> ProcessState( } LoadState(context->States[taskIndex], *parser.ColumnParser("blob").GetOptionalString()); } - } else { + } else { errorMessage << "Not all states exist in database"; } if (errorMessage) { - TIssues issues; - TStringStream ss; - ss << "Failed to select state of checkpoint '" << context->CheckpointId << "'" + TIssues issues; + TStringStream ss; + ss << "Failed to select state of checkpoint '" << context->CheckpointId << "'" << ", taskIds={" << JoinSeq(", ", context->TaskIds) << "}. Selected rows: " << parser.RowsCount(); - - const auto& stats = selectResult.GetStats(); - if (stats) { + + const auto& stats = selectResult.GetStats(); + if (stats) { ss << ". Stats: " << stats->ToString(); - } + } ss << ". " << errorMessage; - - // TODO: print status, etc - - // we use GENERIC_ERROR, because not sure if NOT_FOUND non-retrieable - // also severity is error, because user expects checkpoint to be existed - - return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); - } - - return MakeFuture<TStatus>(selectResult); -} - -//////////////////////////////////////////////////////////////////////////////// - -class TStateStorage : public IStateStorage { - TYdbConnectionPtr YdbConnection; + + // TODO: print status, etc + + // we use GENERIC_ERROR, because not sure if NOT_FOUND non-retrieable + // also severity is error, because user expects checkpoint to be existed + + return MakeFuture(MakeErrorStatus(EStatus::GENERIC_ERROR, ss.Str())); + } + + return MakeFuture<TStatus>(selectResult); +} + +//////////////////////////////////////////////////////////////////////////////// + +class TStateStorage : public IStateStorage { + TYdbConnectionPtr YdbConnection; const NConfig::TYdbStorageConfig Config; - -public: + +public: explicit TStateStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory); - ~TStateStorage() = default; - - TFuture<TIssues> Init() override; - - TFuture<TIssues> SaveState( - ui64 taskId, - const TString& graphId, - const TCheckpointId& checkpointId, + ~TStateStorage() = default; + + TFuture<TIssues> Init() override; + + TFuture<TIssues> SaveState( + ui64 taskId, + const TString& graphId, + const TCheckpointId& checkpointId, const NYql::NDqProto::TComputeActorState& state) override; - - TFuture<TGetStateResult> GetState( + + TFuture<TGetStateResult> GetState( const std::vector<ui64>& taskIds, - const TString& graphId, - const TCheckpointId& checkpointId) override; - - TFuture<TCountStatesResult> CountStates( - const TString& graphId, - const TCheckpointId& checkpointId) override; - - TFuture<TIssues> DeleteGraph( - const TString& graphId) override; - - TFuture<TIssues> DeleteCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointId) override; + const TString& graphId, + const TCheckpointId& checkpointId) override; + + TFuture<TCountStatesResult> CountStates( + const TString& graphId, + const TCheckpointId& checkpointId) override; + + TFuture<TIssues> DeleteGraph( + const TString& graphId) override; + + TFuture<TIssues> DeleteCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointId) override; TFuture<TDataQueryResult> SelectState(const TContextPtr& context); TFuture<TStatus> UpsertState(const TContextPtr& context); TExecDataQuerySettings DefaultExecDataQuerySettings(); -}; - -//////////////////////////////////////////////////////////////////////////////// - +}; + +//////////////////////////////////////////////////////////////////////////////// + TStateStorage::TStateStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) : YdbConnection(NewYdbConnection(config, credentialsProviderFactory)) , Config(config) -{ -} - -TFuture<TIssues> TStateStorage::Init() -{ - TIssues issues; - - // TODO: list at first? - if (YdbConnection->DB != YdbConnection->TablePathPrefix) { - //LOG_STREAMS_STORAGE_SERVICE_INFO("Creating directory: " << YdbConnection->TablePathPrefix); - auto schemeClient = NScheme::TSchemeClient(YdbConnection->Driver); - auto status = schemeClient.MakeDirectory(YdbConnection->TablePathPrefix).GetValueSync(); - if (!status.IsSuccess() && status.GetStatus() != EStatus::ALREADY_EXISTS) { - issues = status.GetIssues(); - - TStringStream ss; - ss << "Failed to create path '" << YdbConnection->TablePathPrefix << "': " << status.GetStatus(); - if (issues) { - ss << ", issues: "; - issues.PrintTo(ss); - } - - //LOG_STREAMS_STORAGE_SERVICE_DEBUG(ss.Str()); - return MakeFuture(std::move(issues)); - } - } - - auto stateDesc = TTableBuilder() +{ +} + +TFuture<TIssues> TStateStorage::Init() +{ + TIssues issues; + + // TODO: list at first? + if (YdbConnection->DB != YdbConnection->TablePathPrefix) { + //LOG_STREAMS_STORAGE_SERVICE_INFO("Creating directory: " << YdbConnection->TablePathPrefix); + auto schemeClient = NScheme::TSchemeClient(YdbConnection->Driver); + auto status = schemeClient.MakeDirectory(YdbConnection->TablePathPrefix).GetValueSync(); + if (!status.IsSuccess() && status.GetStatus() != EStatus::ALREADY_EXISTS) { + issues = status.GetIssues(); + + TStringStream ss; + ss << "Failed to create path '" << YdbConnection->TablePathPrefix << "': " << status.GetStatus(); + if (issues) { + ss << ", issues: "; + issues.PrintTo(ss); + } + + //LOG_STREAMS_STORAGE_SERVICE_DEBUG(ss.Str()); + return MakeFuture(std::move(issues)); + } + } + + auto stateDesc = TTableBuilder() .AddNullableColumn("graph_id", EPrimitiveType::String) - .AddNullableColumn("task_id", EPrimitiveType::Uint64) + .AddNullableColumn("task_id", EPrimitiveType::Uint64) .AddNullableColumn("coordinator_generation", EPrimitiveType::Uint64) .AddNullableColumn("seq_no", EPrimitiveType::Uint64) - .AddNullableColumn("blob", EPrimitiveType::String) + .AddNullableColumn("blob", EPrimitiveType::String) .SetPrimaryKeyColumns({"graph_id", "task_id", "coordinator_generation", "seq_no"}) - .Build(); - - auto status = CreateTable(YdbConnection, StatesTable, std::move(stateDesc)).GetValueSync(); - if (!IsTableCreated(status)) { - issues = status.GetIssues(); - - TStringStream ss; - ss << "Failed to create " << StatesTable << " table: " << status.GetStatus(); - if (issues) { - ss << ", issues: "; - issues.PrintTo(ss); - } - - //LOG_STREAMS_STORAGE_SERVICE_DEBUG(ss.Str()); - } - - return MakeFuture(std::move(issues)); -} - -TFuture<TIssues> TStateStorage::SaveState( - ui64 taskId, - const TString& graphId, - const TCheckpointId& checkpointId, + .Build(); + + auto status = CreateTable(YdbConnection, StatesTable, std::move(stateDesc)).GetValueSync(); + if (!IsTableCreated(status)) { + issues = status.GetIssues(); + + TStringStream ss; + ss << "Failed to create " << StatesTable << " table: " << status.GetStatus(); + if (issues) { + ss << ", issues: "; + issues.PrintTo(ss); + } + + //LOG_STREAMS_STORAGE_SERVICE_DEBUG(ss.Str()); + } + + return MakeFuture(std::move(issues)); +} + +TFuture<TIssues> TStateStorage::SaveState( + ui64 taskId, + const TString& graphId, + const TCheckpointId& checkpointId, const NYql::NDqProto::TComputeActorState& state) -{ - auto future = YdbConnection->Client.RetryOperation( +{ + auto future = YdbConnection->Client.RetryOperation( [prefix = YdbConnection->TablePathPrefix, taskId, graphId, checkpointId, state, thisPtr = TIntrusivePtr(this)] (TSession session) { - auto context = MakeIntrusive<TContext>( - prefix, - taskId, - graphId, - checkpointId, + auto context = MakeIntrusive<TContext>( + prefix, + taskId, + graphId, + checkpointId, state, - session); - + session); + return thisPtr->UpsertState(context); - }); - - return StatusToIssues(future); -} - -TFuture<IStateStorage::TGetStateResult> TStateStorage::GetState( + }); + + return StatusToIssues(future); +} + +TFuture<IStateStorage::TGetStateResult> TStateStorage::GetState( const std::vector<ui64>& taskIds, - const TString& graphId, - const TCheckpointId& checkpointId) -{ + const TString& graphId, + const TCheckpointId& checkpointId) +{ if (taskIds.empty()) { IStateStorage::TGetStateResult result; result.second.AddIssue("Internal error loading state: no task ids specified"); @@ -288,33 +288,33 @@ TFuture<IStateStorage::TGetStateResult> TStateStorage::GetState( taskIds, graphId, checkpointId); - - auto future = YdbConnection->Client.RetryOperation( + + auto future = YdbConnection->Client.RetryOperation( [context, thisPtr = TIntrusivePtr(this)] (TSession session) { context->Session = session; auto future = thisPtr->SelectState(context); - return future.Apply( + return future.Apply( [context] (const TFuture<TDataQueryResult>& future) { return ProcessState(future.GetValue(), context); - }); - }); - - return StatusToIssues(future).Apply( + }); + }); + + return StatusToIssues(future).Apply( [context] (const TFuture<TIssues>& future) { TGetStateResult result; std::swap(result.first, context->States); result.second = future.GetValue(); return MakeFuture(std::move(result)); - }); -} - -TFuture<IStateStorage::TCountStatesResult> TStateStorage::CountStates( - const TString& graphId, - const TCheckpointId& checkpointId) -{ - auto context = MakeIntrusive<TCountStateContext>(); - - auto future = YdbConnection->Client.RetryOperation( + }); +} + +TFuture<IStateStorage::TCountStatesResult> TStateStorage::CountStates( + const TString& graphId, + const TCheckpointId& checkpointId) +{ + auto context = MakeIntrusive<TCountStateContext>(); + + auto future = YdbConnection->Client.RetryOperation( [prefix = YdbConnection->TablePathPrefix, graphId, checkpointId, context, thisPtr = TIntrusivePtr(this)] (TSession session) { // publish nodes @@ -324,52 +324,52 @@ TFuture<IStateStorage::TCountStatesResult> TStateStorage::CountStates( paramsBuilder.AddParam("$seq_no").Uint64(checkpointId.SeqNo).Build(); auto params = paramsBuilder.Build(); - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + declare $graph_id as string; declare $coordinator_generation as Uint64; declare $seq_no as Uint64; - SELECT COUNT(*) as cnt - FROM %s + SELECT COUNT(*) as cnt + FROM %s WHERE graph_id = $graph_id AND coordinator_generation = $coordinator_generation and seq_no = $seq_no; )", prefix.c_str(), StatesTable); - - auto future = session.ExecuteDataQuery( - query, + + auto future = session.ExecuteDataQuery( + query, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params, thisPtr->DefaultExecDataQuerySettings()); - - return future.Apply( - [context] (const TFuture<TDataQueryResult>& future) { - const auto& selectResult = future.GetValue(); - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - TResultSetParser parser(selectResult.GetResultSet(0)); - if (parser.TryNextRow()) { - context->Count = parser.ColumnParser("cnt").GetUint64(); - } - - return MakeFuture<TStatus>(selectResult); - }); - }); - - return future.Apply( - [context] (const TFuture<TStatus>& future) { - TCountStatesResult countResult; - countResult.first = context->Count; - const auto& status = future.GetValue(); - if (!status.IsSuccess()) { - countResult.second = status.GetIssues(); - } - return countResult; - }); -} + + return future.Apply( + [context] (const TFuture<TDataQueryResult>& future) { + const auto& selectResult = future.GetValue(); + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + TResultSetParser parser(selectResult.GetResultSet(0)); + if (parser.TryNextRow()) { + context->Count = parser.ColumnParser("cnt").GetUint64(); + } + + return MakeFuture<TStatus>(selectResult); + }); + }); + + return future.Apply( + [context] (const TFuture<TStatus>& future) { + TCountStatesResult countResult; + countResult.first = context->Count; + const auto& status = future.GetValue(); + if (!status.IsSuccess()) { + countResult.second = status.GetIssues(); + } + return countResult; + }); +} TExecDataQuerySettings TStateStorage::DefaultExecDataQuerySettings() { return TExecDataQuerySettings() .KeepInQueryCache(true) @@ -377,9 +377,9 @@ TExecDataQuerySettings TStateStorage::DefaultExecDataQuerySettings() { .OperationTimeout(TDuration::Seconds(Config.GetOperationTimeoutSec())) .CancelAfter(TDuration::Seconds(Config.GetCancelAfterSec())); } - -TFuture<TIssues> TStateStorage::DeleteGraph(const TString& graphId) { - auto future = YdbConnection->Client.RetryOperation( + +TFuture<TIssues> TStateStorage::DeleteGraph(const TString& graphId) { + auto future = YdbConnection->Client.RetryOperation( [prefix = YdbConnection->TablePathPrefix, graphId, thisPtr = TIntrusivePtr(this)] (TSession session) { // publish nodes @@ -388,38 +388,38 @@ TFuture<TIssues> TStateStorage::DeleteGraph(const TString& graphId) { auto params = paramsBuilder.Build(); - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + declare $graph_id as string; - DELETE - FROM %s - WHERE graph_id = "%s"; - )", prefix.c_str(), StatesTable, graphId.c_str()); - - auto future = session.ExecuteDataQuery( - query, + DELETE + FROM %s + WHERE graph_id = "%s"; + )", prefix.c_str(), StatesTable, graphId.c_str()); + + auto future = session.ExecuteDataQuery( + query, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params, thisPtr->DefaultExecDataQuerySettings()); - - return future.Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); - }); - - return StatusToIssues(future); -} - -TFuture<TIssues> TStateStorage::DeleteCheckpoints( - const TString& graphId, - const TCheckpointId& checkpointUpperBound) -{ - auto future = YdbConnection->Client.RetryOperation( + + return future.Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); + }); + + return StatusToIssues(future); +} + +TFuture<TIssues> TStateStorage::DeleteCheckpoints( + const TString& graphId, + const TCheckpointId& checkpointUpperBound) +{ + auto future = YdbConnection->Client.RetryOperation( [prefix = YdbConnection->TablePathPrefix, graphId, checkpointUpperBound, thisPtr = TIntrusivePtr(this)] (TSession session) { // publish nodes @@ -430,36 +430,36 @@ TFuture<TIssues> TStateStorage::DeleteCheckpoints( auto params = paramsBuilder.Build(); - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + declare $graph_id as string; declare $coordinator_generation as Uint64; declare $seq_no as Uint64; - DELETE - FROM %s + DELETE + FROM %s WHERE graph_id = $graph_id AND (coordinator_generation < $coordinator_generation OR (coordinator_generation = $coordinator_generation AND seq_no < $seq_no)); )", prefix.c_str(), StatesTable); - - auto future = session.ExecuteDataQuery( - query, + + auto future = session.ExecuteDataQuery( + query, TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params, thisPtr->DefaultExecDataQuerySettings()); - - return future.Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); - }); - - return StatusToIssues(future); -} + + return future.Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); + }); + + return StatusToIssues(future); +} TFuture<TDataQueryResult> TStateStorage::SelectState(const TContextPtr& context) { NYdb::TParamsBuilder paramsBuilder; @@ -476,7 +476,7 @@ TFuture<TDataQueryResult> TStateStorage::SelectState(const TContextPtr& context) paramsBuilder.AddParam("$graph_id").String(context->GraphId).Build(); paramsBuilder.AddParam("$coordinator_generation").Uint64(context->CheckpointId.CoordinatorGeneration).Build(); paramsBuilder.AddParam("$seq_no").Uint64(context->CheckpointId.SeqNo).Build(); - + auto params = paramsBuilder.Build(); auto query = Sprintf(R"( @@ -550,15 +550,15 @@ TFuture<TStatus> TStateStorage::UpsertState(const TContextPtr& context) { }); } -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + TStateStoragePtr NewYdbStateStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory) -{ +{ return new TStateStorage(config, credentialsProviderFactory); -} - +} + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.h b/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.h index 85d87bafd02..61dba973de7 100644 --- a/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.h +++ b/ydb/core/yq/libs/checkpoint_storage/ydb_state_storage.h @@ -1,16 +1,16 @@ -#pragma once - -#include "state_storage.h" - +#pragma once + +#include "state_storage.h" + #include <ydb/library/security/ydb_credentials_provider_factory.h> #include <ydb/core/yq/libs/config/protos/storage.pb.h> - + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - + +//////////////////////////////////////////////////////////////////////////////// + TStateStoragePtr NewYdbStateStorage( const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credentialsProviderFactory); - + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.cpp b/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.cpp index a0ae9230ea1..6b415e8ac83 100644 --- a/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.cpp +++ b/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.cpp @@ -1,7 +1,7 @@ #include "checkpoint_id_generator.h" - + #include <ydb/core/yq/libs/checkpointing_common/defs.h> - + namespace NYq { TCheckpointIdGenerator::TCheckpointIdGenerator(TCoordinatorId coordinatorId, TCheckpointId lastCheckpoint) @@ -17,7 +17,7 @@ TCheckpointIdGenerator::TCheckpointIdGenerator(TCoordinatorId coordinatorId, TCh } TCheckpointId NYq::TCheckpointIdGenerator::NextId() { - return TCheckpointId(CoordinatorId.Generation, NextNumber++); + return TCheckpointId(CoordinatorId.Generation, NextNumber++); } } // namespace NYq diff --git a/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.h b/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.h index ea4eabfd37a..bcc295cf334 100644 --- a/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.h +++ b/ydb/core/yq/libs/checkpointing/checkpoint_id_generator.h @@ -6,13 +6,13 @@ namespace NYq { class TCheckpointIdGenerator { private: - TCoordinatorId CoordinatorId; + TCoordinatorId CoordinatorId; ui64 NextNumber; public: explicit TCheckpointIdGenerator(TCoordinatorId id, TCheckpointId lastCheckpoint = TCheckpointId(0, 0)); - TCheckpointId NextId(); + TCheckpointId NextId(); }; } // namespace NYq diff --git a/ydb/core/yq/libs/checkpointing/ut/checkpoint_coordinator_ut.cpp b/ydb/core/yq/libs/checkpointing/ut/checkpoint_coordinator_ut.cpp index fe772d682fe..ceb0a9faf59 100644 --- a/ydb/core/yq/libs/checkpointing/ut/checkpoint_coordinator_ut.cpp +++ b/ydb/core/yq/libs/checkpointing/ut/checkpoint_coordinator_ut.cpp @@ -122,14 +122,14 @@ void MockCheckpointsMetadataResponse(TTestBootstrap& bootstrap, NYql::TIssues is new TEvCheckpointStorage::TEvGetCheckpointsMetadataResponse(TVector<TCheckpointMetadata>(), std::move(issues)))); } -void MockCreateCheckpointResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { +void MockCreateCheckpointResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { bootstrap.Send(new IEventHandle( bootstrap.CheckpointCoordinator, bootstrap.StorageProxy, new TEvCheckpointStorage::TEvCreateCheckpointResponse(checkpointId, std::move(issues), "42"))); } -void MockNodeStateSavedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { +void MockNodeStateSavedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { auto ev = std::make_unique<NYql::NDq::TEvDqCompute::TEvSaveTaskStateResult>(); ev->Record.MutableCheckpoint()->SetGeneration(checkpointId.CoordinatorGeneration); ev->Record.MutableCheckpoint()->SetId(checkpointId.SeqNo); @@ -140,7 +140,7 @@ void MockNodeStateSavedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpoin ev.release())); } -void MockNodeStateSaveFailedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { +void MockNodeStateSaveFailedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { auto ev = std::make_unique<NYql::NDq::TEvDqCompute::TEvSaveTaskStateResult>(); ev->Record.MutableCheckpoint()->SetGeneration(checkpointId.CoordinatorGeneration); ev->Record.MutableCheckpoint()->SetId(checkpointId.SeqNo); @@ -151,21 +151,21 @@ void MockNodeStateSaveFailedEvent(TTestBootstrap& bootstrap, TCheckpointId& chec ev.release())); } -void MockSetCheckpointPendingCommitStatusResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { +void MockSetCheckpointPendingCommitStatusResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { bootstrap.Send(new IEventHandle( bootstrap.CheckpointCoordinator, bootstrap.StorageProxy, new TEvCheckpointStorage::TEvSetCheckpointPendingCommitStatusResponse(checkpointId, std::move(issues)))); } -void MockChangesCommittedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { +void MockChangesCommittedEvent(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, TActorId& sender) { bootstrap.Send(new IEventHandle( bootstrap.CheckpointCoordinator, sender, new NYql::NDq::TEvDqCompute::TEvStateCommitted(checkpointId.SeqNo, checkpointId.CoordinatorGeneration, bootstrap.ActorToTask[sender]))); } -void MockCompleteCheckpointResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { +void MockCompleteCheckpointResponse(TTestBootstrap& bootstrap, TCheckpointId& checkpointId, NYql::TIssues issues = NYql::TIssues()) { bootstrap.Send(new IEventHandle( bootstrap.CheckpointCoordinator, bootstrap.StorageProxy, diff --git a/ydb/core/yq/libs/checkpointing_common/defs.cpp b/ydb/core/yq/libs/checkpointing_common/defs.cpp index 8718c684e1e..e487b6542cc 100644 --- a/ydb/core/yq/libs/checkpointing_common/defs.cpp +++ b/ydb/core/yq/libs/checkpointing_common/defs.cpp @@ -1,43 +1,43 @@ -#include "defs.h" - -#include <util/digest/multi.h> - +#include "defs.h" + +#include <util/digest/multi.h> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -TString TCoordinatorId::ToString() const { - TStringStream ss; - PrintTo(ss); - return ss.Str(); -} - -void TCoordinatorId::PrintTo(IOutputStream& out) const -{ + +//////////////////////////////////////////////////////////////////////////////// + +TString TCoordinatorId::ToString() const { + TStringStream ss; + PrintTo(ss); + return ss.Str(); +} + +void TCoordinatorId::PrintTo(IOutputStream& out) const +{ out << GraphId << "." << Generation; -} - -size_t TCheckpointIdHash::operator ()(const TCheckpointId& checkpointId) -{ +} + +size_t TCheckpointIdHash::operator ()(const TCheckpointId& checkpointId) +{ return MultiHash(checkpointId.CoordinatorGeneration, checkpointId.SeqNo); -} - +} + } // namespace NYq - -//////////////////////////////////////////////////////////////////////////////// - -template<> + +//////////////////////////////////////////////////////////////////////////////// + +template<> void Out<NYq::TCoordinatorId>( - IOutputStream& out, + IOutputStream& out, const NYq::TCoordinatorId& coordinatorId) -{ - coordinatorId.PrintTo(out); -} - -template<> +{ + coordinatorId.PrintTo(out); +} + +template<> void Out<NYq::TCheckpointId>( - IOutputStream& out, + IOutputStream& out, const NYq::TCheckpointId& checkpointId) -{ +{ out << checkpointId.CoordinatorGeneration << ":" << checkpointId.SeqNo; -} +} diff --git a/ydb/core/yq/libs/checkpointing_common/defs.h b/ydb/core/yq/libs/checkpointing_common/defs.h index f37417fdcab..c57d1c4ff47 100644 --- a/ydb/core/yq/libs/checkpointing_common/defs.h +++ b/ydb/core/yq/libs/checkpointing_common/defs.h @@ -1,93 +1,93 @@ -#pragma once +#pragma once #include <ydb/core/yq/libs/graph_params/proto/graph_params.pb.h> - -#include <util/datetime/base.h> + +#include <util/datetime/base.h> #include <util/generic/maybe.h> -#include <util/stream/str.h> - +#include <util/stream/str.h> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -struct TCoordinatorId { - TCoordinatorId(TString graphId, ui64 generation) - : GraphId(std::move(graphId)) - , Generation(generation) { - } - - TString GraphId; - ui64 Generation; - - TString ToString() const; - void PrintTo(IOutputStream& out) const; -}; - -using TCoordinators = TVector<TCoordinatorId>; - -//////////////////////////////////////////////////////////////////////////////// - -struct TCheckpointId { + +//////////////////////////////////////////////////////////////////////////////// + +struct TCoordinatorId { + TCoordinatorId(TString graphId, ui64 generation) + : GraphId(std::move(graphId)) + , Generation(generation) { + } + + TString GraphId; + ui64 Generation; + + TString ToString() const; + void PrintTo(IOutputStream& out) const; +}; + +using TCoordinators = TVector<TCoordinatorId>; + +//////////////////////////////////////////////////////////////////////////////// + +struct TCheckpointId { ui64 CoordinatorGeneration = 0; ui64 SeqNo = 0; - + TCheckpointId(ui64 gen, ui64 SeqNo) : CoordinatorGeneration(gen) , SeqNo(SeqNo) - { - } - - bool operator ==(const TCheckpointId& rhs) const { + { + } + + bool operator ==(const TCheckpointId& rhs) const { return CoordinatorGeneration == rhs.CoordinatorGeneration && SeqNo == rhs.SeqNo; - } - - bool operator <(const TCheckpointId& rhs) const { + } + + bool operator <(const TCheckpointId& rhs) const { return CoordinatorGeneration < rhs.CoordinatorGeneration || (CoordinatorGeneration == rhs.CoordinatorGeneration && SeqNo < rhs.SeqNo); - } -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct TCheckpointIdHash { - size_t operator ()(const TCheckpointId& checkpointId); -}; - -//////////////////////////////////////////////////////////////////////////////// - -enum class ECheckpointStatus { + } +}; + +//////////////////////////////////////////////////////////////////////////////// + +struct TCheckpointIdHash { + size_t operator ()(const TCheckpointId& checkpointId); +}; + +//////////////////////////////////////////////////////////////////////////////// + +enum class ECheckpointStatus { Unspecified, - Pending, - PendingCommit, - Completed, - Aborted, - GC, -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct TCheckpointMetadata { - TCheckpointMetadata(TString graphId, - const TCheckpointId& checkpointId, - ECheckpointStatus status, - TInstant created, - TInstant modified) - : GraphId(std::move(graphId)) - , CheckpointId(checkpointId) - , Status(status) - , Created(created) - , Modified(modified) - { - } - - TString GraphId; - TCheckpointId CheckpointId; - ECheckpointStatus Status; - - TInstant Created; - TInstant Modified; + Pending, + PendingCommit, + Completed, + Aborted, + GC, +}; + +//////////////////////////////////////////////////////////////////////////////// + +struct TCheckpointMetadata { + TCheckpointMetadata(TString graphId, + const TCheckpointId& checkpointId, + ECheckpointStatus status, + TInstant created, + TInstant modified) + : GraphId(std::move(graphId)) + , CheckpointId(checkpointId) + , Status(status) + , Created(created) + , Modified(modified) + { + } + + TString GraphId; + TCheckpointId CheckpointId; + ECheckpointStatus Status; + + TInstant Created; + TInstant Modified; TMaybe<NProto::TGraphParams> Graph; -}; - -using TCheckpoints = TVector<TCheckpointMetadata>; - +}; + +using TCheckpoints = TVector<TCheckpointMetadata>; + } // namespace NYq diff --git a/ydb/core/yq/libs/checkpointing_common/ya.make b/ydb/core/yq/libs/checkpointing_common/ya.make index 578f49b1441..43e8d1593d3 100644 --- a/ydb/core/yq/libs/checkpointing_common/ya.make +++ b/ydb/core/yq/libs/checkpointing_common/ya.make @@ -1,15 +1,15 @@ OWNER(g:yq) - -LIBRARY() - -SRCS( - defs.cpp -) - + +LIBRARY() + +SRCS( + defs.cpp +) + PEERDIR( ydb/core/yq/libs/graph_params/proto ) -GENERATE_ENUM_SERIALIZATION(defs.h) - -END() +GENERATE_ENUM_SERIALIZATION(defs.h) + +END() diff --git a/ydb/core/yq/libs/ydb/util.cpp b/ydb/core/yq/libs/ydb/util.cpp index 1913c736278..121f9aeafc8 100644 --- a/ydb/core/yq/libs/ydb/util.cpp +++ b/ydb/core/yq/libs/ydb/util.cpp @@ -1,22 +1,22 @@ -#include "util.h" - -#include <util/folder/pathsplit.h> - +#include "util.h" + +#include <util/folder/pathsplit.h> + namespace NYq { - -using namespace NYdb; - -//////////////////////////////////////////////////////////////////////////////// - -TString JoinPath(const TString& basePath, const TString& path) { - if (basePath.empty()) { - return path; - } - - TPathSplitUnix prefixPathSplit(basePath); - prefixPathSplit.AppendComponent(path); - - return prefixPathSplit.Reconstruct(); -} - + +using namespace NYdb; + +//////////////////////////////////////////////////////////////////////////////// + +TString JoinPath(const TString& basePath, const TString& path) { + if (basePath.empty()) { + return path; + } + + TPathSplitUnix prefixPathSplit(basePath); + prefixPathSplit.AppendComponent(path); + + return prefixPathSplit.Reconstruct(); +} + } // namespace NYq diff --git a/ydb/core/yq/libs/ydb/util.h b/ydb/core/yq/libs/ydb/util.h index 7e179a6b7f2..6ebdb86c7b5 100644 --- a/ydb/core/yq/libs/ydb/util.h +++ b/ydb/core/yq/libs/ydb/util.h @@ -1,14 +1,14 @@ -#pragma once - +#pragma once + #include <ydb/public/sdk/cpp/client/ydb_types/status/status.h> #include <ydb/library/yql/public/issue/yql_issue_id.h> - -#include <util/generic/fwd.h> - + +#include <util/generic/fwd.h> + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -TString JoinPath(const TString& basePath, const TString& path); - + +//////////////////////////////////////////////////////////////////////////////// + +TString JoinPath(const TString& basePath, const TString& path); + } // namespace NYq diff --git a/ydb/core/yq/libs/ydb/ya.make b/ydb/core/yq/libs/ydb/ya.make index ecef6619e20..ddd0511bbad 100644 --- a/ydb/core/yq/libs/ydb/ya.make +++ b/ydb/core/yq/libs/ydb/ya.make @@ -1,19 +1,19 @@ OWNER(g:yq) - -LIBRARY() - -SRCS( - util.cpp - ydb.cpp -) - -PEERDIR( + +LIBRARY() + +SRCS( + util.cpp + ydb.cpp +) + +PEERDIR( ydb/core/yq/libs/config ydb/library/security ydb/public/sdk/cpp/client/ydb_scheme ydb/public/sdk/cpp/client/ydb_table -) - -GENERATE_ENUM_SERIALIZATION(ydb.h) - -END() +) + +GENERATE_ENUM_SERIALIZATION(ydb.h) + +END() diff --git a/ydb/core/yq/libs/ydb/ydb.cpp b/ydb/core/yq/libs/ydb/ydb.cpp index 840b08c2638..d6096abce32 100644 --- a/ydb/core/yq/libs/ydb/ydb.cpp +++ b/ydb/core/yq/libs/ydb/ydb.cpp @@ -1,191 +1,191 @@ -#include "ydb.h" - -#include "util.h" - -#include <util/stream/str.h> -#include <util/string/printf.h> +#include "ydb.h" + +#include "util.h" + +#include <util/stream/str.h> +#include <util/string/printf.h> #include <util/stream/file.h> #include <util/string/strip.h> #include <util/system/env.h> - + #include <ydb/library/security/ydb_credentials_provider_factory.h> namespace NYq { - -using namespace NThreading; -using namespace NYdb; -using namespace NYdb::NTable; - -using NYql::TIssues; - -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -TFuture<TDataQueryResult> SelectGeneration(const TGenerationContextPtr& context) { - // TODO: use prepared queries - - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - - SELECT %s, %s - FROM %s - WHERE %s = "%s"; - )", context->TablePathPrefix.c_str(), - context->PrimaryKeyColumn.c_str(), - context->GenerationColumn.c_str(), - context->Table.c_str(), - context->PrimaryKeyColumn.c_str(), - context->PrimaryKey.c_str()); - - auto ttxControl = TTxControl::BeginTx(TTxSettings::SerializableRW()); - if (context->OperationType == TGenerationContext::Check && context->CommitTx) { - ttxControl.CommitTx(); - } - - return context->Session.ExecuteDataQuery(query, ttxControl); -} - -TFuture<TStatus> CheckGeneration( - const TDataQueryResult& selectResult, - const TGenerationContextPtr& context) -{ - if (!selectResult.IsSuccess()) { - return MakeFuture<TStatus>(selectResult); - } - - - TResultSetParser parser(selectResult.GetResultSet(0)); - if (parser.TryNextRow()) { + +using namespace NThreading; +using namespace NYdb; +using namespace NYdb::NTable; + +using NYql::TIssues; + +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +TFuture<TDataQueryResult> SelectGeneration(const TGenerationContextPtr& context) { + // TODO: use prepared queries + + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + + SELECT %s, %s + FROM %s + WHERE %s = "%s"; + )", context->TablePathPrefix.c_str(), + context->PrimaryKeyColumn.c_str(), + context->GenerationColumn.c_str(), + context->Table.c_str(), + context->PrimaryKeyColumn.c_str(), + context->PrimaryKey.c_str()); + + auto ttxControl = TTxControl::BeginTx(TTxSettings::SerializableRW()); + if (context->OperationType == TGenerationContext::Check && context->CommitTx) { + ttxControl.CommitTx(); + } + + return context->Session.ExecuteDataQuery(query, ttxControl); +} + +TFuture<TStatus> CheckGeneration( + const TDataQueryResult& selectResult, + const TGenerationContextPtr& context) +{ + if (!selectResult.IsSuccess()) { + return MakeFuture<TStatus>(selectResult); + } + + + TResultSetParser parser(selectResult.GetResultSet(0)); + if (parser.TryNextRow()) { context->GenerationRead = parser.ColumnParser(context->GenerationColumn).GetOptionalUint64().GetOrElse(0); - } - - bool isOk = false; - bool requiresTransaction = false; - switch (context->OperationType) { - case TGenerationContext::Register: - { - isOk = context->GenerationRead < context->Generation; - requiresTransaction = true; - break; - } - case TGenerationContext::RegisterCheck: - { - isOk = context->GenerationRead <= context->Generation; - requiresTransaction = true; - break; - } - case TGenerationContext::Check: - { - isOk = context->GenerationRead == context->Generation; - if (!context->CommitTx) { - requiresTransaction = true; - } - break; - } - } - - context->Transaction = selectResult.GetTransaction(); - - if (!isOk) { - RollbackTransaction(context); // don't care about result - - TStringStream ss; - ss << "Table: " << JoinPath(context->TablePathPrefix, context->Table) - << ", pk: " << context->PrimaryKey - << ", current generation: " << context->GenerationRead - << ", expected/new generation: " << context->Generation - << ", operation: " << context->OperationType; - - return MakeFuture(MakeErrorStatus(EStatus::ALREADY_EXISTS, ss.Str())); - } - - if (requiresTransaction && !context->Transaction) { - // just sanity check, normally should not happen. - // note that we use retriable error - TStringStream ss; - ss << "Table: " << JoinPath(context->TablePathPrefix, context->Table) - << ", pk: " << context->PrimaryKey - << ", current generation: " << context->GenerationRead - << ", expected/new generation: " << context->Generation - << ", failed to get transaction after select"; - - return MakeFuture(MakeErrorStatus(EStatus::ABORTED, ss.Str(), NYql::TSeverityIds::S_WARNING)); - } - - return MakeFuture<TStatus>(selectResult); -} - -TFuture<TStatus> SelectGenerationWithCheck(const TGenerationContextPtr& context) { - auto future = SelectGeneration(context); - return future.Apply( - [context] (const TFuture<TDataQueryResult>& future) { - return CheckGeneration(future.GetValue(), context); - }); -} - -TFuture<TStatus> UpsertGeneration(const TGenerationContextPtr& context) { - auto query = Sprintf(R"( - --!syntax_v1 - PRAGMA TablePathPrefix("%s"); - - UPSERT INTO %s (%s, %s) VALUES - ("%s", %lu); - )", context->TablePathPrefix.c_str(), - context->Table.c_str(), - context->PrimaryKeyColumn.c_str(), - context->GenerationColumn.c_str(), - context->PrimaryKey.c_str(), - context->Generation); - - auto ttxControl = TTxControl::Tx(*context->Transaction); - if (context->CommitTx) { - ttxControl.CommitTx(); - context->Transaction.Clear(); - } - - return context->Session.ExecuteDataQuery(query, ttxControl).Apply( - [] (const TFuture<TDataQueryResult>& future) { - TStatus status = future.GetValue(); - return status; - }); -} - -TFuture<TStatus> RegisterGenerationWrapper( - const TFuture<TStatus>& selectGenerationFuture, - const TGenerationContextPtr& context) -{ - return selectGenerationFuture.Apply( - [context] (const TFuture<TStatus>& selectGenerationFuture) { - const auto& selectResult = selectGenerationFuture.GetValue(); - if (!selectResult.IsSuccess()) { - return MakeFuture(selectResult); - } - return UpsertGeneration(context); - }); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// - -TYdbConnection::TYdbConnection(const TDriverConfig& driverConfig, - const NConfig::TYdbStorageConfig& config) - : Driver(driverConfig) - , Client(Driver) - , DB(config.GetDatabase()) - , TablePathPrefix(JoinPath(DB, config.GetTablePrefix())) -{ -} - -TYdbConnection::~TYdbConnection() -{ - Driver.Stop(true); -} - -//////////////////////////////////////////////////////////////////////////////// - + } + + bool isOk = false; + bool requiresTransaction = false; + switch (context->OperationType) { + case TGenerationContext::Register: + { + isOk = context->GenerationRead < context->Generation; + requiresTransaction = true; + break; + } + case TGenerationContext::RegisterCheck: + { + isOk = context->GenerationRead <= context->Generation; + requiresTransaction = true; + break; + } + case TGenerationContext::Check: + { + isOk = context->GenerationRead == context->Generation; + if (!context->CommitTx) { + requiresTransaction = true; + } + break; + } + } + + context->Transaction = selectResult.GetTransaction(); + + if (!isOk) { + RollbackTransaction(context); // don't care about result + + TStringStream ss; + ss << "Table: " << JoinPath(context->TablePathPrefix, context->Table) + << ", pk: " << context->PrimaryKey + << ", current generation: " << context->GenerationRead + << ", expected/new generation: " << context->Generation + << ", operation: " << context->OperationType; + + return MakeFuture(MakeErrorStatus(EStatus::ALREADY_EXISTS, ss.Str())); + } + + if (requiresTransaction && !context->Transaction) { + // just sanity check, normally should not happen. + // note that we use retriable error + TStringStream ss; + ss << "Table: " << JoinPath(context->TablePathPrefix, context->Table) + << ", pk: " << context->PrimaryKey + << ", current generation: " << context->GenerationRead + << ", expected/new generation: " << context->Generation + << ", failed to get transaction after select"; + + return MakeFuture(MakeErrorStatus(EStatus::ABORTED, ss.Str(), NYql::TSeverityIds::S_WARNING)); + } + + return MakeFuture<TStatus>(selectResult); +} + +TFuture<TStatus> SelectGenerationWithCheck(const TGenerationContextPtr& context) { + auto future = SelectGeneration(context); + return future.Apply( + [context] (const TFuture<TDataQueryResult>& future) { + return CheckGeneration(future.GetValue(), context); + }); +} + +TFuture<TStatus> UpsertGeneration(const TGenerationContextPtr& context) { + auto query = Sprintf(R"( + --!syntax_v1 + PRAGMA TablePathPrefix("%s"); + + UPSERT INTO %s (%s, %s) VALUES + ("%s", %lu); + )", context->TablePathPrefix.c_str(), + context->Table.c_str(), + context->PrimaryKeyColumn.c_str(), + context->GenerationColumn.c_str(), + context->PrimaryKey.c_str(), + context->Generation); + + auto ttxControl = TTxControl::Tx(*context->Transaction); + if (context->CommitTx) { + ttxControl.CommitTx(); + context->Transaction.Clear(); + } + + return context->Session.ExecuteDataQuery(query, ttxControl).Apply( + [] (const TFuture<TDataQueryResult>& future) { + TStatus status = future.GetValue(); + return status; + }); +} + +TFuture<TStatus> RegisterGenerationWrapper( + const TFuture<TStatus>& selectGenerationFuture, + const TGenerationContextPtr& context) +{ + return selectGenerationFuture.Apply( + [context] (const TFuture<TStatus>& selectGenerationFuture) { + const auto& selectResult = selectGenerationFuture.GetValue(); + if (!selectResult.IsSuccess()) { + return MakeFuture(selectResult); + } + return UpsertGeneration(context); + }); +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// + +TYdbConnection::TYdbConnection(const TDriverConfig& driverConfig, + const NConfig::TYdbStorageConfig& config) + : Driver(driverConfig) + , Client(Driver) + , DB(config.GetDatabase()) + , TablePathPrefix(JoinPath(DB, config.GetTablePrefix())) +{ +} + +TYdbConnection::~TYdbConnection() +{ + Driver.Stop(true); +} + +//////////////////////////////////////////////////////////////////////////////// + NYdb::TDriverConfig GetDriverConfig(const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory) { @@ -201,10 +201,10 @@ NYdb::TDriverConfig GetDriverConfig(const NConfig::TYdbStorageConfig& config, const TString iamEndpoint = config.GetIamEndpoint(); const TString saKeyFile = config.GetSaKeyFile(); - auto driverConfig = TDriverConfig() - .SetEndpoint(config.GetEndpoint()) + auto driverConfig = TDriverConfig() + .SetEndpoint(config.GetEndpoint()) .SetDatabase(config.GetDatabase()); - + NKikimr::TYdbCredentialsSettings credSettings; credSettings.UseLocalMetadata = config.GetUseLocalMetadataService(); credSettings.OAuthToken = oauth; @@ -228,22 +228,22 @@ NYdb::TDriverConfig GetDriverConfig(const NConfig::TYdbStorageConfig& config, TYdbConnectionPtr NewYdbConnection(const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory) { auto driverConfig = GetDriverConfig(config, credProviderFactory); - return MakeIntrusive<TYdbConnection>(driverConfig, config); -} - -TStatus MakeErrorStatus( - EStatus code, - const TString& msg, - NYql::ESeverity severity) -{ - NYql::TIssues issues; - issues.AddIssue(msg); - auto& issue = issues.back(); - issue.SetCode((ui32)code, severity); - + return MakeIntrusive<TYdbConnection>(driverConfig, config); +} + +TStatus MakeErrorStatus( + EStatus code, + const TString& msg, + NYql::ESeverity severity) +{ + NYql::TIssues issues; + issues.AddIssue(msg); + auto& issue = issues.back(); + issue.SetCode((ui32)code, severity); + return TStatus(code, std::move(issues)); -} - +} + NYql::TIssues StatusToIssues(const NYdb::TStatus& status) { TIssues issues; if (!status.IsSuccess()) { @@ -252,87 +252,87 @@ NYql::TIssues StatusToIssues(const NYdb::TStatus& status) { return issues; } -TFuture<TIssues> StatusToIssues(const TFuture<TStatus>& future) { - return future.Apply( - [] (const TFuture<TStatus>& future) { +TFuture<TIssues> StatusToIssues(const TFuture<TStatus>& future) { + return future.Apply( + [] (const TFuture<TStatus>& future) { return StatusToIssues(future.GetValue()); - }); -} - -TFuture<TStatus> CreateTable( - const TYdbConnectionPtr& ydbConnection, - const TString& name, - TTableDescription&& description) -{ - auto tablePath = JoinPath(ydbConnection->TablePathPrefix, name.c_str()); - - return ydbConnection->Client.RetryOperation( - [tablePath = std::move(tablePath), description = std::move(description)] (TSession session) mutable { - return session.CreateTable(tablePath, TTableDescription(description)); - }); -} - -bool IsTableCreated(const NYdb::TStatus& status) { - return status.IsSuccess() || - status.GetStatus() == NYdb::EStatus::ALREADY_EXISTS || - status.GetStatus() == NYdb::EStatus::CLIENT_CANCELLED; -} - -TFuture<TStatus> RegisterGeneration(const TGenerationContextPtr& context) { - context->OperationType = TGenerationContext::Register; - auto future = SelectGenerationWithCheck(context); - return RegisterGenerationWrapper(future, context); -} - -TFuture<TStatus> RegisterCheckGeneration(const TGenerationContextPtr& context) { - context->OperationType = TGenerationContext::RegisterCheck; - auto future = SelectGenerationWithCheck(context); - - return future.Apply( - [context] (const TFuture<TStatus>& future) { - if (future.HasException()) { - return future; - } - const auto& status = future.GetValue(); - if (!status.IsSuccess()) { - return future; - } - - // check successful, which means that either: - // - generation in DB is same as in context - // - generation in DB is lower than in context - if (context->Generation > context->GenerationRead) { - // Check was OK, but we still have to register our generation - return RegisterGenerationWrapper(future, context); - } else { - // Check was OK, but we need to care about transaction: - // we will not upsert, if user requested to finish transaction - // we need to finish it (rare case, nobody probably needs check - // without transaction) - if (context->CommitTx) { - // we don't check result of rollback, because don't care - RollbackTransaction(context); - return future; - } - return future; - } - }); -} - -TFuture<TStatus> CheckGeneration(const TGenerationContextPtr& context) { - context->OperationType = TGenerationContext::Check; - return SelectGenerationWithCheck(context); -} - -TFuture<TStatus> RollbackTransaction(const TGenerationContextPtr& context) { - if (!context->Transaction || !context->Transaction->IsActive()) { - auto status = MakeErrorStatus(EStatus::INTERNAL_ERROR, "trying to rollback non-active transaction"); - return MakeFuture(status); - } - - auto future = context->Transaction->Rollback(); - context->Transaction.Clear(); - return future; -} - + }); +} + +TFuture<TStatus> CreateTable( + const TYdbConnectionPtr& ydbConnection, + const TString& name, + TTableDescription&& description) +{ + auto tablePath = JoinPath(ydbConnection->TablePathPrefix, name.c_str()); + + return ydbConnection->Client.RetryOperation( + [tablePath = std::move(tablePath), description = std::move(description)] (TSession session) mutable { + return session.CreateTable(tablePath, TTableDescription(description)); + }); +} + +bool IsTableCreated(const NYdb::TStatus& status) { + return status.IsSuccess() || + status.GetStatus() == NYdb::EStatus::ALREADY_EXISTS || + status.GetStatus() == NYdb::EStatus::CLIENT_CANCELLED; +} + +TFuture<TStatus> RegisterGeneration(const TGenerationContextPtr& context) { + context->OperationType = TGenerationContext::Register; + auto future = SelectGenerationWithCheck(context); + return RegisterGenerationWrapper(future, context); +} + +TFuture<TStatus> RegisterCheckGeneration(const TGenerationContextPtr& context) { + context->OperationType = TGenerationContext::RegisterCheck; + auto future = SelectGenerationWithCheck(context); + + return future.Apply( + [context] (const TFuture<TStatus>& future) { + if (future.HasException()) { + return future; + } + const auto& status = future.GetValue(); + if (!status.IsSuccess()) { + return future; + } + + // check successful, which means that either: + // - generation in DB is same as in context + // - generation in DB is lower than in context + if (context->Generation > context->GenerationRead) { + // Check was OK, but we still have to register our generation + return RegisterGenerationWrapper(future, context); + } else { + // Check was OK, but we need to care about transaction: + // we will not upsert, if user requested to finish transaction + // we need to finish it (rare case, nobody probably needs check + // without transaction) + if (context->CommitTx) { + // we don't check result of rollback, because don't care + RollbackTransaction(context); + return future; + } + return future; + } + }); +} + +TFuture<TStatus> CheckGeneration(const TGenerationContextPtr& context) { + context->OperationType = TGenerationContext::Check; + return SelectGenerationWithCheck(context); +} + +TFuture<TStatus> RollbackTransaction(const TGenerationContextPtr& context) { + if (!context->Transaction || !context->Transaction->IsActive()) { + auto status = MakeErrorStatus(EStatus::INTERNAL_ERROR, "trying to rollback non-active transaction"); + return MakeFuture(status); + } + + auto future = context->Transaction->Rollback(); + context->Transaction.Clear(); + return future; +} + } // namespace NYq diff --git a/ydb/core/yq/libs/ydb/ydb.h b/ydb/core/yq/libs/ydb/ydb.h index 55fd88bc54d..14c07422883 100644 --- a/ydb/core/yq/libs/ydb/ydb.h +++ b/ydb/core/yq/libs/ydb/ydb.h @@ -1,129 +1,129 @@ -#pragma once - +#pragma once + #include <ydb/library/security/ydb_credentials_provider_factory.h> #include <ydb/core/yq/libs/config/protos/storage.pb.h> - + #include <ydb/public/sdk/cpp/client/ydb_table/table.h> - + namespace NYq { - -//////////////////////////////////////////////////////////////////////////////// - -struct TYdbConnection : public TThrRefBase { - NYdb::TDriver Driver; - NYdb::NTable::TTableClient Client; - const TString DB; - const TString TablePathPrefix; - - TYdbConnection( - const NYdb::TDriverConfig& driverConfig, - const NConfig::TYdbStorageConfig& config); - - ~TYdbConnection(); -}; - -using TYdbConnectionPtr = TIntrusivePtr<TYdbConnection>; - -//////////////////////////////////////////////////////////////////////////////// - -struct TGenerationContext : public TThrRefBase { - enum EOperationType { - Register, - RegisterCheck, - Check, - }; - - // set internally, do not touch it - EOperationType OperationType = Register; - - // within this session we execute transaction - NYdb::NTable::TSession Session; - - // - In Register and RegisterCheck operation - whether - // to commit or not after upserting new generation (usually true) - // - In Check operation - whether to commit or not - // after selecting generation (normally false) - // - // - When check succeeds, and flag is true, it's up to caller - // to finish transaction. - // - When check fails then transaction is aborted automatically - const bool CommitTx; - - const TString TablePathPrefix; - const TString Table; - const TString PrimaryKeyColumn; - const TString GenerationColumn; - - const TString PrimaryKey; - - // - In Register operation - it is new generation to be registered, - // caller with higher generation wins - // - In RegisterCheck operation - it is new generation to be registered, - // if DB contains smaller generation, when generation is the same - operation - // equals to Check - // - In Check operation - expected generation, caller normally uses - // it with Transaction (must have CommitTx = false) - const ui64 Generation; - - TMaybe<NYdb::NTable::TTransaction> Transaction; - - // result of Select - ui64 GenerationRead = 0; - - TGenerationContext(NYdb::NTable::TSession session, - bool commitTx, - const TString& tablePathPrefix, - const TString& table, - const TString& primaryKeyColumn, - const TString& generationColumn, - const TString& primaryKey, - ui64 generation) - : Session(session) - , CommitTx(commitTx) - , TablePathPrefix(tablePathPrefix) - , Table(table) - , PrimaryKeyColumn(primaryKeyColumn) - , GenerationColumn(generationColumn) - , PrimaryKey(primaryKey) - , Generation(generation) - { - } -}; - -using TGenerationContextPtr = TIntrusivePtr<TGenerationContext>; - -//////////////////////////////////////////////////////////////////////////////// - + +//////////////////////////////////////////////////////////////////////////////// + +struct TYdbConnection : public TThrRefBase { + NYdb::TDriver Driver; + NYdb::NTable::TTableClient Client; + const TString DB; + const TString TablePathPrefix; + + TYdbConnection( + const NYdb::TDriverConfig& driverConfig, + const NConfig::TYdbStorageConfig& config); + + ~TYdbConnection(); +}; + +using TYdbConnectionPtr = TIntrusivePtr<TYdbConnection>; + +//////////////////////////////////////////////////////////////////////////////// + +struct TGenerationContext : public TThrRefBase { + enum EOperationType { + Register, + RegisterCheck, + Check, + }; + + // set internally, do not touch it + EOperationType OperationType = Register; + + // within this session we execute transaction + NYdb::NTable::TSession Session; + + // - In Register and RegisterCheck operation - whether + // to commit or not after upserting new generation (usually true) + // - In Check operation - whether to commit or not + // after selecting generation (normally false) + // + // - When check succeeds, and flag is true, it's up to caller + // to finish transaction. + // - When check fails then transaction is aborted automatically + const bool CommitTx; + + const TString TablePathPrefix; + const TString Table; + const TString PrimaryKeyColumn; + const TString GenerationColumn; + + const TString PrimaryKey; + + // - In Register operation - it is new generation to be registered, + // caller with higher generation wins + // - In RegisterCheck operation - it is new generation to be registered, + // if DB contains smaller generation, when generation is the same - operation + // equals to Check + // - In Check operation - expected generation, caller normally uses + // it with Transaction (must have CommitTx = false) + const ui64 Generation; + + TMaybe<NYdb::NTable::TTransaction> Transaction; + + // result of Select + ui64 GenerationRead = 0; + + TGenerationContext(NYdb::NTable::TSession session, + bool commitTx, + const TString& tablePathPrefix, + const TString& table, + const TString& primaryKeyColumn, + const TString& generationColumn, + const TString& primaryKey, + ui64 generation) + : Session(session) + , CommitTx(commitTx) + , TablePathPrefix(tablePathPrefix) + , Table(table) + , PrimaryKeyColumn(primaryKeyColumn) + , GenerationColumn(generationColumn) + , PrimaryKey(primaryKey) + , Generation(generation) + { + } +}; + +using TGenerationContextPtr = TIntrusivePtr<TGenerationContext>; + +//////////////////////////////////////////////////////////////////////////////// + NYdb::TDriverConfig GetDriverConfig(const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory); TYdbConnectionPtr NewYdbConnection(const NConfig::TYdbStorageConfig& config, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory); - -NYdb::TStatus MakeErrorStatus( - NYdb::EStatus code, - const TString& msg, - NYql::ESeverity severity = NYql::TSeverityIds::S_WARNING); - + +NYdb::TStatus MakeErrorStatus( + NYdb::EStatus code, + const TString& msg, + NYql::ESeverity severity = NYql::TSeverityIds::S_WARNING); + NYql::TIssues StatusToIssues(const NYdb::TStatus& status); -NThreading::TFuture<NYql::TIssues> StatusToIssues( - const NThreading::TFuture<NYdb::TStatus>& future); - -NThreading::TFuture<NYdb::TStatus> CreateTable( - const TYdbConnectionPtr& ydbConnection, - const TString& name, - NYdb::NTable::TTableDescription&& description); - -bool IsTableCreated(const NYdb::TStatus& status); - -// Succeeds only if specified generation strictly greater than in DB -NThreading::TFuture<NYdb::TStatus> RegisterGeneration(const TGenerationContextPtr& context); - -// Succeeds if specified generation is greater or equal than in DB -NThreading::TFuture<NYdb::TStatus> RegisterCheckGeneration(const TGenerationContextPtr& context); - -// Checks that generation is equal to the one in DB -NThreading::TFuture<NYdb::TStatus> CheckGeneration(const TGenerationContextPtr& context); - -NThreading::TFuture<NYdb::TStatus> RollbackTransaction(const TGenerationContextPtr& context); - +NThreading::TFuture<NYql::TIssues> StatusToIssues( + const NThreading::TFuture<NYdb::TStatus>& future); + +NThreading::TFuture<NYdb::TStatus> CreateTable( + const TYdbConnectionPtr& ydbConnection, + const TString& name, + NYdb::NTable::TTableDescription&& description); + +bool IsTableCreated(const NYdb::TStatus& status); + +// Succeeds only if specified generation strictly greater than in DB +NThreading::TFuture<NYdb::TStatus> RegisterGeneration(const TGenerationContextPtr& context); + +// Succeeds if specified generation is greater or equal than in DB +NThreading::TFuture<NYdb::TStatus> RegisterCheckGeneration(const TGenerationContextPtr& context); + +// Checks that generation is equal to the one in DB +NThreading::TFuture<NYdb::TStatus> CheckGeneration(const TGenerationContextPtr& context); + +NThreading::TFuture<NYdb::TStatus> RollbackTransaction(const TGenerationContextPtr& context); + } // namespace NYq diff --git a/ydb/core/yql_testlib/yql_testlib.cpp b/ydb/core/yql_testlib/yql_testlib.cpp index e3d96bc43b8..35838c40f6a 100644 --- a/ydb/core/yql_testlib/yql_testlib.cpp +++ b/ydb/core/yql_testlib/yql_testlib.cpp @@ -178,7 +178,7 @@ void TYqlServer::Initialize() { SetupTabletServices(*Runtime, &app, StaticNodes() == 1 && Settings->EnableMockOnSingleNode, Settings->CustomDiskParams); - CreateBootstrapTablets(); + CreateBootstrapTablets(); SetupStorage(); for (ui32 nodeIdx = 0; nodeIdx < GetSettings().NodeCount; ++nodeIdx) { diff --git a/ydb/library/http_proxy/error/error.cpp b/ydb/library/http_proxy/error/error.cpp index 8d36d6ed595..0c91aac8595 100644 --- a/ydb/library/http_proxy/error/error.cpp +++ b/ydb/library/http_proxy/error/error.cpp @@ -197,16 +197,16 @@ extern const TErrorClass INVALID_ATTRIBUTE_VALUE = { "The specified attribute value is invalid." }; -extern const TErrorClass LEADER_RESOLVING_ERROR = { +extern const TErrorClass LEADER_RESOLVING_ERROR = { "InternalFailure", 500, - "Queue leader resolving error." + "Queue leader resolving error." }; -extern const TErrorClass LEADER_SESSION_ERROR = { +extern const TErrorClass LEADER_SESSION_ERROR = { "InternalFailure", 500, - "Queue leader session error." + "Queue leader session error." }; extern const TErrorClass TIMEOUT = { diff --git a/ydb/library/http_proxy/error/error.h b/ydb/library/http_proxy/error/error.h index 0c7f8a7ba2c..02b9dca3d97 100644 --- a/ydb/library/http_proxy/error/error.h +++ b/ydb/library/http_proxy/error/error.h @@ -86,9 +86,9 @@ extern const TErrorClass RECEIPT_HANDLE_IS_INVALID; extern const TErrorClass INVALID_ATTRIBUTE_NAME; extern const TErrorClass INVALID_ATTRIBUTE_VALUE; -// Leader resolving errors -extern const TErrorClass LEADER_RESOLVING_ERROR; -extern const TErrorClass LEADER_SESSION_ERROR; +// Leader resolving errors +extern const TErrorClass LEADER_RESOLVING_ERROR; +extern const TErrorClass LEADER_SESSION_ERROR; // Internal timeout extern const TErrorClass TIMEOUT; diff --git a/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h b/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h index 07502374230..deaadefb42c 100644 --- a/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h +++ b/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h @@ -9,7 +9,7 @@ #include <ydb/core/scheme/scheme_tabledefs.h> // TODO: TTableId #include <ydb/core/base/kikimr_issue.h> -#include <ydb/core/tablet_flat/util_basics.h> // TODO: IDestructable +#include <ydb/core/tablet_flat/util_basics.h> // TODO: IDestructable #include <ydb/library/yql/dq/actors/protos/dq_events.pb.h> #include <ydb/library/yql/dq/common/dq_common.h> @@ -744,11 +744,11 @@ protected: protected: // virtual methods (TODO: replace with static_cast<TDerived*>(this)->Foo() - virtual THolder<NKikimr::IDestructable> GetSourcesState() { + virtual THolder<NKikimr::IDestructable> GetSourcesState() { return nullptr; } - virtual void PollSources(THolder<NKikimr::IDestructable> /* state */) { + virtual void PollSources(THolder<NKikimr::IDestructable> /* state */) { } virtual void TerminateSources(const TString& /* message */, bool /* success */) { diff --git a/ydb/public/api/protos/ydb_coordination.proto b/ydb/public/api/protos/ydb_coordination.proto index b9c951fccd5..378045e78e8 100644 --- a/ydb/public/api/protos/ydb_coordination.proto +++ b/ydb/public/api/protos/ydb_coordination.proto @@ -26,7 +26,7 @@ enum ConsistencyMode { // The default or current value CONSISTENCY_MODE_UNSET = 0; - // Strict mode makes sure operations may only complete on current leader + // Strict mode makes sure operations may only complete on current leader CONSISTENCY_MODE_STRICT = 1; // Relaxed mode allows operations to complete on stale masters @@ -57,7 +57,7 @@ message Config { // Period in milliseconds for self-checks (default 1 second) uint32 self_check_period_millis = 2; - // Grace period for sessions on leader change (default 10 seconds) + // Grace period for sessions on leader change (default 10 seconds) uint32 session_grace_period_millis = 3; // Concistency mode for read operations diff --git a/ydb/public/api/protos/ydb_persqueue_v1.proto b/ydb/public/api/protos/ydb_persqueue_v1.proto index ba94337ad04..93a7fb6c79d 100644 --- a/ydb/public/api/protos/ydb_persqueue_v1.proto +++ b/ydb/public/api/protos/ydb_persqueue_v1.proto @@ -1047,7 +1047,7 @@ message ReadInfoResult { string client_node = 11; // Host name of proxy node that processing this reading session. string proxy_node = 12; - // Host name of node where partition leader is running. + // Host name of node where partition leader is running. string tablet_node = 13; // Assign identifier of actual partition assignment. diff --git a/ydb/public/api/protos/ydb_table.proto b/ydb/public/api/protos/ydb_table.proto index 6fe0e27cfe0..c8063d9475c 100644 --- a/ydb/public/api/protos/ydb_table.proto +++ b/ydb/public/api/protos/ydb_table.proto @@ -223,7 +223,7 @@ message ReplicationPolicy { // will be created in each availability zone. Ydb.FeatureFlag.Status create_per_availability_zone = 3; // If this feature in enabled then read-only replicas can be promoted - // to leader. + // to leader. Ydb.FeatureFlag.Status allow_promotion = 4; } diff --git a/ydb/public/lib/deprecated/kicli/cpp_ut.cpp b/ydb/public/lib/deprecated/kicli/cpp_ut.cpp index d279d26dbd1..cb7dc3ed6d9 100644 --- a/ydb/public/lib/deprecated/kicli/cpp_ut.cpp +++ b/ydb/public/lib/deprecated/kicli/cpp_ut.cpp @@ -41,7 +41,7 @@ Tests::TServer StartupKikimr(NGRpcProxy::TGRpcClientConfig& clientConfig, settings.SetLogBackend(logBackend); settings.AppConfig.CopyFrom(config); settings.SetEnableSystemViews(false); - settings.SetEnableMvcc(false); + settings.SetEnableMvcc(false); Tests::TServer Server(settings); Server.EnableGRpc(grpcPort); diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp index 11d28d6359e..2f94b2fc033 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp @@ -172,7 +172,7 @@ void TCommandCreateTable::Config(TConfig& config) { "will be created in each availability zone.") .StoreTrue(&CreatePerAvailabilityZone); config.Opts->AddLongOption("allow-promotion", "If this feature in enabled then read-only replicas can be promoted " - "to leader.") + "to leader.") .StoreTrue(&AllowPromotion); } diff --git a/ydb/services/ydb/ydb_ut.cpp b/ydb/services/ydb/ydb_ut.cpp index 60a8d821b4d..2d370630799 100644 --- a/ydb/services/ydb/ydb_ut.cpp +++ b/ydb/services/ydb/ydb_ut.cpp @@ -3337,16 +3337,16 @@ void InitConfigs(TKikimrWithGrpcAndRootSchema &server) { { REPLICATION_POLICY1.Clear(); - REPLICATION_POLICY1.SetFollowerCount(1); + REPLICATION_POLICY1.SetFollowerCount(1); REPLICATION_POLICY1.SetCrossDataCenter(true); - REPLICATION_POLICY1.SetAllowFollowerPromotion(false); + REPLICATION_POLICY1.SetAllowFollowerPromotion(false); } { REPLICATION_POLICY2.Clear(); - REPLICATION_POLICY2.SetFollowerCount(2); + REPLICATION_POLICY2.SetFollowerCount(2); REPLICATION_POLICY2.SetCrossDataCenter(false); - REPLICATION_POLICY2.SetAllowFollowerPromotion(true); + REPLICATION_POLICY2.SetAllowFollowerPromotion(true); } { @@ -3654,20 +3654,20 @@ void Apply(const NKikimrConfig::TReplicationPolicy &policy, { auto &partition = *description.MutablePartitionConfig(); - partition.ClearFollowerCount(); - partition.ClearCrossDataCenterFollowerCount(); - partition.ClearAllowFollowerPromotion(); - partition.ClearFollowerGroups(); - if (policy.HasFollowerCount()) { - auto& followerGroup = *partition.AddFollowerGroups(); - followerGroup.SetFollowerCount(policy.GetFollowerCount()); + partition.ClearFollowerCount(); + partition.ClearCrossDataCenterFollowerCount(); + partition.ClearAllowFollowerPromotion(); + partition.ClearFollowerGroups(); + if (policy.HasFollowerCount()) { + auto& followerGroup = *partition.AddFollowerGroups(); + followerGroup.SetFollowerCount(policy.GetFollowerCount()); if (policy.GetCrossDataCenter()) { - followerGroup.SetRequireAllDataCenters(true); + followerGroup.SetRequireAllDataCenters(true); } else { - followerGroup.SetRequireAllDataCenters(false); + followerGroup.SetRequireAllDataCenters(false); } - if (policy.HasAllowFollowerPromotion()) { - followerGroup.SetAllowLeaderPromotion(policy.GetAllowFollowerPromotion()); + if (policy.HasAllowFollowerPromotion()) { + followerGroup.SetAllowLeaderPromotion(policy.GetAllowFollowerPromotion()); } } } @@ -4693,16 +4693,16 @@ Y_UNIT_TEST_SUITE(TTableProfileTests) { for (auto &description : result.replication_policy_presets()) { if (description.name() == "default") { CheckLabels(description.labels(), - {{ {TString("followers"), TString("disabled")} }}); + {{ {TString("followers"), TString("disabled")} }}); } else if (description.name() == "replication1"){ CheckLabels(description.labels(), - {{ {TString("followers"), TString("1")}, + {{ {TString("followers"), TString("1")}, {TString("promotion"), TString("disabled")}, {TString("per_zone"), TString("true")} }}); } else { UNIT_ASSERT_VALUES_EQUAL(description.name(), "replication2"); CheckLabels(description.labels(), - {{ {TString("followers"), TString("2")}, + {{ {TString("followers"), TString("2")}, {TString("promotion"), TString("enabled")}, {TString("per_zone"), TString("false")} }}); } diff --git a/ydb/tests/functional/scheme_shard/test_alter_ops.py b/ydb/tests/functional/scheme_shard/test_alter_ops.py index 7713721383f..d3869272bf2 100644 --- a/ydb/tests/functional/scheme_shard/test_alter_ops.py +++ b/ydb/tests/functional/scheme_shard/test_alter_ops.py @@ -298,7 +298,7 @@ class TestSchemeShardAlterTest(object): AlterTableRequest(os.path.join(self.root_dir, dirname), tablename) .with_partition_config( TPartitionConfig() - .with_followers(1) + .with_followers(1) .with_executor_cache_size(scheme.ExecutorCacheSize * 2) .with_tx_read_size_limit(scheme.TxReadSizeLimit * 3) ).protobuf, @@ -319,7 +319,7 @@ class TestSchemeShardAlterTest(object): CreateTableRequest(self.root_dir, table_name) .add_column('key', PType.Uint32, is_key=True).with_partitions(100) .with_partition_config( - TPartitionConfig().with_followers(1) + TPartitionConfig().with_followers(1) .with_in_mem_force_size_to_snapshot(16777216) .with_in_mem_steps_to_snapshot(300) ).protobuf, @@ -335,7 +335,7 @@ class TestSchemeShardAlterTest(object): AlterTableRequest(self.root_dir, table_name) .with_partition_config( TPartitionConfig() - .with_followers(1) + .with_followers(1) .with_in_mem_force_size_to_snapshot(c_policy.InMemForceSizeToSnapshot * 2) .with_in_mem_steps_to_snapshot(c_policy.InMemStepsToSnapshot // 2) ).protobuf, @@ -362,7 +362,7 @@ class TestSchemeShardAlterTest(object): resp = self.cluster.client.send( AlterTableRequest(self.root_dir, table_name) .with_partition_config( - TPartitionConfig().with_followers(1) + TPartitionConfig().with_followers(1) .with_in_mem_force_size_to_snapshot(16777216) .with_in_mem_steps_to_snapshot(300) ).protobuf, diff --git a/ydb/tests/functional/scheme_shard/test_copy_ops.py b/ydb/tests/functional/scheme_shard/test_copy_ops.py index dcfba415b9d..e55a985fd11 100644 --- a/ydb/tests/functional/scheme_shard/test_copy_ops.py +++ b/ydb/tests/functional/scheme_shard/test_copy_ops.py @@ -90,7 +90,7 @@ class TestSchemeShardCopyOps(object): ) assert_that( - description.PathDescription.Table.PartitionConfig.FollowerGroups, + description.PathDescription.Table.PartitionConfig.FollowerGroups, has_length( equal_to( 1 @@ -99,9 +99,9 @@ class TestSchemeShardCopyOps(object): ) assert_that( - description.PathDescription.Table.PartitionConfig.FollowerGroups[0], + description.PathDescription.Table.PartitionConfig.FollowerGroups[0], has_property( - 'FollowerCount', + 'FollowerCount', equal_to( 2 ) @@ -115,7 +115,7 @@ class TestSchemeShardCopyOps(object): ) assert_that( - description.PathDescription.Table.PartitionConfig.FollowerGroups, + description.PathDescription.Table.PartitionConfig.FollowerGroups, has_length( equal_to( 1 @@ -124,9 +124,9 @@ class TestSchemeShardCopyOps(object): ) assert_that( - description.PathDescription.Table.PartitionConfig.FollowerGroups[0], + description.PathDescription.Table.PartitionConfig.FollowerGroups[0], has_property( - 'FollowerCount', + 'FollowerCount', equal_to( 2 ) diff --git a/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_datashard_/flat_datashard.schema b/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_datashard_/flat_datashard.schema index 954e8a29fe6..10d5f2ef246 100644 --- a/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_datashard_/flat_datashard.schema +++ b/ydb/tests/functional/scheme_tests/canondata/tablet_scheme_tests.TestTabletSchemes.test_tablet_schemes_flat_datashard_/flat_datashard.schema @@ -1424,47 +1424,47 @@ "Blobs": 1 } } - }, - { - "TableId": 27, - "TableName": "UserTablesStats", - "TableKey": [ - 1 - ], - "ColumnsAdded": [ - { - "ColumnId": 1, - "ColumnName": "Tid", - "ColumnType": "Uint64" - }, - { - "ColumnId": 2, - "ColumnName": "FullCompactionTs", - "ColumnType": "Uint64" - } - ], - "ColumnsDropped": [], - "ColumnFamilies": { - "0": { - "Columns": [ - 1, - 2 - ], - "RoomID": 0, - "Codec": 0, - "InMemory": false, - "Cache": 0, - "Small": 4294967295, - "Large": 4294967295 - } - }, - "Rooms": { - "0": { - "Main": 1, - "Outer": 1, - "Blobs": 1 - } - } + }, + { + "TableId": 27, + "TableName": "UserTablesStats", + "TableKey": [ + 1 + ], + "ColumnsAdded": [ + { + "ColumnId": 1, + "ColumnName": "Tid", + "ColumnType": "Uint64" + }, + { + "ColumnId": 2, + "ColumnName": "FullCompactionTs", + "ColumnType": "Uint64" + } + ], + "ColumnsDropped": [], + "ColumnFamilies": { + "0": { + "Columns": [ + 1, + 2 + ], + "RoomID": 0, + "Codec": 0, + "InMemory": false, + "Cache": 0, + "Small": 4294967295, + "Large": 4294967295 + } + }, + "Rooms": { + "0": { + "Main": 1, + "Outer": 1, + "Blobs": 1 + } + } }, { "TableId": 28, diff --git a/ydb/tests/functional/serverless/conftest.py b/ydb/tests/functional/serverless/conftest.py index 9b139dce66b..0edf2c4bb73 100644 --- a/ydb/tests/functional/serverless/conftest.py +++ b/ydb/tests/functional/serverless/conftest.py @@ -19,7 +19,7 @@ def local_cluster_configuration(): erasure=Erasure.NONE, nodes=1, enable_metering=True, - disable_mvcc=True, + disable_mvcc=True, additional_log_configs={ 'TX_PROXY': LogLevels.DEBUG, 'KQP_PROXY': LogLevels.DEBUG, diff --git a/ydb/tests/functional/sqs/test_multinode_cluster.py b/ydb/tests/functional/sqs/test_multinode_cluster.py index a0b7ff6e815..047ae56198d 100644 --- a/ydb/tests/functional/sqs/test_multinode_cluster.py +++ b/ydb/tests/functional/sqs/test_multinode_cluster.py @@ -187,7 +187,7 @@ class TestSqsMultinodeCluster(KikimrSqsTestBase): assert_that( call_receive, - raises(RuntimeError, pattern='failed with status 50.*\n.*Queue leader session error.') + raises(RuntimeError, pattern='failed with status 50.*\n.*Queue leader session error.') ) logging.debug('_run_receive_message finished') self.receive_message_finished = True diff --git a/ydb/tests/library/common/protobuf_ss.py b/ydb/tests/library/common/protobuf_ss.py index 2b1ac16997e..90b0638eb41 100644 --- a/ydb/tests/library/common/protobuf_ss.py +++ b/ydb/tests/library/common/protobuf_ss.py @@ -74,9 +74,9 @@ class TPartitionConfig(AbstractProtobufBuilder): self.protobuf.CompactionPolicy.InMemForceStepsToSnapshot = in_mem_force_steps_to_snapshot return self - def with_followers(self, follower_count, allow_follower_promotion=True): - self.protobuf.FollowerCount = follower_count - self.protobuf.AllowFollowerPromotion = allow_follower_promotion + def with_followers(self, follower_count, allow_follower_promotion=True): + self.protobuf.FollowerCount = follower_count + self.protobuf.AllowFollowerPromotion = allow_follower_promotion return self def with_partitioning_policy(self, size_to_split_bytes): @@ -529,7 +529,7 @@ class CreateTableRequest(AbstractTSchemeOperationRequest): self.__partitions_count = 1 self.__partition_config = TPartitionConfig() - self.__partition_config.with_followers(follower_count=1) + self.__partition_config.with_followers(follower_count=1) self.__columns_family = list() self.__storage_config = {} @@ -659,7 +659,7 @@ class AlterTableRequest(AbstractTSchemeOperationRequest): self.protobuf.Transaction.ModifyScheme.WorkingDir = path self.__alter_table_protobuf.Name = table_name - self.with_partition_config(TPartitionConfig().with_followers(follower_count=1)) + self.with_partition_config(TPartitionConfig().with_followers(follower_count=1)) @property def __alter_table_protobuf(self): diff --git a/ydb/tests/library/harness/kikimr_config.py b/ydb/tests/library/harness/kikimr_config.py index 26aec20dae2..57c282b9f41 100644 --- a/ydb/tests/library/harness/kikimr_config.py +++ b/ydb/tests/library/harness/kikimr_config.py @@ -109,7 +109,7 @@ class KikimrConfigGenerator(object): yql_config_path=None, enable_datastreams=False, auth_config_path=None, - disable_mvcc=False, + disable_mvcc=False, enable_public_api_external_blobs=False, ): self._version = version @@ -218,7 +218,7 @@ class KikimrConfigGenerator(object): ) ) ) - + self.__build() if self.grpc_ssl_enable: |