Server 2008R2的数据库在凌晨5点多抛出下面告警信息:

Space,占用400GB的Disk Space实在浪费Disk Resource,于是使用DBCC
Shrink收缩Log File:


dbcc shrinkfile(testdb_log_5,10240,notruncate)
dbcc shrinkfile(testdb_log_5,10240,truncateonly)

 The log scan
number (620023:3702:1) passed to log scan in database ‘xxxx’ is not
valid. This error may indicate data corruption or that the log file
(.ldf) does not match the data file (.mdf). If this error occurred
during replication, re-create the publication. Otherwise, restore from
backup if the problem results in a failure during startup.





由于test db的还原模式是Simple,并且没有active

乍一看,还以为数据库损坏了(data corruption),但是在做完DBCC
process could not execute

select count(0)
from sys.fn_dblog(null,null) f
where f.Description ='REPLICATE'


在Publisher database中,使用 sp_repltrans

Common Causes


  • The last LSN in Transaction Log is less than what the LSN Log Reader
    is trying to find. An old backup may have been restored on top of
    Published Database. After the restore, the new Transaction Log
    doesn’t contain the data now distributor & subscriber(s) have.

  • Database corruption.


sp_repltrans returns a result set of all
the transactions in the publication database transaction log that are
marked for replication but have not been marked as distributed.

How to fix this


  • Ensure database consistency by running DBCC CHECKDB on the

  • If an old backup was restored on top of published database then
    use sp_replrestart

  • If going back to the most recent transaction log backup is not an
    option then execute sp_replrestart澳门新萄京 ,  on
    publisher in published database. This stored procedure is used when
    the highest log sequence number (LSN) value at the Distributor does
    match the highest LSN value at the Publisher.

  • This stored procedure will insert compensating LSNs (No Operation)
    in the publisher database log file till one the compensating LSN
    becomes more than the highest distributed LSN in distribution
    database for this published database. After this it inserts this new
    high LSN in the msrepl_transactions table in the distribution
    database and executes sp_repldone on published database to update
    the internal structures to mark a new starting point for log reader

  • Ensure that the log reader agent is stopped and there is no incoming
    transactions on the published database, when this SP is executed.

  • Since transactions may have been lost, we recommend to reinitialize
    the subscriber(s) and/or recreate publication/subscription(s).  For
    large databases consider using “Initialize from Backup” as discussed
    in SQL Book Online.


数据库既没有损坏,也没有还原过。 只能是Replication出现了错误,但是在SQL







exec sys.sp_repltrans

Unable to execute
procedure. The database is not published. Execute the procedure in a
database that is published for replication.

database,必须设置 database 为publish,表示 Database can be used for
other types of publications.


电子邮件地址不会被公开。 必填项已用*标注