This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bdc596f Fix sync last query (#2540)
bdc596f is described below
commit bdc596ff2f0007c6f9c0c1f9d63e6610e67aca9c
Author: Tianan Li <[email protected]>
AuthorDate: Thu Jan 21 18:54:03 2021 +0800
Fix sync last query (#2540)
---
.../engine/storagegroup/StorageGroupProcessor.java | 33 ++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 7d3f114..2e88108 100755
---
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -79,6 +79,7 @@ import
org.apache.iotdb.db.exception.StorageGroupProcessorException;
import org.apache.iotdb.db.exception.TsFileProcessorException;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.WriteProcessRejectException;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.query.OutOfTTLException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -1917,18 +1918,46 @@ public class StorageGroupProcessor {
newFilePartitionId)) {
updateLatestTimeMap(newTsFileResource);
}
+ resetLastCacheWhenLoadingTsfile(newTsFileResource);
} catch (DiskSpaceInsufficientException e) {
logger.error(
"Failed to append the tsfile {} to storage group processor {}
because the disk space is insufficient.",
tsfileToBeInserted.getAbsolutePath(),
tsfileToBeInserted.getParentFile().getName());
IoTDBDescriptor.getInstance().getConfig().setReadOnly(true);
throw new LoadFileException(e);
+ } catch (IllegalPathException | WriteProcessException e) {
+ logger.error("Failed to reset last cache when loading file {}",
newTsFileResource.getTsFilePath());
+ throw new LoadFileException(e);
} finally {
tsFileManagement.writeUnlock();
writeUnlock();
}
}
+ private void resetLastCacheWhenLoadingTsfile(TsFileResource
newTsFileResource)
+ throws IllegalPathException, WriteProcessException {
+ for (String device : newTsFileResource.getDevices()) {
+ tryToDeleteLastCacheByDevice(new PartialPath(device));
+ }
+ }
+
+ private void tryToDeleteLastCacheByDevice(PartialPath deviceId) throws
WriteProcessException {
+ if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()) {
+ return;
+ }
+ try {
+ MNode node = IoTDB.metaManager.getDeviceNode(deviceId);
+
+ for (MNode measurementNode : node.getChildren().values()) {
+ if (measurementNode != null) {
+ ((MeasurementMNode) measurementNode).resetCache();
+ }
+ }
+ } catch (MetadataException e) {
+ throw new WriteProcessException(e);
+ }
+ }
+
/**
* Load a new tsfile to storage group processor. Tne file may have overlap
with other files. <p>
* that there has no file which is overlapping with the new file.
@@ -1977,6 +2006,7 @@ public class StorageGroupProcessor {
loadTsFileByType(LoadTsFileType.LOAD_SEQUENCE, tsfileToBeInserted,
newTsFileResource,
newFilePartitionId);
}
+ resetLastCacheWhenLoadingTsfile(newTsFileResource);
// update latest time map
updateLatestTimeMap(newTsFileResource);
@@ -1988,6 +2018,9 @@ public class StorageGroupProcessor {
tsfileToBeInserted.getAbsolutePath(),
tsfileToBeInserted.getParentFile().getName());
IoTDBDescriptor.getInstance().getConfig().setReadOnly(true);
throw new LoadFileException(e);
+ } catch (IllegalPathException | WriteProcessException e) {
+ logger.error("Failed to reset last cache when loading file {}",
newTsFileResource.getTsFilePath());
+ throw new LoadFileException(e);
} finally {
tsFileManagement.writeUnlock();
writeUnlock();