Skip to content

Commit 9091efd

Browse files
committed
CheckTableReads
1 parent 43cb92c commit 9091efd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ydb/core/kqp/ut/common/kqp_ut_common.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,35 @@ int GetCumulativeCounterValue(Tests::TServer& server, const TString& path, const
15381538
return result;
15391539
}
15401540

1541+
void CheckTableReads(NYdb::NTable::TSession& session, const TString& tableName, bool checkFollower, bool readsExpected) {
1542+
for (size_t attempt = 0; attempt < 30; ++attempt)
1543+
{
1544+
Cerr << "... SELECT from partition_stats for " << tableName << " , attempt " << attempt << Endl;
1545+
1546+
const TString selectPartitionStats(Q_(Sprintf(R"(
1547+
SELECT *
1548+
FROM `/Root/.sys/partition_stats`
1549+
WHERE FollowerId %s 0 AND (RowReads != 0 OR RangeReadRows != 0) AND Path = '%s'
1550+
)", (checkFollower ? "!=" : "="), tableName.c_str())));
1551+
1552+
auto result = session.ExecuteDataQuery(selectPartitionStats, TTxControl::BeginTx().CommitTx()).ExtractValueSync();
1553+
AssertSuccessResult(result);
1554+
Cerr << selectPartitionStats << Endl;
1555+
1556+
auto rs = result.GetResultSet(0);
1557+
if (readsExpected) {
1558+
if (rs.RowsCount() != 0)
1559+
return;
1560+
Sleep(TDuration::Seconds(5));
1561+
} else {
1562+
if (rs.RowsCount() == 0)
1563+
return;
1564+
Y_FAIL("!readsExpected, but there are read stats for %s", tableName.c_str());
1565+
}
1566+
}
1567+
Y_FAIL("readsExpected, but there is timeout waiting for read stats from %s", tableName.c_str());
1568+
}
1569+
15411570
NJson::TJsonValue SimplifyPlan(NJson::TJsonValue& opt, const TGetPlanParams& params) {
15421571
if (auto ops = opt.GetMapSafe().find("Operators"); ops != opt.GetMapSafe().end()) {
15431572
auto opName = ops->second.GetArraySafe()[0].GetMapSafe().at("Name").GetStringSafe();

ydb/core/kqp/ut/common/kqp_ut_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ void WaitForZeroSessions(const NKqp::TKqpCounters& counters);
386386
void WaitForZeroReadIterators(Tests::TServer& server, const TString& path);
387387
int GetCumulativeCounterValue(Tests::TServer& server, const TString& path, const TString& counterName);
388388

389+
void CheckTableReads(NYdb::NTable::TSession& session, const TString& tableName, bool checkFollower, bool readsExpected);
390+
389391
bool JoinOrderAndAlgosMatch(const TString& optimized, const TString& reference);
390392

391393
struct TGetPlanParams {

0 commit comments

Comments
 (0)