Skip to content

Commit da1324e

Browse files
author
Paultagoras
committed
Update jdbc-v2.md
1 parent 0509982 commit da1324e

File tree

1 file changed

+50
-1
lines changed
  • docs/en/integrations/language-clients/java

1 file changed

+50
-1
lines changed

docs/en/integrations/language-clients/java/jdbc-v2.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,56 @@ try (HikariDataSource ds = new HikariDataSource(poolConfig);
181181
}
182182
```
183183

184-
185184
## More Information
186185
For more information, see our [GitHub repository](https://github.com/ClickHouse/clickhouse-java) and [Client-V2 documentation](/docs/en/integrations/language-clients/java/client-v2.md).
186+
187+
188+
## Troubleshooting
189+
### Logging
190+
The driver uses [slf4j](https://www.slf4j.org/) for logging, and will use the first available implementation on the classpath.
191+
192+
### Resolving JDBC Timeout on Large Inserts
193+
194+
When performing large inserts in ClickHouse with long execution times, you may encounter JDBC timeout errors like:
195+
196+
```plaintext
197+
Caused by: java.sql.SQLException: Read timed out, server myHostname [uri=https://hostname.aws.clickhouse.cloud:8443]
198+
```
199+
These errors can disrupt the data insertion process and affect system stability. To address this issue you may need to adjust a few timeout settings in the client's OS.
200+
201+
#### Mac OS
202+
203+
On Mac OS, the following settings can be adjusted to resolve the issue:
204+
205+
- `net.inet.tcp.keepidle`: 60000
206+
- `net.inet.tcp.keepintvl`: 45000
207+
- `net.inet.tcp.keepinit`: 45000
208+
- `net.inet.tcp.keepcnt`: 8
209+
- `net.inet.tcp.always_keepalive`: 1
210+
211+
#### Linux
212+
213+
On Linux, the equivalent settings alone may not resolve the issue. Additional steps are required due to the differences in how Linux handles socket keep-alive settings. Follow these steps:
214+
215+
1. Adjust the following Linux kernel parameters in `/etc/sysctl.conf` or a related configuration file:
216+
217+
- `net.inet.tcp.keepidle`: 60000
218+
- `net.inet.tcp.keepintvl`: 45000
219+
- `net.inet.tcp.keepinit`: 45000
220+
- `net.inet.tcp.keepcnt`: 8
221+
- `net.inet.tcp.always_keepalive`: 1
222+
- `net.ipv4.tcp_keepalive_intvl`: 75
223+
- `net.ipv4.tcp_keepalive_probes`: 9
224+
- `net.ipv4.tcp_keepalive_time`: 60 (You may consider lowering this value from the default 300 seconds)
225+
226+
2. After modifying the kernel parameters, apply the changes by running the following command:
227+
228+
```shell
229+
sudo sysctl -p
230+
```
231+
232+
After Setting those settings, you need to ensure that your client enables the Keep Alive option on the socket:
233+
234+
```java
235+
properties.setProperty("socket_keepalive", "true");
187236
```

0 commit comments

Comments
 (0)