【发布时间】:2014-08-30 06:02:21
【问题描述】:
我通过其 .NET 连接器 (6.8.3) 广泛使用 MySQL 服务器 (5.6) 数据库。出于性能原因,所有表都是使用 MyISAM 引擎创建的。我只有一个进程,一个线程顺序访问数据库,所以不需要事务和并发。
请注意:这不太可能是超时配置问题,因为我的查询很简单。我确实阅读了所有与超时相关的问题(下面的链接)。当然,我可能是错的,但只是说“增加 net_write_timeout 参数”而不解释为什么它在这里可能是相关的,这不是一个答案。
我的一些表是在程序执行期间动态创建的,所以我使用 create on first use 习惯用法,使用以下方法检查表是否存在:
private bool TableExists(Space baseSpace, Space extendedSpace)
{
var tableName = GenerateTableName(baseSpace, extendedSpace);
var sqlConnection = this.connectionPool.Take();
this.existsCommand.Connection = sqlConnection;
this.existsCommand.Parameters["@tableName"].Value = tableName.Trim('`');
var result = existsCommand.ExecuteScalar() as long?;
this.connectionPool.Putback(sqlConnection);
return result == 1;
}
existsCommand里面的查询如下(为了便于阅读,这里分成两行):
SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = 'my_schema' AND table_name = @tableName
this.existsCommand.Parameters["@tableName"].Value 变量的值包含表的正确名称,在这种情况下已经存在 ("sample_matches_A_to_A_x")。
this.connectionPool.Take() 方法从我的可用连接集合中返回满足以下谓词的第一个 MySqlConnection 对象:
private bool IsAvailable(MySqlConnection connection)
{
return connection != null
&& connection.State == System.Data.ConnectionState.Open;
}
通常这可以正常工作几个小时,然后突然在该行发生异常:
var result = existsCommand.ExecuteScalar() as long?;
内容如下:
命令执行过程中遇到致命错误
堆栈跟踪:
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior 行为)
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
在 implementation.SampleMatchesMySqlTable.TableExists(Space baseSpace, Space extendedSpace) in C:...\SampleMatchesMySqlTable.cs:line 168
内部异常:
无法将数据写入传输连接:软件导致连接中止。
内部异常:
软件导致连接中止。
ErrorCode 等于 10053 且 SocketErrorCode 为 System.Net.Sockets.SocketError.ConnectionAborted
最里面异常的堆栈跟踪:
在 System.Net.Sockets.Socket.Send(Byte[] 缓冲区,Int32 偏移量,Int32 大小,SocketFlags socketFlags)
在 System.Net.Sockets.NetworkStream.Write(Byte[] 缓冲区,Int32 偏移量,Int32 大小)
我查看了以下可能的重复项,不幸的是,它们似乎与此处无关,除了一个:
SHOW TABLES encountered Fatal error encountered during command execution
很遗憾,它没有提供足够的信息来确定它是否是完全重复的,也没有得到回答。
有涉及到超时问题。我的查询很小,只返回一个整数,并在包含类似 20 个其他表的元表中搜索一个表。
Fatal error encountered during command execution. in C# when i use Insert Into
https://stackoverflow.com/questions/7895178/fatal-error-in-mysql
MySQL Exception - Fatal Error Encountered During Data Read
Fatal error encountered during data read
Fatal error causing timeout -mysql
ADO.Net Entity framework, Fatal error encountered during data read
关于读取结果集的不同错误:
Fatal error encountered during command execution
语法错误和连接字符串问题:
Mysql Fatal error encountered during command execution
fatal error encountered during execution... during update
Fatal error encountered during command execution
fatal error encountered during command execution during update
fatal error encountered during command execution c# mysql
Fatal error encountered during command execution with a mySQL INSERT
I have Fatal error encountered during command execution
MySql exception was unhandled - Fatal error encountered during command execution
Fatal Error Encounter During Command Execution MySQL VB
"Fatal error encountered during command execution." mysql-connector .net
"Fatal error encountered during command execution."
创建视图: "fatal error encountered during command execution" when trying to add a view from MySQL DB
读取 CSV 文件:
Fatal error encountered during command execution while importing from csv to mysql
【问题讨论】: