From 9182f15ee0c404d48b72793c147c4bf95d9649a6 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Wed, 2 Nov 2022 11:17:20 +0800 Subject: [PATCH] test cron --- internal/cron_task/clear_msg.go | 9 ++++++++- pkg/common/db/mongoModel.go | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/cron_task/clear_msg.go b/internal/cron_task/clear_msg.go index 0f3b05263..32243ac1b 100644 --- a/internal/cron_task/clear_msg.go +++ b/internal/cron_task/clear_msg.go @@ -78,13 +78,18 @@ func deleteMongoMsg(operationID string, ID string, index int64, delMsgIDList *[] msgs, err := db.DB.GetUserMsgListByIndex(ID, index) if err != nil || msgs.UID == "" { if err != nil { - log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID) + if err == db.ErrMsgListNotExist { + log.NewDebug(operationID, utils.GetSelfFuncName(), ID, index, err.Error()) + } else { + log.NewError(operationID, utils.GetSelfFuncName(), "GetUserMsgListByIndex failed", err.Error(), index, ID) + } } return getDelMaxSeqByIDList(*delMsgIDList), delMongoMsgs(operationID, delMsgIDList) } if index == 0 && msgs == nil { return 0, nil } + log.NewDebug(operationID, "ID:", ID, "index:", index, "uid:", msgs.UID, "len:", len(msgs.Msg)) if len(msgs.Msg) > db.GetSingleGocMsgNum() { log.NewWarn(operationID, utils.GetSelfFuncName(), "msgs too large", len(msgs.Msg), msgs.UID) } @@ -162,6 +167,8 @@ func checkMaxSeqWithMongo(operationID, ID string, diffusionType int) error { } if math.Abs(float64(msgPb.Seq-uint32(maxSeq))) > 10 { log.NewWarn(operationID, utils.GetSelfFuncName(), maxSeq, msgPb.Seq, "redis maxSeq is different with msg.Seq") + } else { + log.NewInfo(operationID, utils.GetSelfFuncName(), diffusionType, ID, "seq and msg OK", msgPb.Seq, uint32(maxSeq)) } return nil } diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index 719c06ccc..0b4bd2617 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -268,7 +268,7 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er regex := fmt.Sprintf("/^%s/", ID) findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1}) var msgs []UserChat - cursor, err := c.Find(ctx, bson.M{"uid": bson.M{"$regex": primitive.Regex{Pattern: regex}}}, findOpts) + cursor, err := c.Find(ctx, bson.M{"uid": primitive.Regex{Pattern: regex}}, findOpts) if err != nil { return nil, utils.Wrap(err, "") } @@ -281,7 +281,6 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er } else { return nil, ErrMsgListNotExist } - //return &msgs, nil } func (d *DataBases) DelMongoMsgs(IDList []string) error {