Changeset: 0dd353ec7b4b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0dd353ec7b4b
Modified Files:
        gdk/gdk_string.c
        monetdb5/mal/mal_interpreter.c
        tools/merovingian/daemon/argvcmds.c
        tools/merovingian/daemon/forkmserver.c
        tools/merovingian/daemon/merovingian.c
        tools/merovingian/daemon/monetdbd.1.in
        tools/merovingian/utils/utils.c
        tools/merovingian/utils/utils.h
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (224 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -108,8 +108,8 @@ strCleanHash(Heap *h, bool rebuild)
         * started. */
        memset(newhash, 0, sizeof(newhash));
        pos = GDK_STRHASHSIZE;
-       while (pos < h->free && pos < GDK_ELIMLIMIT) {
-               pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
+       while (pos < h->free &&
+              pos + (pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1))) < 
GDK_ELIMLIMIT) {
                if (pad < sizeof(stridx_t))
                        pad += GDK_VARALIGN;
                pos += pad + extralen;
@@ -219,7 +219,6 @@ checkUTF8(const char *v)
 var_t
 strPut(Heap *h, var_t *dst, const char *v)
 {
-       size_t elimbase = GDK_ELIMBASE(h->free);
        size_t pad;
        size_t pos, len = strLen(v);
        const size_t extralen = h->hashash ? EXTRALEN : 0;
@@ -265,19 +264,16 @@ strPut(Heap *h, var_t *dst, const char *
        }
 
        pad = GDK_VARALIGN - (h->free & (GDK_VARALIGN - 1));
-       if (elimbase == 0) {    /* i.e. h->free < GDK_ELIMLIMIT */
+       if (GDK_ELIMBASE(h->free + pad) == 0) { /* i.e. h->free+pad < 
GDK_ELIMLIMIT */
                if (pad < sizeof(stridx_t)) {
                        /* make room for hash link */
                        pad += GDK_VARALIGN;
                }
-       } else if (extralen == 0) {     /* i.e., h->hashash == FALSE */
-               /* no VARSHIFT and no string hash value stored => no
-                * padding/alignment needed */
+       } else if (GDK_ELIMBASE(h->free) != 0) {
+               /* no extra padding needed when no hash links needed
+                * (but only when padding doesn't cross duplicate
+                * elimination boundary) */
                pad = 0;
-       } else {
-               /* pad to align on VARALIGN for VARSHIFT and/or string
-                * hash value */
-               pad &= (GDK_VARALIGN - 1);
        }
 
        /* check heap for space (limited to a certain maximum after
@@ -328,7 +324,7 @@ strPut(Heap *h, var_t *dst, const char *
 
        /* maintain hash table */
        pos -= extralen;
-       if (elimbase == 0) {    /* small string heap: link the next pointer */
+       if (GDK_ELIMBASE(pos) == 0) {   /* small string heap: link the next 
pointer */
                /* the stridx_t next pointer directly precedes the
                 * string and optional (depending on hashash) hash
                 * value */
diff --git a/tools/merovingian/daemon/argvcmds.c 
b/tools/merovingian/daemon/argvcmds.c
--- a/tools/merovingian/daemon/argvcmds.c
+++ b/tools/merovingian/daemon/argvcmds.c
@@ -509,19 +509,26 @@ command_stop(confkeyval *ckv, int argc, 
                return(1);
        }
 
-       /* wait up to 30 seconds for monetdbd to actually stop */
-       for (i = 0; i < 60; i++) {
-               tv.tv_sec = 0;
-               tv.tv_usec = 500000;
-               select(0, NULL, NULL, NULL, &tv);
-               if (kill(daemon, 0) == -1) {
-                       /* daemon has died */
-                       return(0);
+       int exittimeout = getConfNum(ckv, "exittimeout");
+       if (exittimeout != 0) {
+               if (exittimeout > 0) {
+                       /* wait a tad longer for monetdbd to die than for the
+                        * mserver processes */
+                       exittimeout += 5;
                }
-       }
+               for (i = 0; exittimeout < 0 || i < exittimeout * 2; i++) {
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 500000;
+                       select(0, NULL, NULL, NULL, &tv);
+                       if (kill(daemon, 0) == -1) {
+                               /* daemon has died */
+                               return(0);
+                       }
+               }
 
-       /* done waiting, use harsher measures */
-       kill(daemon, SIGKILL);
+               /* done waiting, use harsher measures */
+               kill(daemon, SIGKILL);
+       }
 
        return(0);
 }
diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -120,7 +120,8 @@ terminateProcess(char *dbname, pid_t pid
                return false;
        }
        kv = findConfKey(_mero_props, "exittimeout");
-       for (i = 0; i < atoi(kv->val) * 2; i++) {
+       int exittimeout = atoi(kv->val);
+       for (i = 0; exittimeout < 0 || i < exittimeout * 2; i++) {
                if (stats != NULL)
                        msab_freeStatus(&stats);
                sleep_ms(500);
diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -358,7 +358,7 @@ main(int argc, char *argv[])
                {"listenaddr",    strdup("localhost"),     0,                  
LADDR},
                {"port",          strdup(MERO_PORT),       atoi(MERO_PORT),    
INT},
 
-               {"exittimeout",   strdup("60"),            60,                 
INT},
+               {"exittimeout",   strdup("60"),            60,                 
SINT},
                {"forward",       strdup("proxy"),         0,                  
OTHER},
 
                {"discovery",     strdup("true"),          1,                  
BOOLEAN},
@@ -1069,7 +1069,7 @@ shutdown:
        /* stop started mservers */
 
        kv = findConfKey(ckv, "exittimeout");
-       if (d->next != NULL && atoi(kv->val) > 0) {
+       if (d->next != NULL && atoi(kv->val) != 0) {
                dpair t;
                threadlist tl = NULL, tlw = tl;
 
diff --git a/tools/merovingian/daemon/monetdbd.1.in 
b/tools/merovingian/daemon/monetdbd.1.in
--- a/tools/merovingian/daemon/monetdbd.1.in
+++ b/tools/merovingian/daemon/monetdbd.1.in
@@ -20,10 +20,8 @@ The use of
 .I monetdbd
 is either as user-oriented way to configure, start and stop a database
 farm, or to be started from a startup script, such as from
-.I /etc/init.d/
-on Linux systems or
-.IR smf (5)
-on Solaris systems, as part of a system startup.
+.IR systemd (1)
+on Linux systems, as part of a system startup.
 .P
 .I Monetdbd
 is the system formerly known as
@@ -40,11 +38,10 @@ at many places for historical reasons.
 .P
 A
 .I monetdbd
-instance manages one local cluster based, which is a directory in the
-system, referred to as the
+instance manages one local cluster of databases, which is a directory
+in the system, referred to as the
 .IR dbfarm .
-Nowadays, the dbfarm location always has to be given as argument
-to
+The dbfarm location must always be given as argument to
 .IR monetdbd .
 .P
 Within its local cluster
@@ -93,7 +90,7 @@ and
 The commands facilitate initializing a dbfarm, starting and stopping the
 MonetDB Database Server, and retrieving or setting options.
 .TP
-.B create dbfarm
+\fBcreate\fP \fIdbfarm\fP
 Initializes a new database farm, such that a MonetDB Database Server can
 be started on that location.  All necessary directories are attempted to
 be created, and an initial properties file is created in the directory
@@ -115,6 +112,14 @@ calling environment, until given a stop 
 Sends a stop signal to the
 .I monetdbd
 process responsible for the given dbfarm.
+If the
+.B exittimeout
+value is non-zero (see below), all mserver processes will be sent a
+termination signal.  The current process will wait for the manager
+process to terminate, but sends a SIGKILL signal if waiting takes
+longer than 5 seconds more than the value of exittimeout.  If
+exittimeout is negative, both monetdbd processes involved will wait
+until the servers have all terminated and no extra signals are sent.
 .TP
 \fBget\fP <\fBall\fP | \fIproperty\fP[,\fIproperty\fP[,..]]> \fIdbfarm\fP
 Prints the requested properties, or all known properties, for the given
diff --git a/tools/merovingian/utils/utils.c b/tools/merovingian/utils/utils.c
--- a/tools/merovingian/utils/utils.c
+++ b/tools/merovingian/utils/utils.c
@@ -223,8 +223,14 @@ setConfVal(confkeyval *ckv, const char *
                                        ckv->key);
                        return(strdup(buf));
                }
+               case SINT:
                case INT: {
                        const char *p = val;
+                       int sign = 1;
+                       if (ckv->type == SINT && *p == '-') {
+                               sign = -1;
+                               p++;
+                       }
                        while (isdigit((unsigned char) *p))
                                p++;
                        if (*p != '\0') {
@@ -234,7 +240,7 @@ setConfVal(confkeyval *ckv, const char *
                                                ckv->key, val);
                                return(strdup(buf));
                        }
-                       ival = atoi(val);
+                       ival = sign * atoi(val);
                }; break;
                case BOOLEAN: {
                        if (strcasecmp(val, "true") == 0 ||
diff --git a/tools/merovingian/utils/utils.h b/tools/merovingian/utils/utils.h
--- a/tools/merovingian/utils/utils.h
+++ b/tools/merovingian/utils/utils.h
@@ -16,6 +16,7 @@
 enum valtype {
        INVALID = 0,
        INT,
+       SINT,
        BOOLEAN,
        STR,
        MURI,
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to