Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC hangs #3973

monetdb-team opened this issue Nov 30, 2020 · 0 comments

JDBC hangs #3973

monetdb-team opened this issue Nov 30, 2020 · 0 comments


Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2016-04-04 14:49:43 +0200
From: Kovacs, Kalman <<kalman.kovacs>>
To: clients devs <>
Version: 11.21.19 (Jul2015-SP4)
CC: kalman.kovacs, martin.van.dinther

Last updated: 2016-12-21 13:08:19 +0100

Comment 22007

Date: 2016-04-04 14:49:43 +0200
From: Kovacs, Kalman <<kalman.kovacs>>

User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Build Identifier:

Sometimes JDBC does not answer for a connection request. In the code it seems that the sockTimeout is not set at the start of making a new connection.

Reproducible: Sometimes

We think that in the constructors of a new int parameter (sockTimeout) is required.
So right after a new Socket is created, its setSoTimeout method should be called with the new (sockTimeout) parameter.
So at nl.cwi.monetdb.jdbc.MonetConnection when you calls server.connect the parameter (sockTimeout) should be add to the parameters.

Comment 22008

Date: 2016-04-05 10:55:43 +0200
From: Kovacs, Kalman <<kalman.kovacs>>

We have rethought our solution for this problem, that is:

0., Do not make a new constructor of MapiSocket

1., There should be a new local variable in MapiSocket:
private int soTimeout = 0;

2., Make up the setSoTimeout method to handle the timeout setting before and after the Socket creation:
public void setSoTimeout(int s) throws SocketException {
if (s < 0) {
throw new IllegalArgumentException("timeout can't be negative");
// limit time to wait on blocking operations (0 = indefinite)
soTimeout = s;
//We have to check wheather the socket has been created already
if (con != null) {

3., In MonetConnection we set socket timeout, before calling connect:
try {
// Socket timeout should set before the socket created.
List warnings =
server.connect(hostname, port, username, password);
for (String warning : warnings) {
addWarning(warning, "01M02");

Comment 22009

Date: 2016-04-05 11:00:40 +0200
From: Kovacs, Kalman <<kalman.kovacs>>

And - of course - in the MapiSocket's connect method we have to set socket timeout right after the new socket was created:

if (makeConnection) {
con = new Socket(host, port);
// Set socket timeout
// set nodelay, as it greatly speeds up small messages (like we
// often do)

Comment 24703

Date: 2016-11-17 17:42:49 +0100
From: MonetDB Mercurial Repository <>

Changeset 6cc63d6cb224, made by Martin van Dinther in the monetdb-java repo, refers to this bug.

For complete details, see;node=6cc63d6cb224

Changeset description:

Implemented fix as suggested in Bug #3973
The MapiSocket object now supports getting and setting the socket timeout, even before the TCP socket is created.
Also improved the close() method to continue closing all opened resources, even if one of them failed to close.

To set the socket timeout specify it in the JDBC URL, for example:
This enables the timeout and sets it to 8000 milliseconds (= 8 seconds).
By default the timeout is not set, so wait infinitely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant