Skip to content

Commit 9ce899e

Browse files
authored
Merge pull request #2214 from ClickHouse/adjust-reliability-of-select
Adding multiple loops for count verification
2 parents 1e26fbb + 1b715d4 commit 9ce899e

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

performance/src/test/com/clickhouse/benchmark/clients/BenchmarkBase.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,16 @@ public static void insertData(String tableName, InputStream dataStream, ClickHou
190190
}
191191

192192

193-
public static void verifyCount(String tableName, long expectedCount) {
193+
public static boolean verifyCount(String tableName, long expectedCount) {
194194
syncQuery(tableName);
195195
List<GenericRecord> records = runQuery(BenchmarkRunner.getSelectCountQuery(tableName));
196196
BigInteger count = records.get(0).getBigInteger(1);
197197
if (count.longValue() != expectedCount) {
198-
throw new IllegalStateException(String.format("Expected %d rows but got %d", expectedCount, count));
198+
LOGGER.error("Expected {} but got {}", expectedCount, count);
199+
return false;
199200
}
201+
LOGGER.info("Count verified: {}", count);
202+
return true;
200203
}
201204

202205
protected static ClickHouseClient getClientV1() {

performance/src/test/com/clickhouse/benchmark/clients/InsertClient.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ public class InsertClient extends BenchmarkBase {
3030

3131
@TearDown(Level.Invocation)
3232
public void verifyRowsInsertedAndCleanup(DataState dataState) {
33-
verifyCount(dataState.tableNameEmpty, dataState.dataSet.getSize());
33+
boolean success;
34+
int count = 0;
35+
do {
36+
success = verifyCount(dataState.tableNameEmpty, dataState.dataSet.getSize());
37+
if (!success) {
38+
LOGGER.warn("Retrying to verify rows inserted");
39+
try {
40+
Thread.sleep(2500);
41+
} catch (InterruptedException e) {
42+
LOGGER.error("Error: ", e);
43+
}
44+
}
45+
} while (!success && count++ < 10);
46+
if (!success) {
47+
LOGGER.error("Failed to verify rows inserted");
48+
throw new RuntimeException("Failed to verify rows inserted");
49+
}
3450
truncateTable(dataState.tableNameEmpty);
35-
syncQuery(dataState.tableNameEmpty);
3651
}
3752

3853
@Benchmark

0 commit comments

Comments
 (0)