修复访问日志表可能无法自动创建的Bug

This commit is contained in:
GoEdgeLab
2022-03-23 10:05:42 +08:00
parent 26f22a39c9
commit b4d0f49802
4 changed files with 46 additions and 12 deletions

View File

@@ -221,7 +221,23 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLog
Sets(fields).
Insert()
if err != nil {
return err
// 错误重试
if CheckSQLErrCode(err, 1146) { // Error 1146: Table 'xxx' doesn't exist
err = SharedHTTPAccessLogManager.CreateTable(dao.Instance, tableDef.Name)
if err != nil {
return err
}
// 重新尝试
lastId, err = dao.Query(tx).
Table(tableDef.Name).
Sets(fields).
Insert()
}
if err != nil {
return err
}
}
if accessLogEnableAutoPartial && accessLogRowsPerTable > 0 && lastId%accessLogRowsPerTable == 0 {