Changeset: b4606c48fc8b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b4606c48fc8b
Modified Files:
        gdk/gdk_tracer.c
        monetdb5/scheduler/run_memo.c
Branch: gdk_tracer
Log Message:

Send messages to stderr if GDKtracer is not initialized or file is not open && 
always flush ERROR and CRITICAL messages


diffs (71 lines):

diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -473,7 +473,13 @@ GDKtracer_log(LOG_LEVEL level, char *fmt
 
     // Flush the current buffer in case the event is 
     // important depending on the flush-level
-    if(level == CUR_FLUSH_LEVEL)
+    // Always flush CRITICAL and ERROR messages - prevent cases 
+    // like mserver5 refusing to start due to allocated port 
+    // and the error is never reported to the user because it 
+    // is still in the buffer which it never gets flushed.
+    if(level == CUR_FLUSH_LEVEL || 
+       level == M_CRITICAL      || 
+       level == M_ERROR)
     {
         GDK_result = GDKtracer_flush_buffer();
         if(GDK_result == GDK_FAIL)
@@ -503,11 +509,17 @@ GDKtracer_flush_buffer(void)
 
     if(ATOMIC_GET(&CUR_ADAPTER) == BASIC)
     {
-        // Check if file is open
-        _GDKtracer_file_is_open(output_file);
-        
+        // Check if file is open - if not send the output to stderr. There are 
cases that 
+        // this is needed - e.g: on startup of mserver5 GDKmalloc is called 
before GDKinit. 
+        // In GDKinit GDKtracer is getting initialized (open_file and 
initialize log level 
+        // per component). Since the file is not open yet and there is an 
assert, we need 
+        // to do something - and as a backup plan we send the logs to stderr.
+        // _GDKtracer_file_is_open(output_file);
+        if(!output_file)
+            output_file = stderr;
+
         fwrite(&fl_tracer->buffer, fl_tracer->allocated_size, 1, output_file);
-        fflush(output_file);
+        fflush(stderr);
             
         // Reset buffer
         memset(fl_tracer->buffer, 0, BUFFER_SIZE);
@@ -521,7 +533,8 @@ GDKtracer_flush_buffer(void)
     // The file is kept open no matter the adapter
     // When GDKtracer stops we need also to close the file
     if(GDK_TRACER_STOP)
-        fclose(output_file);
+        if(output_file)
+            fclose(output_file);
 
     return GDK_SUCCEED;
 }
diff --git a/monetdb5/scheduler/run_memo.c b/monetdb5/scheduler/run_memo.c
--- a/monetdb5/scheduler/run_memo.c
+++ b/monetdb5/scheduler/run_memo.c
@@ -177,7 +177,7 @@ RUNchoice(Client cntxt, MalBlkPtr mb, Ma
                }
        }
 
-       TRC_DEBUG(MAL_MEMO, "Function target '%s' cost: %ld\n", getVarName(mb, 
target), mincost);
+       TRC_DEBUG(MAL_MEMO, "Function target '%s' cost: %lld\n", getVarName(mb, 
target), mincost);
        (void) cntxt;
 
        /* remove non-qualifying variables */
@@ -189,7 +189,7 @@ RUNchoice(Client cntxt, MalBlkPtr mb, Ma
 
        propagateNonTarget(mb, pc + 1);
 
-       TRC_DEBUG(MAL_MEMO, "Cost choice selected: %s %ld\n", getVarName(mb, 
target), mincost);
+       TRC_DEBUG(MAL_MEMO, "Cost choice selected: %s %lld\n", getVarName(mb, 
target), mincost);
        debugFunction(MAL_MEMO, mb, stk, 1);
 
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to