diff options
author | alexvru <alexvru@ydb.tech> | 2023-01-25 13:18:36 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2023-01-25 13:18:36 +0300 |
commit | 932e4cdf61843c075375eca1a80e395e0752df6a (patch) | |
tree | c176651e30adb6b00c169d27fc01936b47470f70 | |
parent | 3a25c623a3b31ea10258fe997095be654d4c2638 (diff) | |
download | ydb-932e4cdf61843c075375eca1a80e395e0752df6a.tar.gz |
Fix Discover query
-rw-r--r-- | ydb/core/blob_depot/agent/storage_discover.cpp | 22 | ||||
-rw-r--r-- | ydb/core/blob_depot/blob_depot_tablet.h | 11 |
2 files changed, 26 insertions, 7 deletions
diff --git a/ydb/core/blob_depot/agent/storage_discover.cpp b/ydb/core/blob_depot/agent/storage_discover.cpp index db1ea8f96b..27bfab0593 100644 --- a/ydb/core/blob_depot/agent/storage_discover.cpp +++ b/ydb/core/blob_depot/agent/storage_discover.cpp @@ -18,6 +18,9 @@ namespace NKikimr::NBlobDepot { std::unordered_set<TString> ValueChainsWithNodata; TString ValueChain; + bool IsUnassimilated = false; + + NKikimrBlobDepot::TEvResolve Resolve; public: using TBlobStorageQuery::TBlobStorageQuery; @@ -26,6 +29,7 @@ namespace NKikimr::NBlobDepot { BDEV_QUERY(BDEV16, "TEvDiscover_begin", (U.TabletId, Request.TabletId), (U.ReadBody, Request.ReadBody), (U.MinGeneration, Request.MinGeneration)); + GenerateInitialResolve(); IssueResolve(); if (Request.DiscoverBlockedGeneration) { @@ -40,13 +44,12 @@ namespace NKikimr::NBlobDepot { } } - void IssueResolve() { + void GenerateInitialResolve() { const ui8 channel = 0; const TLogoBlobID from(Request.TabletId, Request.MinGeneration, 0, channel, 0, 0); const TLogoBlobID to(Request.TabletId, Max<ui32>(), Max<ui32>(), channel, TLogoBlobID::MaxBlobSize, TLogoBlobID::MaxCookie); - NKikimrBlobDepot::TEvResolve resolve; - auto *item = resolve.AddItems(); + auto *item = Resolve.AddItems(); auto *range = item->MutableKeyRange(); range->SetBeginningKey(from.AsBinaryString()); range->SetIncludeBeginning(true); @@ -56,8 +59,10 @@ namespace NKikimr::NBlobDepot { range->SetReverse(true); item->SetTabletId(Request.TabletId); item->SetMustRestoreFirst(true); + } - Agent.Issue(std::move(resolve), this, nullptr); + void IssueResolve() { + Agent.Issue(Resolve, this, nullptr); } void ProcessResponse(ui64 id, TRequestContext::TPtr context, TResponse response) override { @@ -111,6 +116,8 @@ namespace NKikimr::NBlobDepot { return EndWithError(NKikimrProto::ERROR, TStringBuilder() << "empty ValueChain"); } ValueChain = GetValueChainId(item.GetValueChain()); + IsUnassimilated = item.ValueChainSize() == 1 && item.GetValueChain(0).GetGroupId() == Agent.DecommitGroupId && + LogoBlobIDFromLogoBlobID(item.GetValueChain(0).GetBlobId()) == Id; TReadArg arg{ item.GetValueChain(), NKikimrBlobStorage::Discover, @@ -153,6 +160,13 @@ namespace NKikimr::NBlobDepot { if (ValueChainsWithNodata.insert(std::exchange(ValueChain, {})).second) { // this may indicate a data race between locator and key value, we have to restart our resolution query IssueResolve(); + } else if (IsUnassimilated) { + // we are reading blob from the original group and it may be partially written -- it is totally + // okay to have some; we need to advance to the next readable blob + auto *range = Resolve.MutableItems(0)->MutableKeyRange(); + range->SetEndingKey(Id.AsBinaryString()); + range->ClearIncludeEnding(); + IssueResolve(); } else { Y_VERIFY_DEBUG_S(false, "data is lost AgentId# " << Agent.LogId << " BlobId# " << Id); STLOG(PRI_CRIT, BLOB_DEPOT_AGENT, BDA39, "failed to Discover blob -- data is lost", diff --git a/ydb/core/blob_depot/blob_depot_tablet.h b/ydb/core/blob_depot/blob_depot_tablet.h index e229220259..d2efc2bff7 100644 --- a/ydb/core/blob_depot/blob_depot_tablet.h +++ b/ydb/core/blob_depot/blob_depot_tablet.h @@ -202,11 +202,16 @@ namespace NKikimr::NBlobDepot { TString GetLogId() const { const auto *executor = Executor(); const ui32 generation = executor ? executor->Generation() : 0; + TStringBuilder sb; + sb << '{' << TabletID(); if (Config.HasVirtualGroupId()) { - return TStringBuilder() << "{" << TabletID() << ":" << generation << "@" << Config.GetVirtualGroupId() << "}"; - } else { - return TStringBuilder() << "{" << TabletID() << ":" << generation << "}"; + sb << '@' << Config.GetVirtualGroupId(); + } + sb << '}'; + if (generation) { + sb << ':' << generation; } + return sb; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |