Repository navigation
Description
Description
After a change in jdbc-v2 or client-v2 source (and no change in the shim's own sources), tests/clickhouse-client/scripts/build.sh installs the new module jars, but the shim fat jar tests/clickhouse-client/target/clickhouse-client-cli-1.0.0.jar keeps the classes of the previous build. bin/clickhouse-client, and with it run-upstream-tests.sh, KNOWN_FAILURES=... runs and the steps of "Find the cause of a failure" in the README, then runs the old client code. A fix can look like it does not work, and a regression can look absent. A revert is lost in the same way.
The jar stays stale on each later build.sh. It becomes correct only when a shim source file changes or after mvn -f tests/clickhouse-client/pom.xml clean. CI is not affected: each run starts from a fresh checkout.
Root cause: build.sh:35 runs package for the shim without clean. maven-jar-plugin finds target/clickhouse-client-cli-1.0.0.jar up to date, because the shim's classes did not change, so it does not create the jar again (the jar step prints no "Building jar" line). But that file is the shaded jar of the previous build. maven-shade-plugin then uses it as the project artifact, and its old copies of the dependency classes win over the new dependency jars.
The fix is one change in build.sh. Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Steps to reproduce
- On a fresh checkout, build the shim:
tests/clickhouse-client/scripts/build.sh -DskipTests. - Add a private method to a
jdbc-v2class and to aclient-v2class, and runbuild.sh -DskipTestsagain (Code Example). - Look for the method in the installed module jars and in the shim jar (Code Example).
Error Log or Exception StackTrace
Output of the Code Example (1 = the class has the new method):
jdbc-v2 jar: 1
shim jar: 0
client-v2 jar: 1
shim jar: 0
The shim build of step 2, without --quiet:
[INFO] --- jar:3.4.2:jar (default-jar) @ clickhouse-client-cli ---
[INFO]
[INFO] --- shade:3.5.1:shade (default) @ clickhouse-client-cli ---
...
[WARNING] clickhouse-client-cli-1.0.0.jar, client-v2-0.12.0-rc1-SNAPSHOT.jar define 173 overlapping classes:
[WARNING] clickhouse-client-cli-1.0.0.jar, jdbc-v2-0.12.0-rc1-SNAPSHOT.jar define 386 overlapping classes and resources:
Expected Behaviour
After each build.sh, the shim jar has the classes of the current source. The header of build.sh (step 2) and the README (line 85, "packages the shim against exactly that version") say so. After mvn -f tests/clickhouse-client/pom.xml clean, the same build.sh gives 1 for both shim lines.
Code Example
tests/clickhouse-client/scripts/build.sh -DskipTests
sed -i 's/^public class ResultSetImpl implements ResultSet, JdbcV2Wrapper {/&\n private static void staleMarker() { }/' \
jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java
sed -i 's/^public class Client implements AutoCloseable {/&\n private static void staleMarker() { }/' \
client-v2/src/main/java/com/clickhouse/client/api/Client.java
tests/clickhouse-client/scripts/build.sh -DskipTests
V=0.12.0-rc1-SNAPSHOT; M2=~/.m2/repository/com/clickhouse
SHIM=tests/clickhouse-client/target/clickhouse-client-cli-1.0.0.jar
echo "jdbc-v2 jar: $(javap -p -cp $M2/jdbc-v2/$V/jdbc-v2-$V.jar com.clickhouse.jdbc.ResultSetImpl | grep -c staleMarker)"
echo "shim jar: $(javap -p -cp $SHIM com.clickhouse.jdbc.ResultSetImpl | grep -c staleMarker)"
echo "client-v2 jar: $(javap -p -cp $M2/client-v2/$V/client-v2-$V.jar com.clickhouse.client.api.Client | grep -c staleMarker)"
echo "shim jar: $(javap -p -cp $SHIM com.clickhouse.client.api.Client | grep -c staleMarker)"Configuration
Client Configuration
Not applicable: a build of the test harness.
Environment
- Cloud
- Client version:
mainat 27d63e9 (0.12.0-rc1-SNAPSHOT) - Language version: JDK 17.0.21.1, Maven 3.9.15 (maven-jar-plugin 3.4.2, maven-shade-plugin 3.5.1)
- OS: Linux (Ubuntu 22.04 container)
ClickHouse Server
- ClickHouse Server version: not needed (build only)
- ClickHouse Server non-default settings, if any: none
CREATE TABLEstatements for tables involved: none- Sample data for all these tables: none
Classification: impact: none · area: Docs & project (core SQL test harness, build.sh)
Found by automated analysis (Polyglot AI) while working on #3488. Verified with a local build.
Activity