neuyilan commented on a change in pull request #1956:
URL: https://github.com/apache/iotdb/pull/1956#discussion_r519545699
##########
File path:
cluster/src/main/java/org/apache/iotdb/cluster/log/manage/serializable/SyncLogDequeSerializer.java
##########
@@ -945,23 +1008,34 @@ private int comparePersistLogFileName(File file1, File
file2) {
if (endIndex - startIndex > maxNumberOfLogsPerFetchOnDisk) {
newEndIndex = startIndex + maxNumberOfLogsPerFetchOnDisk;
}
- logger.debug("intend to get logs between[{}, {}], actually get logs
between[{},{}]", startIndex,
- endIndex, startIndex, newEndIndex);
+ logger
+ .debug("intend to get logs between[{}, {}], actually get logs
between[{},{}]", startIndex,
+ endIndex, startIndex, newEndIndex);
- List<Pair<File, Pair<Long, Long>>> logDataFileAndOffsetList =
getLogDataFileAndOffset(
- startIndex, newEndIndex);
- if (logDataFileAndOffsetList.isEmpty()) {
- return Collections.emptyList();
- }
+ // maybe the logs will be delete during checkDeletePersistRaftLog or
clearAllLogs,
+ // use writeLock for two reasons:
+ // 1.if the log file to read is the last log file, we need to get write
lock to flush logBuffer,
+ // 2.avoid log files be deleted
+ lock.writeLock().lock();
Review comment:
i intend to use ReentrantLock instead of ReentrantReadWriteLock
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]