Unable to shrink a 50GB log db file

  • 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

  • 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.

  • 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
  • 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

  • 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
  • CDC is not enabled on this db. Verified using the following query:

    SELECT [name], database_id, is_cdc_enabled

    FROM sys.databases

  • 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
  • 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!

  • 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
  • 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

  • USE [YourDatabase];

    SELECT name,

    recovery_model_desc,

    log_reuse_wait_desc,

    is_cdc_enabled

    FROM sys.databases

    WHERE name = DB_NAME();

    DBCC OPENTRAN;

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply