小编N.A*_*yaz的帖子

考虑通过将“EnableRetryOnFailure()”添加到“UseMySql”调用来启用瞬态错误弹性

我有一个基于 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)

mysql f# asynchronous entity-framework async-await

14
推荐指数
2
解决办法
5万
查看次数

标签 统计

async-await ×1

asynchronous ×1

entity-framework ×1

f# ×1

mysql ×1