The log scan number (620043:3702:1) passed to log scan in da

2019-10-04 19:32栏目:网站首页

明天一台SQL Server 二〇一〇奥迪Q52的数据库在晚上5点多抛出上面告警信息:

应用Backup创建测量试验境况之后,开采testdb的Log File过大,达到400GB,由于测验境况实际上无需如此大的Log 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.

命名推行到位未来,开掘还应该有300多GB,实际Log File占用的长空的比重充足低,0.000428%




出于test db的重振旗鼓形式是Simple,况且未有active user,最大的恐怕是db的Trasaction log被标志为Replication,使用以下函数计算,开掘有大气的log未被LogReader读取。

   乍一看,还认为数据库损坏了(data corruption),不过在做完DBCC CHECKDB后,发现实际数据库其实是突出的。那么势必是跟Replication有关。不过在研究了连带质感,仅仅在The process could not execute ‘sp_repldone/sp_replcounters” 那篇博客中找到了近似错误的资料:

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


在Publisher database中,使用 sp_repltrans 查看未有被Log里德r标志为Distributed的Transaction。

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

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

  • 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 Server的Replication中又从未找到有关错误音讯,本人这一个是AWS的DMS自动生成的Replication,比非常多中间消息不太精晓(例如,是还是不是出现至极),官方也平昔不找到很详细的介绍那一个颠倒是非的有关材质。在此记录一下。







exec sys.sp_repltrans

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

鉴于testdb是使用backup还原的测量检验数据库,没有在master中注册为Publisher database,必需设置 database 为publish,表示 Database can be used for other types of publications.

exec sys.sp_replicationdboption
        @dbname = N'testdb', 
        @optname = N'publish', 
        @value = N'true' 

挂号成功今后,使用 sp_repldone,将持有的Transaction Log 标志为Distributed。

sp_repldone updates the record that identifies the last distributed transaction of the server.

EXEC sys.sp_repldone 
        @xactid = NULL, 
        @xact_segno = NULL, 
        @numtrans = 0,     
        @time = 0, 
        @reset = 1  

When xactid is NULL, xact_seqno is NULL, and reset is 1, all replicated transactions in the log are marked as distributed. This is useful when there are replicated transactions in the transaction log that are no longer valid and you want to truncate the log,

最终,使用DBCC ShrinkFile命令,Transaction Log File减少完结。



sp_repltrans (Transact-SQL).aspx)

sp_replicationdboption (Transact-SQL).aspx)

sp_repldone (Transact-SQL).aspx)

版权声明:本文由威尼斯人app发布于网站首页,转载请注明出处:The log scan number (620043:3702:1) passed to log scan in da