Changeset: 38fc8010364a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=38fc8010364a
Modified Files:
        common/utils/msabaoth.c
        sql/benchmarks/tpch/Tests/01-explain.stable.out
        sql/benchmarks/tpch/Tests/03-explain.stable.out
        sql/benchmarks/tpch/Tests/05-explain.stable.out
        sql/benchmarks/tpch/Tests/06-explain.stable.out
        sql/benchmarks/tpch/Tests/07-explain.stable.out
        sql/benchmarks/tpch/Tests/08-explain.stable.out
        sql/benchmarks/tpch/Tests/09-explain.stable.out
        sql/benchmarks/tpch/Tests/10-explain.stable.out
        sql/benchmarks/tpch/Tests/11-explain.stable.out
        sql/benchmarks/tpch/Tests/14-explain.stable.out
        sql/benchmarks/tpch/Tests/15-explain.stable.out
        sql/benchmarks/tpch/Tests/17-explain.stable.out
        sql/benchmarks/tpch/Tests/19-explain.stable.out
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/connections.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/discoveryrunner.c
        tools/merovingian/daemon/forkmserver.c
        tools/merovingian/daemon/handlers.c
        tools/merovingian/daemon/handlers.h
        tools/merovingian/daemon/merovingian.c
        tools/merovingian/daemon/merovingian.h
        tools/merovingian/daemon/multiplex-funnel.c
        tools/merovingian/utils/properties.c
Branch: Dec2016
Log Message:

Merge with Jun2016 branch.


diffs (truncated from 1137 to 300 lines):

diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -594,6 +594,85 @@ msab_getSingleStatus(const char *pathbuf
        sdb->path = strdup(buf);
        sdb->dbname = sdb->path + strlen(sdb->path) - strlen(dbname);
 
+
+       /* check the state of the server by looking at its gdk lock:
+        * - if we can lock it, the server has crashed or isn't running
+        * - if we can't open it because it's locked, the server is
+        *   running
+        * - to distinguish between a crash and proper shutdown, consult
+        *   the uplog
+        * - one exception to all above; if this is the same process, we
+        *   cannot lock (it always succeeds), hence, if we have the
+        *   same signature, we assume running if the uplog states so.
+        */
+       snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname,
+                        _sabaoth_internal_uuid);
+       if (stat(buf, &statbuf) != -1) {
+               /* database has the same process signature as ours, which
+                * means, it must be us, rely on the uplog state */
+               snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
+               if ((f = fopen(log, "r")) != NULL) {
+                       (void)fseek(f, -1, SEEK_END);
+                       if (fread(data, 1, 1, f) != 1) {
+                               /* the log is empty, assume no crash */
+                               sdb->state = SABdbInactive;
+                       } else if (data[0] == '\t') {
+                               /* see if the database has finished starting */
+                               snprintf(buf, sizeof(buf), "%s/%s/%s",
+                                                pathbuf, dbname, STARTEDFILE);
+                               if (stat(buf, &statbuf) == -1) {
+                                       sdb->state = SABdbStarting;
+                               } else {
+                                       sdb->state = SABdbRunning;
+                               }
+                       } else { /* should be \n */
+                               sdb->state = SABdbInactive;
+                       }
+                       (void)fclose(f);
+               }
+       } else if ((snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
".gdk_lock") > 0) & /* no typo */
+                          ((fd = MT_lockf(buf, F_TEST, 4, 1)) == -2)) {
+               /* Locking failed; this can be because the lockfile couldn't
+                * be created.  Probably there is no Mserver running for
+                * that case also.
+                */
+               sdb->state = SABdbInactive;
+       } else if (fd == -1) {
+               /* file is locked, so mserver is running, see if the database
+                * has finished starting */
+               snprintf(buf, sizeof(buf), "%s/%s/%s",
+                                pathbuf, dbname, STARTEDFILE);
+               if (stat(buf, &statbuf) == -1) {
+                       sdb->state = SABdbStarting;
+               } else {
+                       sdb->state = SABdbRunning;
+               }
+       } else {
+               /* file is not locked, check for a crash in the uplog */
+               snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
+               if ((f = fopen(log, "r")) != NULL) {
+                       (void)fseek(f, -1, SEEK_END);
+                       if (fread(data, 1, 1, f) != 1) {
+                               /* the log is empty, assume no crash */
+                               sdb->state = SABdbInactive;
+                       } else if (data[0] == '\n') {
+                               sdb->state = SABdbInactive;
+                       } else { /* should be \t */
+                               sdb->state = SABdbCrashed;
+                       }
+                       (void)fclose(f);
+               } else {
+                       /* no uplog, so presumably never started */
+                       sdb->state = SABdbInactive;
+               }
+       }
+       snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
MAINTENANCEFILE);
+       if (stat(buf, &statbuf) == -1) {
+               sdb->locked = 0;
+       } else {
+               sdb->locked = 1;
+       }
+
        /* add scenarios that are supported */
        sdb->scens = NULL;
        snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, SCENARIOFILE);
@@ -638,84 +717,6 @@ msab_getSingleStatus(const char *pathbuf
                (void)fclose(f);
        }
 
-
-       /* check the state of the server by looking at its gdk lock:
-        * - if we can lock it, the server has crashed or isn't running
-        * - if we can't open it because it's locked, the server is
-        *   running
-        * - to distinguish between a crash and proper shutdown, consult
-        *   the uplog
-        * - one exception to all above; if this is the same process, we
-        *   cannot lock (it always succeeds), hence, if we have the
-        *   same signature, we assume running if the uplog states so.
-        */
-       snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname,
-                        _sabaoth_internal_uuid);
-       if (stat(buf, &statbuf) != -1) {
-               /* database has the same process signature as ours, which
-                * means, it must be us, rely on the uplog state */
-               snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
-               if ((f = fopen(log, "r")) != NULL) {
-                       (void)fseek(f, -1, SEEK_END);
-                       if (fread(data, 1, 1, f) != 1) {
-                               /* the log is empty, assume no crash */
-                               sdb->state = SABdbInactive;
-                       } else if (data[0] == '\t') {
-                               /* see if the database has finished starting */
-                               snprintf(buf, sizeof(buf), "%s/%s/%s",
-                                                pathbuf, dbname, STARTEDFILE);
-                               if (stat(buf, &statbuf) == -1) {
-                                       sdb->state = SABdbStarting;
-                               } else {
-                                       sdb->state = SABdbRunning;
-                               }
-                       } else { /* should be \n */
-                               sdb->state = SABdbInactive;
-                       }
-                       (void)fclose(f);
-               }
-       } else if ((snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
".gdk_lock") > 0) & /* no typo */
-                          ((fd = MT_lockf(buf, F_TEST, 4, 1)) == -2)) {
-               /* Locking failed; this can be because the lockfile couldn't
-                * be created.  Probably there is no Mserver running for
-                * that case also.
-                */
-               sdb->state = SABdbInactive;
-       } else if (fd == -1) {
-               /* lock denied, so mserver is running, see if the database
-                * has finished starting */
-               snprintf(buf, sizeof(buf), "%s/%s/%s",
-                                pathbuf, dbname, STARTEDFILE);
-               if (stat(buf, &statbuf) == -1) {
-                       sdb->state = SABdbStarting;
-               } else {
-                       sdb->state = SABdbRunning;
-               }
-       } else {
-               /* locking succeed, check for a crash in the uplog */
-               snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, 
UPLOGFILE);
-               if ((f = fopen(log, "r")) != NULL) {
-                       (void)fseek(f, -1, SEEK_END);
-                       if (fread(data, 1, 1, f) != 1) {
-                               /* the log is empty, assume no crash */
-                               sdb->state = SABdbInactive;
-                       } else if (data[0] == '\n') {
-                               sdb->state = SABdbInactive;
-                       } else { /* should be \t */
-                               sdb->state = SABdbCrashed;
-                       }
-                       (void)fclose(f);
-               } else {
-                       /* no uplog, so presumably never started */
-                       sdb->state = SABdbInactive;
-               }
-       }
-       snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, 
MAINTENANCEFILE);
-       if (stat(buf, &statbuf) == -1) {
-               sdb->locked = 0;
-       } else {
-               sdb->locked = 1;
-       }
        return sdb;
 }
 
diff --git a/sql/benchmarks/tpch/Tests/01-explain.stable.out 
b/sql/benchmarks/tpch/Tests/01-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/01-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/01-explain.stable.out
@@ -55,14 +55,14 @@ function user.main():void;
     X_1244 := bat.new(nil:str);
     X_1251 := bat.append(X_1244,"sys.lineitem");
     X_1261 := bat.append(X_1251,"sys.lineitem");
