Browse Source

Merge pull request #9942 from ghalliday/issue17564

HPCC-17564 Fix various threading issues with stats in ContextLogger

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 years ago
parent
commit
4366cc19db
1 changed files with 4 additions and 1 deletions
  1. 4 1
      roxie/ccd/ccd.hpp

+ 4 - 1
roxie/ccd/ccd.hpp

@@ -558,6 +558,7 @@ class ContextLogger : implements IRoxieContextLogger, public CInterface
 {
 protected:
     mutable CriticalSection crit;
+    mutable CriticalSection statsCrit;
     unsigned start;
     unsigned ctxTraceLevel;
     mutable CRuntimeStatisticCollection stats;
@@ -648,6 +649,7 @@ public:
 
     StringBuffer &getStats(StringBuffer &s) const
     {
+        CriticalBlock block(statsCrit);
         return stats.toStr(s);
     }
 
@@ -665,11 +667,12 @@ public:
     {
         if (aborted)
             throw MakeStringException(ROXIE_ABORT_ERROR, "Roxie server requested abort for running activity");
-        stats.addStatistic(kind, value);
+        stats.addStatisticAtomic(kind, value);
     }
 
     virtual void mergeStats(const CRuntimeStatisticCollection &from) const
     {
+        CriticalBlock block(statsCrit);
         stats.merge(from);
     }
     virtual const CRuntimeStatisticCollection &queryStats() const