SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Unable to shrink a 50GB log db file


Unable to shrink a 50GB log db file

Author
Message
pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
Hello there,
I'm trying to shrink a 50GB log db file down to GB using the following script.

USE [master]
GO
ALTER DATABASE [database] SET RECOVERY SIMPLE WITH NO_WAIT;
GO

USE [database]
GO
DBCC SHRINKFILE (N'database_name_log' , 0, TRUNCATEONLY)
GO


USE [master]
GO
ALTER DATABASE [database] MODIFY FILE ( NAME = N'database_name_log', SIZE = 204800KB ,
FILEGROWTH = 1048576KB )
GO

USE [master]
GO
ALTER DATABASE [database] SET RECOVERY FULL WITH NO_WAIT;
GO


but it wont do anything to the log file. I did check for open transactions using opentran and this is what I see:

Replicated Transaction Information:
Oldest distributed LSN : (0:0:0)
Oldest non-distributed LSN : (1686:11756:1)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

I've reading allover that the non-distributed LSN value means that there is some incomplete replication that's still pending but then there is no replication going on in the DB setup, what else could be preventing the shrink that I'm trying to get done? Please advise.

Thanks in Advance!!

Regards,
Madhu
pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
Forgot to mention that the size of MDF is just around 2GB and also this seems to be taking up a lot of space on the data drive.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)

Group: General Forum Members
Points: 222675 Visits: 46294
You have (or had) snapshot replication?
See this article, specifically the section on replication, and the blog post that it references
http://www.sqlservercentral.com/articles/Transaction+Log/72488/

p.s. The truncateonly option is not valid for log files. It's ignored. Don't shrink log files to 0. Shrink to a sensible size.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
I'm dont think there were any snapshot replications that were done on this db but I did run the following query:
SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases

and the log_reuse_wait_desc shows 'REPLICATION' against the db that is in concern. Not sure what else could be going on here
GilaMonster
GilaMonster
SSC Guru
SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)

Group: General Forum Members
Points: 222675 Visits: 46294
CDC perhaps? It uses the replication log reader hence shows as replication.

Please have a look at the article I referenced.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
CDC is not enabled on this db. Verified using the following query:
SELECT [name], database_id, is_cdc_enabled
FROM sys.databases
GilaMonster
GilaMonster
SSC Guru
SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)

Group: General Forum Members
Points: 222675 Visits: 46294
If you have a replication log wait then you have either CDC or replication somewhere, either running or improperly removed. Please see the article I referenced.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
Ok, based on the queries suggested in the article, I do not see any replication tasks or CDC going on in my DB. The article says that on a 2005 SQL there was a bug which caused the log wait to be set to replication status but I'm using SQL 2008R2 Express edition. Are there anyother queries that I can use to check on possible replication tasks or improper truncations?

Thanks!
GilaMonster
GilaMonster
SSC Guru
SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)SSC Guru (222K reputation)

Group: General Forum Members
Points: 222675 Visits: 46294
If you know there's no replication inentionally configured and running, then just take the steps listed to remove the replication effects.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


pmadhu
pmadhu
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 21
I was able to remove the replication using the SP sp_removedbreplication and it did drop down the size of the ldf file but I'm still curious to know what might have caused this lockup... is there a way to determine this before I use this same SP once again if I were to come across the same scenario?

Thanks once again for the assistance!!

Regards,
Madhu
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search