SimpleClient.InsertReturnEntity有偶发问题 返回

SqlSugar 沟通中
8 344

数据库:Mysql 8.0.26

包:SqlSugarCoreNoDrive 5.1.4.170

驱动:MySqlConnector 2.3.7

报错:

执行SQL出错:Unable to connect to any of the specified MySQL hosts.

错误SQLUPDATE `collect_record_process`  SET

           `RecordName`=@RecordName,`UserId`=@UserId,`StartTime`=@StartTime,`EndTime`=@EndTime,`SendedCount`=@SendedCount,`RecvOkCount`=@RecvOkCount,`ProcessStatus`=@ProcessStatus,`ProcessResult`=@ProcessResult,`Soucre`=@Soucre  WHERE `Id`=@Id

堆栈   at SqlSugar.Check.Exception(Boolean isException, String message, String[] args)

   at SqlSugar.MySqlProvider.GetCommandAsync(String sql, SugarParameter[] parameters)

   at SqlSugar.MySqlProvider.ExecuteCommandAsync(String sql, SugarParameter[] parameters) |  |  | 

2024-12-04 17:46:38.9556 |  | ERROR | Zw.Dwh.Fore.Extensions.DbExtension |  |  |  | 执行SQL出错:中文提示 :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0".

English Message : Connection open error . Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0" 

错误SQLINSERT INTO `collect_record_process`  

           (`RecordName`,`UserId`,`StartTime`,`EndTime`,`SendedCount`,`RecvOkCount`,`ProcessStatus`,`ProcessResult`,`Soucre`)

     VALUES

           (@RecordName,@UserId,@StartTime,@EndTime,@SendedCount,@RecvOkCount,@ProcessStatus,@ProcessResult,@Soucre) ;SELECT LAST_INSERT_ID();

堆栈   at SqlSugar.Check.Exception(Boolean isException, String message, String[] args)

   at SqlSugar.AdoProvider.CheckConnection()

   at SqlSugar.MySqlProvider.GetCommand(String sql, SugarParameter[] parameters)

   at SqlSugar.AdoProvider.GetScalar(String sql, SugarParameter[] parameters) |  |  | 

2024-12-04 17:46:38.9556 |  | ERROR | Zw.Service.Business.Service.RabbitServices.InventoryToolDeadQueneComsumerService |  |  |  | SqlSugar.SqlSugarException: 中文提示 :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0".

English Message : Connection open error . Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0"  |  |  | SqlSugar.SqlSugarException: 中文提示 :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0".

English Message : Connection open error . Unable to connect to any of the specified MySQL hosts.DbType="MySql";ConfigId="0" 

   at SqlSugar.Check.Exception(Boolean isException, String message, String[] args)

   at SqlSugar.AdoProvider.CheckConnection()

   at SqlSugar.MySqlProvider.GetCommand(String sql, SugarParameter[] parameters)

   at SqlSugar.AdoProvider.GetScalar(String sql, SugarParameter[] parameters)

   at SqlSugar.InsertableProvider`1.ExecuteReturnBigIdentity()

   at SqlSugar.InsertableProvider`1.ExecuteCommandIdentityIntoEntity()

   at SqlSugar.InsertableProvider`1.ExecuteReturnEntity()

   at SqlSugar.SimpleClient`1.InsertReturnEntity(T insertObj)


描述:已经使用CopyNew。还是有这个问题


image.png

热忱回答8

  • fate sta fate sta VIP0
    1个月前

    这个网络问题

    0 回复
  • fate sta fate sta VIP0
    1个月前

    Unable to connect to any of the specified MySQL hosts.

    0 回复
  • Sheldon Sheldon VIP0
    1个月前

    数据库和代码部署在一个机子上,也会有网络问题的吗

    0 回复
  • fate sta fate sta VIP0
    1个月前

    @Sheldon:这个错就是这个问题,也可能服务器配置或者字符串问题

    0 回复
  • Sheldon Sheldon VIP0
    1个月前

    如果是服务器配置,有没有可以指导一下应该去检查哪些配置吗?比如会不会跟超时时间有关?

    0 回复
  • Sheldon Sheldon VIP0
    1个月前

    我是把连接池禁用掉的。

    我怀疑是连接池满的问题。就把连接池打开。

    但是打开之后,就频繁出

    执行SQL出错:中文提示 :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:Cannot Open when State is Connecting.DbType="MySql";ConfigId="0".

    English Message : Connection open error . Cannot Open when State is Connecting.DbType="MySql";ConfigId="0" 

    这个了。

    堆栈是在一个InsertMany的同步方法里面

    0 回复
  • fate sta fate sta VIP0
    1个月前

    @SheldonCannot Open when State is Connecting 这个是线程安全问题

    0 回复
  • fate sta fate sta VIP0
    1个月前

    https://www.donet5.com/Home/Doc?typeId=1224

    0 回复