Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #7545] Fix set mapped file to null cause file can not destroy #7612

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,9 @@ public void shutdown() {
this.fileStatus.set(IndexStatusEnum.SHUTDOWN);
if (this.mappedFile != null) {
this.mappedFile.shutdown(TimeUnit.SECONDS.toMillis(10));
this.mappedFile = null;
}
if (this.compactMappedFile != null) {
this.compactMappedFile.shutdown(TimeUnit.SECONDS.toMillis(10));
this.compactMappedFile = null;
}
} catch (Exception e) {
log.error("IndexStoreFile shutdown failed, timestamp: {}, status: {}", this.getTimestamp(), fileStatus.get(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.apache.rocketmq.store.logfile.DefaultMappedFile;
Expand Down Expand Up @@ -101,6 +102,10 @@ private void doConvertOldFormatFile(String filePath) {
private void recover() {
Stopwatch stopwatch = Stopwatch.createStarted();

// delete compact file directory
UtilAll.deleteFile(new File(Paths.get(storeConfig.getStorePathRootDir(),
FILE_DIRECTORY_NAME, FILE_COMPACTED_DIRECTORY_NAME).toString()));

// recover local
File dir = new File(Paths.get(storeConfig.getStorePathRootDir(), FILE_DIRECTORY_NAME).toString());
this.doConvertOldFormatFile(Paths.get(dir.getPath(), "0000").toString());
Expand Down Expand Up @@ -141,6 +146,10 @@ private void recover() {

for (TieredFileSegment fileSegment : flatFile.getFileSegmentList()) {
IndexFile indexFile = new IndexStoreFile(storeConfig, fileSegment);
IndexFile localFile = timeStoreTable.get(indexFile.getTimestamp());
if (localFile != null) {
localFile.destroy();
}
timeStoreTable.put(indexFile.getTimestamp(), indexFile);
log.info("IndexStoreService recover load remote file, timestamp: {}", indexFile.getTimestamp());
}
Expand Down Expand Up @@ -248,6 +257,7 @@ public void doCompactThenUploadFile(IndexFile indexFile) {
if (IndexFile.IndexStatusEnum.UPLOAD.equals(indexFile.getFileStatus())) {
log.error("IndexStoreService file status not correct, so skip, timestamp: {}, status: {}",
indexFile.getTimestamp(), indexFile.getFileStatus());
indexFile.destroy();
return;
}

Expand Down
Loading