[
https://issues.apache.org/jira/browse/BOOKKEEPER-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13209560#comment-13209560
]
Ivan Kelly commented on BOOKKEEPER-169:
---------------------------------------
{code}
+ // repair partial index
+ if (null != fc && fc.size() < 1024) {
+ if (success) {
+ writeHeader();
+ } else if (null != masterKey) {
+ writeHeader();
+ } else {
+ if (null != error) {
+ throw new IOException("Reading header error: ", error);
+ } else {
+ throw new IOException("Reading header error.");
+ }
+ }
+ }
{code}
If success, then there's no need to rewrite the header, the first write will
skip past first 1024 bytes anyhow. Instead of the success flag, I'd just do the
following.
{code}
try {
readHeader();
} catch (BufferUnderflowException buf) {
LOG.warn("Exception when reading header of {} : {}", lf, buf);
if (null != masterKey) {
LOG.warn("Attempting to write header again");
writeHeader();
} else {
throw new IOException("Error reading header " + lf);
}
}
{code}
If the header was incomplete, readHeader should have thrown
BufferUnderflowException, otherwise everything is normal.
Also, where 1024 is used as a literal, you should use START_OF_DATA.
I think we should move all the test Journal write methods to the same class to
keep them all together.
> bookie hangs on reading header when encountering partial header index file
> --------------------------------------------------------------------------
>
> Key: BOOKKEEPER-169
> URL: https://issues.apache.org/jira/browse/BOOKKEEPER-169
> Project: Bookkeeper
> Issue Type: Bug
> Components: bookkeeper-server
> Affects Versions: 4.0.0
> Reporter: Sijie Guo
> Assignee: Sijie Guo
> Fix For: 4.1.0
>
> Attachments: BK-169.diff
>
>
> bookie server hangs on reading header part when reading partial header index
> file (whose header part is less than 1k). This kind of index file existed
> because bookie server shuts down when writing header of index file.
> bookie server should check file size when reading header. in pre-v3 journal,
> we don't have master key stored in journal, so if master key is missing, we
> have no chance to repair it just throw an IOException when reading header. in
> post-v3 journal, we store master key as an meta entry in journal, so we can
> rewrite the header part.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira