Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Truncate log for Mirrored Database Expand / Collapse
Author
Message
Posted Sunday, October 19, 2008 11:46 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 23, 2009 8:19 AM
Points: 36, Visits: 75
Hello,

I am running Mirroring on my Database. Log file for my database growing day by day on Principal server. Recovery Model is Full. Data file is only 2 GB but Transaction Log file is 50 GB.

I am running 2 Management Plans on Principal Server.

First Management plan is running Full Database back up every 3rd day and is running fine.
Second Management Plan is running the following
a) Transaction log backup.
b) TSQL Command backup log with no_log
c) Shrink Database utility.
transaction log backup works fine but for TSQL command it gives error that log can not truncate for mirrored database.

Is there any option I can truncate Log file for Mirrored database through Management Plan, without removing mirroring?

Response would be greatly appreciated.

Thanks
Rishabh
Post #588288
Posted Sunday, October 19, 2008 12:13 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 42,485, Visits: 35,554
You cannot truncate the log of a mirrored database. You should not be truncating your log anyway. It breaks the log chain and means that you will not be able to do a point-in-time restore of the db to any point after the log truncation, until you take another full/diff backup.

a) Transaction log backup.
b) TSQL Command backup log with no_log
c) Shrink Database utility.


Why truncate the log at the 2nd step? You've just backed up the log which will discard all inactive transactions (after backing them up). The only thing that will achieve is to break the log chain.

Why do you want to shrink your database every 3 days. It results in sever index fragmentation and the DB is just going to grow again as soon as data is added. The repeated shrink/grow can result in fragmentation at a file-system level.

Have a quick read through these two blog posts please
http://sqlinthewild.co.za/index.php/2007/09/08/shrinking-databases/
http://sqlinthewild.co.za/index.php/2008/07/23/recovery-model-and-transaction-logs/



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #588298
Posted Monday, October 20, 2008 1:59 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
Another reasons to grow your Tlog is if your Mirroring is not working properly(i.e. latency is more) or if Mirroring is pending on destination DB it won't truncate the log.

Check and make sure Mirroring is workind smoothly.


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #588402
Posted Monday, October 20, 2008 4:49 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, September 6, 2011 7:51 AM
Points: 105, Visits: 581
No, you cannot shrink the tlog on a mirrored database without breaking the mirror first.

Given that your log is 50Gb vs data at 2Gb you're going to need to bite the bullet and turn off mirroring for a moment while you sort this out. Something is clearly amis here and you're going to need to get at things to figure out what which means turning off the mirror. The only job you should need to keep the tlog a sensible size is a regular tlog backup (via maint wizard if necessary). I'd also check this t-log backup actually working (ie you're getting a nice .trn file and it can be restored to a test system) and it is running regularly enough for the number of transactions that are being pumped through the database.
Post #588472
Posted Monday, October 20, 2008 2:52 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 23, 2009 8:19 AM
Points: 36, Visits: 75
Mirroring is working properly.
Post #588826
Posted Monday, October 20, 2008 2:54 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 23, 2009 8:19 AM
Points: 36, Visits: 75
FNS (10/20/2008)
No, you cannot shrink the tlog on a mirrored database without breaking the mirror first.

Given that your log is 50Gb vs data at 2Gb you're going to need to bite the bullet and turn off mirroring for a moment while you sort this out. Something is clearly amis here and you're going to need to get at things to figure out what which means turning off the mirror. The only job you should need to keep the tlog a sensible size is a regular tlog backup (via maint wizard if necessary). I'd also check this t-log backup actually working (ie you're getting a nice .trn file and it can be restored to a test system) and it is running regularly enough for the number of transactions that are being pumped through the database.




I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.
Post #588830
Posted Monday, October 20, 2008 3:31 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 42,485, Visits: 35,554
rishgup (10/20/2008)

I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.


You need to backup the log a lot more than once a week. Depending on activity, once or twice an hour.

How often are you backing up the log? Is you query the sys.databases view, what does the column log_reuse_wait_desc show for the DB in question?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #588841
Posted Monday, October 20, 2008 7:50 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 23, 2009 8:19 AM
Points: 36, Visits: 75
GilaMonster (10/20/2008)
rishgup (10/20/2008)

I have scedule transaction log back every weekend. nut still no use. Trans log file is growing day by day.


You need to backup the log a lot more than once a week. Depending on activity, once or twice an hour.

How often are you backing up the log? Is you query the sys.databases view, what does the column log_reuse_wait_desc show for the DB in question?


Now I setup Transaction log back up every 2 hours and the log_reuse_wait_desc for database is LOG_BACKUP
Post #588910
Posted Tuesday, October 21, 2008 12:38 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 42,485, Visits: 35,554
Then you should be set. That column value indicates that the log space is not been reused because a log backup is required. Once the log backup runs (check and make sure that they are actually running successfully), the space in the log should be reused.

You can shrink the file down to a reasonable size (say 1GB) and see how things go from there.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #588962
Posted Wednesday, October 22, 2008 11:28 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 23, 2009 8:19 AM
Points: 36, Visits: 75
GilaMonster (10/21/2008)
Then you should be set. That column value indicates that the log space is not been reused because a log backup is required. Once the log backup runs (check and make sure that they are actually running successfully), the space in the log should be reused.

You can shrink the file down to a reasonable size (say 1GB) and see how things go from there.

Thanks I'll update you guys
Post #589987
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse