在新的 TFS 2013 构建机器上构建时出现 EsentVersionStoreOutOfMemoryAndCleanupTimedOutException

EsentVersionStoreOutOfMemoryAndCleanupTimedOutException when building on new TFS 2013 build machine

我在构建项目时一直遇到此异常。在过去的几天里,我刚刚在机器上安装了 OS、构建代理、依赖项和 SQL Server 2008 R2。我从一台运行良好的旧构建机器上复制了所有数据库的备份 (.bak),并将它们全部恢复到新硬件上。我移植的所有其他项目都运行良好,但这是最后一个项目,我不知道如何处理这个错误。

从我的 MSBuild 日志文件中,我可以看到它编译了 FooBar.sqlproj 文件,然后继续创建 .dacpac 文件,但它在那里爆炸了。由于此异常,有许多后续的 .sqlproj 个项目无法进行。

如何解决错误并构建项目?

PrepareForBuild:
     Creating directory ".\sql\".
   GenerateSqlTargetFrameworkMoniker:
   Skipping target "GenerateSqlTargetFrameworkMoniker" because all output files are up-to-date with respect to the input files.
   CoreCompile:
     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /highentropyva- /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /out:obj\Default\FooBar.dll /target:library /utf8output "C:\Users\User_Foo\AppData\Local\Temp\.NETFramework,Version=v4.0.SqlClrAttributes.cs"
   SqlBuild:
     Creating a model to represent the project...
     Loading project references...
     Loading project files...
     Building the project model and resolving object interdependencies...
     Validating the project model...
     Writing model to D:\Builds\Foo\Sources\Database\FooBar\obj\Default\Model.xml...
   CopyFilesToOutputDirectory:
     Copying file from "obj\Default\FooBar.dll" to ".\sql\FooBar.dll".
     FooBar -> D:\Builds\Foo\Sources\Database\FooBar\sql\FooBar.dll
   SqlPrepareForRun:
     FooBar -> D:\Builds\Foo\Sources\Database\FooBar\sql\FooBar.dacpac
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets (550): The "SqlBuildTask" task failed unexpectedly.
Microsoft.Isam.Esent.Interop.EsentVersionStoreOutOfMemoryAndCleanupTimedOutException: Version store out of memory (and cleanup attempt failed to complete)
   at Microsoft.Isam.Esent.Interop.Update.Save(Byte[] bookmark, Int32 bookmarkSize, Int32& actualBookmarkSize)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelStore.EseCommand.InsertRow(Object[] values)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelStore.RelationshipEntry.AddAnnotation(IModelAnnotation annotation)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilderSchemaAnalyzer.Annotate(IModelAnnotationHolder annotationHolder, ModelRelationshipClass relationshipClass, SqlElementDescriptor rightHandSide, TSqlFragment fragment)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilderSchemaAnalyzer.CreateRelationshipEntry(IModelRelationship relationship, ModelRelationshipClass relationshipClass, SqlElementDescriptor rightHandSide, IModelElement lhs, TSqlFragment fragment)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilderSchemaAnalyzer.IdentifiedRelationshipRegularAction(TSqlFragment fragment, SqlElementDescriptor leftHandSide, ModelRelationshipClass relationshipClass, SqlElementDescriptor rightHandSide, IEnumerable`1 annotationDescriptors)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor.IdentifyRelationshipToResolvedDescriptor(SqlSchemaAnalyzer analyzer, SqlElementDescriptor leftHandSide, ModelRelationshipClass relationship, ResolvedDescriptor descriptor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor.VisitResolvedDescriptor(SqlSchemaAnalyzer analyzer, ResolvedDescriptor descriptor, Boolean createRelationship)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SetClauseInterpretationVisitor90.ExplicitVisit(AssignmentSetClause node)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlInterpretationUtils.InterpretSetClause(SetClause node, SqlSchemaAnalyzer analyzer, SqlInterpretationContext context, SqlColumnResolver columnResolver, SqlColumnResolver dmlTargetColumnResolver, List`1 errors)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.UpdateSpecificationInterpretationVisitor90.InterpretUpdateSpecification(UpdateSpecification node)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlInterpretationUtils.InterpretDmlSpecification(DataModificationSpecification node, SqlSchemaAnalyzer analyzer, SqlInterpretationContext context, List`1 errors)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.UpdateStatementInterpretationVisitor.InterpretUpdateStatement(UpdateStatement node)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor.InterpretDmlWithNewVisitor(TSqlFragment node, SqlInterpretationVisitor visitor)
   at Microsoft.SqlServer.TransactSql.ScriptDom.StatementList.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.SqlServer.TransactSql.ScriptDom.BeginEndBlockStatement.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor90.ExplicitVisit(IfStatement node)
   at Microsoft.SqlServer.TransactSql.ScriptDom.StatementList.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.SqlServer.TransactSql.ScriptDom.BeginEndBlockStatement.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor90.ExplicitVisit(WhileStatement node)
   at Microsoft.SqlServer.TransactSql.ScriptDom.StatementList.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SubroutineInterpretationVisitor.ExplicitVisit(StatementList node)
   at Microsoft.SqlServer.TransactSql.ScriptDom.CreateProcedureStatement.AcceptChildren(TSqlFragmentVisitor visitor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.ProcedureStatementInterpretationVisitor.ExplicitVisit(CreateProcedureStatement node)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.InterpretationVisitors.SqlInterpretationVisitor.InterpretDdlWithNewVisitor(TSqlFragment node, SqlInterpretationVisitor visitor)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.Sql100Interpreter.InterpretImpl(TSqlFragment fragment, SqlSchemaAnalyzer analyzer, IList`1& errors)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilder.InterpretTSqlScript(String filename, TSqlScript script, NecessaryOptions parsedMetadata, IList`1 parseErrors)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilder.ParseAndInterpret(String filename, TextReader objectsSource, IDictionary`2 metadata)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlModelBuilder.AddObjects(String cacheIdentifier, TextReader script, IDictionary`2 metadata)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelBuilder.AddOrUpdateObjects(ScriptHandle script)
   at Microsoft.Data.Tools.Schema.Utilities.Sql.Jobs.ModelBuilderJob.BatchLoadOrUpdate(ModelBuilder mb, IList`1 scripts, Int32 index, Int32 count, List`1& processedCacheIds, Exception& handledEx)
   at Microsoft.Data.Tools.Schema.Sql.Build.SqlTaskHost.Add(IList`1 sourceScripts)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.TaskHostLoader.LoadSourceFiles(TaskLoggingHelper providedLogger, SqlTaskHost host, ErrorManager errors)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.TaskHostLoader.LoadImpl(ITaskHost providedHost, TaskLoggingHelper providedLogger)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.TaskHostLoader.Load(ITaskHost providedHost, TaskLoggingHelper providedLogger)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteLoadTaskHostStep()
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteStep(Func`1 step)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

您是否尝试过强制使用内存模型:

https://connect.microsoft.com/SQLServer/feedback/details/749108/msbuild-fails-randomly-with-version-store-out-of-memory-cleanup-already-attempted-errors-msb4018

This looks like a problem with our file-backed storage. We're looking at the core problem, but I've added a command-line switch to our next SSDT release (post-December 2013) to force the msbuild commandline utilities to use an in-memory model. With the next release define <CmdLineInMemoryStorage>True</CmdLineInMemoryStorage> in the first PropertyGroup in your .sqlproj file.