Skip to content

Commit 9dd48ee

Browse files
Merge remote-tracking branch 'origin/main' into polyglot/shim-jdbc-fixedstring-padding
# Conflicts: # tests/clickhouse-client/src/main/java/com/clickhouse/client/cli/TsvRenderer.java
2 parents 1504146 + 9f9fac4 commit 9dd48ee

7 files changed

Lines changed: 164 additions & 58 deletions

File tree

‎.claude/skills/issue-classification/SKILL.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@ repository" at the end.
5252
| Impact | Use when |
5353
|---|---|
5454
| **Security** | Two parts. A **vulnerability**: a defect makes the protection weaker: it exposes credentials or data (also a secret that leaks to a log, an error message, a URL, or another host), lets a value change the meaning of a query (injection), skips or weakens a TLS or identity check, corrupts memory (an out-of-bounds write, a use after free), or lets input that the application takes from its users stop the client; also a vulnerability in a dependency. The boundaries "Hostile server or network" and "Dependencies" below say when these count. **Authentication**: an authentication method that does not work or is missing, or how the client takes credentials (for example a token provider or a credentials file); a secret that leaks is a vulnerability, not authentication. Say which part applies: the priority rules of a repo rate the two parts differently. |
55-
| **Data integrity** | Data that the caller wrote, or a result that the caller reads, is missing, incomplete, or different from the value given or stored, and the client reports no error. This includes a failed operation that the client reports as a success, a server error that the client ignores, overflow, lost precision, a time zone shift, a wrong decode, a stream that loses synchronization, a duplicate write, and a write to the wrong table. |
55+
| **Data integrity** | Data that the caller wrote, or a result that the caller reads, is missing, incomplete, or different from the value given or stored, and the client reports no error. A write that stays although the client reports an error counts too (see the boundaries). This includes a failed operation that the client reports as a success, a server error that the client ignores, overflow, lost precision, a time zone shift, a wrong decode, a stream that loses synchronization, a duplicate write, and a write to the wrong table. |
5656
| **Stability** | The process stops in a way that the caller cannot handle as a normal error (abort, segmentation fault, unrecovered panic, stack overflow), a call does not return (deadlock, hang), or a resource leaks until none is left (connections, sockets, memory). Also a thread-safety defect. |
5757
| **Performance** | The result is correct, but the operation is too slow, or uses too much memory or CPU. Also a request to make an operation faster. |
5858

5959
Boundaries:
6060

61-
- **Data integrity needs "no error".** When the client rejects a value with an error, the
62-
issue has no Data integrity impact. When the caller gets an error, but the error is wrong
63-
or not clear, the issue has no Data integrity impact either: it has the area API &
64-
diagnostics.
61+
- **Data integrity needs "no error".** When the client rejects a value with an error and
62+
stores nothing, the issue has no Data integrity impact. When the caller gets an error, but
63+
the error is wrong or not clear, the issue has no Data integrity impact either: it has the
64+
area API & diagnostics. One exception: a write that stays in the table although the call
65+
reported an error is Data integrity, because the caller cannot know that the data is there
66+
(for example, a retry after an error writes the rows a second time). So for a write, check
67+
the stored rows, also after an error.
68+
- **Bytes on the wire.** Other bytes on the wire are not wrong data when the stored and the
69+
returned values are correct.
6570
- **Security and values that are not quoted.** A value or an identifier that the client
6671
does not quote or escape gets Security only when the issue shows a path from untrusted
6772
input. A string value that leaves its literal because the client does not escape it is

‎.claude/skills/issue-priority/SKILL.md‎

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ description: >
1313

1414
This skill is the single source of truth for the **Priority** of
1515
`ClickHouse/clickhouse-java` issues. People and automated triage use the same
16-
rules.
16+
rules. Apply them in the same way to every reporter: a report of a workload, a
17+
trace, or a reproduction with the public API is evidence, whoever sends it.
1718

