Przeglądaj źródła

HPCC-17564 Fix various threading issues with stats in ContextLogger

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 lat temu
rodzic
commit
28447282b2
1 zmienionych plików z 4 dodań i 1 usunięć
  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