在C#中使用DacServices.Deploy发布dacpac时,我们随机得到以下错误。除表外,Dacpac还具有部署后脚本,这是引起超时错误的部分。我们正在发布到新的SQL Server 2014数据库(因此,不是升级方案)。有人会建议解决方案吗?
PS:这通常在新服务器的第一次尝试上发生,然后在第二次尝试上完美运行。 DacPac发布是我们安装程序的一部分,安装程序失败给人留下了不好的印象。
错误...
执行超时已过期。逾时时间已过 操作完成或服务器没有响应。
我们已经明确设置了一个超时时间,但是似乎没有发生,因为发布会在超过一分钟的时间内失败,而超时时间设置为600秒。
DacDeployer代码...
async
事件侦听器在DacServices.Deploy上返回的信息,警告和错误日志。
var dacOptions = new DacDeployOptions();
dacOptions.IncludeCompositeObjects = true;
dacOptions.IncludeTransactionalScripts = true;
dacOptions.GenerateSmartDefaults = true;
//Specify timeout in seconds to override the default 60
dacOptions.CommandTimeout = 600;
using (DacPackage dacpac = DacPackage.Load(dacpacName))
{
dacServiceInstance.Deploy(dacpac, DBName, upgradeExisting: true, options: dacOptions);
}
存储过程已调用...
Initializing deployment (Start)
Initializing deployment (Complete)
Analyzing deployment plan (Start)
Analyzing deployment plan (Complete)
Updating database (Start)
Creating DW_Control...
Creating [DW_INTERNAL]...
Creating [DW_INTERNAL].[DB_VERSIONS]...
Creating [DW_INTERNAL].[SCRIPT_LOG]...
Warning! The maximum key length is 900 bytes. The index 'PK_SCRIPT_LOG' has maximum length of 1102 bytes. For some combination of large values, the insert/update operation will fail.
Creating [DW_INTERNAL].[SCRIPT_MASTER]...
Creating [DW_INTERNAL].[SCRIPT_STATUS]...
Warning! The maximum key length is 900 bytes. The index 'PK_SCRIPT_STATUS' has maximum length of 1094 bytes. For some combination of large values, the insert/update operation will fail.
Creating [dbo].[ARCHIVE_STATUS]...
Creating unnamed constraint on ...
Creating [dbo].[FK_...]...
Creating [dbo].[VW_...]...
Creating [DW_INTERNAL].[ADD]...
Creating [DW_INTERNAL].[ADD_SCRIPT]...
Creating [DW_INTERNAL].[UPGRADE]...
Creating [dbo].[VW_AMOUNT_SUMMARY].[MS_Description]...
The transacted portion of the database update succeeded.
.Net SqlClient Data Provider: Msg -2, Level 11, State 0, Line 0 Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Script execution error. The executed script:
EXECUTE DW_INTERNAL.ADD_VERSION @Module = 'CTL', @ToVersion = '1.17.02.00';
EXECUTE DW_INTERNAL.ADD_SCRIPT @Module = 'CTL', @FromVersion = '0.00.00.00', @ToVersion = '1.17.02.00', @ApplyOrder = 40, @UpgrScriptFilepath = 'CTL_0.00.00.00_1.17.02.00_P_DML.sql';
EXECUTE DW_INTERNAL.ADD_SCRIPT @Module = 'CTL', @FromVersion = '0.00.00.00', @ToVersion = '1.17.02.00', @ApplyOrder = 30, @UpgrScriptFilepath = 'CTL_0.00.00.00_1.17.02.00_R_DML.sql';
EXECUTE DW_INTERNAL.ADD_VERSION @Module = 'CTL', @ToVersion = '1.17.07.00';
EXECUTE DW_INTERNAL.ADD_SCRIPT @Module = 'CTL', @FromVersion = '1.17.02.00', @ToVersion = '1.17.07.00', @ApplyOrder = 60, @UpgrScriptFilepath = 'CTL_1.17.02.00_1.17.07.00_P_DML.sql';
EXECUTE DW_INTERNAL.ADD_SCRIPT @M
An error occurred while the batch was being executed.
Updating database (Failed)
Error details: Could not deploy package.
Error SQL72014:
Stack Trace: at Microsoft.SqlServer.Dac.DeployOperation.ThrowIfErrorManagerHasErrors()
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<>c__DisplayClass16.<CreatePlanExecutionOperation>b__13()
at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<CreatePlanExecutionOperation>b__12(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action`3 reportPlanOperation, Boolean executePlan)
at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
at DacDeployer.Program.Main(String[] args)