horizonzy commented on code in PR #4038:
URL: https://github.com/apache/bookkeeper/pull/4038#discussion_r1484912473
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java:
##########
@@ -127,10 +136,16 @@ BufferedLogChannel createNewLog(File dirForNextEntryLog)
throws IOException {
BufferedLogChannel createNewLogForCompaction(File dirForNextEntryLog)
throws IOException {
synchronized (createCompactionLogLock) {
- return allocateNewLog(dirForNextEntryLog, COMPACTING_SUFFIX);
+ BufferedLogChannel bc = allocateNewLog(dirForNextEntryLog,
COMPACTING_SUFFIX);
+ writingCompactingLogId = bc.getLogId();
+ return bc;
}
}
+ void clearCompactingLogId() {
+ writingCompactingLogId = -1;
Review Comment:
> Just wondering if there's a chance that writingLogId and
writingCompactingLogId field changes wouldn't be visible for another thread
that reads these fields.
Make sense, make it volatile.
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java:
##########
@@ -127,10 +136,16 @@ BufferedLogChannel createNewLog(File dirForNextEntryLog)
throws IOException {
BufferedLogChannel createNewLogForCompaction(File dirForNextEntryLog)
throws IOException {
synchronized (createCompactionLogLock) {
- return allocateNewLog(dirForNextEntryLog, COMPACTING_SUFFIX);
+ BufferedLogChannel bc = allocateNewLog(dirForNextEntryLog,
COMPACTING_SUFFIX);
+ writingCompactingLogId = bc.getLogId();
+ return bc;
}
}
+ void clearCompactingLogId() {
+ writingCompactingLogId = -1;
Review Comment:
> > No need this, the `createNewLogForCompaction` and `clearCompactingLogId`
are serial.
>
> What do you mean?
The method `createNewLogForCompaction` is synchronized. It creates compact
file one by one, so the previous log file id can't override the next log file
id.
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLoggerAllocator.java:
##########
@@ -90,16 +92,19 @@ synchronized long getPreallocatedLogId() {
return preallocatedLogId;
}
+ public boolean isSealed(long logId) {
+ return logId != writingLogId && logId != writingCompactingLogId;
+ }
Review Comment:
`isSealed` means that the entry log file will no longer be written to, we
needn't care that the file sile change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]