Changeset: da85ca693edb for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=da85ca693edb Modified Files: configure.ag geom/monetdb5/geom.mx monetdb5/modules/mal/remote.c monetdb5/optimizer/opt_commonTerms.c monetdb5/optimizer/opt_commonTerms.h monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h monetdb5/optimizer/opt_support.c sql/backends/monet5/sql.mx Branch: headless Log Message:
Merge with default branch. diffs (truncated from 1914 to 300 lines): diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -451,7 +451,7 @@ ;; esac AC_SUBST(oids) -AC_MSG_RESULT($bits bits) +AC_MSG_RESULT($oids bits) AC_C_BIGENDIAN() @@ -3280,7 +3280,7 @@ done echo echo "* Important options:" -echo " OID size: " ${bits} bits +echo " OID size: " ${oids} bits echo dnl give some hints to the user diff --git a/geom/monetdb5/geom.mx b/geom/monetdb5/geom.mx --- a/geom/monetdb5/geom.mx +++ b/geom/monetdb5/geom.mx @@ -1129,13 +1129,11 @@ GEOSGeom_destroy(geosGeometry); #if @6 - if (*out != @5) -#else - if (1 == 1) /* trick compiler for the throw after this return */ + if (*out == @5) + throw(MAL, "geom.@1", "@3 failed"); #endif - return MAL_SUCCEED; + return MAL_SUCCEED; - throw(MAL, "geom.@1", "@3 failed"); } @c @:basic(Dimension,int,GEOSGeom_getDimensions,,0,1)@ diff --git a/java/ChangeLog b/java/ChangeLog --- a/java/ChangeLog +++ b/java/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog file for java # This file is updated with Maddlog +* Thu Jun 30 2011 Fabian Groffen <fab...@cwi.nl> +- Add so_timeout Driver property to specify a SO_TIMEOUT value for the + socket in use to the database. Setting this property to a value in + milliseconds defines the timeout for read calls, which may 'unlock' + the driver if the server hangs, bug #2828 + * Wed May 25 2011 Fabian Groffen <fab...@cwi.nl> - Added a naive implementation for PreparedStatement.setCharacterStream diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -149,7 +149,12 @@ boolean debug = Boolean.valueOf(props.getProperty("debug")).booleanValue(); String hash = props.getProperty("hash"); blobIsBinary = Boolean.valueOf(props.getProperty("treat_blob_as_binary")).booleanValue(); - + int sockTimeout = 0; + try { + sockTimeout = Integer.parseInt(props.getProperty("so_timeout")); + } catch (NumberFormatException e) { + sockTimeout = 0; + } // check input arguments if (hostname == null || hostname.trim().equals("")) throw new IllegalArgumentException("hostname should not be null or empty"); @@ -173,6 +178,7 @@ if (hash != null) server.setHash(hash); if (database != null) server.setDatabase(database); server.setLanguage(language); + server.setSoTimeout(sockTimeout); // we're debugging here... uhm, should be off in real life if (debug) { diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in --- a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in @@ -117,6 +117,7 @@ props.put("port", PORT); props.put("debug", "false"); props.put("language", "sql"); // mal, sql, <future> + props.put("so_timeout", "0"); props.putAll(info); info = props; @@ -239,6 +240,11 @@ prop.description = "Whether BLOBs on the server should be treated as BINARY types, thus mapped to byte[]"; props.add(prop); + prop = new DriverPropertyInfo("so_timeout", "0"); + prop.required = false; + prop.description = "Defines the maximum time to wait in milliseconds on a blocking read socket call"; + props.add(prop); + DriverPropertyInfo[] dpi = new DriverPropertyInfo[props.size()]; return((DriverPropertyInfo[])props.toArray(dpi)); } diff --git a/java/src/nl/cwi/monetdb/mcl/net/MapiSocket.java b/java/src/nl/cwi/monetdb/mcl/net/MapiSocket.java --- a/java/src/nl/cwi/monetdb/mcl/net/MapiSocket.java +++ b/java/src/nl/cwi/monetdb/mcl/net/MapiSocket.java @@ -119,6 +119,9 @@ /** A short in two bytes for holding the block size in bytes */ private byte[] blklen = new byte[2]; + /** SO_TIMEOUT value for the underlying java.net.Socket */ + private int sockTimeout = 0; + /** * Constructs a new MapiSocket. */ @@ -188,6 +191,20 @@ } /** + * Set the SO_TIMEOUT on the underlying Socket. When for some + * reason the connection to the database hangs, this setting can be + * useful to break out of this indefinite wait. + * This option must be enabled prior to entering the blocking + * operation to have effect. + * + * @param timeout The specified timeout, in milliseconds. A timeout + * of zero is interpreted as an infinite timeout. + */ + public void setSoTimeout(int s) { + this.sockTimeout = s; + } + + /** * Connects to the given host and port, logging in as the given * user. If followRedirect is false, a RedirectionException is * thrown when a redirect is encountered. @@ -203,7 +220,7 @@ * @throws MCLParseException if bogus data is received * @throws MCLException if an MCL related error occurs */ - public List connect(String host, int port, String user, String pass) + public List connect(String host, int port, String user, String pass) throws IOException, MCLParseException, MCLException { // Wrap around the internal connect that needs to know if it @@ -212,7 +229,7 @@ } private List connect(String host, int port, String user, String pass, - boolean makeConnection) + boolean makeConnection) throws IOException, MCLParseException, MCLException { if (ttl-- <= 0) @@ -223,6 +240,8 @@ // set nodelay, as it greatly speeds up small messages (like we // often do) con.setTcpNoDelay(true); + // limit time to wait on blocking operations (0 = indefinite) + con.setSoTimeout(sockTimeout); fromMonet = new BlockInputStream(con.getInputStream()); toMonet = new BlockOutputStream(con.getOutputStream()); @@ -678,7 +697,7 @@ // write the actual block out.write(block, 0, writePos); - + if (debug) { if (last) { logTd("write final block: " + writePos + " bytes"); diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All --- a/monetdb5/modules/mal/Tests/All +++ b/monetdb5/modules/mal/Tests/All @@ -33,6 +33,7 @@ remote04 remote06 remote08 +remote09 # needs Merovingian and aims at SQL #remote88 #remote89 diff --git a/monetdb5/modules/mal/Tests/remote09.mal b/monetdb5/modules/mal/Tests/remote09.mal new file mode 100644 --- /dev/null +++ b/monetdb5/modules/mal/Tests/remote09.mal @@ -0,0 +1,42 @@ +# let connect figure out itself how to connect to the running db +uri := sabaoth.getLocalConnectionURI(); + +# create a persistent connecton to ourself +conn1:str := remote.connect(uri, "monetdb", "monetdb"); + +b := bat.new(:oid, :str); + +b := bat.insert(b, nil:oid, "maandag"); +b := bat.insert(b, nil:oid, "dinsdag"); +b := bat.insert(b, nil:oid, "woensdag"); +b := bat.insert(b, nil:oid, "donderdag"); +b := bat.insert(b, nil:oid, "vrijdag"); +b := bat.insert(b, nil:oid, "januari"); +b := bat.insert(b, nil:oid, "februari"); +b := bat.insert(b, nil:oid, "maart"); +b := bat.insert(b, nil:oid, "april"); +b := bat.insert(b, nil:oid, "mei"); +b := bat.insert(b, nil:oid, "juni"); +b := bat.insert(b, nil:oid, "juli"); +b := bat.insert(b, nil:oid, "augustus"); +b := bat.insert(b, nil:oid, "september"); +b := bat.insert(b, nil:oid, "oktober"); +b := bat.insert(b, nil:oid, "november"); +b := bat.insert(b, nil:oid, "december"); +b := bat.insert(b, nil:oid, "morgen"); +b := bat.insert(b, nil:oid, "middag"); +b := bat.insert(b, nil:oid, "avond"); +b := bat.insert(b, nil:oid, "nacht"); +b := bat.insert(b, nil:oid, "licht"); +b := bat.insert(b, nil:oid, "duisternis"); + +b := algebra.markH(b); + +rb2 := remote.put(conn1, b); +lb2:bat[:oid,:str] := remote.get(conn1, rb2); + +io.print(lb2); + +# help testweb a bit, since currently no cleanup is done on server +# shutdown +remote.disconnect(conn1); diff --git a/monetdb5/modules/mal/Tests/remote09.stable.err b/monetdb5/modules/mal/Tests/remote09.stable.err new file mode 100644 --- /dev/null +++ b/monetdb5/modules/mal/Tests/remote09.stable.err @@ -0,0 +1,31 @@ +stderr of test 'remote09` in directory 'modules/mal` itself: + + +# 15:38:56 > +# 15:38:56 > mserver5 --debug=10 --set gdk_nr_threads=0 --set "gdk_dbfarm=/net/volund.ins.cwi.nl/export/scratch0/fabian/vtmp/mtest-current-volund.ins.cwi.nl/five/dbfarm" --set mapi_open=true --set mapi_port=32448 --set monet_prompt= --trace --forcemito --set mal_listing=2 --dbname=mTests_modules_mal remote09.mal +# 15:38:56 > + +# builtin opt gdk_dbname = demo +# builtin opt gdk_dbfarm = /ufs/fabian/scratch/monetdb/current/program-x86_64/var/lib/monetdb5/dbfarm +# builtin opt gdk_debug = 0 +# builtin opt gdk_alloc_map = no +# builtin opt gdk_vmtrim = yes +# builtin opt monet_prompt = > +# builtin opt monet_daemon = no +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt gdk_dbfarm = /net/volund.ins.cwi.nl/export/scratch0/fabian/vtmp/mtest-current-volund.ins.cwi.nl/five/dbfarm +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 32448 +# cmdline opt monet_prompt = +# cmdline opt mal_listing = 2 +# cmdline opt gdk_dbname = mTests_modules_mal + +# 15:38:57 > +# 15:38:57 > Done. +# 15:38:57 > + diff --git a/monetdb5/modules/mal/Tests/remote09.stable.out b/monetdb5/modules/mal/Tests/remote09.stable.out new file mode 100644 --- /dev/null +++ b/monetdb5/modules/mal/Tests/remote09.stable.out @@ -0,0 +1,86 @@ +stdout of test 'remote09` in directory 'modules/mal` itself: + + +# 15:38:56 > +# 15:38:56 > mserver5 --debug=10 --set gdk_nr_threads=0 --set "gdk_dbfarm=/net/volund.ins.cwi.nl/export/scratch0/fabian/vtmp/mtest-current-volund.ins.cwi.nl/five/dbfarm" --set mapi_open=true --set mapi_port=32448 --set monet_prompt= --trace --forcemito --set mal_listing=2 --dbname=mTests_modules_mal remote09.mal +# 15:38:56 > + +# MonetDB 5 server v11.4.0 "current-a384b06d6f96" +# Serving database 'mTests_modules_mal', using 4 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs dynamically linked +# Found 7.749 GiB available main-memory. +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2011 MonetDB B.V., all rights reserved +# Visit http://monetdb.cwi.nl/ for further information +# Listening for connection requests on mapi:monetdb://volund.ins.cwi.nl:32448/ +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +function user.main():void; +# let connect figure out itself how to connect to the running db + uri := sabaoth.getLocalConnectionURI(); +# create a persistent connecton to ourself + conn1:str := remote.connect(uri,"monetdb","monetdb"); + b := bat.new(:oid,:str); + b := bat.insert(b,nil:oid,"maandag"); + b := bat.insert(b,nil:oid,"dinsdag"); + b := bat.insert(b,nil:oid,"woensdag"); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list