fix(inputs.sqlserver): Suppress error on secondary replicas (#12528)

This commit is contained in:
deweter 2023-01-26 14:52:15 +01:00 committed by GitHub
parent 00347033ab
commit 7e87a25123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 100 additions and 82 deletions

View File

@ -453,6 +453,7 @@ END
BEGIN TRY
SELECT
[measurement],[sql_instance],[database_name],[session_id]
,ISNULL([request_id],0) AS [request_id]
@ -533,6 +534,11 @@ WHERE
AND [session_id] <> @@SPID
)
OPTION(MAXDOP 1);
END TRY
BEGIN CATCH
IF (ERROR_NUMBER() <> 976) --Avoid possible errors from secondary replica
THROW;
END CATCH
`
const sqlAzureMISchedulers string = `

View File

@ -1328,7 +1328,13 @@ WHERE 1 = 1
OR (s.session_id IN (SELECT blocking_session_id FROM #blockingSessions))
OPTION(MAXDOP 1)'
BEGIN TRY
EXEC sp_executesql @SqlStatement
END TRY
BEGIN CATCH
IF (ERROR_NUMBER() <> 976) --Avoid possible errors from secondary replica
THROW;
END CATCH
`
const sqlServerVolumeSpaceV2 string = `

View File

@ -1139,7 +1139,13 @@ WHERE
)
OPTION(MAXDOP 1)'
BEGIN TRY
EXEC sp_executesql @SqlStatement
END TRY
BEGIN CATCH
IF (ERROR_NUMBER() <> 976) --Avoid possible errors from secondary replica
THROW;
END CATCH
`
const sqlServerVolumeSpace string = `