Skip to content

Commit 4fddd58

Browse files
authored
[IoTConsensusV2 X Pipe Deletion]: Release deletion resource when delete region & Improve for release when buffer is null (apache#14227)
* release deletion resource when delete region * improve
1 parent 0bb51c6 commit 4fddd58

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/persist/PageCacheDeletionBuffer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.nio.charset.StandardCharsets;
4242
import java.util.ArrayList;
4343
import java.util.List;
44+
import java.util.Optional;
4445
import java.util.concurrent.BlockingQueue;
4546
import java.util.concurrent.ExecutorService;
4647
import java.util.concurrent.PriorityBlockingQueue;
@@ -142,7 +143,8 @@ public void start() {
142143
public boolean isAllDeletionFlushed() {
143144
buffersLock.lock();
144145
try {
145-
return deletionResources.isEmpty() && serializeBuffer.position() == 0;
146+
int pos = Optional.ofNullable(serializeBuffer).map(ByteBuffer::position).orElse(0);
147+
return deletionResources.isEmpty() && pos == 0;
146148
} finally {
147149
buffersLock.unlock();
148150
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import org.apache.iotdb.db.consensus.SchemaRegionConsensusImpl;
8484
import org.apache.iotdb.db.exception.StorageEngineException;
8585
import org.apache.iotdb.db.pipe.agent.PipeDataNodeAgent;
86+
import org.apache.iotdb.db.pipe.consensus.deletion.DeletionResourceManager;
8687
import org.apache.iotdb.db.protocol.client.ConfigNodeInfo;
8788
import org.apache.iotdb.db.protocol.client.cn.DnToCnInternalServiceAsyncRequestManager;
8889
import org.apache.iotdb.db.protocol.client.cn.DnToCnRequestType;
@@ -2252,6 +2253,9 @@ public TSStatus deleteRegion(TConsensusGroupId tconsensusGroupId) {
22522253
if (consensusGroupId instanceof DataRegionId) {
22532254
try {
22542255
DataRegionConsensusImpl.getInstance().deleteLocalPeer(consensusGroupId);
2256+
Optional.ofNullable(
2257+
DeletionResourceManager.getInstance(String.valueOf(tconsensusGroupId.getId())))
2258+
.ifPresent(DeletionResourceManager::close);
22552259
} catch (ConsensusException e) {
22562260
if (!(e instanceof ConsensusGroupNotExistException)) {
22572261
return RpcUtils.getStatus(TSStatusCode.DELETE_REGION_ERROR, e.getMessage());

0 commit comments

Comments
 (0)