Skip to content

Commit b1c1f5a

Browse files
maximyurchukDarychiddqdexpnv1
authored
stable-25-1: cross version tpc-h test (ydb-platform#16683)
Co-authored-by: Aidar Samerkhanov <aidarsamer@ydb.tech> Co-authored-by: Олег <150132506+iddqdex@users.noreply.github.com> Co-authored-by: Nikolay Perfilov <pnv1@yandex-team.ru>
1 parent 9b00e4f commit b1c1f5a

File tree

12 files changed

+482
-95
lines changed

12 files changed

+482
-95
lines changed

ydb/apps/ydb/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added `--retries` to `ydb workload <clickbenh|tpch|tpcds> run` command.
2+
* Added `--partition-size` param to `ydb workload <clickbench/tpcds/tpch> init`.
13
* Fixed return code of command `ydb workload * run --check-canonical` for the case when benchmark query results differ from canonical ones.
24
* Added support for dual configuration mode in the `ydb admin cluster config fetch` command, allowing it to handle separate cluster and storage config sections.
35
* Add options for client certificates in SSL/TLS connections.

ydb/library/workload/benchmark_base/workload.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,18 @@ void TWorkloadGeneratorBase::GenerateDDLForTable(IOutputStream& result, const NJ
8282
}
8383

8484
result << "WITH (" << Endl;
85-
if (Params.GetStoreType() == TWorkloadBaseParams::EStoreType::ExternalS3) {
85+
switch (Params.GetStoreType()) {
86+
case TWorkloadBaseParams::EStoreType::ExternalS3:
8687
result << " DATA_SOURCE = \""+ Params.GetFullTableName(nullptr) + "_s3_external_source\", FORMAT = \"parquet\", LOCATION = \"" << Params.GetS3Prefix()
8788
<< "/" << (single ? TFsPath(Params.GetPath()).GetName() : (tableName + "/")) << "\"" << Endl;
88-
} else {
89-
if (Params.GetStoreType() == TWorkloadBaseParams::EStoreType::Column) {
90-
result << " STORE = COLUMN," << Endl;
91-
}
89+
break;
90+
case TWorkloadBaseParams::EStoreType::Column:
91+
result << " STORE = COLUMN," << Endl;
92+
result << " AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = " << table["partitioning"].GetUIntegerSafe(64) << Endl;
93+
break;
94+
case TWorkloadBaseParams::EStoreType::Row:
95+
result << " STORE = ROW," << Endl;
96+
result << " AUTO_PARTITIONING_PARTITION_SIZE_MB = " << Params.GetPartitionSizeMb() << ", " << Endl;
9297
result << " AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = " << table["partitioning"].GetUIntegerSafe(64) << Endl;
9398
}
9499
result << ");" << Endl;
@@ -170,6 +175,8 @@ void TWorkloadBaseParams::ConfigureOpts(NLastGetopt::TOpts& opts, const ECommand
170175
opts.AddLongOption("string", "Use String type in tables instead Utf8 one.").NoArgument().StoreValue(&StringType, "String");
171176
opts.AddLongOption("datetime", "Use Date and Timestamp types in tables instead Date32 and Timestamp64 ones.").NoArgument()
172177
.StoreValue(&DateType, "Date").StoreValue(&TimestampType, "Timestamp");
178+
opts.AddLongOption("partition-size", "Maximum partition size in megabytes (AUTO_PARTITIONING_PARTITION_SIZE_MB) for row tables.")
179+
.DefaultValue(PartitionSizeMb).StoreResult(&PartitionSizeMb);
173180
break;
174181
case TWorkloadParams::ECommandType::Root:
175182
opts.AddLongOption('p', "path", "Path where benchmark tables are located")

ydb/library/workload/benchmark_base/workload.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TWorkloadBaseParams: public TWorkloadParams {
3232
YDB_READONLY(TString, StringType, "Utf8");
3333
YDB_READONLY(TString, DateType, "Date32");
3434
YDB_READONLY(TString, TimestampType, "Timestamp64");
35+
YDB_READONLY(ui64, PartitionSizeMb, 2000);
3536
};
3637

3738
class TWorkloadGeneratorBase : public IWorkloadQueryGenerator {

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

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,6 @@ TString FullTablePath(const TString& database, const TString& table) {
131131
return prefixPathSplit.Reconstruct();
132132
}
133133

134-
135-
TMaybe<TQueryBenchmarkResult> ResultByStatus(const TStatus& status, const TString& deadlineName) {
136-
if (status.IsSuccess()) {
137-
return Nothing();
138-
}
139-
TStringBuilder errorInfo;
140-
switch (status.GetStatus()) {
141-
case NYdb::EStatus::CLIENT_DEADLINE_EXCEEDED:
142-
errorInfo << deadlineName << " deadline expiried: " << status.GetIssues();
143-
break;
144-
default:
145-
errorInfo << "Operation failed with status " << status.GetStatus() << ": " << status.GetIssues().ToString();
146-
break;
147-
}
148-
return TQueryBenchmarkResult::Error(errorInfo, "", "");
149-
}
150-
151134
bool HasCharsInString(const TString& str) {
152135
for(TStringBuf q(str), line; q.ReadLine(line);) {
153136
line = line.NextTok("--");
@@ -184,7 +167,7 @@ class TQueryResultScanner {
184167
}
185168

186169
template <typename TIterator>
187-
bool Scan(TIterator& it, std::optional<TString> planFileName = std::nullopt) {
170+
TStatus Scan(TIterator& it, std::optional<TString> planFileName = std::nullopt) {
188171

189172
TProgressIndication progressIndication(true);
190173
TMaybe<NQuery::TExecStats> execStats;
@@ -254,7 +237,7 @@ class TQueryResultScanner {
254237
if (!streamPart.IsSuccess()) {
255238
if (!streamPart.EOS()) {
256239
OnError(streamPart.GetStatus(), streamPart.GetIssues().ToString());
257-
return false;
240+
return streamPart;
258241
}
259242
break;
260243
}
@@ -268,10 +251,39 @@ class TQueryResultScanner {
268251
QueryPlan = execStats->GetPlan().value_or("");
269252
PlanAst = execStats->GetAst().value_or("");
270253
}
271-
return true;
254+
return TStatus(EStatus::SUCCESS, NIssue::TIssues());
272255
}
273256
};
274257

258+
TQueryBenchmarkResult ConstructResultByStatus(const TStatus& status, const THolder<TQueryResultScanner>& scaner, const TQueryBenchmarkSettings& becnhmarkSettings) {
259+
if (status.IsSuccess()) {
260+
Y_ENSURE(scaner);
261+
return TQueryBenchmarkResult::Result(
262+
scaner->ExtractRawResults(),
263+
scaner->GetServerTiming(),
264+
scaner->GetQueryPlan(),
265+
scaner->GetPlanAst()
266+
);
267+
}
268+
TStringBuilder errorInfo;
269+
TString plan, ast;
270+
switch (status.GetStatus()) {
271+
case NYdb::EStatus::CLIENT_DEADLINE_EXCEEDED:
272+
errorInfo << becnhmarkSettings.Deadline.Name << " deadline expiried: " << status.GetIssues();
273+
break;
274+
default:
275+
if (scaner) {
276+
errorInfo << scaner->GetErrorInfo();
277+
plan = scaner->GetQueryPlan();
278+
ast = scaner->GetPlanAst();
279+
} else {
280+
errorInfo << "Operation failed with status " << status.GetStatus() << ": " << status.GetIssues().ToString();
281+
}
282+
break;
283+
}
284+
return TQueryBenchmarkResult::Error(errorInfo, plan, ast);
285+
}
286+
275287
template<class TSettings>
276288
TMaybe<TQueryBenchmarkResult> SetTimeoutSettings(TSettings& settings, const TQueryBenchmarkDeadline& deadline) {
277289
if (deadline.Deadline != TInstant::Max()) {
@@ -284,39 +296,32 @@ TMaybe<TQueryBenchmarkResult> SetTimeoutSettings(TSettings& settings, const TQue
284296
return Nothing();
285297
}
286298

287-
TQueryBenchmarkResult ExecuteImpl(const TString& query, NTable::TTableClient& client, const TQueryBenchmarkDeadline& deadline, bool explainOnly) {
299+
TQueryBenchmarkResult ExecuteImpl(const TString& query, NTable::TTableClient& client, const TQueryBenchmarkSettings& benchmarkSettings, bool explainOnly) {
288300
TStreamExecScanQuerySettings settings;
289301
settings.CollectQueryStats(ECollectQueryStatsMode::Full);
290302
settings.Explain(explainOnly);
291-
if (const auto error = SetTimeoutSettings(settings, deadline)) {
303+
if (const auto error = SetTimeoutSettings(settings, benchmarkSettings.Deadline)) {
292304
return *error;
293305
}
294-
auto it = client.StreamExecuteScanQuery(query, settings).GetValueSync();
295-
if (const auto error = ResultByStatus(it, deadline.Name)) {
296-
return *error;
297-
}
298-
299-
TQueryResultScanner composite;
300-
composite.SetDeadlineName(deadline.Name);
301-
if (!composite.Scan(it)) {
302-
return TQueryBenchmarkResult::Error(
303-
composite.GetErrorInfo(), composite.GetQueryPlan(), composite.GetPlanAst());
304-
} else {
305-
return TQueryBenchmarkResult::Result(
306-
composite.ExtractRawResults(),
307-
composite.GetServerTiming(),
308-
composite.GetQueryPlan(),
309-
composite.GetPlanAst()
310-
);
311-
}
306+
THolder<TQueryResultScanner> composite;
307+
const auto resStatus = client.RetryOperationSync([&composite, &benchmarkSettings, &query, &settings](NTable::TTableClient& tc) -> TStatus {
308+
auto it = tc.StreamExecuteScanQuery(query, settings).GetValueSync();
309+
if (!it.IsSuccess()) {
310+
return it;
311+
}
312+
composite = MakeHolder<TQueryResultScanner>();
313+
composite->SetDeadlineName(benchmarkSettings.Deadline.Name);
314+
return composite->Scan(it);
315+
}, benchmarkSettings.RetrySettings);
316+
return ConstructResultByStatus(resStatus, composite, benchmarkSettings);
312317
}
313318

314319
TQueryBenchmarkResult Execute(const TString& query, NTable::TTableClient& client, const TQueryBenchmarkSettings& settings) {
315-
return ExecuteImpl(query, client, settings.Deadline, false);
320+
return ExecuteImpl(query, client, settings, false);
316321
}
317322

318-
TQueryBenchmarkResult Explain(const TString& query, NTable::TTableClient& client, const TQueryBenchmarkDeadline& deadline) {
319-
return ExecuteImpl(query, client, deadline, true);
323+
TQueryBenchmarkResult Explain(const TString& query, NTable::TTableClient& client, const TQueryBenchmarkSettings& settings) {
324+
return ExecuteImpl(query, client, settings, true);
320325
}
321326

322327
TQueryBenchmarkResult ExecuteImpl(const TString& query, NQuery::TQueryClient& client, const TQueryBenchmarkSettings& benchmarkSettings, bool explainOnly) {
@@ -329,36 +334,27 @@ TQueryBenchmarkResult ExecuteImpl(const TString& query, NQuery::TQueryClient& cl
329334
if (auto error = SetTimeoutSettings(settings, benchmarkSettings.Deadline)) {
330335
return *error;
331336
}
332-
auto it = client.StreamExecuteQuery(
333-
query,
334-
NYdb::NQuery::TTxControl::BeginTx().CommitTx(),
335-
settings).GetValueSync();
336-
if (auto error = ResultByStatus(it, benchmarkSettings.Deadline.Name)) {
337-
return *error;
338-
}
339-
340-
TQueryResultScanner composite;
341-
composite.SetDeadlineName(benchmarkSettings.Deadline.Name);
342-
if (!composite.Scan(it, benchmarkSettings.PlanFileName)) {
343-
return TQueryBenchmarkResult::Error(
344-
composite.GetErrorInfo(), composite.GetQueryPlan(), composite.GetPlanAst());
345-
} else {
346-
return TQueryBenchmarkResult::Result(
347-
composite.ExtractRawResults(),
348-
composite.GetServerTiming(),
349-
composite.GetQueryPlan(),
350-
composite.GetPlanAst()
351-
);
352-
}
337+
THolder<TQueryResultScanner> composite;
338+
const auto resStatus = client.RetryQuerySync([&composite, &benchmarkSettings, &query, &settings](NQuery::TQueryClient& qc) -> TStatus {
339+
auto it = qc.StreamExecuteQuery(
340+
query,
341+
NYdb::NQuery::TTxControl::BeginTx().CommitTx(),
342+
settings).GetValueSync();
343+
if (!it.IsSuccess()) {
344+
return it;
345+
}
346+
composite = MakeHolder<TQueryResultScanner>();
347+
composite->SetDeadlineName(benchmarkSettings.Deadline.Name);
348+
return composite->Scan(it);
349+
}, benchmarkSettings.RetrySettings);
350+
return ConstructResultByStatus(resStatus, composite, benchmarkSettings);
353351
}
354352

355353
TQueryBenchmarkResult Execute(const TString& query, NQuery::TQueryClient& client, const TQueryBenchmarkSettings& settings) {
356354
return ExecuteImpl(query, client, settings, false);
357355
}
358356

359-
TQueryBenchmarkResult Explain(const TString& query, NQuery::TQueryClient& client, const TQueryBenchmarkDeadline& deadline) {
360-
TQueryBenchmarkSettings settings;
361-
settings.Deadline = deadline;
357+
TQueryBenchmarkResult Explain(const TString& query, NQuery::TQueryClient& client, const TQueryBenchmarkSettings& settings) {
362358
return ExecuteImpl(query, client, settings, true);
363359
}
364360

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ struct TQueryBenchmarkSettings {
8282
TQueryBenchmarkDeadline Deadline;
8383
std::optional<TString> PlanFileName;
8484
bool WithProgress = false;
85+
NYdb::NRetry::TRetryOperationSettings RetrySettings;
8586
};
8687

8788
TString FullTablePath(const TString& database, const TString& table);
8889
bool HasCharsInString(const TString& str);
8990
TQueryBenchmarkResult Execute(const TString & query, NTable::TTableClient & client, const TQueryBenchmarkSettings& settings);
9091
TQueryBenchmarkResult Execute(const TString & query, NQuery::TQueryClient & client, const TQueryBenchmarkSettings& settings);
91-
TQueryBenchmarkResult Explain(const TString & query, NTable::TTableClient & client, const TQueryBenchmarkDeadline& deadline);
92-
TQueryBenchmarkResult Explain(const TString & query, NQuery::TQueryClient & client, const TQueryBenchmarkDeadline& deadline);
92+
TQueryBenchmarkResult Explain(const TString & query, NTable::TTableClient & client, const TQueryBenchmarkSettings& settings);
93+
TQueryBenchmarkResult Explain(const TString & query, NQuery::TQueryClient & client, const TQueryBenchmarkSettings& settings);
9394
NJson::TJsonValue GetQueryLabels(ui32 queryId);
9495
NJson::TJsonValue GetSensorValue(TStringBuf sensor, TDuration& value, ui32 queryId);
9596
NJson::TJsonValue GetSensorValue(TStringBuf sensor, double value, ui32 queryId);

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace NYdb::NConsoleClient {
1212
TWorkloadCommandBenchmark::TWorkloadCommandBenchmark(NYdbWorkload::TWorkloadParams& params, const NYdbWorkload::IWorkloadQueryGenerator::TWorkloadType& workload)
1313
: TWorkloadCommandBase(workload.CommandName, params, NYdbWorkload::TWorkloadParams::ECommandType::Run, workload.Description, workload.Type)
1414
{
15-
15+
RetrySettings.MaxRetries(0);
1616
}
1717

1818

@@ -43,6 +43,7 @@ void TWorkloadCommandBenchmark::Config(TConfig& config) {
4343
config.Opts->AddLongOption("query-prefix", "Query prefix.\nEvery prefix is a line that will be added to the beginning of each query. For multiple prefixes lines use this option several times.")
4444
.AppendTo(&QuerySettings);
4545
config.Opts->MutuallyExclusive("query-prefix", "query-settings");
46+
config.Opts->AddLongOption("retries", "Max retry count for every request.").StoreResult(&RetrySettings.MaxRetries_).DefaultValue(RetrySettings.MaxRetries_);
4647
auto fillTestCases = [](TStringBuf line, std::function<void(ui32)>&& op) {
4748
for (const auto& token : StringSplitter(line).Split(',').SkipEmpty()) {
4849
TStringBuf part = token.Token();
@@ -352,7 +353,7 @@ int TWorkloadCommandBenchmark::RunBench(TClient* client, NYdbWorkload::IWorkload
352353
TQueryBenchmarkResult res = TQueryBenchmarkResult::Error("undefined", "undefined", "undefined");
353354
try {
354355
if (client) {
355-
res = Explain(query, *client, GetDeadline());
356+
res = Explain(query, *client, GetBenchmarkSettings(false));
356357
} else {
357358
res = TQueryBenchmarkResult::Result(TQueryBenchmarkResult::TRawResults(), TDuration::Zero(), "", "");
358359
}
@@ -369,18 +370,13 @@ int TWorkloadCommandBenchmark::RunBench(TClient* client, NYdbWorkload::IWorkload
369370
break;
370371
}
371372
TQueryBenchmarkResult res = TQueryBenchmarkResult::Error("undefined", "undefined", "undefined");
372-
373-
TQueryBenchmarkSettings settings;
374-
settings.Deadline = GetDeadline();
375-
settings.WithProgress = true;
376-
377-
if (PlanFileName) {
378-
settings.PlanFileName = TStringBuilder() << PlanFileName << "." << queryN << "." << ToString(i) << ".in_progress";
379-
}
380-
381373
try {
382374
if (client) {
383-
res = Execute(query, *client, settings);
375+
auto settings = GetBenchmarkSettings(true);
376+
if (PlanFileName) {
377+
settings.PlanFileName = TStringBuilder() << PlanFileName << "." << queryN << "." << ToString(i) << ".in_progress";
378+
}
379+
res = Execute(query, *client, settings);
384380
} else {
385381
res = TQueryBenchmarkResult::Result(TQueryBenchmarkResult::TRawResults(), TDuration::Zero(), "", "");
386382
}
@@ -540,16 +536,18 @@ void TWorkloadCommandBenchmark::SavePlans(const BenchmarkUtils::TQueryBenchmarkR
540536
}
541537
}
542538

543-
BenchmarkUtils::TQueryBenchmarkDeadline TWorkloadCommandBenchmark::GetDeadline() const {
544-
BenchmarkUtils::TQueryBenchmarkDeadline result;
539+
BenchmarkUtils::TQueryBenchmarkSettings TWorkloadCommandBenchmark::GetBenchmarkSettings(bool withProgress) const {
540+
BenchmarkUtils::TQueryBenchmarkSettings result;
541+
result.WithProgress = withProgress;
542+
result.RetrySettings = RetrySettings;
545543
if (GlobalDeadline != TInstant::Max()) {
546-
result.Deadline = GlobalDeadline;
547-
result.Name = "Global ";
544+
result.Deadline.Deadline = GlobalDeadline;
545+
result.Deadline.Name = "Global ";
548546
}
549547
TInstant requestDeadline = (RequestTimeout == TDuration::Zero()) ? TInstant::Max() : (Now() + RequestTimeout);
550-
if (requestDeadline < result.Deadline) {
551-
result.Deadline = requestDeadline;
552-
result.Name = "Request";
548+
if (requestDeadline < result.Deadline.Deadline) {
549+
result.Deadline.Deadline = requestDeadline;
550+
result.Deadline.Name = "Request";
553551
}
554552
return result;
555553
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace NYdb::NConsoleClient {
66

77
namespace BenchmarkUtils {
88
class TQueryBenchmarkResult;
9-
struct TQueryBenchmarkDeadline;
9+
struct TQueryBenchmarkSettings;
1010
}
1111

1212
class TWorkloadCommandBenchmark final: public TWorkloadCommandBase {
@@ -30,7 +30,7 @@ class TWorkloadCommandBenchmark final: public TWorkloadCommandBase {
3030
int RunBench(TClient* client, NYdbWorkload::IWorkloadQueryGenerator& workloadGen);
3131
void SavePlans(const BenchmarkUtils::TQueryBenchmarkResult& res, ui32 queryNum, const TStringBuf name) const;
3232
void PrintResult(const BenchmarkUtils::TQueryBenchmarkResult& res, IOutputStream& out, const std::string& expected) const;
33-
BenchmarkUtils::TQueryBenchmarkDeadline GetDeadline() const;
33+
BenchmarkUtils::TQueryBenchmarkSettings GetBenchmarkSettings(bool withProgress) const;
3434

3535
private:
3636
EQueryExecutor QueryExecuterType = EQueryExecutor::Generic;
@@ -47,6 +47,7 @@ class TWorkloadCommandBenchmark final: public TWorkloadCommandBase {
4747
TDuration GlobalTimeout = TDuration::Zero();
4848
TDuration RequestTimeout = TDuration::Zero();
4949
TInstant GlobalDeadline = TInstant::Max();
50+
NYdb::NRetry::TRetryOperationSettings RetrySettings;
5051
};
5152

5253
}

ydb/tests/functional/benchmarks_init/canondata/test_init.TestClickbenchInit.test_s1_row/s1_row

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ CREATE TABLE `/Root/db/Root/db/clickbench/s1` (
110110
PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID)
111111
)
112112
WITH (
113+
STORE = ROW,
114+
AUTO_PARTITIONING_PARTITION_SIZE_MB = 2000,
113115
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 128
114116
);
115117

0 commit comments

Comments
 (0)