1819
The value goes into the org issue field **Priority** (`Urgent`, `High`,
1920
`Medium`, `Low`). The field is visible to org members only. An automated tool
@@ -52,9 +53,10 @@ the v1 stack.
5253
(**Security** → **Report a vulnerability**), never in a public issue,
5354
comment, or pull request. If a public issue reports it, copy the title, the
5455
text, and the comments of the issue into the report first.
55-
- Set no Priority on the public issue. Close it with a comment that gives no
56-
details, and ask a repository administrator to delete it: closing does not
57-
hide the text of the issue.
56+
- Set no Priority on the public issue, and do not comment on it, close it, or
57+
lock it. A maintainer decides whether to close or lock it, or to ask a
58+
repository administrator to delete it: closing does not hide the text of the
59+
issue.
5860
- Rate the vulnerability with the rules below, and put the level and its reason
5961
into the private report as the proposed severity.
6062

@@ -83,9 +85,8 @@ both conditions are true:
8385

8486
1. The severity (section 2) is "Wrong data or security" or "Broken, no
8587
workaround".
86-
2. The issue shows that customers are affected: it links a Linear customer
87-
request (`linear.app`), or a maintainer or a ClickHouse employee says that
88-
customers are affected.
88+
2. The issue shows that customers are affected: a maintainer or a ClickHouse
89+
employee says so on the issue.
8990

9091
The reach tiers, the base level, and the modifiers (sections 1, 3, and 4) do
9192
not apply to a legacy issue. This includes modifier 1: a v1 vulnerability gets
@@ -120,6 +121,25 @@ or Narrow has that tier, also when its class is in Core.
120121
[`docs/source-map.md`](../../../docs/source-map.md) maps classes and stack
121122
traces to the modules.
122123

124+
**Then look at the trigger**: the input, the type, the option, or the setup
125+
that the defect needs. A common method or type alone says little. Rate the
126+
trigger of the defect, not the trigger of the reproduction in the issue: a
127+
short reproduction often uses a rare value for a defect that common values also
128+
show.
129+
130+
- When the defect needs a trigger that few applications have, use **Narrow**,
131+
also when the API is Core or Common. Examples: an input that few
132+
applications send (control characters in an `Enum` name), an option that is
133+
not the default and that no common setup sets, a rare server setting.
134+
- A trigger that is not the default can still be common, for example a setting
135+
that a proxy, a common tool, or a framework sets, or SQL that a common tool
136+
generates. Then keep the tier of the API.
137+
- Count a trigger once: when the tier table already gives a tier to the option
138+
(for example compressed requests, `decompress`, in Common), the option does
139+
not lower the tier again.
140+
- When you cannot tell how common the trigger is, keep the tier of the API.
141+
- The trigger never gives Satellite, and never raises the tier.
142+
123143
jdbc-v2 is built on client-v2: both use the same HTTP transport, connection
124144
pool, readers, and type-name parser (`client-v2` `api/internal/`,
125145
`api/data_formats/`, and `clickhouse-data`). A defect in that code has the
@@ -141,7 +161,12 @@ fails with it.
141161

142162
## 2. Severity
143163

144-
First name the **impacts** of the issue with the classification skill of this
164+
**Check the contract first.** Compare the reported behavior with the docs, the
165+
tests, and the earlier decisions of the maintainers. A request to change a
166+
behavior that the docs or the tests define is a proposal: rate it as a feature
167+
request (last row), not as a defect.
168+
169+
Then name the **impacts** of the issue with the classification skill of this
145170
repository
146171
([`../issue-classification/SKILL.md`](../issue-classification/SKILL.md)): none,
147172
one, or more of Security (part vulnerability or part authentication), Data
@@ -152,10 +177,17 @@ highest row applies:
152177

