Skip to content

Fix AG secondary filter to skip all inaccessible databases#360

Merged
erikdarlingdata merged 1 commit intodevfrom
fix/ag-secondary-filter-v2
Feb 27, 2026
Merged

Fix AG secondary filter to skip all inaccessible databases#360
erikdarlingdata merged 1 commit intodevfrom
fix/ag-secondary-filter-v2

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • Fixes Data collection errors related to secondary database availability. #325 — previous AG secondary filter only excluded READ_ONLY secondaries, missing NO connections and suspended data movement
  • Replace complex NOT IN subquery (using sys.availability_replicas + sys.dm_hadr_availability_group_states) with a simpler LEFT JOIN to sys.dm_hadr_database_replica_states
  • Only query databases that are not in any AG or are the primary replica — skips all secondaries regardless of configuration
  • Fixed in all 4 affected files: install/09, install/39, and both Lite collector services

Test plan

  • Install on server with AG secondaries — no errors from inaccessible databases
  • Non-AG servers unaffected (LEFT JOIN produces NULL, passes filter)
  • Primary replica databases still collected normally

🤖 Generated with Claude Code

Previous filter only excluded secondaries with READ_ONLY connections,
missing secondaries configured with NO connections or suspended data
movement. Replace complex NOT IN subquery with a simpler LEFT JOIN to
sys.dm_hadr_database_replica_states — only query databases not in an
AG or on the primary replica.

Fixes all 4 affected files: install scripts 09/39 and Lite collectors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit ac3d821 into dev Feb 27, 2026
7 checks passed
@erikdarlingdata erikdarlingdata deleted the fix/ag-secondary-filter-v2 branch February 27, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant