Thursday, June 19, 2008

Which Sector is "torn" in Torn Page Error ?

Recently I'm doing the analysis of the "torn page" thing again. If the SQL server throws the torn page error, it doesn't show which sector the page is torn. Let's review again the definition of "torn page" from Kalen Delaney's "Inside Microsoft SQL Server 2000" : causes a bit to be flipped for each 512 byte sector in a database page (8 KB) whenever the page is written to disk..

In practice, there are two kinds of torn page error events. By this event, I am referring to the behaviour of MS SQL 2000.

First, torn page error during the database attachment process. Usually, this is caused by some corrupted data that occur in MS SQL server's important pages, such as PFS pages.

Second, torn page during accessing records, i.e. ours important pages :)

Since the data is of utmost important, the precise determination of which sector of size 512 bytes that gets torn apart is required.

To perform this kind of analysis, I am creating the testing database (named Test), create table and input some record using SQL Enterprise Manager. Next, I am determining the first page that contain my data :

use test
dbcc checkalloc

Table TestTbl Object ID 357576312.
Index ID 0. FirstIAM (1:91). Root (1:90). Dpages 1.
Index ID 0. 2 pages used in 0 dedicated extents.
Total number of extents is 0.

So, the first page of my data is located at page 90 which is at offset 90 * 8192 = 737280 = 0xB4000 in physical file.

Now, lets see the physical page created by MS SQL Server using hex editor :

Here, the offset 5 (marked with green box) in the page header is somehow related to the torn page checking. Turning the first nibble to zero (i.e. from 0x81 to 0x80) should bypass the torn page checking. But it is not, see the paragraph below for further information.

OK, let's go back to the original question. To determine which sector is get torn, we have to examine the calculation of m_tornbits flag in relation to the last offset at each 512 sector. Here is how it is done :

First byte of m_tornbits is masked with 0x03, so any byte will end up with either the value 0x00, 0x01, 0x02 or 0x03. For the above example, first byte is 0x01, with this operation, it will give 0x01. This value is used to compare with the last byte offset of second sector onward (or sector 1, if I count first sector as zero) (starting from offset 0x03FF onward).

The last byte of each sector is performed using the same operation as above and compared with the value from masked first byte of m_tornbits. If there are any differences, the torn page error will be thrown.

So, using the above operation, it is possible to determine which sector is not in synch with the rest of the sector or in other word, which sector is a torn page. But, it is inevitable with the assumption that, the first sector which contains the page header, hence the m_tornbits value, is a valid one.

However, it is not possible to temporarily turn off torn page checking by resetting the byte in offset 5 at page header. SQL server seems perform the consistency checking :

So, you should change the last offset of defected sector one by one in order to be accessed by MS SQL Server.

Happy torn page-ing :)


Anonymous said...

Get [url=]coumadin online[/url] here - Unprecedented Chance lotrisone online here - Colossal Price

Anonymous said...

HcDNWD tentex royal buy iKsgqY tizanidine visa/mastercard/amex/echeck FpQSUB tofranil sale cYUPjq topamax discount txtWdR toprol xl online EueYmM tramadol get azVkAw trandate rx

Anonymous said...




ringtone nasyid
swinger mobile rapidshare
safelink cell phone
dzwonek true tone depeche mode
new cell phone service
free ringtone downloads metropcs
compare cell phone plans
my t-mobile album cell phone
quagmire message tone
mantle cell lymphoma dr. schulze
free mobile cumshots
free emergency call anyone to mobile by pc in india
lg cell phone software
free wwe entrance ringtones
sfr jeux mobile
free cell phone gps tracking
t mobile caller itunes
ps2 cheet codes for splinter cell the game
tomtom mobile
froot loops free with subcription of ring tone
christ the lord is risen today ringtones
funny videos for your mobile phone
free virgin mobile samsung unlocking codes
free ringtones at no charge
ring lighting
how long does a belly button ring take to heal
apple mobile me met keygen via rapidshare file
3gp for mobile clips adult
signet ring significance
free blackberry 8900 ringtones
ring ceremony wedding vows
free mobile equalizer
free online mobile tracker
myxertones/caller tones
microsoft windows mobile 5.0 aku 2 bluetooth a2dp
virgin mobile uk tariffs
cell phone tracking
mothers ring free shipping next day
youporm mobile
sell my mobile phone uk
free kill bill ringtone download
how to call an australian mobile from the uk
join poly 3ds max
keeping the faith ringtone
jill foster willard schools cell phone
government funding stem cell research 2008
mts mobility ringtones
redfish wedding ring
lowest priced cell phone plans
clonedvd mobile v1.0.4.1 crack by tft-team.rar
free ringtones for metro pc
smallest cell phone
free ring tones for boostmobile
red cell increasing
neverwinter nights ring
slide rails for push outs in mobile homes
how do i recieve a free metropcs cell phone
mobile phone prices in india
indestructible cell phone
free golf swing downloads for my cell phone
international cell phone rental
mobile me email sign in
sample mobile porn videos
download mobile games sex
how to network unlock mobile phones
luxor 2 mobile java donwload
samsung mobile cost 2000-3000
mobile granny porn vids
mobile me email sign in
mobile price india
uses and abuses of cell phone
sidekick ringtones
mobile communications
35 version full secretary mobile
diamonds in my pinky ring lyric
t mobile beltgoed opwarderen
free ringtones for motorola tracfone
mobile porn free trailer
mobile beastialety video clips free
rash, dry skin in ring around stomach
satellite dish mobile
mobile phones coming soon
7ozo mobile
xmas classic peggy lee ring those christmas bella vujohof

Anonymous said...

kMIKr6fBYa Dog Clothes Casino BaOcAvZXN Casino Game Online tUa7r8OMX4 Casino Card Game e8fL0ZAYx Casino Hotel dmZ5usbTKq Slot Machine j1huK6N5w Casino 3 4L3MlupmoO Casino Share cfFEL7hBG Poker Tournaments

Anonymous said...

You are right.

Anonymous said...

I love! Here I always find a lot of helpful information for myself. Thanks you for your work.
Webmaster of and
Best regards

Anonymous said...

clomid and period cycle | to buy clomid - order clomid no prescription, when do u ovulate on clomid

Anonymous said...

progesterone and clomid trying to conceive | buying clomid - safe buy clomid online, how many cycles of clomid

Anonymous said...

clomid and multiple pregnancy | i want to buy clomid online - clomid cost, how to get clomid

Anonymous said...

clomid ovulation calculator | - ordering clomid online safe, clomid and triplets

Anonymous said...

on clomid when will i ovulate | [url=]buy clomid online[/url] - clomid 50, ttik clomid on cycle