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

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

JDBC hangs #3973

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working Client interfaces major

Comments

@monetdb-team
Copy link

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 nl.cwi.monetdb.mcl.net.MapiSocket 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) {
con.setSoTimeout(s);
}
}

3., In MonetConnection we set socket timeout, before calling connect:
try {
// Socket timeout should set before the socket created.
server.setSoTimeout(sockTimeout);
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
con.setSoTimeout(soTimeout);
// set nodelay, as it greatly speeds up small messages (like we
// often do)
con.setTcpNoDelay(true);

Comment 24703

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

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

For complete details, see http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;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:
  jdbc:monetdb://localhost:50000/demo?so_timeout=8000
This enables the timeout and sets it to 8000 milliseconds (= 8 seconds).
By default the timeout is not set, so wait infinitely.
@monetdb-team monetdb-team added bug Something isn't working Client interfaces major labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client interfaces major
Projects
None yet
Development

No branches or pull requests

2 participants