diff options
author | ilnaz <ilnaz@ydb.tech> | 2023-02-03 21:28:14 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2023-02-03 21:28:14 +0300 |
commit | 8806efb22f7da9345f0833a8b4ba3bb1ae5edaf4 (patch) | |
tree | 3cd773d0c3d4c0a4cdd35a89850d8f540ada09d8 | |
parent | 6d8a9540c8f443be7228254169cca75484412034 (diff) | |
download | ydb-8806efb22f7da9345f0833a8b4ba3bb1ae5edaf4.tar.gz |
Fill item's progress
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard_export.cpp | 26 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_export.cpp | 42 |
2 files changed, 56 insertions, 12 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard_export.cpp b/ydb/core/tx/schemeshard/schemeshard_export.cpp index 00eef5a0dbc..c02aab47d15 100644 --- a/ydb/core/tx/schemeshard/schemeshard_export.cpp +++ b/ydb/core/tx/schemeshard/schemeshard_export.cpp @@ -38,16 +38,10 @@ namespace { Ydb::Export::ExportItemProgress& itemProgress) { Y_VERIFY(itemIdx < exportInfo->Items.size()); - const auto& item = exportInfo->Items.at(itemIdx); - if (item.WaitTxId == InvalidTxId) { - return; - } - - const TOperationId opId(item.WaitTxId, FirstSubTxId); - const TPath path = TPath::Resolve(ExportItemPathName(ss, exportInfo, itemIdx), ss); - if (ss->TxInFlight.contains(opId)) { + const auto opId = TOperationId(item.WaitTxId, FirstSubTxId); + if (item.WaitTxId != InvalidTxId && ss->TxInFlight.contains(opId)) { const auto& txState = ss->TxInFlight.at(opId); if (txState.TxType != TTxState::TxBackup) { return; @@ -56,17 +50,25 @@ namespace { itemProgress.set_parts_total(txState.Shards.size()); itemProgress.set_parts_completed(txState.Shards.size() - txState.ShardsInProgress.size()); *itemProgress.mutable_start_time() = SecondsToProtoTimeStamp(txState.StartTime.Seconds()); - } else if (path.IsResolved()) { - if (!ss->Tables.contains(path.Base()->PathId)) { + } else { + const auto path = TPath::Resolve(ExportItemPathName(ss, exportInfo, itemIdx), ss); + if (!path.IsResolved() || !ss->Tables.contains(path.Base()->PathId)) { return; } auto table = ss->Tables.at(path.Base()->PathId); - if (!table->BackupHistory.contains(item.WaitTxId)) { + auto it = table->BackupHistory.end(); + if (item.WaitTxId != InvalidTxId) { + it = table->BackupHistory.find(item.WaitTxId); + } else if (table->BackupHistory.size() == 1) { + it = table->BackupHistory.begin(); + } + + if (it == table->BackupHistory.end()) { return; } - const auto& backupResult = table->BackupHistory.at(item.WaitTxId); + const auto& backupResult = it->second; itemProgress.set_parts_total(backupResult.TotalShardCount); itemProgress.set_parts_completed(backupResult.TotalShardCount); *itemProgress.mutable_start_time() = SecondsToProtoTimeStamp(backupResult.StartDateTime); diff --git a/ydb/core/tx/schemeshard/ut_export.cpp b/ydb/core/tx/schemeshard/ut_export.cpp index c3d60bb0cfc..0609751f617 100644 --- a/ydb/core/tx/schemeshard/ut_export.cpp +++ b/ydb/core/tx/schemeshard/ut_export.cpp @@ -891,4 +891,46 @@ partitioning_settings { const auto afterForget = waitForStats(1); UNIT_ASSERT_STRINGS_EQUAL(expected.DebugString(), afterForget.DebugString()); } + + Y_UNIT_TEST(CheckItemProgress) { + TTestBasicRuntime runtime; + TTestEnv env(runtime); + ui64 txId = 100; + + TestCreateTable(runtime, ++txId, "/MyRoot", R"( + Name: "Table" + Columns { Name: "key" Type: "Utf8" } + Columns { Name: "value" Type: "Utf8" } + KeyColumnNames: ["key"] + )"); + env.TestWaitNotification(runtime, txId); + + TPortManager portManager; + const ui16 port = portManager.GetPort(); + + TS3Mock s3Mock({}, TS3Mock::TSettings(port)); + UNIT_ASSERT(s3Mock.Start()); + + TestExport(runtime, ++txId, "/MyRoot", Sprintf(R"( + ExportToS3Settings { + endpoint: "localhost:%d" + scheme: HTTP + items { + source_path: "/MyRoot/Table" + destination_prefix: "" + } + } + )", port)); + env.TestWaitNotification(runtime, txId); + + const auto desc = TestGetExport(runtime, txId, "/MyRoot"); + const auto& entry = desc.GetResponse().GetEntry(); + UNIT_ASSERT_VALUES_EQUAL(entry.ItemsProgressSize(), 1); + + const auto& item = entry.GetItemsProgress(0); + UNIT_ASSERT_VALUES_EQUAL(item.parts_total(), 1); + UNIT_ASSERT_VALUES_EQUAL(item.parts_completed(), 1); + UNIT_ASSERT(item.has_start_time()); + UNIT_ASSERT(item.has_end_time()); + } } |