aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2023-08-25 11:32:07 +0300
committeralexvru <alexvru@ydb.tech>2023-08-25 11:48:12 +0300
commitac58c6f0f8392ae94455bdfaa632bf64b52e9151 (patch)
tree369bd1bccca84bf27a12cd83aaf1b291ae149519
parent2d3d5795145d4a0e1af689832d96daec93ae09c7 (diff)
downloadydb-ac58c6f0f8392ae94455bdfaa632bf64b52e9151.tar.gz
Fix testshard bug KIKIMR-11082
-rw-r--r--ydb/core/test_tablet/load_actor_impl.cpp6
-rw-r--r--ydb/core/test_tablet/load_actor_impl.h3
-rw-r--r--ydb/core/test_tablet/load_actor_mon.cpp2
-rw-r--r--ydb/core/test_tablet/load_actor_state.cpp64
4 files changed, 45 insertions, 30 deletions
diff --git a/ydb/core/test_tablet/load_actor_impl.cpp b/ydb/core/test_tablet/load_actor_impl.cpp
index ddf55d2ef1..f9154d69a1 100644
--- a/ydb/core/test_tablet/load_actor_impl.cpp
+++ b/ydb/core/test_tablet/load_actor_impl.cpp
@@ -16,9 +16,9 @@ namespace NKikimr::NTestShard {
void TLoadActor::ClearKeys() {
for (auto& [key, info] : Keys) {
- Y_VERIFY((info.ConfirmedState != ::NTestShard::TStateServer::CONFIRMED && info.ConfirmedKeyIndex == Max<size_t>()) ||
- (info.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED && info.ConfirmedKeyIndex != Max<size_t>() &&
- ConfirmedKeys[info.ConfirmedKeyIndex] == key));
+ Y_VERIFY(info.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED
+ ? info.ConfirmedKeyIndex < ConfirmedKeys.size() && ConfirmedKeys[info.ConfirmedKeyIndex] == key
+ : info.ConfirmedKeyIndex == Max<size_t>());
info.ConfirmedKeyIndex = Max<size_t>();
}
Keys.clear();
diff --git a/ydb/core/test_tablet/load_actor_impl.h b/ydb/core/test_tablet/load_actor_impl.h
index a1c3a6e0ab..3c803b7401 100644
--- a/ydb/core/test_tablet/load_actor_impl.h
+++ b/ydb/core/test_tablet/load_actor_impl.h
@@ -174,6 +174,9 @@ namespace NKikimr::NTestShard {
::NTestShard::TStateServer::EEntityState to, std::unique_ptr<TEvKeyValue::TEvRequest> ev = nullptr);
void Handle(TEvStateServerWriteResult::TPtr ev);
+ void MakeConfirmed(TKey& key);
+ void MakeUnconfirmed(TKey& key);
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tablet monitoring
diff --git a/ydb/core/test_tablet/load_actor_mon.cpp b/ydb/core/test_tablet/load_actor_mon.cpp
index 0a0301f134..84c1bcce13 100644
--- a/ydb/core/test_tablet/load_actor_mon.cpp
+++ b/ydb/core/test_tablet/load_actor_mon.cpp
@@ -42,7 +42,7 @@ namespace NKikimr::NTestShard {
std::vector<TDuration> intervals;
constexpr size_t orders = 4;
- constexpr size_t stepsPerOrder = 20;
+ constexpr size_t stepsPerOrder = 40;
intervals.reserve(orders * stepsPerOrder + 2);
for (ui32 i = 0; i < orders * stepsPerOrder + 1; ++i) {
const double seconds = 1e-5 * round(100 * pow(10, (double)i / stepsPerOrder));
diff --git a/ydb/core/test_tablet/load_actor_state.cpp b/ydb/core/test_tablet/load_actor_state.cpp
index a574c767fa..f39a48f2c9 100644
--- a/ydb/core/test_tablet/load_actor_state.cpp
+++ b/ydb/core/test_tablet/load_actor_state.cpp
@@ -15,37 +15,22 @@ namespace NKikimr::NTestShard {
Y_VERIFY(from != ::NTestShard::TStateServer::DELETED);
Y_VERIFY(to != ::NTestShard::TStateServer::ABSENT);
- // unconfirm the key
- if (from == ::NTestShard::TStateServer::CONFIRMED) {
- Y_VERIFY(key.second.ConfirmedKeyIndex != Max<size_t>() && key.second.ConfirmedKeyIndex < ConfirmedKeys.size());
- auto& cell = ConfirmedKeys[key.second.ConfirmedKeyIndex];
- Y_VERIFY(cell == key.first);
- std::swap(cell, ConfirmedKeys.back());
- ConfirmedKeys.pop_back();
- if (key.second.ConfirmedKeyIndex != ConfirmedKeys.size()) {
- const auto it = Keys.find(cell);
- Y_VERIFY(it != Keys.end());
- Y_VERIFY(it->second.ConfirmedKeyIndex == ConfirmedKeys.size());
- it->second.ConfirmedKeyIndex = key.second.ConfirmedKeyIndex;
- }
- key.second.ConfirmedKeyIndex = Max<size_t>();
- } else if (to == ::NTestShard::TStateServer::CONFIRMED) {
- Y_VERIFY(key.second.ConfirmedKeyIndex == Max<size_t>());
- key.second.ConfirmedKeyIndex = ConfirmedKeys.size();
- ConfirmedKeys.push_back(key.first);
- }
-
if (!Settings.HasStorageServerHost()) {
if (from == ::NTestShard::TStateServer::WRITE_PENDING && to == ::NTestShard::TStateServer::CONFIRMED) {
BytesOfData += key.second.Len;
}
+ if (from == ::NTestShard::TStateServer::CONFIRMED) {
+ MakeUnconfirmed(key);
+ } else if (to == ::NTestShard::TStateServer::CONFIRMED) {
+ MakeConfirmed(key);
+ }
if (to == ::NTestShard::TStateServer::DELETED) {
Keys.erase(key.first);
} else {
key.second.ConfirmedState = key.second.PendingState = to;
- Y_VERIFY((key.second.ConfirmedState != ::NTestShard::TStateServer::CONFIRMED && key.second.ConfirmedKeyIndex == Max<size_t>()) ||
- (key.second.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED && key.second.ConfirmedKeyIndex != Max<size_t>() &&
- ConfirmedKeys[key.second.ConfirmedKeyIndex] == key.first));
+ Y_VERIFY(key.second.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED
+ ? key.second.ConfirmedKeyIndex < ConfirmedKeys.size() && ConfirmedKeys[key.second.ConfirmedKeyIndex] == key.first
+ : key.second.ConfirmedKeyIndex == Max<size_t>());
}
if (ev) {
Send(TabletActorId, ev.release());
@@ -108,6 +93,11 @@ namespace NKikimr::NTestShard {
}
// switch to correct state
+ if (key.second.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED) {
+ MakeUnconfirmed(key);
+ } else if (key.second.PendingState == ::NTestShard::TStateServer::CONFIRMED) {
+ MakeConfirmed(key);
+ }
key.second.ConfirmedState = key.second.PendingState;
if (auto& r = key.second.Request) {
if (const auto it = WritesInFlight.find(r->Record.GetCookie()); it != WritesInFlight.end()) {
@@ -119,13 +109,35 @@ namespace NKikimr::NTestShard {
Y_VERIFY(key.second.ConfirmedKeyIndex == Max<size_t>());
Keys.erase(key.first);
} else {
- Y_VERIFY((key.second.ConfirmedState != ::NTestShard::TStateServer::CONFIRMED && key.second.ConfirmedKeyIndex == Max<size_t>()) ||
- (key.second.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED && key.second.ConfirmedKeyIndex != Max<size_t>() &&
- ConfirmedKeys[key.second.ConfirmedKeyIndex] == key.first));
+ Y_VERIFY(key.second.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED
+ ? key.second.ConfirmedKeyIndex < ConfirmedKeys.size() && ConfirmedKeys[key.second.ConfirmedKeyIndex] == key.first
+ : key.second.ConfirmedKeyIndex == Max<size_t>());
}
// perform some action if possible
Action();
}
+ void TLoadActor::MakeConfirmed(TKey& key) {
+ Y_VERIFY(key.second.ConfirmedKeyIndex == Max<size_t>());
+ key.second.ConfirmedKeyIndex = ConfirmedKeys.size();
+ ConfirmedKeys.push_back(key.first);
+ }
+
+ void TLoadActor::MakeUnconfirmed(TKey& key) {
+ Y_VERIFY(key.second.ConfirmedKeyIndex < ConfirmedKeys.size());
+ Y_VERIFY(ConfirmedKeys[key.second.ConfirmedKeyIndex] == key.first);
+ if (key.second.ConfirmedKeyIndex + 1 != ConfirmedKeys.size()) {
+ auto& cell = ConfirmedKeys[key.second.ConfirmedKeyIndex];
+ std::swap(cell, ConfirmedKeys.back());
+ const auto it = Keys.find(cell);
+ Y_VERIFY(it != Keys.end());
+ auto& otherKey = it->second;
+ Y_VERIFY(otherKey.ConfirmedKeyIndex + 1 == ConfirmedKeys.size());
+ otherKey.ConfirmedKeyIndex = key.second.ConfirmedKeyIndex;
+ }
+ ConfirmedKeys.pop_back();
+ key.second.ConfirmedKeyIndex = Max<size_t>();
+ }
+
} // NKikimr::NTestShard