CDC on Sql Server 2017 with HA cluster stopped working I am currently using Sql Server 2017 (14.0.3294.2) running on Windows Server 2016 as an HA cluster, one primary with two secondaries.
A few days ago, the primary was rebooted and I think the person that did it executed some operations that made the primary server primary again. Since then, CDC stopped working. Querying the cdc tables doesn't offer a clue about the status. The CDC job is enabled.
I found this post: https://stackoverflow.com/questions/23744083/cdc-is-enabled-but-cdc-dbotable-name-ct-table-is-not-being-populated, however, I am very reluctant to use the solution in this context.
The last error in the CDC job log is (after the primary was restarted):

Executed as user: UserName. Failed to update database &quot;DatabaseName&quot;
because the database is read-only. [SQLSTATE 25000] (Error 3906).
NOTE: The step was retried the requested number of times (10) without
succeeding.  The step failed.

Any suggestions on how to make CDC work again?
Thank you
it seems that the problem is generated by the fact that the database is not primary.
In fact it is read-only state. Try to fail back the relative AG group.
https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/perform-a-planned-manual-failover-of-an-availability-group-sql-server?view=sql-server-ver15
About the cdc job you need to have it in every node that of the AG cluster.
Take a look at how to manage cdc in an alwayson environment:
https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/replicate-track-change-data-capture-always-on-availability?view=sql-server-ver15