1

We restored databases to our UAT environment and set up AlwaysOn. Whenever I try and backup the log I'm getting "The log was not truncated because records at the beginning of the log are pending replication or Change Data Capture. Ensure the Log Reader Agent or capture job is running or use sp_repldone to mark transactions as distributed or captured."

I've removed CDCs from the database and removed all replication but I'm still getting the above error. The log_reuse_wait_desc is showing up as AVAILABILITY_REPLICA or REPLICATION.

I've also tried running the following.

EXEC sys.sp_replflush

EXEC sp_removedbreplication

EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,     @time = 0, @reset = 1

Any suggestions?

Thanks, Tim

4

3 回答 3

0

The production database, which is what this DB was restored from, does have replication set up. Even though this copy was restored without any replication there was a transaction in the log still from prod. To fix this I set up a new publication with one table from the problem database, didn't even create a subscription, then deleted the publication and the problem went away.

Thanks, Tim

于 2013-09-12T12:58:36.717 回答
0

Running the below solved the problem for us:

use myDB
go

EXEC sys.sp_cdc_enable_db 
go

EXEC sys.sp_cdc_disable_db 
go

EXEC sp_removedbreplication myDB
于 2017-05-04T07:16:47.210 回答
0

Had the same problem (SQL 2012) - a prod database set as a replication publisher, and using a restored copy in a lab environment where we don't use replication. Found this solution here:

EXEC sp_replicationdboption 'MyDB','publish','true',1

If you get a

~"distributor not configured" error,

your server may not be set up to manage replication. To get past this you can just make your server a distributor:

In SSMS: Server name: Right click on Replication, and walk through the steps to set up a distributor. Local machine should be OK.

EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,    @time = 0, @reset = 1

EXEC sp_replicationdboption 'MyDB','publish','false',1

Re-running the log backup after this was much faster and the hanging log record(s) were cleared.

于 2020-07-03T18:08:53.407 回答