HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is there such thing as an Availability Group failover trigger?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
suchtriggergroupfailoveravailabilitytherething

Problem

Is there such thing as a trigger for Availability Group failovers?

I want a certain action to happen when an AG fails over. Specifically, I want to turn on a database setting (turning on RCSI). I want to do this on a failover in order to minimize disruption to 24/7 workloads and scheduled maintenance windows are hard to come by.

I know that sp_procoption can be used to mark procedures as startup procedures.
This seems like it could work for failover clusters, but not for Availability Groups.

I did consider adding an alert (sp_add_alert) on message_id=26069 in order to respond to failover actions with a sql agent job. But this seems less direct and in practice it seems slow

Solution

No. Triggers are not at an instance or AG level. You'd need to base something on the failover event or better yet, as part of a SQL Server Agent job, just check to see if that replica is the primary and then do (or not do) something.

Context

StackExchange Database Administrators Q#235085, answer score: 6

Revisions (0)

No revisions yet.