1

在代码中,我删除一个表,然后创建表,并在一台服务器上的多个数据库中执行相同的操作,一切正常。然后我用SQL“SHOW TABLES”查询表,有时这个 sql 抛出异常:Fatal error encountered during command execution,有时它工作正常。而且我确信这不是由COMMAND TIMEOUT提出的。应该是其他原因。

这是删除表和创建表sql:

DROP TABLE IF EXISTS `a`;
CREATE TABLE IF NOT EXISTS `a`
SELECT 
  id,
  IF (mapping.name IS NULL, ne.autoname, mapping.name) AS autoname FROM b ne
LEFT JOIN test.a_mapping mapping ON ne.autoName = mapping.autoname;
ALTER TABLE `a` ADD INDEX `id_idx` (`id`); 
DELETE FROM `a` WHERE id = 1000000; 
INSERT INTO `a`(id, autoname) VALUES(1000000, @count);

这是显示表代码:

  MySqlDataReader dataReader = null;
    try{            
        MySqlCommand cmd = new MySqlCommand(MySqlUtils.SQL_GET_TABLES, connection);
        cmd.CommandTimeout = BaseOptimonConfig.Instance.CommandTimeout;
        dataReader = MySqlUtils.ExecuteReader(cmd); // just add try catch in this method.
        while (dataReader.Read())
        {
            if (MySqlUtils.GetSqlString(dataReader, 0).ToLower().Equals(tableName))
            {
                return true;
            }
        }
    }
    finally
    {
        MySqlUtils.CloseSqlReader(dataReader);
    }
4

0 回答 0