[
https://issues.apache.org/jira/browse/BOOKKEEPER-821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14238592#comment-14238592
]
Flavio Junqueira commented on BOOKKEEPER-821:
---------------------------------------------
I'm a bit confused about your point, @zhaijia. setLastLogId is outside that
loop and there could be a few reasons for IOException to be thrown, so I'm not
convinced your proposal is correct.
> 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_no-prefix.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)