This is an automated email from the ASF dual-hosted git repository.
zyk 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 9077f03e1a4 Fix NPE in SchemaStatisticsTest (#11490)
9077f03e1a4 is described below
commit 9077f03e1a483bb86f5803d885a6fd3fa17b3289
Author: Chen YZ <[email protected]>
AuthorDate: Wed Nov 8 09:10:42 2023 +0800
Fix NPE in SchemaStatisticsTest (#11490)
---
.../mtree/impl/pbtree/cache/CacheManager.java | 35 +++++++++++++---------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/cache/CacheManager.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/cache/CacheManager.java
index df6335e61be..b8c055fd4c3 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/cache/CacheManager.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/cache/CacheManager.java
@@ -227,6 +227,22 @@ public abstract class CacheManager implements
ICacheManager {
nodeBuffer.remove(getCacheEntry(node));
}
+ private void addItselfAndAncestorToCache(ICachedMNode node) {
+ // the volatile subtree of this node has been deleted, thus there's no
need to flush it
+ // add the node and its ancestors to cache
+ // if there's flush failure, such node and ancestors will be removed from
cache again by
+ // #updateCacheStatusAfterFlushFailure
+ ICachedMNode tmp = node;
+ while (!tmp.isDatabase()
+ && !isInNodeCache(getCacheEntry(tmp))
+ && !getCachedMNodeContainer(tmp).hasChildrenInBuffer()
+ && !getCacheEntry(tmp).isVolatile()) {
+ nodeBuffer.remove(getCacheEntry(tmp));
+ addToNodeCache(getCacheEntry(tmp), tmp);
+ tmp = tmp.getParent();
+ }
+ }
+
/**
* Collect updated storage group node.
*
@@ -274,17 +290,7 @@ public abstract class CacheManager implements
ICacheManager {
nextSubtree = node;
return;
} else if (!node.isDatabase()) {
- // the volatile subtree of this node has been deleted, thus
there's no need to flush it
- // add the node and its ancestors to cache
- // if there's flush failure, such node and ancestors will be
removed from cache again by
- // #updateCacheStatusAfterFlushFailure
- ICachedMNode tmp = node;
- while (!tmp.isDatabase()
- && !isInNodeCache(getCacheEntry(tmp))
- && !getCachedMNodeContainer(tmp).hasChildrenInBuffer()) {
- addToNodeCache(getCacheEntry(tmp), tmp);
- tmp = tmp.getParent();
- }
+ addItselfAndAncestorToCache(node);
}
}
}
@@ -376,13 +382,14 @@ public abstract class CacheManager implements
ICacheManager {
@Override
public void remove(ICachedMNode node) {
removeRecursively(node);
+ addItselfAndAncestorToCache(node.getParent());
}
private void removeOne(CacheEntry cacheEntry, ICachedMNode node) {
- if (cacheEntry.isVolatile()) {
- nodeBuffer.remove(cacheEntry);
- } else {
+ if (isInNodeCache(cacheEntry)) {
removeFromNodeCache(cacheEntry);
+ } else {
+ nodeBuffer.remove(cacheEntry);
}
node.setCacheEntry(null);