Skip to content

Commit 9dd07f5

Browse files
authored
Fix Abort on dry run benchmarks (#12886)
1 parent f962f2e commit 9dd07f5

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

ydb/apps/ydb/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fixed a bug where `ydb workload * run` command could crash in `--dry-run` mode.
12
* Added support for views in local backups: `ydb tools dump` and `ydb tools restore`. Views are backed up as `CREATE VIEW` queries saved in the `create_view.sql` files, which can be executed to recreate the original views.
23
* Replaced option `--query-settings` by `--query-prefix` one in `ydb workload <workload> run`.
34
* Added new options to `ydb workload topic`: --tx-commit-interval and --tx-commit-messages, allowing you to specify commit interval either in milliseconds or in number of messages written.

ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void CollectStats(TPrettyTable& table, IOutputStream* csv, NJson::TJsonValue* js
286286
}
287287

288288
template <typename TClient>
289-
bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloadQueryGenerator& workloadGen) {
289+
bool TWorkloadCommandBenchmark::RunBench(TClient* client, NYdbWorkload::IWorkloadQueryGenerator& workloadGen) {
290290
using namespace BenchmarkUtils;
291291
TOFStream outFStream{OutFilePath};
292292
TPrettyTable statTable(ColumnNames);
@@ -344,7 +344,11 @@ bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloa
344344
if (PlanFileName) {
345345
TQueryBenchmarkResult res = TQueryBenchmarkResult::Error("undefined", "undefined", "undefined");
346346
try {
347-
res = Explain(query, client, GetDeadline());
347+
if (client) {
348+
res = Explain(query, *client, GetDeadline());
349+
} else {
350+
res = TQueryBenchmarkResult::Result(TQueryBenchmarkResult::TRawResults(), TDuration::Zero(), "", "");
351+
}
348352
} catch (...) {
349353
res = TQueryBenchmarkResult::Error(CurrentExceptionMessage(), "", "");
350354
}
@@ -355,7 +359,11 @@ bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloa
355359
auto t1 = TInstant::Now();
356360
TQueryBenchmarkResult res = TQueryBenchmarkResult::Error("undefined", "undefined", "undefined");
357361
try {
358-
res = Execute(query, client, GetDeadline());
362+
if (client) {
363+
res = Execute(query, *client, GetDeadline());
364+
} else {
365+
res = TQueryBenchmarkResult::Result(TQueryBenchmarkResult::TRawResults(), TDuration::Zero(), "", "");
366+
}
359367
} catch (...) {
360368
res = TQueryBenchmarkResult::Error(CurrentExceptionMessage(), "", "");
361369
}
@@ -526,10 +534,10 @@ BenchmarkUtils::TQueryBenchmarkDeadline TWorkloadCommandBenchmark::GetDeadline()
526534

527535
int TWorkloadCommandBenchmark::DoRun(NYdbWorkload::IWorkloadQueryGenerator& workloadGen, TConfig& /*config*/) {
528536
if (QueryExecuterType == "scan") {
529-
return !RunBench(*TableClient, workloadGen);
537+
return !RunBench(TableClient.Get(), workloadGen);
530538
}
531539
if (QueryExecuterType == "generic") {
532-
return !RunBench(*QueryClient, workloadGen);
540+
return !RunBench(QueryClient.Get(), workloadGen);
533541
}
534542
ythrow yexception() << "Incorrect executer type. Available options: \"scan\", \"generic\"." << Endl;
535543
}

ydb/public/lib/ydb_cli/commands/ydb_benchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TWorkloadCommandBenchmark final: public TWorkloadCommandBase {
2020
bool NeedRun(const ui32 queryIdx) const;
2121

2222
template <typename TClient>
23-
bool RunBench(TClient& client, NYdbWorkload::IWorkloadQueryGenerator& workloadGen);
23+
bool RunBench(TClient* client, NYdbWorkload::IWorkloadQueryGenerator& workloadGen);
2424
void SavePlans(const BenchmarkUtils::TQueryBenchmarkResult& res, ui32 queryNum, const TStringBuf name) const;
2525
void PrintResult(const BenchmarkUtils::TQueryBenchmarkResult& res, IOutputStream& out, const std::string& expected) const;
2626
BenchmarkUtils::TQueryBenchmarkDeadline GetDeadline() const;

0 commit comments

Comments
 (0)