diff --git a/internal/msg_transfer/logic/init.go b/internal/msg_transfer/logic/init.go index c382de7f0..8f5cc0695 100644 --- a/internal/msg_transfer/logic/init.go +++ b/internal/msg_transfer/logic/init.go @@ -24,6 +24,8 @@ var ( singleMsgSuccessCount uint64 groupMsgCount uint64 singleMsgFailedCount uint64 + + singleMsgSuccessCountMutex sync.Mutex ) func Init() { diff --git a/internal/msg_transfer/logic/offline_history_msg_handler.go b/internal/msg_transfer/logic/offline_history_msg_handler.go index 13d168ddb..876beb30e 100644 --- a/internal/msg_transfer/logic/offline_history_msg_handler.go +++ b/internal/msg_transfer/logic/offline_history_msg_handler.go @@ -53,7 +53,9 @@ func (mc *OfflineHistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey s log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String()) return } + singleMsgSuccessCountMutex.Lock() singleMsgSuccessCount++ + singleMsgSuccessCountMutex.Unlock() log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now)) } if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID { diff --git a/internal/msg_transfer/logic/online_history_msg_handler.go b/internal/msg_transfer/logic/online_history_msg_handler.go index 43bd240c4..dd1f22634 100644 --- a/internal/msg_transfer/logic/online_history_msg_handler.go +++ b/internal/msg_transfer/logic/online_history_msg_handler.go @@ -86,7 +86,9 @@ func (och *OnlineHistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey s log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String()) return } + singleMsgSuccessCountMutex.Lock() singleMsgSuccessCount++ + singleMsgSuccessCountMutex.Unlock() log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", time.Since(now)) } if !isSenderSync && msgKey == msgFromMQ.MsgData.SendID {