diff options
author | t1mursadykov <t1mursadykov@ydb.tech> | 2023-04-27 16:05:47 +0300 |
---|---|---|
committer | t1mursadykov <t1mursadykov@ydb.tech> | 2023-04-27 16:05:47 +0300 |
commit | 52e7b4925a98dfa47839635e14b083d83d53ea1d (patch) | |
tree | cb7d3dc60eb41dd2575026ed3c3b6223fa0f61a3 | |
parent | 97af411cb998faab7ec06b0c3bf177ecb8f701f5 (diff) | |
download | ydb-52e7b4925a98dfa47839635e14b083d83d53ea1d.tar.gz |
Fix rollback in LogManager
-rw-r--r-- | ydb/core/cms/cluster_info.h | 11 | ||||
-rw-r--r-- | ydb/core/cms/cms_ut.cpp | 35 |
2 files changed, 38 insertions, 8 deletions
diff --git a/ydb/core/cms/cluster_info.h b/ydb/core/cms/cluster_info.h index 85cd007ca4c..923b5a7d05f 100644 --- a/ydb/core/cms/cluster_info.h +++ b/ydb/core/cms/cluster_info.h @@ -625,13 +625,12 @@ public: } void RollbackOperations() { - for (auto operation : Log) { - if (operation->Type == OPERATION_TYPE_ROLLBACK_POINT) { - Log.pop_back(); - break; - } + while (!Log.empty() && Log.back()->Type != OPERATION_TYPE_ROLLBACK_POINT) { + Log.back()->Undo(); + Log.pop_back(); + } - operation->Undo(); + if (!Log.empty() && Log.back()->Type == OPERATION_TYPE_ROLLBACK_POINT) { Log.pop_back(); } } diff --git a/ydb/core/cms/cms_ut.cpp b/ydb/core/cms/cms_ut.cpp index 4d4b6e79605..4b7ea52ce1f 100644 --- a/ydb/core/cms/cms_ut.cpp +++ b/ydb/core/cms/cms_ut.cpp @@ -1457,9 +1457,9 @@ Y_UNIT_TEST_SUITE(TCmsTest) { env.ProcessQueueCount = 0; for (ui32 i = 0; i < RequestsCount; ++i) { auto req = MakePermissionRequest("user", true, true, false, - MakeAction(NKikimrCms::TAction::RESTART_SERVICES, env.GetNodeId(i), 60000000, "storage")); + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(i), 60000000, "storage")); req->Record.SetDuration(600000); - req->Record.SetAvailabilityMode(NKikimrCms::MODE_MAX_AVAILABILITY); + req->Record.SetAvailabilityMode(MODE_MAX_AVAILABILITY); env.SendToCms(req.Release()); } @@ -1476,6 +1476,37 @@ Y_UNIT_TEST_SUITE(TCmsTest) { } UNIT_ASSERT_VALUES_EQUAL(env.ProcessQueueCount, RequestsCount); } + + Y_UNIT_TEST(TestLogOperationsRollback) + { + TCmsTestEnv env(24); + + const ui32 requestsCount = 8; + + env.SetLimits(0, 0, 3, 0); + env.CreateDefaultCmsPipe(); + for (ui32 i = 0; i < requestsCount; ++i) { + auto req = MakePermissionRequest("user", false, true, false, + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(i), 60000000, "storage"), + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(i + 8), 60000000, "storage"), + MakeAction(TAction::RESTART_SERVICES, env.GetNodeId(i + 16), 60000000, "storage")); + req->Record.SetDuration(60000000); + req->Record.SetAvailabilityMode(MODE_KEEP_AVAILABLE); + + env.SendToCms(req.Release()); + } + env.DestroyDefaultCmsPipe(); + + // Check responses order + for (ui32 i = 0; i < requestsCount; ++i) { + TAutoPtr<IEventHandle> handle; + auto reply = env.GrabEdgeEventRethrow<TEvCms::TEvPermissionResponse>(handle); + const auto &rec = reply->Record; + + UNIT_ASSERT_VALUES_EQUAL(rec.permissions_size(), 3); + UNIT_ASSERT_VALUES_EQUAL(rec.status().code(), TStatus::ALLOW); + } + } } } // NCmsTest } // NKikimr |