Intermittent errors with SMO expanding databases when they're in an AG
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
研究方向
先閱讀連結的 dbatools 報告,並追蹤報告的進入點:EnumProcesses() 和 Databases 集合,以及 Copy-DbaLogin.ps1 第 324 行所顯示的呼叫端。重現可用性群組錯誤並比較兩條路徑;當間歇性失敗已獲得理解,並依據受影響的 SMO 行為完成驗證後,即表示完成。
由索引模型根據 Issue 內容生成。
描述
So this is hard to explain, there is a bug report for dbatools that I am also experiencing, where running Copy-DbaLogin works for most users most of the time, but pretty much every day I get at least one (different login, different database in error message) that fails out with the following error:
The target database ('DBNAME') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.
The normal path is that these databases are just skipped, but occasionally it seems like SMO tries to get in for some reason.
This is the get-error output
Exception :
Type : System.Management.Automation.MethodInvocationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Exception calling "EnumProcesses" with "0" argument(s): "Enumerate processes failed for Server 'SERVERNAME'. "
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : FailedOperationException
InvocationInfo :
ScriptLineNumber : 324
OffsetInLine : 33
HistoryId : 81
ScriptName : C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1
Line : $activeConnections = $destServer.EnumProcesses() | Where-Object Login -eq $newUserName
Statement : $activeConnections = $destServer.EnumProcesses() | Where-Object Login -eq $newUserName
PositionMessage : At C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1:324 char:33
+  $activeConnections = $destServer.EnumProcesses() | Where- 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\temp\loginrefresh\dbatools\dbatools\public
PSCommandPath : C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1
CommandOrigin : Internal
ScriptStackTrace : at Copy-Login, C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1: line 324
at Copy-DbaLogin<Process>, C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1: line 462
at Select-DefaultView<Process>, C:\temp\loginrefresh\dbatools\dbatools\private\functions\Select-DefaultView.ps1: line 70
at Get-DbaLogin<Process>, C:\temp\loginrefresh\dbatools\dbatools\public\Get-DbaLogin.ps1: line 281
at <ScriptBlock>, C:\temp\loginrefresh\login-loop.ps1: line 24
at <ScriptBlock>, C:\temp\loginrefresh\login-loop.ps1: line 22
at <ScriptBlock>, <No file>: line 1
WasThrownFromThrowStatement : True
TargetSite :
Name : CheckActionPreference
DeclaringType : [System.Management.Automation.ExceptionHandlingOps]
MemberType : Method
Module : System.Management.Automation.dll
Message : Exception calling "EnumProcesses" with "0" argument(s): "Enumerate processes failed for Server 'SERVERNAME'. "
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : Microsoft.SqlServer.Management.Smo.FailedOperationException
SmoExceptionType : FailedOperationException
Operation : Enumerate processes
FailedObject : [SERVERNAME]
Message : Enumerate processes failed for Server 'SERVERNAME'.
HelpLink : https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=17.100.76.0&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Enumerate+processes+Server&LinkId=20476
TargetSite :
Name : EnumProcesses
DeclaringType : [Microsoft.SqlServer.Management.Smo.Server]
MemberType : Method
Module : Microsoft.SqlServer.Smo.dll
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : Microsoft.SqlServer.Management.Sdk.Sfc.EnumeratorException
TargetSite :
Name : Process
DeclaringType : [Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator]
MemberType : Method
Module : Microsoft.SqlServer.Management.Sdk.Sfc.dll
Message : Failed to retrieve data for this request.
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : Microsoft.Data.SqlClient.SqlException
Errors :
Source : Core Microsoft SqlClient Data Provider
Number : 978
State : 1
Class : 14
Server : SERVERNAME
Message : The target database ('DBNAME') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.
LineNumber : 1
ClientConnectionId : 48273446-1530-408d-9685-b3f0e9eb411b
Class : 14
LineNumber : 1
Number : 978
Server : SERVERNAME
State : 1
Source : Core Microsoft SqlClient Data Provider
ErrorCode : -2146232060
TargetSite :
Name : ThrowExceptionAndWarning
DeclaringType : [Microsoft.Data.SqlClient.TdsParser]
MemberType : Method
Module : Microsoft.Data.SqlClient.dll
Message : The target database ('DBNAME') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.
Data : System.Collections.ListDictionaryInternal
HResult : -2146232060
StackTrace :
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
at Microsoft.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
at Microsoft.Data.SqlClient.SqlDataReader.Read()
at Microsoft.SqlServer.Management.Smo.DataProvider.ReadInternal()
at Microsoft.SqlServer.Management.Smo.DataProvider.SetConnectionAndQuery(ExecuteSql execSql, String query)
at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataProvider(StringCollection query, Object con, StatementBuilder sb, RetriveMode rm)
at Microsoft.SqlServer.Management.Smo.SqlObjectBase.FillDataWithUseFailure(SqlEnumResult sqlresult, ResultType resultType)
at Microsoft.SqlServer.Management.Smo.SqlObjectBase.BuildResult(EnumResult result)
at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData()
at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo, Request request)
at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request)
Source : Microsoft.SqlServer.Management.Sdk.Sfc
HResult : -2146233088
StackTrace :
at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.GetEnumeratorData(Request req)
at Microsoft.SqlServer.Management.Smo.Server.EnumProcesses()
Source : Microsoft.SqlServer.Smo
HResult : -2146233088
StackTrace :
at Microsoft.SqlServer.Management.Smo.Server.EnumProcesses()
at CallSite.Target(Closure, CallSite, Object)
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : FailedOperationException
InvocationInfo :
ScriptLineNumber : 324
OffsetInLine : 33
HistoryId : 81
ScriptName : C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1
Line : $activeConnections = $destServer.EnumProcesses() | Where-Object Login -eq $newUserName
Statement : $activeConnections = $destServer.EnumProcesses() | Where-Object Login -eq $newUserName
PositionMessage : At C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1:324 char:33
+  $activeConnections = $destServer.EnumProcesses() | Where- 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\temp\loginrefresh\dbatools\dbatools\public
PSCommandPath : C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1
CommandOrigin : Internal
ScriptStackTrace : at Copy-Login, C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1: line 324
at Copy-DbaLogin<Process>, C:\temp\loginrefresh\dbatools\dbatools\public\Copy-DbaLogin.ps1: line 462
at Select-DefaultView<Process>, C:\temp\loginrefresh\dbatools\dbatools\private\functions\Select-DefaultView.ps1: line 70
at Get-DbaLogin<Process>, C:\temp\loginrefresh\dbatools\dbatools\public\Get-DbaLogin.ps1: line 281
at <ScriptBlock>, C:\temp\loginrefresh\login-loop.ps1: line 24
at <ScriptBlock>, C:\temp\loginrefresh\login-loop.ps1: line 22
at <ScriptBlock>, <No file>: line 1
```
these are the commands that seem to throw the errors most often, but there is more info on the dbatools issue.
$destServer = Connect-DbaInstance -SqlInstance mssql1
$activeConnections = $destServer.EnumProcesses() | Where-Object Login -eq $newUserName
#or
$ownedDbs = $destServer.Databases | Where-Object Owner -eq $newUserName
- 主要語言
- C#
- 星號
- 143
- 分支
- 29
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/sqlmanagementobjects 的其他 Issue
-
Path parsing functions are incorrect when running on Linux可能已有人在做 @shueybubbles 於 7 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 62/100
-
難度 3/5 1-2 天 新手友好度 72/100
-
難度 4/5 3-5 天 新手友好度 74/100
-
難度 3/5 1-2 天 新手友好度 78/100
查看 microsoft/sqlmanagementobjects 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
stryker-mutator/stryker-net#3892 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
MobiFlight/MobiFlight-Connector#3419 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
Kryptos-FR/MarkView.Avalonia#105 ·
維護者通常 1 天內回覆
-
[辞書]未關閉提案 辞書
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
microsoft/fluentui-blazor#5410 ·
維護者通常 1 天內回覆