153178
| Severity | Use when |
154179
| ----------------------- | -------- |
155-
| Wrong data or security | impact **Data integrity**: the client returns or stores wrong or incomplete data with no error, or reports success for a query that failed; or impact **Security** with a vulnerability (for a vulnerability in a dependency: only when the client calls the vulnerable code) |
156-
| Broken, no workaround | the feature fails (an exception, a hang, a leak that ends in an `OutOfMemoryError` or in exhausted connections), and the caller has no reasonable workaround; also a wrong or incomplete error with no workaround: the failure is reported, but its type, code, or message is wrong or lost. The impact **Stability** (a hang, a `StackOverflowError` or `OutOfMemoryError`, such a leak) uses this row when the caller has no reasonable workaround |
157-
| Workaround exists | the feature fails, but the caller can avoid the failure with a small change in their own code (name the workaround in the reason); also impact **Performance** of a defect: a result that is correct but slow or uses too much memory (a request to make an operation faster is a feature request: last row) |
158-
| Cosmetic, docs, feature | wrong log or message text, documentation, a feature request; also a request to make an operation faster, and a dependency update (also one for a vulnerability in a dependency, in code that the client does not call) |
180+
| Wrong data or security | impact **Data integrity**: the client returns or stores wrong or incomplete data with no error, or reports success for a query that failed, or keeps a write although it reported an error; or impact **Security** with a vulnerability (for a vulnerability in a dependency: only when the client calls the vulnerable code) |
181+
| Broken, no workaround | the feature fails (an exception, a hang, a leak that ends in an `OutOfMemoryError` or in exhausted connections), and the caller has no reasonable workaround; also an exception of the wrong type or code, when the exception handler that the docs describe does not catch it (an exception message that is only wrong or not clear is in the last row). The impact **Stability** (a hang, a `StackOverflowError` or `OutOfMemoryError`, such a leak) uses this row when the caller has no reasonable workaround; also impact **Performance** when a supported workload can no longer finish within its time or memory budget |
182+
| Workaround exists | the feature fails, but the caller can avoid the failure with a small change in their own code (name the workaround in the reason); also impact **Performance** of a defect: a correct result with a measured slowdown or memory use that materially delays a workload, and a Performance defect with no measurement yet (a request to make an operation faster is a feature request: last row) |
183+
| Cosmetic, docs, feature | wrong log or message text (also an exception message that is wrong, not clear, or incomplete when the type and the code of the exception are correct, for example for an input that is not valid and that the client rejects with an awkward message), documentation, a feature request; also a request to make an operation faster, and a dependency update (also one for a vulnerability in a dependency, in code that the client does not call); also impact **Performance** of a defect with a small measured effect on the workload (for example 5% slower) |
184+
185+
**A reasonable workaround** keeps the result that the caller asked for, in the
186+
caller's setup, with a small and safe change (name it in the reason). These
187+
are not reasonable workarounds: a change to another protocol or transport,
188+
skipping a required authentication or TLS check, and a check of every returned
189+
row or value. When the only workaround is one of these, use the row "Broken,
190+
no workaround".
159191

160192
**An exception of a type that the API does not declare.** The JDBC methods of
161193
jdbc-v2 must throw `SQLException`, and client-v2 throws the subclasses of
@@ -222,9 +254,6 @@ Apply them in this order:
222254
pre-release (`vX.Y.Z-rcN`); a patch release of an older line (for example
223255
`v0.9.9`, published after `v0.10.0`) is not the latest release. The release
224256
before it is the next lower version that is not a pre-release.
225-
4. **Customer request in Linear.** The issue links (`linear.app`) a Linear
226-
issue for a customer request: up one level, but never to `Urgent` (`High`
227-
stays `High`).
228257

229258
A defect on the query path (`Client.query`, `queryAll`, `queryRecords`,
230259
`Statement.executeQuery`, the getters of `ResultSet`) gets no ingestion
@@ -253,4 +282,8 @@ For a legacy issue, the line is:
253282
`Legacy (<path>) · <impacts, or "no impact"> · <severity> · <"critical for customers: <evidence>", or "not critical for customers"> → <level>.`
254283

255284
Name the workaround when the severity is "Workaround exists". When the
256-
confidence is `LOW`, say what is missing.
285+
confidence is `LOW`, say what is missing. When the trigger sets the tier, name
286+
it after the path, for example
287+
`Narrow (ResultSetImpl.getString of Enum8; trigger: control characters in an Enum name)`.
288+
For the impact Performance, give the measurements before and after, and the
289+
limit that the workload hits.

‎.github/ISSUE_TEMPLATE/bug_report.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ assignees: ''
2222
- environment
2323
- documentation
2424
- tests
25+
- ci
2526
- other
2627
2728
Detail Labels:
@@ -30,6 +31,7 @@ assignees: ''
3031
3132
Other Labels:
3233
- performance
34+
- flaky-test
3335
-->
3436
## Description
3537

‎clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.net.Inet4Address;
2323
import java.net.Inet6Address;
2424
import java.net.InetAddress;
25+
import java.net.ServerSocket;
2526
import java.net.UnknownHostException;
2627
import java.nio.charset.StandardCharsets;
2728
import java.nio.file.Files;
@@ -2733,16 +2734,18 @@ public void testRowBinaryWithDefaults() throws ClickHouseException, IOException,
27332734
}
27342735

27352736
@Test(dataProvider = "loadBalancingPolicies", groups = {"unit"})
2736-
public void testLoadBalancingPolicyFailover(ClickHouseLoadBalancingPolicy loadBalancingPolicy) {
2737-
String firstEndpoint = "111.1.1.1";
2738-
String secondEndpoint = "222.2.2.2";
2737+
public void testLoadBalancingPolicyFailover(ClickHouseLoadBalancingPolicy loadBalancingPolicy) throws IOException {
2738+
String endpoint = "127.0.0.1";
2739+
int[] ports = findUnusedPorts(endpoint, 2);
2740+
int firstPort = ports[0];
2741+
int secondPort = ports[1];
27392742

27402743
Properties props = new Properties();
27412744
props.setProperty("failover", "1");
27422745

27432746
// nodes where the first node is failed
27442747
ClickHouseNodes nodes = ClickHouseNodes.of(
2745-
getProtocol() + "://" + firstEndpoint + "," + secondEndpoint,
2748+
getProtocol() + "://" + endpoint + ":" + firstPort + "," + endpoint + ":" + secondPort,
27462749
props
27472750
);
27482751

@@ -2753,21 +2756,47 @@ public void testLoadBalancingPolicyFailover(ClickHouseLoadBalancingPolicy loadBa
27532756
Assert.fail("Exception expected for query on failed node");
27542757
} catch (Exception failoverException) {
27552758
ClickHouseNode failoverNode = loadBalancingPolicy.suggest(nodes, nodes.nodes.getFirst(), failoverException);
2756-
Assert.assertEquals(failoverNode.getHost(), secondEndpoint, "The next node is expected to be suggested by the load balancing policy");
2759+
Assert.assertEquals(failoverNode.getHost(), endpoint, "The next node is expected to be suggested by the load balancing policy");
2760+
Assert.assertEquals(failoverNode.getPort(), secondPort, "The next node is expected to be suggested by the load balancing policy");
2761+
}
2762+
}
2763+
2764+
/**
2765+
* Returns distinct TCP ports on the given local address that have no listener, so a connection to them is
2766+
* refused at once. All sockets stay open until every port is known, so the OS cannot return the same port twice.
2767+
*/
2768+
private static int[] findUnusedPorts(String localAddress, int count) throws IOException {
2769+
InetAddress address = InetAddress.getByName(localAddress);
2770+
ServerSocket[] sockets = new ServerSocket[count];
2771+
try {
2772+
int[] ports = new int[count];
2773+
for (int i = 0; i < count; i++) {
2774+
sockets[i] = new ServerSocket(0, 1, address);
2775+
ports[i] = sockets[i].getLocalPort();
2776+
}
2777+
return ports;
2778+
} finally {
2779+
for (ServerSocket socket : sockets) {
2780+
if (socket != null) {
2781+
socket.close();
2782+
}
2783+
}
27572784
}
27582785
}
27592786

27602787
@Test(groups = {"integration"})
2761-
public void testFailover() throws ClickHouseException {
2788+
public void testFailover() throws ClickHouseException, IOException {
27622789
if (isCloud()) return; //TODO: testFailover - Revisit, see: https://github.com/ClickHouse/clickhouse-java/issues/1747
27632790
ClickHouseNode availableNode = getServer();
27642791
Properties props = new Properties();
27652792
props.setProperty("failover", "1");
27662793
props.setProperty(ClickHouseDefaults.PASSWORD.getKey(), getPassword());
27672794

27682795
// nodes with the first node is unavailable
2796+
String unavailableEndpoint = "127.0.0.1";
2797+
int unavailablePort = findUnusedPorts(unavailableEndpoint, 1)[0];
27692798
ClickHouseNodes nodes = ClickHouseNodes.of(
2770-
getProtocol() + "://111.1.1.1," + availableNode.getBaseUri(),
2799+
getProtocol() + "://" + unavailableEndpoint + ":" + unavailablePort + "," + availableNode.getBaseUri(),
27712800
props
27722801
);
27732802

0 commit comments

Comments
 (0)