none
How to create a torn page. RRS feed

  • Question

  • I want to write a magazine article about torn pages. Is there an easy way to create a torn page? Or does anybody have a backup of a sample database such as AdventureWorks that has a torn page?
    Friday, December 30, 2005 3:19 PM

Answers

  • To simulate a torn page, you'll have to "corrupt" a database page on disk.

    This can be done with a hex editor, or other tool.

    Our pages are 8K in size, so 16 sectors of 512bytes.

    We have 2 kinds of validation: checksum or torn page. 

    For the torn page, you'll want to corrupt bytes at 0 mod 512 in sectors 1..15 of a page.  You could write 0x00 at offset 512, and 0xFF at offset 1024, for example.

    Checksums are more robust, so you should be able to change any bit on the page to cause the corruption to be detected.

    In order for this corruption to cause any problem, you'd have to pick a page that actually holds data, and then cause the engine to try to read that page.

    Hope that gives you some ideas.

    Wednesday, January 4, 2006 1:40 AM

All replies

  • I suppose you have to simulate a disk failure at the right moment.  I don't think it is very easy to simulate tbh.

    But do keep us informed if you find a way to do so.

    Friday, December 30, 2005 5:56 PM
  • To simulate a torn page, you'll have to "corrupt" a database page on disk.

    This can be done with a hex editor, or other tool.

    Our pages are 8K in size, so 16 sectors of 512bytes.

    We have 2 kinds of validation: checksum or torn page. 

    For the torn page, you'll want to corrupt bytes at 0 mod 512 in sectors 1..15 of a page.  You could write 0x00 at offset 512, and 0xFF at offset 1024, for example.

    Checksums are more robust, so you should be able to change any bit on the page to cause the corruption to be detected.

    In order for this corruption to cause any problem, you'd have to pick a page that actually holds data, and then cause the engine to try to read that page.

    Hope that gives you some ideas.

    Wednesday, January 4, 2006 1:40 AM
  • Aah, think out of the box :-)

    Great tip.

    Wednesday, January 4, 2006 6:48 PM