diff options
author | chertus <azuikov@ydb.tech> | 2023-02-21 18:07:09 +0300 |
---|---|---|
committer | chertus <azuikov@ydb.tech> | 2023-02-21 18:07:09 +0300 |
commit | 6d27cf6d71a0f582f95db5e9c9940b1a712a631c (patch) | |
tree | c45bd0130db71b7072f598d07d0433c3d31bb2c3 | |
parent | cf5c82b0e7c3741a363c782402c1082db9dbffad (diff) | |
download | ydb-6d27cf6d71a0f582f95db5e9c9940b1a712a631c.tar.gz |
add cleanup lost exporting blobs logic
-rw-r--r-- | ydb/core/protos/tx_columnshard.proto | 1 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/blob.h | 6 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/blob_manager.cpp | 9 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/blob_manager_db.cpp | 1 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/columnshard__init.cpp | 19 |
5 files changed, 24 insertions, 12 deletions
diff --git a/ydb/core/protos/tx_columnshard.proto b/ydb/core/protos/tx_columnshard.proto index e503da4984c..a641c247d9d 100644 --- a/ydb/core/protos/tx_columnshard.proto +++ b/ydb/core/protos/tx_columnshard.proto @@ -55,7 +55,6 @@ message TMetadata { message TEvictMetadata { optional string TierName = 1; - optional uint32 TierVersion = 2; } message TEvWrite { diff --git a/ydb/core/tx/columnshard/blob.h b/ydb/core/tx/columnshard/blob.h index 2a568e7572f..93feda49b8f 100644 --- a/ydb/core/tx/columnshard/blob.h +++ b/ydb/core/tx/columnshard/blob.h @@ -312,12 +312,14 @@ enum class EEvictState : ui8 { SELF_CACHED = 2, // source, extern, cached blobs: 11- EXTERN = 3, // source, extern, cached blobs: -1- CACHED = 4, // source, extern, cached blobs: -11 - ERASED = 5, // source, extern, cached blobs: --- + ERASING = 5, // source, extern, cached blobs: -?? + //ERASED = 6, // source, extern, cached blobs: --- }; inline bool IsExported(EEvictState state) { return state == EEvictState::SELF_CACHED || - state == EEvictState::EXTERN; + state == EEvictState::EXTERN || + state == EEvictState::CACHED; } inline bool IsDeleted(EEvictState state) { diff --git a/ydb/core/tx/columnshard/blob_manager.cpp b/ydb/core/tx/columnshard/blob_manager.cpp index 4bd25e460dc..fb3c6c5e3f3 100644 --- a/ydb/core/tx/columnshard/blob_manager.cpp +++ b/ydb/core/tx/columnshard/blob_manager.cpp @@ -564,6 +564,8 @@ bool TBlobManager::UpdateOneToOne(TEvictedBlob&& evict, IBlobManagerDb& db, bool Y_VERIFY(extracted); switch (evict.State) { + case EEvictState::EVICTING: + Y_FAIL(); case EEvictState::SELF_CACHED: Y_VERIFY(old.State == EEvictState::EVICTING); break; @@ -614,7 +616,6 @@ bool TBlobManager::LoadOneToOneExport(IBlobManagerDb& db, THashSet<TUnifiedBlobI for (auto& [evict, metadata] : dropped) { if (evict.IsEvicting()) { droppedEvicting.insert(evict.Blob); - //continue; // keep them in DroppedEvictedBlobs till next tablet restart } NKikimrTxColumnShard::TEvictMetadata meta; @@ -647,8 +648,10 @@ TEvictedBlob TBlobManager::GetDropped(const TUnifiedBlobId& blobId, TEvictMetada void TBlobManager::GetCleanupBlobs(THashSet<TEvictedBlob>& cleanup) const { TString strBlobs; for (auto& [evict, _] : DroppedEvictedBlobs) { - strBlobs += "'" + evict.Blob.ToStringNew() + "' "; - cleanup.insert(evict); + if (evict.State != EEvictState::EVICTING) { + strBlobs += "'" + evict.Blob.ToStringNew() + "' "; + cleanup.insert(evict); + } } if (!strBlobs.empty()) { LOG_S_NOTICE("Cleanup evicted blobs " << strBlobs << "at tablet " << TabletInfo->TabletID); diff --git a/ydb/core/tx/columnshard/blob_manager_db.cpp b/ydb/core/tx/columnshard/blob_manager_db.cpp index 05802e328da..b5a42098e03 100644 --- a/ydb/core/tx/columnshard/blob_manager_db.cpp +++ b/ydb/core/tx/columnshard/blob_manager_db.cpp @@ -163,6 +163,7 @@ void TBlobManagerDb::UpdateEvictBlob(const TEvictedBlob& evict, const TString& m switch (evict.State) { case EEvictState::EVICTING: + Y_VERIFY(!meta.empty()); db.Table<Schema::OneToOneEvictedBlobs>().Key(serializedBlobId).Update( NIceDb::TUpdate<Schema::OneToOneEvictedBlobs::Size>(evict.Blob.BlobSize()), NIceDb::TUpdate<Schema::OneToOneEvictedBlobs::State>((ui8)evict.State), diff --git a/ydb/core/tx/columnshard/columnshard__init.cpp b/ydb/core/tx/columnshard/columnshard__init.cpp index 30e9b26e013..51f5b23cd6e 100644 --- a/ydb/core/tx/columnshard/columnshard__init.cpp +++ b/ydb/core/tx/columnshard/columnshard__init.cpp @@ -318,21 +318,28 @@ bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx) } } - // Clear dropped evicting records - // TODO: better cleanup logic. Check if blob exists in external storage (and remove it if so). + // Set dropped evicting records to be erased in future cleanups TString strBlobs; for (auto& blobId : lostEvictions) { TEvictMetadata meta; auto evict = Self->BlobManager->GetDropped(blobId, meta); - bool erased = Self->BlobManager->EraseOneToOne(evict, blobManagerDb); - if (erased) { + Y_VERIFY(evict.State == EEvictState::EVICTING); + evict.State = EEvictState::ERASING; + + if (meta.GetTierName().empty()) { + LOG_S_ERROR("Blob " << evict.Blob << " eviction with empty tier name at tablet " << Self->TabletID()); + } + + bool dropped; + bool present = Self->BlobManager->UpdateOneToOne(std::move(evict), blobManagerDb, dropped); + if (present) { strBlobs += "'" + evict.Blob.ToStringNew() + "' "; } else { - LOG_S_ERROR("Forget unknown dropped evicting blob " << evict.Blob << " at tablet " << Self->TabletID()); + LOG_S_ERROR("Unknown dropped evicting blob " << evict.Blob << " at tablet " << Self->TabletID()); } } if (!strBlobs.empty()) { - LOG_S_NOTICE("Forget dropped evicting blobs " << strBlobs << "at tablet " << Self->TabletID()); + LOG_S_NOTICE("Erasing potentially exported blobs " << strBlobs << "at tablet " << Self->TabletID()); } Self->UpdateInsertTableCounters(); |