You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by mi...@apache.org on 2010/06/30 19:08:39 UTC
svn commit: r959378 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/store/raw/data/ engine/org/apache/derby/loc/
shared/org/apache/derby/shared/common/reference/
testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: mikem
Date: Wed Jun 30 17:08:38 2010
New Revision: 959378
URL: http://svn.apache.org/viewvc?rev=959378&view=rev
Log:
DERBY-3727 Improve error information reported when encountering "ERROR XSDB3: Container information cannot change once written: was 103, now 80"
Added error reporting of the container id when an error is encountered while
writing the container header information.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java
db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java?rev=959378&r1=959377&r2=959378&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java Wed Jun 30 17:08:38 2010
@@ -841,15 +841,25 @@ abstract class FileContainer
@exception StandardException Derby Standard error policy
@exception IOException error in writing the header to file
*/
- protected void writeHeader(byte[] pageData)
+ protected void writeHeader(
+ Object identity,
+ byte[] pageData)
throws StandardException, IOException
{
// write out the current containerInfo in the borrowed space to byte
// array containerInfo
writeHeaderToArray(containerInfo);
+ try
+ {
AllocPage.WriteContainerInfo(containerInfo, pageData, false);
}
+ catch (StandardException se)
+ {
+ throw StandardException.newException(
+ SQLState.DATA_BAD_CONTAINERINFO_WRITE, se, identity);
+ }
+ }
/**
Write the container header directly to file.
@@ -862,8 +872,11 @@ abstract class FileContainer
@exception StandardException Derby Standard error policy
@exception IOException error in writing the header to file
*/
- protected void writeHeader(StorageRandomAccessFile file,
- boolean create, byte[] epage)
+ protected void writeHeader(
+ Object identity,
+ StorageRandomAccessFile file,
+ boolean create,
+ byte[] epage)
throws IOException, StandardException
{
// write out the current containerInfo in the borrowed space to byte
@@ -873,8 +886,16 @@ abstract class FileContainer
// RESOLVE: get no wait on the page cache to see if allocation page is
// there, if so, use that instead of making a new array and a static
// function.
+ try
+ {
+ AllocPage.WriteContainerInfo(containerInfo, epage, create);
+ }
+ catch (StandardException se)
+ {
+ throw StandardException.newException(
+ SQLState.DATA_BAD_CONTAINERINFO_WRITE, se, identity);
+ }
- AllocPage.WriteContainerInfo(containerInfo, epage, create);
// now epage has the containerInfo written inside it
// force WAL - and check to see if database is corrupt or is frozen.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java?rev=959378&r1=959377&r2=959378&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java Wed Jun 30 17:08:38 2010
@@ -386,7 +386,7 @@ class RAFContainer extends FileContainer
// write header into the alloc page array regardless of dirty
// bit because the alloc page have zero'ed out the borrowed
// space
- writeHeader(pageData);
+ writeHeader(getIdentity(), pageData);
if (SanityManager.DEBUG)
{
@@ -531,7 +531,9 @@ class RAFContainer extends FileContainer
// Instead, just clobber the container info, which is
// checksum'ed seperately from the alloc page
//
- writeRAFHeader(fileData,
+ writeRAFHeader(
+ getIdentity(),
+ fileData,
false, // don't create, container exists
true); // syncfile
@@ -667,7 +669,10 @@ class RAFContainer extends FileContainer
if false, the container already exist
@param syncFile if true, sync the file
*/
- private void writeRAFHeader(StorageRandomAccessFile file, boolean create,
+ private void writeRAFHeader(
+ Object identity,
+ StorageRandomAccessFile file,
+ boolean create,
boolean syncFile)
throws IOException, StandardException
{
@@ -695,7 +700,7 @@ class RAFContainer extends FileContainer
// need to check for frozen state
- writeHeader(file, create, epage);
+ writeHeader(identity, file, create, epage);
if (syncFile)
{
@@ -1091,9 +1096,12 @@ class RAFContainer extends FileContainer
// with container header and encrypt it if the database
// is encrypted.
- byte[] dataToWrite = updatePageArray(pageNumber,
+ byte[] dataToWrite =
+ updatePageArray(
+ pageNumber,
page.getPageArray(),
- encryptionBuf, false);
+ encryptionBuf,
+ false);
backupRaf.write(dataToWrite, 0, pageSize);
// unlatch releases page from cache, see
@@ -1316,26 +1324,30 @@ class RAFContainer extends FileContainer
}
// This container format specifies that the first page is an
- // allocation page and the container information is stored within
- // it. The allocation page needs to be somewhat formatted
- // because if the system crashed after the create container log
- // operation is written, it needs to be well formed enough to get
- // the container information back out of it.
+ // allocation page and the container information is stored
+ // within it. The allocation page needs to be somewhat
+ // formatted because if the system crashed after the create
+ // container log operation is written, it needs to be well
+ // formed enough to get the container information back out of
+ // it.
//
- // Don't try to go thru the page cache here because the container
- // object cannot be found in the container cache at this point
- // yet. However, if we use the page cache to store the first
- // allocation page, then in order to write itself out, it needs to
- // ask the container to do so, which is going to create a
- // deadlock. The allocation page cannot write itself out without
- // going thru the container because it doesn't know where its
- // offset is. Here we effectively hardwired page 0 at offset 0 of
- // the container file to be the first allocation page.
-
- // create an embryonic page - if this is not a temporary container,
- // synchronously write out the file header.
- writeRAFHeader(fileData, true,
- (actionIdentity.getSegmentId() != ContainerHandle.TEMPORARY_SEGMENT));
+ // Don't try to go thru the page cache here because the
+ // container object cannot be found in the container cache at
+ // this point yet. However, if we use the page cache to store
+ // the first allocation page, then in order to write itself
+ // out, it needs to ask the container to do so, which is going
+ // to create a deadlock. The allocation page cannot write
+ // itself out without going thru the container because it
+ // doesn't know where its offset is. Here we effectively
+ // hardwire page 0 at offset 0 of the container file to be
+ // the first allocation page.
+
+ // create an embryonic page - if this is not a temporary
+ // container, synchronously write out the file header.
+ writeRAFHeader(
+ actionIdentity, fileData, true,
+ (actionIdentity.getSegmentId() !=
+ ContainerHandle.TEMPORARY_SEGMENT));
} catch (SecurityException se) {
@@ -1495,7 +1507,9 @@ class RAFContainer extends FileContainer
// write the header to the stub
stubData = stub.getRandomAccessFile( "rw");
- writeRAFHeader(stubData,
+ writeRAFHeader(
+ actionIdentity,
+ stubData,
true, /* create */
true); /* sync */
Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=959378&r1=959377&r2=959378&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Wed Jun 30 17:08:38 2010
@@ -5603,6 +5603,12 @@ ln=lower-case two-letter ISO-639 languag
<arg>value</arg>
</msg>
+ <msg>
+ <name>XSDBC.D</name>
+ <text>Write of container information to page 0 of container {0} failed. See nested error for more information. </text>
+ <arg>container</arg>
+ </msg>
+
</family>
Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=959378&r1=959377&r2=959378&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Wed Jun 30 17:08:38 2010
@@ -499,6 +499,7 @@ public interface SQLState {
String DATA_CORRUPT_STREAM_CONTAINER = "XSDB9.D";
String DATA_OBJECT_ALLOCATION_FAILED = "XSDBA.D";
String DATA_UNKNOWN_PAGE_FORMAT_2 = "XSDBB.D";
+ String DATA_BAD_CONTAINERINFO_WRITE = "XSDBC.D";
/*
** RawStore - Data.Filesystem statement exceptions
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java?rev=959378&r1=959377&r2=959378&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java Wed Jun 30 17:08:38 2010
@@ -202,6 +202,7 @@ public final class ErrorCodeTest extends
{"XSDB9","Stream container {0} is corrupt.","45000"},
{"XSDBA","Attempt to allocate object {0} failed.","45000"},
{"XSDBB", "Unknown page format at page {0}, page dump follows: {1} ", "45000"},
+ {"XSDBC", "Write of container information to page 0 of container {0} failed. See nested error for more information. ", "45000"},
{"XSDG0","Page {0} could not be read from disk.","45000"},
{"XSDG1","Page {0} could not be written to disk, please check if the disk is full, or if a file system limit, such as a quota or a maximum file size, has been reached.","45000"},
{"XSDG2","Invalid checksum on Page {0}, expected={1}, on-disk version={2}, page dump follows: {3}","45000"},