Skip to content

Commit 425bb85

Browse files
authored
Merge pull request #943 from zhicwu/cli-client
Fix timeout issues
2 parents 1911dbd + 802ccf6 commit 425bb85

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
continue-on-error: true
108108
- name: Build project
109109
run: |
110-
mvn --batch-mode --update-snapshots -DskipTests -pl clickhouse-benchmark -am package
110+
mvn --batch-mode -DskipTests -pl clickhouse-benchmark -am package
111111
cd clickhouse-benchmark
112112
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf json ${{ github.event.inputs.options }} > output.txt
113113
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
run: mvn --batch-mode --update-snapshots -Drelease -DskipTests install
9292
- name: Build
9393
run: |
94-
mvn --batch-mode --update-snapshots -Drelease -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=${{ matrix.protocol }} verify
94+
mvn --batch-mode -Drelease -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=${{ matrix.protocol }} verify
9595
- name: Upload test results
9696
uses: actions/upload-artifact@v2
9797
if: failure()

.github/workflows/timezone.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ jobs:
6161
--also-make install
6262
- name: Test JDBC driver
6363
run: |
64-
mvn --batch-mode --update-snapshots \
65-
--projects clickhouse-jdbc \
64+
mvn --batch-mode --projects clickhouse-jdbc \
6665
-DclickhouseTimezone=${{ matrix.serverTz }} \
6766
-DclickhouseVersion=22.3 \
6867
-Duser.timezone=${{ matrix.clientTz }} \

clickhouse-cli-client/src/main/java/com/clickhouse/client/cli/ClickHouseCommandLine.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static boolean check(int timeout, String command, String... args) {
6969
}
7070
return exitValue == 0;
7171
} else {
72-
log.trace("Timed out waiting for command %s to complete", list);
72+
log.trace("Timed out after waiting %d ms for command %s to complete", timeout, list);
7373
}
7474
} catch (InterruptedException e) {
7575
Thread.currentThread().interrupt();
@@ -358,33 +358,31 @@ IOException getError() {
358358
error = "";
359359
}
360360
try {
361-
if (!process.waitFor(request.getConfig().getSocketTimeout(), TimeUnit.MILLISECONDS)) {
362-
return new IOException("Timed out waiting for command to terminate");
361+
int exitValue = process.waitFor();
362+
if (exitValue != 0) {
363+
if (error.isEmpty()) {
364+
error = ClickHouseUtils.format("Command exited with value %d", exitValue);
365+
} else {
366+
int index = error.trim().indexOf('\n');
367+
error = index > 0 ? error.substring(index + 1) : error;
368+
}
369+
} else {
370+
if (!error.isEmpty()) {
371+
// TODO update response summary
372+
log.trace(() -> {
373+
for (String line : error.split("\n")) {
374+
log.trace(line);
375+
}
376+
return "";
377+
});
378+
}
379+
error = "";
363380
}
364381
} catch (InterruptedException e) {
365382
Thread.currentThread().interrupt();
366383
process.destroyForcibly();
367384
throw new CompletionException(e);
368385
}
369-
if (process.exitValue() != 0) {
370-
if (error.isEmpty()) {
371-
error = ClickHouseUtils.format("Command exited with value %d", process.exitValue());
372-
} else {
373-
int index = error.trim().indexOf('\n');
374-
error = index > 0 ? error.substring(index + 1) : error;
375-
}
376-
} else {
377-
if (!error.isEmpty()) {
378-
// TODO update response summary
379-
log.trace(() -> {
380-
for (String line : error.split("\n")) {
381-
log.trace(line);
382-
}
383-
return "";
384-
});
385-
}
386-
error = "";
387-
}
388386
}
389387
return !ClickHouseChecker.isNullOrBlank(error) ? new IOException(error) : null;
390388
}

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseClient.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,8 @@ static ClickHouseOutputStream getAsyncRequestOutputStream(ClickHouseConfig confi
105105
final CountDownLatch latch = new CountDownLatch(1);
106106
final ClickHousePipedOutputStream stream = ClickHouseDataStreamFactory.getInstance()
107107
.createPipedOutputStream(config, () -> {
108-
long timeout = config.getSocketTimeout();
109108
try {
110-
if (timeout > 0L) {
111-
if (!latch.await(timeout, TimeUnit.MILLISECONDS)) {
112-
throw new IllegalStateException(
113-
ClickHouseUtils.format("Async write timed out after %d ms", timeout));
114-
}
115-
} else {
116-
latch.await();
117-
}
109+
latch.await();
118110

119111
if (postCloseAction != null) {
120112
postCloseAction.run();

0 commit comments

Comments
 (0)