Skip to content

Commit

Permalink
Fix async recover TsfileResource error handle
Browse files Browse the repository at this point in the history
  • Loading branch information
HTHou committed Nov 28, 2024
1 parent b34b714 commit ca2b37a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,8 @@ private Callable<Void> recoverFilesInPartition(
Callable<Void> asyncRecoverTask = null;
for (TsFileResource tsFileResource : resourceList) {
tsFileManager.add(tsFileResource, isSeq);
if (fileTimeIndexMap.containsKey(tsFileResource.getTsFileID())) {
if (fileTimeIndexMap.containsKey(tsFileResource.getTsFileID())
&& tsFileResource.resourceFileExists()) {
tsFileResource.setTimeIndex(fileTimeIndexMap.get(tsFileResource.getTsFileID()));
tsFileResource.setStatus(TsFileResourceStatus.NORMAL);
resourceListForAsyncRecover.add(tsFileResource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.apache.iotdb.db.storageengine.dataregion.utils;

import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.CompactionUtils;
import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResourceStatus;
Expand Down Expand Up @@ -61,6 +63,7 @@

public class TsFileResourceUtils {
private static final Logger logger = LoggerFactory.getLogger(TsFileResourceUtils.class);
private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
private static final String VALIDATE_FAILED = "validate failed,";

private TsFileResourceUtils() {
Expand Down Expand Up @@ -428,14 +431,15 @@ public static void updateTsFileResource(

public static void updateTsFileResource(
Map<IDeviceID, List<TimeseriesMetadata>> device2Metadata, TsFileResource tsFileResource) {
ITimeIndex newTimeIndex = config.getTimeIndexLevel().getTimeIndex();
for (Map.Entry<IDeviceID, List<TimeseriesMetadata>> entry : device2Metadata.entrySet()) {
for (TimeseriesMetadata timeseriesMetaData : entry.getValue()) {
tsFileResource.updateStartTime(
newTimeIndex.updateStartTime(
entry.getKey(), timeseriesMetaData.getStatistics().getStartTime());
tsFileResource.updateEndTime(
entry.getKey(), timeseriesMetaData.getStatistics().getEndTime());
newTimeIndex.updateEndTime(entry.getKey(), timeseriesMetaData.getStatistics().getEndTime());
}
}
tsFileResource.setTimeIndex(newTimeIndex);
}

/**
Expand Down

0 comments on commit ca2b37a

Please sign in to comment.