This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch 1.10
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/1.10 by this push:
new d925db128b fixes #3260 by making cached split info a softref (#3261)
d925db128b is described below
commit d925db128b568d61fd67647e5e033dfccf26f8dc
Author: Keith Turner <[email protected]>
AuthorDate: Thu Mar 30 19:54:50 2023 -0400
fixes #3260 by making cached split info a softref (#3261)
The changes in #3249 introduce per tablet caching of split information so
that it does not need to be recomputed. If a tablet happens to have large keys
and those end up getting cached by the new code in #3249 then it could cause
memory pressure or OOMEs in the tablet server. This commit attempts to avoid
those problems by using a softref to store the cached information.
---
.../java/org/apache/accumulo/tserver/tablet/Tablet.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 580616ee3f..9cd5cbd968 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -1821,8 +1822,12 @@ public class Tablet implements TabletCommitter {
}
}
- private AtomicReference<SplitComputations> lastSplitComputation = new
AtomicReference<>();
- private Lock splitComputationLock = new ReentrantLock();
+ // The following caches keys from users files needed to compute a tablets
split point. This cached
+ // data could potentially be large and is therefore stored using a soft
refence so the Java GC can
+ // release it if needed. If the cached information is not there it can
always be recomputed.
+ private volatile SoftReference<SplitComputations> lastSplitComputation =
+ new SoftReference<>(null);
+ private final Lock splitComputationLock = new ReentrantLock();
/**
* Computes split point information from files when a tablets set of files
changes. Do not call
@@ -1870,16 +1875,16 @@ public class Tablet implements TabletCommitter {
}
newComputation = new SplitComputations(files, midpoint, lastRow);
+
+ lastSplitComputation = new SoftReference<>(newComputation);
} catch (IOException e) {
- lastSplitComputation.set(null);
+ lastSplitComputation.clear();
log.error("Failed to compute split information from files " +
e.getMessage());
return Optional.absent();
} finally {
splitComputationLock.unlock();
}
- lastSplitComputation.set(newComputation);
-
return Optional.of(newComputation);
} else {
// some other thread seems to be working on split, let the other thread
work on it