Solved

The LSN (70:729:1) passed to log scan in database 'bpl' is invalid

Posted on 2002-07-17
8
1,440 Views
Last Modified: 2008-03-17
I have a .dbf file and a .ldf file and I am trying to restore the database in some other system.

I am using the follwing syntax to attach the database

EXEC sp_attach_db @dbname = N'<bpl>',
   @filename1 = N'd:\newdatafiles\bpl_2000_data.mdf',
   @filename2 = N'd:\newdatafiles\bpl_2000_log.ldf'

When I am doing so I am getting the following error
---
Server: Msg 9003, Level 20, State 1, Line 1
The LSN (70:729:1) passed to log scan in database 'bpl' is invalid.
Connection Broken
---

When I attach only the .dbf file. The database is created and the working fine. But I am getting error while attaching the .ldf file. What might be the problem.
0
Comment
Question by:Ambience
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7159060
I guess that either the database was not at all or not properly shut down when copying the files. Please enure that the source sql server was stopped when copying the files, or at least the database detached (sp_detach_db) from the server before starting the copy.
CHeers
0
 

Author Comment

by:Ambience
ID: 7159191
Angelllll
Ok fine. Thanks,
But can you tell me what is the possible reason for such kind of error.
regds
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 7159212
if the .mdf and .ldf there are differences in the internal numbering of transactions:
* the data.mdf is copied to bck.mdf
* a transaction occurs (written to the data.mdf and the data.ldf)
* the data.ldf is copied to bck.ldf

Then the bck.mdf does not know about this new transaction which is in bck.ldf, and rejects to take this log file.

CHeers
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:Ambience
ID: 7159467
Angelllll
Ok fine. Thanks,
But can you tell me what is the possible reason for such kind of error.
regds
0
 
LVL 4

Expert Comment

by:TheSpirit
ID: 7160880
A way that may avoid this is to issue a checkpoint command prior to taking the copy of the files
0
 
LVL 9

Expert Comment

by:miron
ID: 7161291
sql server communicates with the rest of world using protective cushion of transaction log,
each sql server operation results in a transaction record being generated and logged into
transaction log. Each transaction is assigned unique LSN, sort of an index into array.
At every check point all transactions passed "commit" are written into data file with the
last transaction LSN ( offset id ) that is "in flight" being marked as last known transaction
in data file, as well as in Transaction file. Apparently for some reason LSN
marked as last known in Transaction File and Data File got out of synch.

What might have caused it is hard to guess. To avoid this condition use 'backup database' command.
Backup, if created successfully is guaranteed against similar mishaps.

Cheers

P. S.
--The LSN (70:729:1)
in your case was assigned to transaction log file while its offset id was not registered in the data file.
looking at the next couple of words in the error message
--passed to log scan in database 'bpl'
I read that during attach( ment ) database is actually going through a hidden "restore"
operation in somewhat reduced form, and one of the phases of this restore is re-scan of
existing transaction log file.
--is invalid.
means that the data file has no indication of such transaction existence
( remember, its LSN is not within known LSN(s) to data file )

what caused it - sadden electric current shutdown or hard drive capacity bottleneck,
or developer copying live database files using low level file access routines, hard to say.
What is apparent is a few transactions were lost with corrupted log file.

0
 

Author Comment

by:Ambience
ID: 7161311
Miron,
Thanks for the detailed description. It made me realize what exactly happens. I have taken a backup after detaching the database and everything worked fine. But your explanation was real great.
Thanks Alot
0
 

Author Comment

by:Ambience
ID: 7161317
Miron,
Thanks for the detailed description. It made me realize what exactly happens. I have taken a backup after detaching the database and everything worked fine. But your explanation was real great.
Thanks Alot
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
The AZure backup problem 11 51
MS SQL Sever Import/export problem 7 44
Ideas on migrating very large  system from SQL 2005 to SQL 2014 3 28
Need SSIS project 2 23
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question