为什么我看到“恢复中”消息,我该如何预防?

发布于 2024-09-04 17:34:45 字数 2811 浏览 8 评论 0原文

我正在处理的项目为您处理的每个 SVN 分支创建 SQL Server 数据库的本地副本。我们在本地计算机上运行具有高级服务的 SQL Server 2008 Express 来托管它。

当我们创建新分支时,构建脚本将使用该分支的 ID 创建一个新数据库,创建模式对象,并从生产影子服务器复制选定的数据。

创建数据库后,它或本地计算机上的其他数据库通常会进入“恢复”模式几分钟。几次刷新后,它会出现并且很高兴,但偶尔会回到“恢复中”模式。

数据库以简单恢复模式创建。未指定文件名,因此它使用文件的默认路径。

加载数据后数据库的大小约为 400 兆。它在 SQL Server 2005 兼容模式下运行。

创建数据库的命令是:

sqlcmd -S $(DBServer) -Q "IF NOT EXISTS (SELECT [name] FROM sysdatabases WHERE [name] = '$(DBName)') BEGIN CREATE DATABASE [$(DBName)]; print '已创建 $(数据库名称)';END"

...其中 $(DBName) 和 $(DBServer) 是 MSBuild 参数。

今天早上我得到了一个干净的日志文件。当我打开计算机时,它会启动所有五个数据库。然而,其中两个显示事务正在向前和向后滚动。它只是不断尝试启动所有五个数据库。

2010-06-10 08:24:59.74 spid52      Starting up database 'ASPState'.
2010-06-10 08:24:59.82 spid52      Starting up database 'CommunityLibrary'.
2010-06-10 08:25:03.97 spid52      Starting up database 'DLG-R8441'.
2010-06-10 08:25:05.07 spid52      2 transactions rolled forward in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:05.14 spid52      0 transactions rolled back in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:05.14 spid52      Recovery is writing a checkpoint in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:11.23 spid52      Starting up database 'DLG-R8979'.
2010-06-10 08:25:12.31 spid36s     Starting up database 'DLG-R8441'.
2010-06-10 08:25:13.17 spid52      2 transactions rolled forward in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:13.22 spid52      0 transactions rolled back in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:13.22 spid52      Recovery is writing a checkpoint in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:18.43 spid52      Starting up database 'Rls QA'.
2010-06-10 08:25:19.13 spid46s     Starting up database 'DLG-R8979'.
2010-06-10 08:25:23.29 spid36s     Starting up database 'DLG-R8441'.
2010-06-10 08:25:27.91 spid52      Starting up database 'ASPState'.
2010-06-10 08:25:29.80 spid41s     Starting up database 'DLG-R8979'.
2010-06-10 08:25:31.22 spid52      Starting up database 'Rls QA'.

在这种情况下,它一直尝试连续启动数据库,直到我在 23 分钟后的 08:48:19.72 关闭 SQL Server。与此同时,我实际上大部分时间都能够使用数据库。

日志文件中最后一个有趣的行是......

2010-06-10 08:35:01.52 spid34s     Recovery completed for database DLG-R8441 (database ID 6) in 1 second(s) (analysis 603 ms, redo 0 ms, undo 219 ms.) This is an informational message only. No user action is required.

The project I'm working on creates a local copy of the SQL Server database for each SVN branch you work on. We're running SQL Server 2008 Express with Advanced Services on our local machine to host it.

When we create a new branch, the build script will create a new database with the ID of that branch, creates the schema objects, and copies over a selection of data from the production shadow server.

After the database is created, it, or other databases on the local machine, will often go into "In Recovery" mode for several minutes. After several refreshes it comes up and is happy, but will occasionally go back into "In Recovery" mode.

The database is created in simple recovery mode. The file names aren't specified, so it uses default paths for files.

The size of the database after loading data is ~400 megs. It is running in SQL Server 2005 compatibility mode.

The command that creates the database is:

sqlcmd -S $(DBServer) -Q "IF NOT EXISTS (SELECT [name] FROM sysdatabases WHERE [name] = '$(DBName)') BEGIN CREATE DATABASE [$(DBName)]; print 'Created $(DBName)'; END"

...where $(DBName) and $(DBServer) are MSBuild parameters.

I got a nice clean log file this morning. When I turned on my computer it starts all five databases. However, two of them show transactions being rolled forward and backwards. The it just keeps trying to start up all five of the databases.

2010-06-10 08:24:59.74 spid52      Starting up database 'ASPState'.
2010-06-10 08:24:59.82 spid52      Starting up database 'CommunityLibrary'.
2010-06-10 08:25:03.97 spid52      Starting up database 'DLG-R8441'.
2010-06-10 08:25:05.07 spid52      2 transactions rolled forward in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:05.14 spid52      0 transactions rolled back in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:05.14 spid52      Recovery is writing a checkpoint in database 'DLG-R8441' (6). This is an informational message only. No user action is required.
2010-06-10 08:25:11.23 spid52      Starting up database 'DLG-R8979'.
2010-06-10 08:25:12.31 spid36s     Starting up database 'DLG-R8441'.
2010-06-10 08:25:13.17 spid52      2 transactions rolled forward in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:13.22 spid52      0 transactions rolled back in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:13.22 spid52      Recovery is writing a checkpoint in database 'DLG-R8979' (9). This is an informational message only. No user action is required.
2010-06-10 08:25:18.43 spid52      Starting up database 'Rls QA'.
2010-06-10 08:25:19.13 spid46s     Starting up database 'DLG-R8979'.
2010-06-10 08:25:23.29 spid36s     Starting up database 'DLG-R8441'.
2010-06-10 08:25:27.91 spid52      Starting up database 'ASPState'.
2010-06-10 08:25:29.80 spid41s     Starting up database 'DLG-R8979'.
2010-06-10 08:25:31.22 spid52      Starting up database 'Rls QA'.

In this case it kept trying to start the databases continuously until I shut down SQL Server at 08:48:19.72, 23 minutes later. Meanwhile, I actually am able to use the databases much of the time.

The last interesting line in the log file is this...

2010-06-10 08:35:01.52 spid34s     Recovery completed for database DLG-R8441 (database ID 6) in 1 second(s) (analysis 603 ms, redo 0 ms, undo 219 ms.) This is an informational message only. No user action is required.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

記柔刀 2024-09-11 17:34:45

问题似乎出在“自动关闭”选项上。我把它关掉后,问题就消失了。当您在脚本中创建数据库时,该默认值处于打开状态,但如果您通过 Management Studio 创建数据库,则默认值为关闭状态。

自动关闭功能会在最后一个用户断开连接后释放数据库的所有资源。由于这是一台开发机器,通常只有一个用户,因此它会在每次请求后释放所有资源。此外,似乎 Management Studio 有时会连接到服务器上的每个数据库,导致每个数据库每分钟启动几次。

干杯

The problem appears to have been the "Auto Close" option. After I turned that off, the problem went away. The default value for that is on when you create a database in script, but off if you create the database through management studio.

The Auto Close feature releases all the resources for a database after the last user disconnects. Since this is a development machine, there's usually only one user, so it releases all the resources after each request. Also it appears as though Management Studio occasionally connects to every database on the server, resulting in each database starting up several times a minute.

Cheers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文