未验证 提交 653f8e8b 编写于 作者: J Jackie Tien 提交者: GitHub

[IOTDB-2460] Fix NoSuchFileException while querying and ttl happened same time (#4937)

上级 a235a88c
......@@ -434,7 +434,7 @@ public class TsFileResource {
}
public Set<String> getDevices() {
return timeIndex.getDevices(file.getPath());
return timeIndex.getDevices(file.getPath(), this);
}
public boolean endTimeEmpty() {
......
......@@ -20,6 +20,7 @@
package org.apache.iotdb.db.engine.storagegroup.timeindex;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
import org.apache.iotdb.db.exception.PartitionViolationException;
import org.apache.iotdb.db.rescon.CachedStringPool;
import org.apache.iotdb.db.utils.SerializeUtils;
......@@ -160,7 +161,7 @@ public class DeviceTimeIndex implements ITimeIndex {
}
@Override
public Set<String> getDevices(String tsFilePath) {
public Set<String> getDevices(String tsFilePath, TsFileResource tsFileResource) {
return deviceToIndex.keySet();
}
......
......@@ -20,6 +20,7 @@
package org.apache.iotdb.db.engine.storagegroup.timeindex;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
import org.apache.iotdb.db.exception.PartitionViolationException;
import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
import org.apache.iotdb.tsfile.utils.FilePathUtils;
......@@ -33,6 +34,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.file.NoSuchFileException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
......@@ -79,9 +82,17 @@ public class FileTimeIndex implements ITimeIndex {
}
@Override
public Set<String> getDevices(String tsFilePath) {
public Set<String> getDevices(String tsFilePath, TsFileResource tsFileResource) {
try (TsFileSequenceReader fileReader = new TsFileSequenceReader(tsFilePath)) {
return new HashSet<>(fileReader.getAllDevices());
} catch (NoSuchFileException e) {
// deleted by ttl
if (tsFileResource.isDeleted()) {
return Collections.emptySet();
} else {
logger.error("Can't read file {} from disk ", tsFilePath, e);
throw new RuntimeException("Can't read file " + tsFilePath + " from disk");
}
} catch (IOException e) {
logger.error("Can't read file {} from disk ", tsFilePath, e);
throw new RuntimeException("Can't read file " + tsFilePath + " from disk");
......
......@@ -19,6 +19,7 @@
package org.apache.iotdb.db.engine.storagegroup.timeindex;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
import org.apache.iotdb.db.exception.PartitionViolationException;
import java.io.IOException;
......@@ -62,7 +63,7 @@ public interface ITimeIndex {
*
* @return device names
*/
Set<String> getDevices(String tsFilePath);
Set<String> getDevices(String tsFilePath, TsFileResource tsFileResource);
/** @return whether end time is empty (Long.MIN_VALUE) */
boolean endTimeEmpty();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册