Skip to content

YQL-17553: Fix RPC reader data loss #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions ydb/library/yql/providers/yt/comp_nodes/dq/dq_yt_rpc_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "dq_yt_rpc_reader.h"
#include "dq_yt_rpc_helpers.h"

#include <ydb/library/yql/utils/failure_injector/failure_injector.h>

#include "yt/cpp/mapreduce/common/helpers.h"

#include <yt/yt/library/auth/auth.h>
Expand Down Expand Up @@ -84,6 +86,13 @@ void TParallelFileInputState::Finish() {
MkqlReader_.Finish();
}

void TParallelFileInputState::CheckError() const {
if (!InnerState_->Error.IsOK()) {
Cerr << "YT RPC Reader exception:\n";
InnerState_->Error.ThrowOnError();
}
}

bool TParallelFileInputState::RunNext() {
while (true) {
size_t InputIdx = 0;
Expand Down Expand Up @@ -120,13 +129,19 @@ bool TParallelFileInputState::RunNext() {
Cerr << (TStringBuilder() "Warn: request took: " << elapsed << " mcs)\n");
}
#endif

TFailureInjector::Reach("dq_rpc_reader_read_err_when_empty", [&res_] {
res_ = NYT::TErrorOr<NYT::TSharedRef>(NYT::TError("failure injected"));
});

if (!res_.IsOK()) {
std::lock_guard lock(state->Lock);
state->Error = std::move(res_);
--state->CurrentInflight;
state->WaitPromise.TrySet();
return;
}

auto block = std::move(res_.Value());
NYT::NApi::NRpcProxy::NProto::TRowsetDescriptor descriptor;
NYT::NApi::NRpcProxy::NProto::TRowsetStatistics statistics;
Expand Down Expand Up @@ -160,6 +175,7 @@ bool TParallelFileInputState::NextValue() {
#ifdef RPC_PRINT_TIME
print_add(-1);
#endif
CheckError();
return false;
}
if (MkqlReader_.IsValid()) {
Expand All @@ -186,10 +202,7 @@ bool TParallelFileInputState::NextValue() {
TResult result;
{
std::lock_guard lock(InnerState_->Lock);
if (!InnerState_->Error.IsOK()) {
Cerr << "YT RPC Reader exception:\n";
InnerState_->Error.ThrowOnError();
}
CheckError();
if (InnerState_->Results.empty()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct TReaderState {
bool NextValue();

private:
void CheckError() const;
// Used to pass struct in lambdas. std::shared_ptr copying is thread-safe
struct TInnerState {
TInnerState(size_t inputsCount) : IsInputDone(inputsCount) {};
Expand Down
1 change: 1 addition & 0 deletions ydb/library/yql/providers/yt/comp_nodes/dq/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PEERDIR(
ydb/library/yql/providers/yt/comp_nodes
ydb/library/yql/providers/yt/codec
ydb/library/yql/providers/common/codec
ydb/library/yql/utils/failure_injector
yt/cpp/mapreduce/interface
yt/cpp/mapreduce/common
library/cpp/yson/node
Expand Down