summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcherednik <[email protected]>2023-08-16 12:00:45 +0300
committerdcherednik <[email protected]>2023-08-16 13:17:43 +0300
commit333783d5601f8ac574dcba9c721444985b56d4f8 (patch)
tree6f90e84862dd6a5dd979b16276fd444bb1e1e322
parent70bad0488066ff6cfd400a7e0f5ca9aaa24b2030 (diff)
Avoid race due to non atomic counter inside testlib TGrpcRequestOperationCall lambda. KIKIMR-19052
-rw-r--r--ydb/core/testlib/cs_helper.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/ydb/core/testlib/cs_helper.cpp b/ydb/core/testlib/cs_helper.cpp
index 60b09c7841c..0a2710ee2ec 100644
--- a/ydb/core/testlib/cs_helper.cpp
+++ b/ydb/core/testlib/cs_helper.cpp
@@ -74,12 +74,12 @@ void THelperSchemaless::SendDataViaActorSystem(TString testTable, std::shared_pt
request.set_data(data);
request.set_table(testTable);
- size_t responses = 0;
+ std::atomic<size_t> responses = 0;
using TEvBulkUpsertRequest = NGRpcService::TGrpcRequestOperationCall<Ydb::Table::BulkUpsertRequest,
Ydb::Table::BulkUpsertResponse>;
auto future = NRpcService::DoLocalRpc<TEvBulkUpsertRequest>(std::move(request), "", "", runtime->GetActorSystem(0));
future.Subscribe([&](const NThreading::TFuture<Ydb::Table::BulkUpsertResponse> f) mutable {
- ++responses;
+ responses.fetch_add(1);
auto op = f.GetValueSync().operation();
if (op.status() != Ydb::StatusIds::SUCCESS) {
for (auto& issue : op.issues()) {
@@ -92,7 +92,7 @@ void THelperSchemaless::SendDataViaActorSystem(TString testTable, std::shared_pt
TDispatchOptions options;
options.CustomFinalCondition = [&]() {
- return responses >= 1;
+ return responses.load() >= 1;
};
runtime->DispatchEvents(options);