Skip to content

Commit 480d908

Browse files
committed
SDC-12744. Classification Previews don't always get cleaned up
Changes the expiration for the preview cache from 30 minutes to 5 - there's no need to keep them around for that long. Also adds a background thread to call the cache cleanup method every 5 minutes because Guava isn't actually removing expired previews otherwise. We normally invalidate specific previews from the cache when retrieving their output, so this isn't typically a problem; but if the output isn't retrieved for some reason, the preview isn't cleaned up and removed otherwise. Change-Id: Ib8eee76c7693b480410ed66f8314b6130e7bf6ea Reviewed-on: https://review.streamsets.net/c/datacollector/+/27176 Tested-by: StreamSets CI <streamsets-ci-spam@streamsets.com> Reviewed-by: Pasindu Perera <pasindu@streamsets.com> Reviewed-by: Tony McKeehan <anthony@streamsets.com>
1 parent 790166b commit 480d908

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

container/src/main/java/com/streamsets/datacollector/execution/manager/standalone/StandaloneAndClusterPipelineManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.ArrayList;
6464
import java.util.List;
6565
import java.util.concurrent.ExecutionException;
66+
import java.util.concurrent.Executors;
6667
import java.util.concurrent.ScheduledFuture;
6768
import java.util.concurrent.TimeUnit;
6869
import java.util.function.Function;
@@ -229,7 +230,7 @@ public void runTask() {
229230
runtimeInfo.getMetrics(),
230231
"manager-previewer-cache",
231232
CacheBuilder.newBuilder()
232-
.expireAfterAccess(30, TimeUnit.MINUTES).removalListener((RemovalListener<String, Previewer>) removal -> {
233+
.expireAfterAccess(5, TimeUnit.MINUTES).removalListener((RemovalListener<String, Previewer>) removal -> {
233234
Previewer previewer = removal.getValue();
234235
LOG.warn(
235236
"Evicting idle previewer '{}::{}'::'{}' in status '{}'",
@@ -251,6 +252,12 @@ public void runTask() {
251252
}).build()
252253
);
253254

255+
// Create a background thread to cleanup the previewerCache because guava doesn't always want to do it on its own
256+
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(() -> {
257+
LOG.debug("Triggering previewer cache cleanup");
258+
previewerCache.cleanUp();
259+
}, 5, 5, TimeUnit.MINUTES);
260+
254261
runnerCache = new MetricsCache<>(
255262
runtimeInfo.getMetrics(),
256263
"manager-runner-cache",

0 commit comments

Comments
 (0)