You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bookkeeper.apache.org by "zhaijia (JIRA)" <ji...@apache.org> on 2014/12/08 07:20:12 UTC

[jira] [Commented] (BOOKKEEPER-821) Failing to write lastId to ledger directories should not fail startup of bookies

    [ https://issues.apache.org/jira/browse/BOOKKEEPER-821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14237491#comment-14237491 ] 

zhaijia commented on BOOKKEEPER-821:
------------------------------------

there is already a test case: testMissingLogId

> Failing to write lastId to ledger directories should not fail startup of bookies
> --------------------------------------------------------------------------------
>
>                 Key: BOOKKEEPER-821
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-821
>             Project: Bookkeeper
>          Issue Type: Bug
>          Components: bookkeeper-server
>    Affects Versions: 4.3.0
>            Reporter: zhaijia
>            Assignee: zhaijia
>             Fix For: 4.3.1
>
>         Attachments: BOOKKEEPER-821.patch
>
>   Original Estimate: 5h
>  Remaining Estimate: 5h
>
> In EntryLoggerAllocator::allocateNewLog(), setLastLogId() failed, should not fail startup of bookies. 
> Failed setLastLogId could be tolerated because the while loop handles it.
> {code}
>         /**
>          * Allocate a new log file.
>          */
>         BufferedLogChannel allocateNewLog() throws IOException {
>             List<File> list = ledgerDirsManager.getWritableLedgerDirs();
>             Collections.shuffle(list);
>             // It would better not to overwrite existing entry log files
>             File newLogFile = null;
>             do {
>                 String logFileName = Long.toHexString(++preallocatedLogId) + ".log";
>                 for (File dir : list) {
>                     newLogFile = new File(dir, logFileName);
>                     currentDir = dir;
>                     if (newLogFile.exists()) {     < === this will handle last set fail issue, only caused one more loop.
>                         LOG.warn("Found existed entry log " + newLogFile
>                                + " when trying to create it as a new log.");
>                         newLogFile = null;
>                         break;
>                     }
>                 }
>             } while (newLogFile == null);
>             FileChannel channel = new RandomAccessFile(newLogFile, "rw").getChannel();
>             BufferedLogChannel logChannel = new BufferedLogChannel(channel,
>                     conf.getWriteBufferBytes(), conf.getReadBufferBytes(), preallocatedLogId);
>             logChannel.write((ByteBuffer) LOGFILE_HEADER.clear());
>             for (File f : list) {
>                 setLastLogId(f, preallocatedLogId);
>             }
>             LOG.info("Preallocated entry logger {}.", preallocatedLogId);
>             return logChannel;
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)