Sql-Server
過去兩個月的事務回滾掛起(MSSQL 2016)
我在上使用SQLCMD
2019-01-30
執行了一個查詢,該查詢導致ldf文件呈指數膨脹,它的大小變成了 2TB,然後我的 MSSQL 開始回滾事務2019-02-01
。我曾經KILL SPID WITH STATUSONLY
監控回滾過程:前兩週回滾進度每天大約 2%2019-02-14
,之後回滾過程從 22% 卡住,到今天仍然如此。如果我能就是否有任何方法可以解決此問題獲得專家意見,我將不勝感激 - 如何停止或加快回滾?
請在下面找到有關此問題的程式碼詳細資訊:
SQL
BEGIN TRAN DECLARE @m int SELECT @m = @@ERROR DECLARE @tbname_old varchar(50) = 'OTS_ARCHIVE' DECLARE @tbname_new varchar(50) = 'OTS_ARCHIVE2' DECLARE @column_old varchar(30) = 'GuID_ID' DECLARE @column_new varchar(30) = 'GuID_ID_old' DECLARE @sql varchar(50) = '[' + @tbname_new + '].[' + @column_old + ']' DECLARE @sqlid varchar(100) = 'CAST(CAST(NEWID() AS BINARY(10)) + CAST(GETDATE() AS BINARY(6)) AS UNIQUEIDENTIFIER)' DECLARE @date as datetime DECLARE @i int DECLARE @f int set @date = '2017-01-01' set @i = 0 set @f = 27 WHILE @i < @f BEGIN EXEC ('INSERT INTO ' + @tbname_new + ' select GuID_ID ,Box_ID ,Start_Time ,End_Time ,Duration_Time ,ots_count ,Group_ID ,' + @sqlid + ' from ' + @tbname_old ) END IF @m = 0 COMMIT TRAN ELSE ROLLBACK TRAN SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage
活動監視器
大約 60 天后,回滾過程終於完成。似乎唯一的方法和唯一的解決方案就是等待,等待,然後繼續等待。