笔者最近在做虚拟化迁移,涉及到了SQL的升级迁移,遂使用backup restore的方式将database迁移到SQL2005。用户密码什么的全部迁移完了,使用客户端应用程序测试连接了一下,一切正常,心想这个case终于可以告一段落了,正准备close的时候,抱错啦,network error! 马上晕了,这个玩笑开大了。
查日志,看数据格式,看网络。忙了好一会,后来发现,只要客户端程序出错的时候,SQL2005的事件查看器里,就会有几条日志,记录着什么cache flush的错误。
详细信息见下面,是我在网络上找到的详细说明。
 
In SQL Server 2005, certain database maintenance operations or certain dbcc commands such as “dbcc freeproccache” or “dbcc freesystemcache” will clear the plan cache for the instance of SQL Server. Clearing the plan cache causes a recompilation of all subsequent execution plans and cause a sudden, temporary excessive CPU usage and decrease in query performance. To help identify database operations flushing the plan cache as the cause of the sudden temporary decrease in query performance, SP2 includes an informational message in the ERRORLOG: "SQL Server has encountered %d occurrence(s) of cachestore flush for the '%s' cachestore (part of plan cache) due to some database maintenance or reconfigure operations". This message is logged every five minutes as long as the cache is flushed within that time interval.
 
The following database operations will flush the plan cache:
  • When the database is set to AUTOCLOSE = ON, an operation that initiates an automatic database shutdown clears the plan cache for the instance of SQL Server.
  • ALTER DATABASE [dbName] SET ONLINE
  • ALTER DATABASE [dbName] SET OFFLINE
  • ALTER DATABASE [dbName] SET READ_ONLY
  • ALTER DATABASE [dbName] SET READ_WRITE
  • ALTER DATABASE [dbName] MODIFY NAME = [SomeDB_Name]
  • ALTER DATABASE [dbName] MODIFY FILEGROUP Test1FG1 DEFAULT
  • ALTER DATABASE [dbName] MODIFY FILEGROUP Test1FG1 READ_WRITE
  • ALTER DATABASE [dbName] MODIFY FILEGROUP Test1FG1 READ_ONLY
  • ALTER DATABASE [dbName] COLLATE Collation_Name
  • DROP DATABASE [db_Snapshot_Name]
  • Restore database operation
  • Detach database operation
  • DBCC FREEPROCCACHE
  • DBCC FREESYSTEMCACHE
 
In SQL Server 2005 RTM and SP1, executing DBCC CHECKDB clears the plan cache for the instance of SQL Server. In SP2, executing DBCC CHECKDB does not clear the plan cache.
 
[url]http://support.microsoft.com/kb/314546/zh-cn[/url]
[url]http://support.microsoft.com/kb/917828/en-us[/url]
 
搞到最后,实在搞不定,领导又在催,没办法干脆装SQL2000了。
扒拉扒拉装完配好,测试,哎,一点问题都没有。真是不知道说什么好呢。