【发布时间】:2016-07-13 20:14:28
【问题描述】:
运行 powershell commandlet 时:
Set-AzureRmSqlDatabaseTransparentDataEncryption
在并行和独立的运行空间中,我们看到下面的堆栈跟踪出现瞬态/间歇性故障。但是,当我们串行运行相同的命令行开关时,我没有看到这个问题发生。
到目前为止我想出的可能原因:
- 是否知道此命令行开关不是线程安全的? (故意还是错误?)
- 文件
{ReleaseUser}\AppData\Roaming\Windows Azure Powershell\ErrorRecords\Set-AzureRmSqlDatabaseTransparentDataEncryption_YYYY-MM-DD-THH-MM-SS-PPP.log上的争用/锁定,其中命令行开关似乎记录了与解析令牌相关的信息(此文件中没有实际错误)。
运行此命令的脚本之一的堆栈跟踪:
[异常:System.NullReferenceException:对象引用未设置为对象的实例。\r\n
在 System.Collections.Specialized.OrderedDictionary.OrderedDictionaryEnumerator.get_Value()\r\n
在 Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.GetCustomHandlers()\r\n
在 Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateClient[TClient](AzureContext 上下文,终结点终结点)\r\n
在 Microsoft.Azure.Commands.Sql.TransparentDataEncryption.Services.AzureSqlDatabaseTransparentDataEncryptionCommunicator.GetCurrentSqlClient(String clientRequestId)\r\n
在 Microsoft.Azure.Commands.Sql.TransparentDataEncryption.Adapter.AzureSqlDatabaseTransparentDataEncryptionAdapter.GetTransparentDataEncryption(String resourceGroupName, String serverName, String databaseName)\r\n
在 Microsoft.Azure.Commands.Sql.TransparentDataEncryption.Cmdlet.SetAzureSqlDatabaseTransparentDataEncryption.GetEntity()\r\n
在 Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase'2.ExecuteCmdlet()\r\n
在 Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()]\
堆栈跟踪对于运行相同命令行开关的第二个线程:
消息:“对象引用未设置为对象的实例。”,来源:“System”,StackTrace:“在 System.Collections.Specialized.OrderedDictionary.IndexOfKey(Object key)\r\n 在 System.Collections .Specialized.OrderedDictionary.set_Item(对象键,对象值)\r\n 在 Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.AddHandler[T](T 处理程序)\r\n 在 Microsoft.WindowsAzure.Commands .Utilities.Common.AzurePSCmdlet.BeginProcessing()\r\n 在 System.Management.Automation.Cmdlet.DoBeginProcessing()\r\n 在 System.Management.Automation.CommandProcessorBase.DoBegin()"`
可疑:根据堆栈跟踪,在枚举/访问 System.Collections.Specialized.OrderedDictionary 时,这两个命令都会崩溃。
意义:命令的两个实例是否访问SAME字典?
【问题讨论】:
-
我也将这个问题提交给了微软的 Powershell Azure GitHub 账户:github.com/Azure/azure-powershell/issues/2580
-
请注意,Get-AzureRmSqlDatabase/New-AzureRmSqlDatabase 似乎与并发执行有相同的问题。他们似乎在幕后编辑 ArrayList 的同一个实例。此信息是逐字提供的 - 我没有通过查看这些命令行开关的源代码来确认此行为,我只是根据收到的异常进行假设。
标签: .net powershell azure