You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/06/23 04:14:14 UTC
[incubator-iotdb] branch feature_async_close_tsfile updated: add
lock when delete
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch feature_async_close_tsfile
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/feature_async_close_tsfile by this push:
new 6290ca2 add lock when delete
6290ca2 is described below
commit 6290ca259d1587c4f9fb72e9ca1d3c5ab02e9bd5
Author: qiaojialin <64...@qq.com>
AuthorDate: Sun Jun 23 12:14:12 2019 +0800
add lock when delete
---
.../db/engine/filenodeV2/FileNodeProcessorV2.java | 47 +++++++++++-----------
1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenodeV2/FileNodeProcessorV2.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenodeV2/FileNodeProcessorV2.java
index 7596328..5fcefae 100755
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenodeV2/FileNodeProcessorV2.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenodeV2/FileNodeProcessorV2.java
@@ -353,35 +353,34 @@ public class FileNodeProcessorV2 {
*/
public void delete(String deviceId, String measurementId, long timestamp) throws IOException {
// TODO: how to avoid partial deletion?
- mergeDeleteLock.lock();
- long lastUpdateTime = latestTimeForEachDevice.get(deviceId);
- // no tsfile data, the delete operation is invalid
- if (lastUpdateTime == Long.MIN_VALUE) {
- LOGGER.warn("The last update time is -1, delete overflow is invalid, "
- + "the storage group is {}", storageGroupName);
- return;
- }
-
- // write log
- if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
- if (workSequenceTsFileProcessor != null) {
- workSequenceTsFileProcessor.getLogNode()
- .write(new DeletePlan(timestamp, new Path(deviceId, measurementId)));
- }
- if (workUnSequenceTsFileProcessor != null) {
- workUnSequenceTsFileProcessor.getLogNode()
- .write(new DeletePlan(timestamp, new Path(deviceId, measurementId)));
- }
- }
-
- long version = versionController.nextVersion();
+ lock.writeLock().lock();
// record what files are updated so we can roll back them in case of exception
List<ModificationFile> updatedModFiles = new ArrayList<>();
try {
+ long lastUpdateTime = latestTimeForEachDevice.get(deviceId);
+ // no tsfile data, the delete operation is invalid
+ if (lastUpdateTime == Long.MIN_VALUE) {
+ LOGGER.warn("The last update time is -1, delete overflow is invalid, "
+ + "the storage group is {}", storageGroupName);
+ return;
+ }
+
+ // write log
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
+ if (workSequenceTsFileProcessor != null) {
+ workSequenceTsFileProcessor.getLogNode()
+ .write(new DeletePlan(timestamp, new Path(deviceId, measurementId)));
+ }
+ if (workUnSequenceTsFileProcessor != null) {
+ workUnSequenceTsFileProcessor.getLogNode()
+ .write(new DeletePlan(timestamp, new Path(deviceId, measurementId)));
+ }
+ }
+
Path fullPath = new Path(deviceId, measurementId);
- Deletion deletion = new Deletion(fullPath, version, timestamp);
+ Deletion deletion = new Deletion(fullPath, versionController.nextVersion(), timestamp);
if (mergingModification != null) {
mergingModification.write(deletion);
updatedModFiles.add(mergingModification);
@@ -397,7 +396,7 @@ public class FileNodeProcessorV2 {
}
throw new IOException(e);
} finally {
- mergeDeleteLock.unlock();
+ lock.writeLock().unlock();
}
}