From 28447282b29929e9c5a38ca8c229cd7f65782804 Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Fri, 5 May 2017 17:20:18 +0100 Subject: [PATCH] HPCC-17564 Fix various threading issues with stats in ContextLogger Signed-off-by: Gavin Halliday --- roxie/ccd/ccd.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roxie/ccd/ccd.hpp b/roxie/ccd/ccd.hpp index c4a4a1352df..a4abe7de772 100644 --- a/roxie/ccd/ccd.hpp +++ b/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 @@ class ContextLogger : implements IRoxieContextLogger, public CInterface StringBuffer &getStats(StringBuffer &s) const { + CriticalBlock block(statsCrit); return stats.toStr(s); } @@ -665,11 +667,12 @@ class ContextLogger : implements IRoxieContextLogger, public CInterface { 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