Skip to content

Commit f6e8e70

Browse files
committed
read rows rpc timeout logs
1 parent aa02b3d commit f6e8e70

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

ydb/core/grpc_services/rpc_read_rows.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,41 @@ class TReadRowsRPC : public TActorBootstrapped<TReadRowsRPC> {
759759
}
760760

761761
void HandleTimeout(TEvents::TEvWakeup::TPtr&) {
762-
ReplyWithError(Ydb::StatusIds::TIMEOUT, TStringBuilder() << "ReadRows from table " << GetTable()
763-
<< " timed out, duration: " << (TAppData::TimeProvider->Now() - StartTime).Seconds() << " sec");
762+
TString errorMessage = TStringBuilder() << "ReadRows from table " << GetTable()
763+
<< " timed out, duration: " << (TAppData::TimeProvider->Now() - StartTime).Seconds() << " sec\n";
764+
765+
auto errorLog = TStringBuilder() << "TableName: " << GetTable() << '\n';
766+
767+
errorLog << "ShardIdToReadState: {";
768+
ui64 rowsRequested = 0;
769+
bool first = true;
770+
for (const auto& [shardId, readState] : ShardIdToReadState) {
771+
if (!first) {
772+
errorLog << ", ";
773+
}
774+
first = false;
775+
errorLog << "{"
776+
<< " ShardId: " << shardId
777+
<< " Status: " << readState.Status
778+
<< " ContinuationToken: " << readState.FirstUnprocessedQuery
779+
<< " }";
780+
781+
rowsRequested += readState.Keys.size();
782+
}
783+
errorLog << "}\n";
784+
785+
ui64 rowsRead = 0;
786+
for (auto& result : EvReadResults) {
787+
rowsRead += result->GetRowsCount();
788+
}
789+
790+
errorLog << "ReadsInFlight: " << ReadsInFlight << '\n';
791+
errorLog << "Retries: " << Retries << '\n';
792+
errorLog << "Rows requested: " << rowsRequested << '\n';
793+
errorLog << "Rows read: " << rowsRead << '\n';
794+
errorLog << "Estimated RuCost: " << RuCost << '\n';
795+
ReplyWithError(Ydb::StatusIds::TIMEOUT, errorMessage);
796+
LOG_ERROR_S(TlsActivationContext->AsActorContext(), NKikimrServices::RPC_REQUEST, "TReadRowsRPC HandleTimeout actor state: " << errorLog);
764797
}
765798

766799
void HandleForget(TRpcServices::TEvForgetOperation::TPtr& ev) {

ydb/services/ydb/ydb_read_rows_ut.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,27 @@ Y_UNIT_TEST_SUITE(ReadRows) {
9292
UNIT_ASSERT_VALUES_EQUAL(res.status(), ::Ydb::StatusIds::UNAVAILABLE);
9393
}
9494

95-
}
95+
dsReadResultOberver.Remove();
96+
97+
98+
// Slow read
99+
auto dsReadResultObserver = runtime.AddObserver<TEvDataShard::TEvReadResult>([&](auto&) {
100+
SimulateSleep(runtime, TDuration::Seconds(100));
101+
});
96102

103+
// Timeout
104+
{
105+
Ydb::Table::ReadRowsRequest request = MakeReadRowsRequest("/Root/table-1", {1, 5});
106+
auto readRowsFuture = NRpcService::DoLocalRpc<TEvReadRowsRequest>(
107+
std::move(request), "/Root", "", runtime.GetActorSystem(0));
108+
auto res = runtime.WaitFuture(readRowsFuture, TDuration::Seconds(10));
109+
UNIT_ASSERT_VALUES_EQUAL(res.status(), ::Ydb::StatusIds::TIMEOUT);
110+
UNIT_ASSERT_VALUES_EQUAL(
111+
res.issues().begin()->Getmessage(),
112+
"ReadRows from table /Root/table-1 timed out, duration: 60 sec\n"
113+
);
114+
}
115+
}
97116
}
98117

99118
} // namespace NKikimr

0 commit comments

Comments
 (0)