fix: 修复渠道一致性问题

This commit is contained in:
CaIon
2024-01-12 14:34:44 +08:00
parent febcadb42c
commit e2a1caba4c
3 changed files with 5 additions and 2 deletions

View File

@@ -101,10 +101,12 @@ func Distribute() func(c *gin.Context) {
channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, modelRequest.Model)
if err != nil {
message := fmt.Sprintf("当前分组 %s 下对于模型 %s 无可用渠道", userGroup, modelRequest.Model)
// 如果错误,但是渠道不为空,说明是数据库一致性问题
if channel != nil {
common.SysError(fmt.Sprintf("渠道不存在:%d", channel.Id))
message = "数据库一致性已被破坏,请联系管理员"
}
// 如果错误,而且渠道为空,说明是没有可用渠道
abortWithMessage(c, http.StatusServiceUnavailable, message)
return
}