@ -78,7 +78,7 @@ func (m *customRankPvpModel) RankListByType(ctx context.Context, rankType, topN
}
func (m *customRankPvpModel) UpdateRank(ctx context.Context, rankType int32, data []RankPvp) error {
db := m.conn.WithContext(ctx) //.Session(&gorm.Session{DryRun: true})
db := m.conn.WithContext(ctx)
return db.Transaction(func(tx *gorm.DB) error {
var err error
// delete all by rank_type
@ -11,6 +11,7 @@ import (
"live-service/app/user_center/model"
"live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb"
"time"
)
var Service *Job
@ -300,6 +301,8 @@ func (j *Job) persistence(rankType int32) {
})
if len(dbModel) > 0 {
// 简单避免死锁
time.Sleep(1 * time.Second)
if err = j.svcCtx.RankPvpModel.UpdateRank(j.ctx, rankType, dbModel); err != nil {
logx.Error("更新排行榜错误", err)
return