diff --git a/statemdl/state.go b/statemdl/state.go index c6634b2ee320ba6c4f78ad7a3d220bb83c2e549e..32343c5b025fecd9e794cc05f86e3a749f8802f3 100644 --- a/statemdl/state.go +++ b/statemdl/state.go @@ -392,6 +392,12 @@ func collectStatistics() { clientResponseData.ServicesState = stateCache clientResponseData.QueryState = queryCache + // the marshall function reads data from clientResponseData.ServicesState and clientResponseData.QueryState + // as both are maps, we have passed a referrence of stateCache and queryCache respectively. + // The following lock guards these two underlying data structures. + stateMutex.Lock() + defer stateMutex.Unlock() + ba, marshalError := ffjson.Marshal(clientResponseData) if errormdl.CheckErr(marshalError) != nil { loggermdl.LogError(marshalError)