我有一个基于 F# 的应用程序,我使用 EF-Core 和 MySQL (Pomelo.EntityFrameworkCore.MySql)。我有一个async方法可以更新数据库(MySql)中的数据
let updatePlayerAchievementsAsync (logger:ILogger) (ctx:ReportCacheDbContext) (id: int) = async {
let! account = ctx.AccountCaches.FirstOrDefaultAsync(fun e -> e.AccountId = id) |> Async.AwaitTask
if account <> null then
account.State <- "Closed"
do! ctx.SaveChangesAsync true |> Async.AwaitTask |> Async.Ignore
logger.LogInformation("Account{0} updated", id)
}
Run Code Online (Sandbox Code Playgroud)
当该方法执行到第99个元素时,出现以下错误:
|ERROR|System.InvalidOperationException:An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.
---> MySql.Data.MySqlClient.MySqlException (0x80004005): Connect Timeout expired. …Run Code Online (Sandbox Code Playgroud)