Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 44490 invoked from network); 9 Feb 2011 01:42:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2011 01:42:36 -0000 Received: (qmail 74897 invoked by uid 500); 9 Feb 2011 01:42:36 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 74857 invoked by uid 500); 9 Feb 2011 01:42:36 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 74850 invoked by uid 99); 9 Feb 2011 01:42:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 01:42:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 01:42:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 402EF2388900; Wed, 9 Feb 2011 01:42:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1068730 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Date: Wed, 09 Feb 2011 01:42:15 -0000 To: derby-commits@db.apache.org From: mikem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110209014215.402EF2388900@eris.apache.org> Author: mikem Date: Wed Feb 9 01:42:14 2011 New Revision: 1068730 URL: http://svn.apache.org/viewvc?rev=1068730&view=rev Log: DERBY-5002 In case of checksum error, insure correct error reported to user. backported change #1067357 from trunk to 10.5 branch, some manual merging required. Changed the order of sanity page checking to make sure that if there is a checksum error on reading the page from disk, then it is the error reported. Before this change certain page inconsistencies would be found before doing the checksum check and would report different kinds of errors depending on where the corruption happened on the page. The main error case checksums try to catch is partially written page where because a derby page is made up of multiple OS/drive blocks some blocks can make it to disk before others and in the case of a hardware crash an incomplete page may be written. In this case, the current derby implementation can not recover from log as it needs a valid page to look at in order to apply log records. The db must be recovered from derby backup in this case. Modified: db/derby/code/branches/10.5/ (props changed) db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Propchange: db/derby/code/branches/10.5/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Feb 9 01:42:14 2011 @@ -1,2 +1,2 @@ -/db/derby/code/branches/10.6:942027,957000,962738,965351,987678,997790*,1031623,1055601 +/db/derby/code/branches/10.6:942027,957000,962738,965351,987678,997790*,1031623,1055601,1068474 /db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,961892,962716,964402,965647,967304,980684,986689,986834,987539,98 9099,997325*,999119,1002291,1002682,1002853,1021426,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250 Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java?rev=1068730&r1=1068729&r2=1068730&view=diff ============================================================================== --- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java (original) +++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Wed Feb 9 01:42:14 2011 @@ -802,19 +802,6 @@ public class StoredPage extends CachedPa // if it is null, assume spareSpace and minimumRecordSize is the // same. We would only call initFromData after a restore then. - try - { - readPageHeader(); - initSlotTable(newIdentity); - } - catch (IOException ioe) - { - // i/o methods on the byte array have thrown an IOException - throw dataFactory.markCorrupt( - StandardException.newException( - SQLState.DATA_CORRUPT_PAGE, ioe, newIdentity)); - } - try { validateChecksum(newIdentity); @@ -878,8 +865,19 @@ public class StoredPage extends CachedPa } } - - } + try + { + readPageHeader(); + initSlotTable(newIdentity); + } + catch (IOException ioe) + { + // i/o methods on the byte array have thrown an IOException + throw dataFactory.markCorrupt( + StandardException.newException( + SQLState.DATA_CORRUPT_PAGE, ioe, newIdentity)); + } + } /** * Validate the check sum on the page. @@ -1118,6 +1116,21 @@ public class StoredPage extends CachedPa { try { + if (SanityManager.DEBUG) + { + if (getRecordOffset(slot) <= 0) + { + SanityManager.DEBUG_PRINT("DEBUG_TRACE", + "getTotalSpace failed with getRecordOffset(" + + slot + ") = " + + getRecordOffset(slot) + " must be greater than 0." + + "page dump = \n" + + toUncheckedString()); + SanityManager.THROWASSERT( + "bad record offset found in getTotalSpace()"); + } + } + // A slot entry looks like the following: // 1st field: offset of the record on the page // 2nd field: length of the record on the page @@ -2065,8 +2078,18 @@ public class StoredPage extends CachedPa { if (SanityManager.DEBUG) { - SanityManager.ASSERT(getRecordOffset(slot) != 0); - } + if (getRecordOffset(slot) <= 0) + { + SanityManager.DEBUG_PRINT("DEBUG_TRACE", + "getRecordPortionLength failed with getRecordOffset(" + + slot + ") = " + + getRecordOffset(slot) + " must be greater than 0." + + "page dump = \n" + + toUncheckedString()); + SanityManager.THROWASSERT( + "bad record offset found in getRecordPortionLength()"); + } + } // these reads are always against the page array ArrayInputStream lrdi = rawDataIn; @@ -2094,8 +2117,18 @@ public class StoredPage extends CachedPa { if (SanityManager.DEBUG) { - SanityManager.ASSERT(getRecordOffset(slot) != 0); - } + if (getRecordOffset(slot) <= 0) + { + SanityManager.DEBUG_PRINT("DEBUG_TRACE", + "getReservedCount failed with getRecordOffset(" + + slot + ") = " + + getRecordOffset(slot) + " must be greater than 0." + + "page dump = \n" + + toUncheckedString()); + SanityManager.THROWASSERT( + "bad record offset found in getReservedCount"); + } + } // these reads are always against the page array ArrayInputStream lrdi = rawDataIn; @@ -8000,6 +8033,25 @@ public class StoredPage extends CachedPa return null; } + public String toUncheckedString() + { + if (SanityManager.DEBUG) + { + String str = "---------------------------------------------------\n"; + str += pageHeaderToString(); + + //if (SanityManager.DEBUG_ON("dumpPageImage")) + { + str += "---------------------------------------------------\n"; + str += pagedataToHexDump(pageData); + str += "---------------------------------------------------\n"; + } + return str; + } + else + return null; + } + /** * Provide a hex dump of the data in the in memory version of the page. *