MySql.Data.MySqlClient.MySqlException:超时已过期

时间:2021-08-11 20:30:07

In recent times, a particular page in my web app throws the

最近,我的网络应用程序中的特定页面抛出了

Exception Details: MySql.Data.MySqlClient.MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

异常详细信息:MySql.Data.MySqlClient.MySqlException:超时已过期。操作完成之前经过的超时时间或服务器没有响应。

Though I use Ibtais as persistence layer, this error occurs. I have restarted the MySql service instance but stil i get the same error. It didn't happen earlier but happens frequently in recent times.

虽然我使用Ibtais作为持久层,但会发生此错误。我重新启动了MySql服务实例但是我得到了同样的错误。它没有发生在早期,但最近经常发生。

All the web applications deployed on the server uses Ibatis and the DB server remains on the same machine where IIS is installed. There are about 8000 records in which around 300 to 500 would be filtered on page load

部署在服务器上的所有Web应用程序都使用Ibatis,并且数据库服务器保留在安装IIS的同一台计算机上。大约有8000条记录,其中大约300到500个将在页面加载时进行过滤

Any insights for the cause of the problem?

有关问题原因的任何见解?

2 个解决方案

#1


13  

I encountered the same problem with yours, and I found this MySQLConnection--Specifying default command timeout.

我遇到了与你相同的问题,我发现了这个MySQLConnection - 指定默认命令超时。

Just add "default command timeout=xxx" into your connectString, this key's value is in seconds.
I tried and it worked for me.

只需在connectString中添加“default command timeout = xxx”,此键的值以秒为单位。我试过,它对我有用。

#2


1  

You could set command timeout to 0, its not a good idea though. Some requests could go on indefinitely.

您可以将命令超时设置为0,但这不是一个好主意。有些请求可以无限期地继续下去。

There is an underlying problem that is causing the queries to time out in the first place. Are you inserting, updating, or in any way working with large binary values that would lock the table? That is the most common reason I see for an error like this on such a small amount of data.

有一个潜在的问题导致查询首先超时。您是否正在插入,更新或以任何方式处理将锁定表的大二进制值?这是我在如此少量的数据上看到类似错误的最常见原因。

#1


13  

I encountered the same problem with yours, and I found this MySQLConnection--Specifying default command timeout.

我遇到了与你相同的问题,我发现了这个MySQLConnection - 指定默认命令超时。

Just add "default command timeout=xxx" into your connectString, this key's value is in seconds.
I tried and it worked for me.

只需在connectString中添加“default command timeout = xxx”,此键的值以秒为单位。我试过,它对我有用。

#2


1  

You could set command timeout to 0, its not a good idea though. Some requests could go on indefinitely.

您可以将命令超时设置为0,但这不是一个好主意。有些请求可以无限期地继续下去。

There is an underlying problem that is causing the queries to time out in the first place. Are you inserting, updating, or in any way working with large binary values that would lock the table? That is the most common reason I see for an error like this on such a small amount of data.

有一个潜在的问题导致查询首先超时。您是否正在插入,更新或以任何方式处理将锁定表的大二进制值?这是我在如此少量的数据上看到类似错误的最常见原因。