一个filegroup backup+log backup的bug

USE master;
GO
drop database Sales
go
CREATE DATABASE Sales
ON PRIMARY
( NAME = SPri1_dat,
    FILENAME = 'D:\SalesData\SPri1dat.mdf',
    SIZE = 10,
    MAXSIZE = 50,
    FILEGROWTH = 15% ),
FILEGROUP SalesGroup1
( NAME = SGrp1Fi1_dat,
    FILENAME = 'D:\SalesData\SG1Fi1dt.ndf',
    SIZE = 10,
    MAXSIZE = 50,
    FILEGROWTH = 5 )
LOG ON
( NAME = Sales_log,
    FILENAME = 'D:\SalesLog\salelog.ldf',
    SIZE = 5MB,
    MAXSIZE = 25MB,
    FILEGROWTH = 5MB ) ;
GO
USE Sales
GO
CREATE TABLE TA(A INT ,B INT ,C INTON  SalesGroup1
go
use master
go
backup database sales 
to disk='sales.bck' with init
go
BACKUP DATABASE Sales
   FILEGROUP = 'SalesGroup1'
   TO DISK = 'SalesGroup1.bck' with init
   go
go

insert sales..ta default values

go
BACKUP log Sales
   TO DISK = 'Sales_log.bck' with init
go
 
restore database sales from disk='SalesGroup1.bck' with recovery
go
restore log sales from disk='Sales_log.bck' with recovery
go
select *From sales..TA

 

 

以上这段代码可以正常执行

如果将insert sales..ta default values这句话的注释掉,会返回这个错误

 Msg 8653, Level 16, State 1, Line 1

The query processor is unable to produce a plan for the table or view 'TA' because the table resides in a filegroup which is not online.

如果我们单独执行restore database和restore log语句。会发现两条警告信息

 

The roll forward start point is now at log sequence number (LSN) 25000000019700001. Additional roll forward past LSN 25000000020400001 is required to complete the restore sequence.

RESTORE DATABASE ... FILE=<name> successfully processed 8 pages in 0.036 seconds (1.736 MB/sec).

Processed 0 pages for database 'sales', file 'SGrp1Fi1_dat' on file 1.

The roll forward start point is now at log sequence number (LSN) 25000000019900001. Additional roll forward past LSN 25000000020400001 is required to complete the restore sequence.

RESTORE LOG successfully processed 0 pages in 0.003 seconds (0.000 MB/sec).

 

restore database时显示仍然需要roll forward到25000000020400001 ,但是log备份中的日志并没有达到/超过预期的lsn,而是在25000000019900001就结束了。

我们通过restore head对比

 

restore headeronly  from disk='SalesGroup1.bck'
go
restore headeronly from disk='Sales_log.bck' 

 

 

 

 Log包含的最大的lsn没有办法满足之前restore database所需要的lsn...

 

此问题可以在SQL SERVER 2008 R2 RTM中重现

 

posted on 2011-10-06 09:29  stswordman  阅读(635)  评论(0编辑  收藏  举报