SQL Server – Fixing Error 41145 When Joining Database to Availability Group

availability-groupssql-server-2017

I keep getting from my SQL monitoring service the following alert:

Error: 41145, Severity: 16, State: 1. Cannot join database to
availability group. The database has already joined the
availability group. This is an informational message. No user action
is required.

This error is costantly coming approximately every 2 hours but I can't understand why.

Also, in the SQL error log, I have thousands of this log entry that I've never noticed on any of my other SQL Server installations:
SQL server error log
SQL server error log

This is on a new SQL Server installation that will become my production environment, so I want to make sure that there's nothing wrong with it before we perform the switch of the servers.

Best Answer

I've seen that recurring error about joining the database when automatic seeding was used to initialize the secondary replicas. My solution has always been to disable automatic seeding once the secondary databases have all been created and synchronized:

ALTER AVAILABILITY GROUP YourAgName
MODIFY REPLICA ON 'YourReplicaName'
WITH (SEEDING_MODE = MANUAL);

Those information messages are normal, but I haven't ever seen thousands of them in a row. My experience is that you'll see several of those messages per database per replica when the AG connection to that replica is established.

I just started up some VMs in my home lab environment that have:

  • 1 AG
  • 3 databases in the AG
  • 3 replicas total (primary, sync secondary, async secondary)

I ended up with 90 of those "DbMgrPartnerCommitPolicy" messages (10 messages * 3 databases * 3 replicas).