[
https://issues.apache.org/jira/browse/DERBY-5195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-5195:
---------------------------------
Attachment: LogFileReader.java
Attaching LogFileReader.java, a program for pretty-printing the contents of
Derby log files.
I have successfully run this tool against log files created by 10.1, 10.2,
10.3, 10.4, 10.5, 10.6, 10.7, 10.8, and trunk codelines.
Here is the usage summary:
java LogFileReader
Usage:
java LogFileReader $logFileName [ -v ] [ -p $P ] [ -n $N ]
-v Verbose. Deserialize the logged operations. If you do not set this
flag, the tool just decodes the wrapper headers.
-p Starting position. $P is a positive number, the offset of the first
log entry to read. This causes the tool to skip reading the file header as well.
-n Number of records to read. $N is a non-negative number. If you do not
specify this flag, the tool prints all subsequent log entries.
Here are some examples.
------------------------------------------------------------
1) Decode an entire log file, putting the resulting xml in the file z.xml. You
can then view that file using a browser like Firefox, which lets you collapse
and expand the elements. Because the -v switch is specified, the contents of
the logged operations are deserialized and <details> elements are populated
with the toString() results:
runjava LogFileReader db/log/log2.dat -v > z.xml
------------------------------------------------------------
2) Pretty-print a log file header:
java LogFileReader db/log/log2.dat -n 0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<logFile>
<formatableID>128</formatableID>
<obsoleteVersion>9</obsoleteVersion>
<logFileNumber>2</logFileNumber>
<previousLogRecordEndInstant>
<logFileNumber>1</logFileNumber>
<position>11510</position>
</previousLogRecordEndInstant>
<logRecords>
</logRecords>
<recordCount>0</recordCount>
</logFile>
------------------------------------------------------------
3) Count the number of entries in a log file:
java LogFileReader db/log/log2.dat | grep recordCount
<recordCount>156</recordCount>
------------------------------------------------------------
4) Decode 3 log entries, starting at a given record offset:
java LogFileReader db/log/log2.dat -v -p 29363 -n 3
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<logFile>
<logRecords>
<wrapper>
<forwardLength>1818</forwardLength>
<logInstant>
<logFileNumber>2</logFileNumber>
<position>29363</position>
</logInstant>
<logRecord>
<formatableID>129</formatableID>
<groups hexvalue="180">
<flag>XA_NEEDLOCK</flag>
<flag>RAWSTORE</flag>
</groups>
<transactionID value="192"/>
<operation
type="org.apache.derby.impl.store.raw.data.PurgeOperation">
<details>Page Operation: Page(2,Container(0, 81))
pageVersion 75 : Purge : 36 slots starting at 37 (recordId=43) (recordId=44)
(recordId=45) (recordId=46) (recordId=47) (recordId=48) (recordId=49)
(recordId=50) (recordId=51) (recordId=52) (recordId=53) (recordId=54)
(recordId=55) (recordId=56) (recordId=57) (recordId=58) (recordId=59)
(recordId=60) (recordId=61) (recordId=62) (recordId=63) (recordId=64)
(recordId=65) (recordId=66) (recordId=67) (recordId=68) (recordId=69)
(recordId=70) (recordId=71) (recordId=72) (recordId=73) (recordId=74)
(recordId=75) (recordId=76) (recordId=77) (recordId=78)</details>
</operation>
</logRecord>
<backwardLength>1818</backwardLength>
</wrapper>
<wrapper>
<forwardLength>90</forwardLength>
<logInstant>
<logFileNumber>2</logFileNumber>
<position>31197</position>
</logInstant>
<logRecord>
<formatableID>129</formatableID>
<groups hexvalue="180">
<flag>XA_NEEDLOCK</flag>
<flag>RAWSTORE</flag>
</groups>
<transactionID value="192"/>
<operation
type="org.apache.derby.impl.store.raw.data.InsertOperation">
<details>Page Operation: Page(1,Container(0, 81))
pageVersion 147 : Insert : Slot=1 recordId=79</details>
</operation>
</logRecord>
<backwardLength>90</backwardLength>
</wrapper>
<wrapper>
<forwardLength>17</forwardLength>
<logInstant>
<logFileNumber>2</logFileNumber>
<position>31303</position>
</logInstant>
<logRecord>
<formatableID>129</formatableID>
<groups hexvalue="112">
<flag>LAST</flag>
<flag>COMMIT</flag>
<flag>RAWSTORE</flag>
</groups>
<transactionID value="192"/>
<operation type="org.apache.derby.impl.store.raw.xact.EndXact">
<details>EndXact null Committed : transactionStatus =
Committed</details>
</operation>
</logRecord>
<backwardLength>17</backwardLength>
</wrapper>
</logRecords>
<recordCount>3</recordCount>
</logFile>
------------------------------------------------------------
> Create tools for browsing the files in the database log directory.
> ------------------------------------------------------------------
>
> Key: DERBY-5195
> URL: https://issues.apache.org/jira/browse/DERBY-5195
> Project: Derby
> Issue Type: Task
> Affects Versions: 10.9.0.0
> Reporter: Rick Hillegas
> Attachments: ControlFileReader.java, ControlFileReader.java,
> LogFileReader.java
>
>
> It would be nice to have some tools to examine the contents of the log
> directory. The tools should be able to read the files in that directory
> without disturbing them.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira