Author: kmarsden Date: Tue Mar 3 19:57:18 2009 New Revision: 749718 URL: http://svn.apache.org/viewvc?rev=749718&view=rev Log: DERBY-4072 improve message if log files cannot be accessed. Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/MessageId.java db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/MessageId.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/MessageId.java?rev=749718&r1=749717&r2=749718&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/MessageId.java (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/MessageId.java Tue Mar 3 19:57:18 2009 @@ -62,6 +62,8 @@ // derby.system.durability set to test String LOG_DURABILITY_TESTMODE_NO_SYNC_ERR = "L021"; // hint that error could be because // derby.system.durability was set to test + String LOG_CHANGED_DB_TO_READ_ONLY = "L022"; // a permissions error on log caused us + // to change db to read only. /* * Raw Store data Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java?rev=749718&r1=749717&r2=749718&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java Tue Mar 3 19:57:18 2009 @@ -680,6 +680,13 @@ getStream().println(MessageService.getTextMessage(messageID, a1, a2, a3, a4)); } + /** + * Logs the stack trace of the specified throwable object. + */ + public static void logThrowable(Throwable t) { + t.printStackTrace(getStream().getPrintWriter()); + } + /** * Translate a localeDescription of the form ll[_CC[_variant]] to * a Locale object. Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=749718&r1=749717&r2=749718&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Tue Mar 3 19:57:18 2009 @@ -851,7 +851,7 @@ logFile = getLogFileName(++logFileNumber); } } - + IOException accessException = null; try { theLog = privRandomAccessFile(logFile, "rw"); @@ -859,6 +859,7 @@ catch (IOException ioe) { theLog = null; + accessException = ioe; } if (theLog == null || !privCanWrite(logFile)) @@ -867,7 +868,9 @@ theLog.close(); theLog = null; - + Monitor.logTextMessage(MessageId.LOG_CHANGED_DB_TO_READ_ONLY); + if (accessException != null) + Monitor.logThrowable(accessException); ReadOnlyDB = true; } else @@ -937,6 +940,7 @@ { // if datafactory doesn't think it is readonly, we can // do some futher test of our own + IOException accessException = null; try { if(isWriteSynced) @@ -947,14 +951,18 @@ catch (IOException ioe) { theLog = null; + accessException = ioe; } if (theLog == null || !privCanWrite(logFile)) { if (theLog != null) theLog.close(); theLog = null; - + Monitor.logTextMessage(MessageId.LOG_CHANGED_DB_TO_READ_ONLY); + if (accessException != null) + Monitor.logThrowable(accessException); ReadOnlyDB = true; + } } @@ -3070,6 +3078,8 @@ } else { + Monitor.logTextMessage(MessageId.LOG_CHANGED_DB_TO_READ_ONLY); + Monitor.logThrowable(new Exception("Error writing control file")); // read only database ReadOnlyDB = true; logOut = null; Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties?rev=749718&r1=749717&r2=749718&view=diff ============================================================================== --- db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties (original) +++ db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties Tue Mar 3 19:57:18 2009 @@ -1170,7 +1170,7 @@ L018=System may be in a inconsistent state, missing file {0} L020=WARNING: The database was at least at one time booted with {0}={1}. As a result of this mode being used, it is possible that the database may not be able to recover, committed transactions may be lost, and the database may be in an inconsistent state. This may cause unexpected errors.\n L021=WARNING: The database was either previously booted or is currently booted with {0} set to {1}. Note that this mode {0}={1} does not guarantee recoverability, and is probably what might have caused this boot error.\n - +L022=WARNING: Due to a permissions issue accessing the log files, the status of the database has been changed to read only. # Class Manager C000=Wrote class {0} to file {1}. Please provide support with the file and the following exception information: {2}