Skip to content

Commit 5d2a514

Browse files
author
cherepashka
committed
YT-18541: Sequoia response keeper & cypress dyn config in tests
* Changelog entry Type: introduce Sequoia response keeper Component: master commit_hash:cee0869e8223c77582f2345a8b15a5fc7b4eb741
1 parent 37c65e1 commit 5d2a514

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

yt/yt/core/rpc/response_keeper.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "helpers.h"
55
#include "service.h"
66

7-
#include <atomic>
87
#include <yt/yt/core/concurrency/thread_affinity.h>
98
#include <yt/yt/core/concurrency/periodic_executor.h>
109

@@ -241,9 +240,7 @@ class TResponseKeeper
241240

242241
const auto& responseMessage = responseMessageOrError.Value();
243242

244-
NProto::TResponseHeader header;
245-
YT_VERIFY(TryParseResponseHeader(responseMessage, &header));
246-
bool remember = FromProto<NRpc::EErrorCode>(header.error().code()) != NRpc::EErrorCode::Unavailable;
243+
auto remember = ValidateHeaderAndParseRememberOption(responseMessage);
247244

248245
if (auto setResponseKeeperPromise = EndRequest(mutationId, responseMessage, remember)) {
249246
setResponseKeeperPromise();
@@ -313,20 +310,16 @@ class TResponseKeeper
313310

314311
auto pendingIt = PendingResponses_.find(id);
315312
if (pendingIt != PendingResponses_.end()) {
316-
if (!isRetry) {
317-
THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"")
318-
<< TErrorAttribute("mutation_id", id);
319-
}
313+
ValidateRetry(id, isRetry);
314+
320315
YT_LOG_DEBUG("Replying with pending response (MutationId: %v)", id);
321316
return pendingIt->second;
322317
}
323318

324319
auto finishedIt = FinishedResponses_.find(id);
325320
if (finishedIt != FinishedResponses_.end()) {
326-
if (!isRetry) {
327-
THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"")
328-
<< TErrorAttribute("mutation_id", id);
329-
}
321+
ValidateRetry(id, isRetry);
322+
330323
YT_LOG_DEBUG("Replying with finished response (MutationId: %v)", id);
331324
return MakeFuture(finishedIt->second);
332325
}
@@ -383,6 +376,23 @@ class TResponseKeeper
383376

384377
////////////////////////////////////////////////////////////////////////////////
385378

379+
bool ValidateHeaderAndParseRememberOption(const TSharedRefArray& responseMessage)
380+
{
381+
NProto::TResponseHeader header;
382+
YT_VERIFY(TryParseResponseHeader(responseMessage, &header));
383+
return FromProto<EErrorCode>(header.error().code()) != EErrorCode::Unavailable;
384+
}
385+
386+
void ValidateRetry(TMutationId mutationId, bool isRetry)
387+
{
388+
if (!isRetry) {
389+
THROW_ERROR_EXCEPTION("Duplicate request is not marked as \"retry\"")
390+
<< TErrorAttribute("mutation_id", mutationId);
391+
}
392+
}
393+
394+
////////////////////////////////////////////////////////////////////////////////
395+
386396
IResponseKeeperPtr CreateResponseKeeper(
387397
TResponseKeeperConfigPtr config,
388398
IInvokerPtr invoker,

yt/yt/core/rpc/response_keeper.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ DEFINE_REFCOUNTED_TYPE(IResponseKeeper)
106106

107107
////////////////////////////////////////////////////////////////////////////////
108108

109+
bool ValidateHeaderAndParseRememberOption(const TSharedRefArray& responseMessage);
110+
111+
void ValidateRetry(TMutationId mutationId, bool isRetry);
112+
113+
////////////////////////////////////////////////////////////////////////////////
114+
109115
IResponseKeeperPtr CreateResponseKeeper(
110116
TResponseKeeperConfigPtr config,
111117
IInvokerPtr invoker,

yt/yt/core/rpc/service_detail.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ class TGenericTypedServiceContext
295295
return *Response_;
296296
}
297297

298-
299298
using IServiceContext::Reply;
300299

301300
void Reply()
@@ -315,7 +314,6 @@ class TGenericTypedServiceContext
315314
}
316315
}
317316

318-
319317
const THandlerInvocationOptions& GetOptions() const
320318
{
321319
return Options_;

0 commit comments

Comments
 (0)