Sql-server – AlwaysOn— SQL Jobs Understanding

availability-groupssql server 2014

I am new to AOAGs and Can Anyone please help me get out of below confusion.

I have 3 Replica AOAG.
I have a Archival Job in 3 Replicas scheduled at same time which will run every 15 minutes.

  1. AlwaysOn Job logically will always look for the Primary replica.Is it correct ?
  2. If the same job exists in all the AOAG replicas(Primaries and Secondaries) and scheduled at same time and why it is succeeding still with any failure ?Same job it runs in Primary and secondary without any conflict?can you please help me understanding this logic ?
  3. Which do you recommend ,scheduling the job at same time or with a difference of time around 5 minutes in secondaries.
  4. Can you hint me on what if same time and what if different time scheduled?
  5. Same Job if it runs in Primary will it run even in secondaries also as they are scheduled at same time ?

Best Answer

Are all replicas configured to become primary in case of failover?
In case YES, you need to create the same job in all instances, scheduled at the same time.
Keep in mind that each instance has a different MSDB, which means different jobs/schedules,etc..
So you will need to create a extra "check" in your jobs, to make sure it's running in the primary replica. Here you can find a complete post about it.