-    X_1267 := bat.append(X_1261,"sys.L2");
-    X_1277 := bat.append(X_1267,"sys.L4");
-    X_1284 := bat.append(X_1277,"sys.L6");
-    X_1292 := bat.append(X_1284,"sys.L10");
-    X_1300 := bat.append(X_1292,"sys.L12");
-    X_1310 := bat.append(X_1300,"sys.L14");
-    X_1317 := bat.append(X_1310,"sys.L16");
-    X_1324 := bat.append(X_1317,"sys.L20");
+    X_1267 := bat.append(X_1261,"sys.L5");
+    X_1277 := bat.append(X_1267,"sys.L10");
+    X_1284 := bat.append(X_1277,"sys.L13");
+    X_1292 := bat.append(X_1284,"sys.L16");
+    X_1300 := bat.append(X_1292,"sys.L21");
+    X_1310 := bat.append(X_1300,"sys.L24");
+    X_1317 := bat.append(X_1310,"sys.L27");
+    X_1324 := bat.append(X_1317,"sys.L32");
     X_1246 := bat.new(nil:str);
     X_1253 := bat.append(X_1246,"l_returnflag");
     X_1262 := bat.append(X_1253,"l_linestatus");
diff --git a/sql/benchmarks/tpch/Tests/03-explain.stable.out 
b/sql/benchmarks/tpch/Tests/03-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/03-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/03-explain.stable.out
@@ -57,7 +57,7 @@ function user.s4_1():void;
     X_211:void := querylog.define("explain select\n l_orderkey,\n 
sum(l_extendedprice * (1 - l_discount)) as revenue,\n o_orderdate,\n 
o_shippriority\nfrom\n customer,\n orders,\n lineitem\nwhere\n c_mktsegment = 
\\'BUILDING\\'\n and c_custkey = o_custkey\n and l_orderkey = o_orderkey\n and 
o_orderdate < date \\'1995-03-15\\'\n and l_shipdate > date 
\\'1995-03-15\\'\ngroup by\n l_orderkey,\n o_orderdate,\n o_shippriority\norder 
by\n revenue desc,\n o_orderdate\nlimit 10;","sequential_pipe",78);
     X_170 := bat.new(nil:str);
     X_177 := bat.append(X_170,"sys.lineitem");
-    X_187 := bat.append(X_177,"sys.L2");
+    X_187 := bat.append(X_177,"sys.L4");
     X_197 := bat.append(X_187,"sys.orders");
     X_205 := bat.append(X_197,"sys.orders");
     X_172 := bat.new(nil:str);
diff --git a/sql/benchmarks/tpch/Tests/05-explain.stable.out 
b/sql/benchmarks/tpch/Tests/05-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/05-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/05-explain.stable.out
@@ -58,7 +58,7 @@ function user.s4_1():void;
     X_237:void := querylog.define("explain select\n n_name,\n 
sum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\n customer,\n 
orders,\n lineitem,\n supplier,\n nation,\n region\nwhere\n c_custkey = 
o_custkey\n and l_orderkey = o_orderkey\n and l_suppkey = s_suppkey\n and 
c_nationkey = s_nationkey\n and s_nationkey = n_nationkey\n and n_regionkey = 
r_regionkey\n and r_name = \\'ASIA\\'\n and o_orderdate >= date 
\\'1994-01-01\\'\n and o_orderdate < date \\'1994-01-01\\' + interval \\'1\\' 
year\ngroup by\n n_name\norder by\n revenue desc;","sequential_pipe",93);
     X_210 := bat.new(nil:str);
     X_217 := bat.append(X_210,"sys.nation");
-    X_227 := bat.append(X_217,"sys.L2");
+    X_227 := bat.append(X_217,"sys.L4");
     X_212 := bat.new(nil:str);
     X_219 := bat.append(X_212,"n_name");
     X_229 := bat.append(X_219,"revenue");
diff --git a/sql/benchmarks/tpch/Tests/06-explain.stable.out 
b/sql/benchmarks/tpch/Tests/06-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/06-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/06-explain.stable.out
@@ -55,7 +55,7 @@ function user.s4_1():void;
     X_61 := algebra.projection(C_51,X_17);
     X_62:bat[:lng] := batcalc.*(X_60,X_61);
     X_65:lng := aggr.sum(X_62);
-    sql.resultSet("sys.L2","revenue","decimal",19,4,10,X_65);
+    sql.resultSet("sys.L4","revenue","decimal",19,4,10,X_65);
 end user.s4_1;
 #inline               actions= 0 time=6 usec 
 #remap                actions= 1 time=35 usec 
diff --git a/sql/benchmarks/tpch/Tests/07-explain.stable.out 
b/sql/benchmarks/tpch/Tests/07-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/07-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/07-explain.stable.out
@@ -63,7 +63,7 @@ function user.s4_1():void;
     X_232 := bat.append(X_225,"sys.shipping");
     X_242 := bat.append(X_232,"sys.shipping");
     X_248 := bat.append(X_242,"sys.shipping");
-    X_256 := bat.append(X_248,"sys.L6");
+    X_256 := bat.append(X_248,"sys.L16");
     X_227 := bat.new(nil:str);
     X_234 := bat.append(X_227,"supp_nation");
     X_243 := bat.append(X_234,"cust_nation");
diff --git a/sql/benchmarks/tpch/Tests/08-explain.stable.out 
b/sql/benchmarks/tpch/Tests/08-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/08-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/08-explain.stable.out
@@ -62,7 +62,7 @@ function user.s4_1():void;
     X_272:void := querylog.define("explain select\n o_year,\n sum(case\n when 
nation = \\'BRAZIL\\' then volume\n else 0\n end) / sum(volume) as 
mkt_share\nfrom\n (\n select\n extract(year from o_orderdate) as o_year,\n 
l_extendedprice * (1 - l_discount) as volume,\n n2.n_name as nation\n from\n 
part,\n supplier,\n lineitem,\n orders,\n customer,\n nation n1,\n nation n2,\n 
region\n where\n p_partkey = l_partkey\n and s_suppkey = l_suppkey\n and 
l_orderkey = o_orderkey\n and o_custkey = c_custkey\n and c_nationkey = 
n1.n_nationkey\n and n1.n_regionkey = r_regionkey\n and r_name = 
\\'AMERICA\\'\n and s_nationkey = n2.n_nationkey\n and o_orderdate between date 
\\'1995-01-01\\' and date \\'1996-12-31\\'\n and p_type = \\'ECONOMY ANODIZED 
STEEL\\'\n ) as all_nations\ngroup by\n o_year\norder by\n 
o_year;","sequential_pipe",96);
     X_245 := bat.new(nil:str);
     X_252 := bat.append(X_245,"sys.all_nations");
-    X_262 := bat.append(X_252,"sys.L7");
+    X_262 := bat.append(X_252,"sys.L14");
     X_247 := bat.new(nil:str);
     X_254 := bat.append(X_247,"o_year");
     X_264 := bat.append(X_254,"mkt_share");
diff --git a/sql/benchmarks/tpch/Tests/09-explain.stable.out 
b/sql/benchmarks/tpch/Tests/09-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/09-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/09-explain.stable.out
@@ -61,7 +61,7 @@ function user.s4_1():void;
     X_207 := bat.new(nil:str);
     X_214 := bat.append(X_207,"sys.profit");
     X_224 := bat.append(X_214,"sys.profit");
-    X_232 := bat.append(X_224,"sys.L5");
+    X_232 := bat.append(X_224,"sys.L13");
     X_209 := bat.new(nil:str);
     X_216 := bat.append(X_209,"nation");
     X_225 := bat.append(X_216,"o_year");
diff --git a/sql/benchmarks/tpch/Tests/10-explain.stable.out 
b/sql/benchmarks/tpch/Tests/10-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/10-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/10-explain.stable.out
@@ -67,7 +67,7 @@ function user.s4_1():void;
     X_224 := bat.new(nil:str);
     X_231 := bat.append(X_224,"sys.customer");
     X_241 := bat.append(X_231,"sys.customer");
-    X_249 := bat.append(X_241,"sys.L2");
+    X_249 := bat.append(X_241,"sys.L5");
     X_259 := bat.append(X_249,"sys.customer");
     X_267 := bat.append(X_259,"sys.nation");
     X_276 := bat.append(X_267,"sys.customer");
diff --git a/sql/benchmarks/tpch/Tests/11-explain.stable.out 
b/sql/benchmarks/tpch/Tests/11-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/11-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/11-explain.stable.out
@@ -99,7 +99,7 @@ function user.s4_1():void;
     X_141:lng := sql.dec_round(X_138,100);
     X_160 := bat.new(nil:str);
     X_167 := bat.append(X_160,"sys.partsupp");
-    X_177 := bat.append(X_167,"sys.L2");
+    X_177 := bat.append(X_167,"sys.L4");
     X_162 := bat.new(nil:str);
     X_169 := bat.append(X_162,"ps_partkey");
     X_179 := bat.append(X_169,"value");
diff --git a/sql/benchmarks/tpch/Tests/14-explain.stable.out 
b/sql/benchmarks/tpch/Tests/14-explain.stable.out
--- a/sql/benchmarks/tpch/Tests/14-explain.stable.out
+++ b/sql/benchmarks/tpch/Tests/14-explain.stable.out
@@ -72,7 +72,7 @@ function user.main():void;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to