Changeset: 2a895321ffa4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2a895321ffa4
Modified Files:
        clients/Tests/exports.stable.out
        common/utils/msabaoth.c
        common/utils/msabaoth.h
        monetdb5/mal/mal_profiler.c
        sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

Use sabaoth server UUID as session UUID.


diffs (132 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2430,6 +2430,7 @@ char *msab_getDBfarm(char **ret);
 char *msab_getDBname(char **ret);
 char *msab_getMyStatus(sabdb **ret);
 char *msab_getStatus(sabdb **ret, char *dbname);
+char *msab_getUUID(char **ret);
 char *msab_getUplogInfo(sabuplog *ret, const sabdb *db);
 char *msab_marchConnection(const char *host, const int port);
 char *msab_marchScenario(const char *lang);
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -45,7 +45,7 @@ char *_sabaoth_internal_dbfarm = NULL;
 /** the database which is "active" */
 char *_sabaoth_internal_dbname = NULL;
 /** identifier of the current process */
-char *_sabaoth_internal_uuid = NULL;
+static char *_sabaoth_internal_uuid = NULL;
 
 /**
  * Retrieves the dbfarm path plus an optional extra component added
@@ -242,6 +242,15 @@ msab_getDBname(char **ret)
        return(NULL);
 }
 
+char *
+msab_getUUID(char **ret)
+{
+       if (_sabaoth_internal_uuid == NULL)
+               return(strdup("sabaoth not initialized"));
+       *ret = strdup(_sabaoth_internal_uuid);
+       return NULL;
+}
+
 #define SCENARIOFILE ".scen"
 
 /**
diff --git a/common/utils/msabaoth.h b/common/utils/msabaoth.h
--- a/common/utils/msabaoth.h
+++ b/common/utils/msabaoth.h
@@ -65,6 +65,7 @@ msab_export void msab_dbpathinit(const c
 msab_export void msab_dbfarminit(const char *dbfarm);
 msab_export char *msab_getDBfarm(char **ret);
 msab_export char *msab_getDBname(char **ret);
+msab_export char *msab_getUUID(char **ret);
 msab_export char *msab_marchScenario(const char *lang);
 msab_export char *msab_retreatScenario(const char *lang);
 msab_export char *msab_marchConnection(const char *host, const int port);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -16,6 +16,7 @@
  */
 #include "monetdb_config.h"
 #include "mutils.h"         /* mercurial_revision */
+#include "msabaoth.h"          /* msab_getUUID */
 #include "mal_function.h"
 #include "mal_listing.h"
 #include "mal_profiler.h"
@@ -167,6 +168,12 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
        logadd("\"tag\":%d,%s", stk?stk->tag:0, prettify);
        logadd("\"module\":\"%s\",%s", pci->modname ? pci->modname : "", 
prettify);
        logadd("\"instruction\":\"%s\",%s", pci->fcnname ? pci->fcnname : "", 
prettify);
+       char *uuid;
+       if ((c = msab_getUUID(&uuid)) == NULL) {
+               logadd("\"session\":\"%s\",%s", uuid, prettify);
+               free(uuid);
+       } else
+               free(c);
 
        if( start){
                logadd("\"state\":\"start\",%s", prettify);
@@ -454,6 +461,12 @@ profilerHeartbeatEvent(char *alter)
        lognew();
        logadd("{%s",prettify); // fill in later with the event counter
        logadd("\"source\":\"heartbeat\",%s", prettify);
+       char *uuid, *err;
+       if ((err = msab_getUUID(&uuid)) == NULL) {
+               logadd("\"session\":\"%s\",%s", uuid, prettify);
+               free(uuid);
+       } else
+               free(err);
        logadd("\"clk\":"LLFMT",%s",usec,prettify);
        logadd("\"ctime\":%"PRIu64",%s", microseconds, prettify);
        logadd("\"rss\":%zu,%s", MT_getrss()/1024/1024, prettify);
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -52,6 +52,7 @@
 #include "rel_dump.h"
 #include "rel_remote.h"
 
+#include "msabaoth.h"          /* msab_getUUID */
 #include "muuid.h"
 
 int
@@ -424,18 +425,21 @@ static int
        }
        pushInstruction(curBlk, p);
 
-       str mal_session_uuid = "why";
-       if (mal_session_uuid) {
+       char *mal_session_uuid, *err;
+       if ((err = msab_getUUID(&mal_session_uuid)) == NULL) {
                str rsupervisor_session = GDKstrdup(mal_session_uuid);
                if (rsupervisor_session == NULL) {
+                       free(mal_session_uuid);
                        return -1;
                }
 
                str lsupervisor_session = GDKstrdup(mal_session_uuid);
                if (lsupervisor_session == NULL) {
+                       free(mal_session_uuid);
                        GDKfree(rsupervisor_session);
                        return -1;
                }
+               free(mal_session_uuid);
 
                str rworker_plan_uuid = generateUUID();
                if (rworker_plan_uuid == NULL) {
@@ -487,7 +491,8 @@ static int
                free(rworker_plan_uuid);   /* This was created with strdup */
                GDKfree(lsupervisor_session);
                GDKfree(rsupervisor_session);
-       }
+       } else
+               free(c);
 
        /* (x1, x2, ..., xn) := remote.exec(q, "mod", "fcn"); */
        p = newInstruction(curBlk, remoteRef, execRef);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to