aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorserg-belyakov <serg-belyakov@yandex-team.com>2023-02-15 21:11:24 +0300
committerserg-belyakov <serg-belyakov@yandex-team.com>2023-02-15 21:11:24 +0300
commitedf6e0cd45309faebb548c84879d12781b6f2fe2 (patch)
treebd8a0932c558ab5a052df8c8095e0dd08655b78d
parentfb27e356c0eee23dea9abc1bc8d74af025a8846f (diff)
downloadydb-edf6e0cd45309faebb548c84879d12781b6f2fe2.tar.gz
Improve barrier checks in TGroupOverseer,
Check all the barriers remove test
-rw-r--r--ydb/core/blobstorage/testing/group_overseer/group_state.cpp102
-rw-r--r--ydb/core/blobstorage/testing/group_overseer/group_state.h1
-rw-r--r--ydb/core/blobstorage/ut_testshard/main.cpp2
3 files changed, 42 insertions, 63 deletions
diff --git a/ydb/core/blobstorage/testing/group_overseer/group_state.cpp b/ydb/core/blobstorage/testing/group_overseer/group_state.cpp
index 839781449b6..cb49a95694a 100644
--- a/ydb/core/blobstorage/testing/group_overseer/group_state.cpp
+++ b/ydb/core/blobstorage/testing/group_overseer/group_state.cpp
@@ -59,13 +59,7 @@ namespace NKikimr::NTesting {
isBlocked = Max(isBlocked, IsBlocked(tabletId, generation));
}
- const EConfidence isCollected = IsCollected(msg.Id,
- blob.ConfirmedKeep ? EConfidence::CONFIRMED :
- blob.NumKeepsInFlight ? EConfidence::POSSIBLE :
- EConfidence::SURELY_NOT,
- blob.ConfirmedDoNotKeep ? EConfidence::CONFIRMED :
- blob.NumDoNotKeepsInFlight ? EConfidence::POSSIBLE :
- EConfidence::SURELY_NOT);
+ const EConfidence isCollected = IsCollected(msg.Id, &blob);
const bool inserted = blob.PutsInFlight.emplace(queryId, TBlobInfo::TQueryContext{
.IsBlocked = isBlocked == EConfidence::CONFIRMED, // if true, we can't get OK answer
@@ -161,6 +155,10 @@ namespace NKikimr::NTesting {
.PerGenerationCounter = msg.PerGenerationCounter,
.CollectGeneration = msg.CollectGeneration,
.CollectStep = msg.CollectStep
+ },
+ .Flags{
+ msg.DoNotKeep ? std::set<TLogoBlobID>(msg.DoNotKeep->begin(), msg.DoNotKeep->end()) : std::set<TLogoBlobID>{},
+ msg.Keep ? std::set<TLogoBlobID>(msg.Keep->begin(), msg.Keep->end()) : std::set<TLogoBlobID>{}
}
});
@@ -282,74 +280,54 @@ namespace NKikimr::NTesting {
return it == Blocks.end() ? EConfidence::SURELY_NOT : it->second.IsBlocked(generation);
}
- TGroupState::EConfidence TGroupState::IsCollected(TLogoBlobID id, EConfidence keep, EConfidence doNotKeep) const {
- EConfidence result = EConfidence::SURELY_NOT;
-
+ TGroupState::EConfidence TGroupState::IsCollected(TLogoBlobID id, const TBlobInfo *blob) const {
const TBarrierId barrierId(id.TabletID(), id.Channel());
if (const auto it = Barriers.find(barrierId); it != Barriers.end()) {
const TBarrierInfo& barrier = it->second;
const auto genstep = std::make_tuple(id.Generation(), id.Step());
- EConfidence isCollectedBySoftBarrier;
- switch (keep) {
- case EConfidence::SURELY_NOT:
- isCollectedBySoftBarrier = EConfidence::CONFIRMED;
- break;
-
- case EConfidence::POSSIBLE:
- switch (doNotKeep) {
- case EConfidence::SURELY_NOT:
- case EConfidence::POSSIBLE:
- isCollectedBySoftBarrier = EConfidence::POSSIBLE;
- break;
+ bool confirmedHard = (barrier.Confirmed[true] && genstep <= barrier.Confirmed[true]->GetCollectGenStep());
- case EConfidence::CONFIRMED:
- // this case should not occur
- isCollectedBySoftBarrier = EConfidence::SURELY_NOT;
- break;
- }
- break;
-
- case EConfidence::CONFIRMED:
- switch (doNotKeep) {
- case EConfidence::SURELY_NOT:
- isCollectedBySoftBarrier = EConfidence::SURELY_NOT;
- break;
-
- case EConfidence::POSSIBLE:
- case EConfidence::CONFIRMED:
- isCollectedBySoftBarrier = EConfidence::POSSIBLE;
- break;
- }
- break;
- }
-
- auto getBarrierState = [&](const auto& confirmed, const auto& inflight) {
- if (confirmed && genstep <= confirmed->GetCollectGenStep()) {
- return EConfidence::CONFIRMED;
- }
+ bool inflightHard = false;
+ {
+ const auto& inflight = barrier.InFlight[true];
if (!inflight.empty()) {
const auto& most = *--inflight.end();
if (genstep <= most.Value.GetCollectGenStep()) {
- return EConfidence::POSSIBLE;
+ inflightHard = true;
}
}
- return EConfidence::SURELY_NOT;
- };
+ }
- result = Max(getBarrierState(barrier.Confirmed[true], barrier.InFlight[true]),
- Min(isCollectedBySoftBarrier, getBarrierState(barrier.Confirmed[false], barrier.InFlight[false])));
- }
+ bool confirmedSoft = (!blob || blob->ConfirmedDoNotKeep || !blob->ConfirmedKeep) &&
+ (barrier.Confirmed[false] && genstep <= barrier.Confirmed[false]->GetCollectGenStep());
- return result;
- }
+ bool inflightSoft = false;
+ if (blob && !blob->ConfirmedDoNotKeep) {
+ const auto& inflight = barrier.InFlight[false];
+ auto it = inflight.begin();
+ for (; it != inflight.end() && genstep > it->Value.GetCollectGenStep(); ++it) {}
- TGroupState::EConfidence TGroupState::IsCollected(TLogoBlobID id, const TBlobInfo *blob) const {
- const EConfidence keep = blob->ConfirmedKeep ? EConfidence::CONFIRMED :
- blob->NumKeepsInFlight ? EConfidence::POSSIBLE : EConfidence::SURELY_NOT;
- const EConfidence doNotKeep = blob->ConfirmedDoNotKeep ? EConfidence::CONFIRMED :
- blob->NumDoNotKeepsInFlight ? EConfidence::POSSIBLE : EConfidence::SURELY_NOT;
- return IsCollected(id, keep, doNotKeep);
+ if (it != inflight.end()) {
+ for (; it != inflight.end(); ++it) {
+ if (!it->Flags[true].count(id) || it->Flags[false].count(id)) {
+ // The blob can be collected after applying this barrier
+ inflightSoft = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (confirmedHard || confirmedSoft) {
+ return EConfidence::CONFIRMED;
+ }
+ if (inflightHard || inflightSoft) {
+ return EConfidence::POSSIBLE;
+ }
+ return EConfidence::SURELY_NOT;
+ }
+ return EConfidence::SURELY_NOT;
}
void TGroupState::ApplyBarrier(TBarrierId barrierId, std::optional<std::tuple<ui32, ui32>> prevGenStep,
@@ -398,7 +376,7 @@ namespace NKikimr::NTesting {
blob = LookupBlob(id, false);
}
if (!blob) {
- switch (IsCollected(id, EConfidence::SURELY_NOT, EConfidence::SURELY_NOT)) {
+ switch (IsCollected(id, nullptr)) {
case EConfidence::SURELY_NOT: return EBlobState::NOT_WRITTEN;
case EConfidence::POSSIBLE: return EBlobState::NOT_WRITTEN;
case EConfidence::CONFIRMED: return EBlobState::CERTAINLY_COLLECTED_OR_NEVER_WRITTEN;
diff --git a/ydb/core/blobstorage/testing/group_overseer/group_state.h b/ydb/core/blobstorage/testing/group_overseer/group_state.h
index 4a9fc651425..af491151f5d 100644
--- a/ydb/core/blobstorage/testing/group_overseer/group_state.h
+++ b/ydb/core/blobstorage/testing/group_overseer/group_state.h
@@ -96,6 +96,7 @@ namespace NKikimr::NTesting {
struct TInFlightCollect {
bool Hard;
TValue Value;
+ std::set<TLogoBlobID> Flags[2]; // doNotKeep, keep
friend bool operator <(const TInFlightCollect& x, const TInFlightCollect& y) { return x.Value < y.Value; }
};
diff --git a/ydb/core/blobstorage/ut_testshard/main.cpp b/ydb/core/blobstorage/ut_testshard/main.cpp
index 39354a7dd20..41af4b7ee22 100644
--- a/ydb/core/blobstorage/ut_testshard/main.cpp
+++ b/ydb/core/blobstorage/ut_testshard/main.cpp
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(BlobDepotWithTestShard) {
}
});
- for (ui32 i = 0; i < 1000; ++i) {
+ for (ui32 i = 0; i < 500; ++i) {
for (IActor *actor : blobDepots) {
NBlobDepot::ValidateBlobDepot(actor, env.GroupOverseer);
}