From d4fc77b556871416a710c588fb027eaf38f6bd99 Mon Sep 17 00:00:00 2001 From: icey-yu <1186114839@qq.com> Date: Mon, 9 Sep 2024 17:54:51 +0800 Subject: [PATCH] fix: add logs --- internal/push/push_handler.go | 5 +++++ pkg/rpccache/online.go | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/push/push_handler.go b/internal/push/push_handler.go index 6b1df9efa..e4b57c241 100644 --- a/internal/push/push_handler.go +++ b/internal/push/push_handler.go @@ -40,6 +40,8 @@ import ( "github.com/openimsdk/tools/utils/timeutil" "github.com/redis/go-redis/v9" "google.golang.org/protobuf/proto" + "math/rand" + "strconv" "time" ) @@ -130,6 +132,9 @@ func (c *ConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim s c.onlineCache.Cond.Wait() } c.onlineCache.Lock.Unlock() + ctx := mcontext.SetOperationID(context.TODO(), strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)) + log.ZInfo(ctx, "begin consume messages") + for msg := range claim.Messages() { ctx := c.pushConsumerGroup.GetContextFromMsg(msg) c.handleMs2PsChat(ctx, msg.Value) diff --git a/pkg/rpccache/online.go b/pkg/rpccache/online.go index 0d188bcc4..04b43d9e4 100644 --- a/pkg/rpccache/online.go +++ b/pkg/rpccache/online.go @@ -81,10 +81,6 @@ type OnlineCache struct { func (o *OnlineCache) initUsersOnlineStatus(ctx context.Context) (err error) { log.ZDebug(ctx, "init users online status begin") - defer func() { - o.CurrentPhase = DoOnlineStatusOver - o.Cond.Broadcast() - }() var ( totalSet atomic.Int64 @@ -96,6 +92,8 @@ func (o *OnlineCache) initUsersOnlineStatus(ctx context.Context) (err error) { defer func(t time.Time) { log.ZInfo(ctx, "init users online status end", "cost", time.Since(t), "totalSet", totalSet.Load()) + o.CurrentPhase = DoOnlineStatusOver + o.Cond.Broadcast() }(time.Now()) retryOperation := func(operation func() error, operationName string) error {