Fix unsafe usage of now() function from multiple threads in trace logging.

This commit is contained in:
A.J. Beamon 2019-07-22 12:30:50 -07:00 committed by Alex Miller
parent 2f9f3c184f
commit e98cee016d
2 changed files with 3 additions and 2 deletions

View File

@ -113,7 +113,7 @@ struct SuppressionMap {
};
TraceBatch g_traceBatch;
trace_clock_t g_trace_clock = TRACE_CLOCK_NOW;
thread_local trace_clock_t g_trace_clock = TRACE_CLOCK_REALTIME;
LatestEventCache latestEventCache;
SuppressionMap suppressedEvents;
@ -979,6 +979,7 @@ thread_local bool TraceEvent::networkThread = false;
void TraceEvent::setNetworkThread() {
traceEventThrottlerCache = new TransientThresholdMetricSample<Standalone<StringRef>>(FLOW_KNOBS->TRACE_EVENT_METRIC_UNITS_PER_SAMPLE, FLOW_KNOBS->TRACE_EVENT_THROTTLER_MSG_LIMIT);
networkThread = true;
g_trace_clock = TRACE_CLOCK_NOW;
}
bool TraceEvent::isNetworkThread() {

View File

@ -564,7 +564,7 @@ void addTraceRole(std::string role);
void removeTraceRole(std::string role);
enum trace_clock_t { TRACE_CLOCK_NOW, TRACE_CLOCK_REALTIME };
extern trace_clock_t g_trace_clock;
extern thread_local trace_clock_t g_trace_clock;
extern TraceBatch g_traceBatch;
#endif