Microsoft SQL Server
--
Questions
--
Followers
Top Experts
from time to time we will see a CDC (change data capture) in MSSQL, when running with replication, around every 6 months, will make the user database's log file growth too large and can't come down in size any more.
the pattern is :
1) whenever the SQL job csc.<user database>_capture job STOPPED, this is a clear indicator that something went wrong, the <user database> log file size will be very large.
2) we then verify if it is the problem by running this:
select log_reuse_wait_desc,name, log_reuse_wait from sys.databases;
we should then we in the log_reuse_waiting_desc column, next to our user database, will show REPLICATION instead of ACTIVE_TRANSACTION.
3) we will see if the user database log size increase dynamically to make log disk full.
4) we also run this:
DBCC SQLPERF(logspace)
to see "log Space Used [%]" if it is 99% >.
5) we will finally use
DBCC OPENTRAN(<user database>)
to see if the oldes non-distributed LSN of a transaction has been hold there for a long time and number never change:Oldest active transaction:
SPID (server process ID): 158
UID (user ID) : -1
Name : user_transaction
LSN : (631159:27303:3)
Start time : Jun 25 2015 5:40:47:817AM
SID : 0x010500000000000515000000c5369faad8bb12aa5e06187c0d040000
Replicated Transaction Information:
Oldest distributed LSN : (0:0:0)
Oldest non-distributed LSN : ([b]631159:25862:1[/b])
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
, then we know there is the CDC and replication both work together to make log size can't come down at all.
solution:
we can only:
1) Make sure that the CDC capture job method above can start again, once start it will keep starting and run by itself.
2) we will run this:
sp_replflush
sp_repldone null, null, 0,0,1
sp_replflush
3) once it is flushed, we can the shrink the log by release space only.
this is how we due with it but how you guys handle it in a much robust way ? can automate the whole solution so we this problem will be fixed when system detect it ?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
no. I knew this question is tough and some DBA who was left leave down notes on who to troubleshoot it and we can only follow.
it works all the time except, once start the CDC jobs, we need to wait for 30 minutes before we can run this:
sp_repldone null, null, 0,0,1
or it will not works.
Mate.
we are using bidirectional merge replication.
"• It seems to me that replication does not work properly because log reader should execute automatically and regularly the sp_repldone stored procedure. Check this."
is that mean the replication can not replicate as efficient as possible?
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1b55cd9c-129c-4b2b-97fb-bd1fdf71bae3/using-sprepldone-to-clear-the-replication-transaction-queue?forum=sqlreplication






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
you are talking about if we have log backup we will not have this problem.
I can tell you only this server has this problem as only this server has CDC on together with replication.
the steps about is researched by many DBA in our company before and it seems it is the only solution for that.
I can tell you when this happening, we can't shrink log at all. the CDC and replication will keep locking the log file.
so this is not about the log file big or not, it is about if we don't fixed the CDC the log will keep growth until we execute the command above.
Then replication agent will truncate the log with sp_repldone.
I suggest to build up again the whole replication and CDC and you have to configure replication first and then CDC.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
"when running with replication, around every 6 months, will make the user database's log file growth too large and can't come down in size any more."There's no way to shrink a transaction log file without backup it first.
I can tell you only this server has this problem as only this server has CDC on together with replication.That's because Merge Replication needs CDC.
"There's no way to shrink a transaction log file without backup it first."
I mean withtout this problem, the size of the log very stable.
you know if we rebuild index at the same time, the log growth even faster.
"That's because Merge Replication needs CDC. "
but only one serve has this problem and we have 2 x subscribers,
I am not sure how you guys handle this.
you know if we rebuild index at the same time, the log growth even faster.That's for sure. Reindex heavily uses transaction log.
I am not sure how you guys handle this.To be honest I never used a Merge Replication. Trying to follow the logic here.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
but it seems hold there forever, we give up that on that box already, my boss said too scary to do it on that box.
rebuild index don't hold the log forever.
I knew this topic a bit hard as I don't think so much people will have this at all.
rebuild index don't hold the log forever.Depends how big is the table and how fragmented the index is.
ok, but it still not holding the log forever and let it keep growth for 1xxGB, right?
I never get this before when rebuilding index on a normal server.
now I am focusing on the restoring replication DB in publisher, the keep replication option doesn't shows and diff than normal restore, please see my other ticket. what are we suppose to see after using keep_replication option ?
I am reading this: http://www.sqlservercentral.com/Forums/Topic853719-291-1.aspx, it seem we need to recreate the replication by dropping replication and delete subscriber DB anyway.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
now I am focusing on the restoring replication DB in publisher, the keep replication option doesn't showsHas the server any replication enabled?
that one is in the restore distribution database ticket.
then give us an alert so that we can then, have SQL server start the job automatically followed by the action we define:
1:sp_replflush
2:
3:sp_repldone null, null, 0,0,1
4:
5:sp_replflush
it is easier is no solution for it (I don't think we have a solution as all DBA in US office has tried that before).






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
If not even Microsoft recommend it why are you using it? Move on to a more simpler solution.
Will do it but let me show you our diagram, I am wondering sth if it works as we have one publisher replicate to
so if we need to protect publisher, Server A and Server B, we should need 3 x AO group and between AO groups, serve can still talk to each other even not all member in any AO failover?
"I suggest to build up again the whole replication and CDC and you have to configure replication first and then CDC. "
I thought CDC is created when replication is created, right?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I thought CDC is created when replication is created, right?Why did you say that?
because you said:
"That's because Merge Replication needs CDC."
That statement was only to your case in particular.
From your question:
", then we know there is the CDC and replication both work together to make log size can't come down at all."






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
so it is still true that replication will create that CDC job as well ?
Are you able to create one from the scratch?
I can tell you, since last time we have this problem, it already 2 months and we don't see this anymore and the T-LOG stay still at 8GB,
so I don't think log backup doesn't really help in this case.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
actually I talked to MS to put replication to the in memory engine as no lock any more, or the replication will lock a lot of queries.
Microsoft SQL Server
--
Questions
--
Followers
Top Experts
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.