This is an automated email from the ASF dual-hosted git repository.

cwylie pushed a commit to branch 36.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/36.0.0 by this push:
     new 68c312dbb8a rename evictImmediatelyOnHoldRelease to 
areWeakEntriesEphemeral (#18900) (#18913)
68c312dbb8a is described below

commit 68c312dbb8aa7cb0aa8d14dde6eb595317f54a7e
Author: Clint Wylie <[email protected]>
AuthorDate: Wed Jan 14 10:42:05 2026 -0800

    rename evictImmediatelyOnHoldRelease to areWeakEntriesEphemeral (#18900) 
(#18913)
---
 .../druid/segment/loading/SegmentLoaderConfig.java   | 20 ++++++++++----------
 .../segment/loading/SegmentLocalCacheManager.java    | 14 +++++++-------
 .../druid/segment/loading/StorageLocation.java       | 18 ++++++++++++------
 .../segment/loading/SegmentLoaderConfigTest.java     |  4 ++--
 .../loading/SegmentLocalCacheManagerTest.java        |  2 +-
 5 files changed, 32 insertions(+), 26 deletions(-)

diff --git 
a/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderConfig.java
 
b/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderConfig.java
index 28570a0e780..4c075240bbd 100644
--- 
a/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderConfig.java
+++ 
b/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderConfig.java
@@ -82,8 +82,8 @@ public class SegmentLoaderConfig
    * waiting for space pressure to trigger eviction. This setting is not 
intended to be configured directly by
    * administrators. Instead, it is expected to be set when appropriate via 
{@link #setVirtualStorage}.
    */
-  @JsonProperty("virtualStorageFabricEvictImmediatelyOnHoldRelease")
-  private boolean virtualStorageFabricEvictImmediatelyOnHoldRelease = false;
+  @JsonProperty("virtualStorageIsEphemeral")
+  private boolean virtualStorageIsEphemeral = false;
 
   private long combinedMaxSize = 0;
 
@@ -162,9 +162,9 @@ public class SegmentLoaderConfig
     return virtualStorageLoadThreads;
   }
 
-  public boolean isVirtualStorageFabricEvictImmediatelyOnHoldRelease()
+  public boolean isVirtualStorageEphemeral()
   {
-    return virtualStorageFabricEvictImmediatelyOnHoldRelease;
+    return virtualStorageIsEphemeral;
   }
 
   public SegmentLoaderConfig withLocations(List<StorageLocationConfig> 
locations)
@@ -177,15 +177,15 @@ public class SegmentLoaderConfig
   }
 
   /**
-   * Sets {@link #virtualStorage} and {@link 
#virtualStorageFabricEvictImmediatelyOnHoldRelease}.
+   * Sets {@link #virtualStorage} and {@link #virtualStorageIsEphemeral}.
    */
   public SegmentLoaderConfig setVirtualStorage(
       boolean virtualStorage,
-      boolean virtualStorageFabricEvictImmediatelyOnHoldRelease
+      boolean virtualStorageFabricEphemeral
   )
   {
     this.virtualStorage = virtualStorage;
-    this.virtualStorageFabricEvictImmediatelyOnHoldRelease = 
virtualStorageFabricEvictImmediatelyOnHoldRelease;
+    this.virtualStorageIsEphemeral = virtualStorageFabricEphemeral;
     return this;
   }
 
@@ -219,9 +219,9 @@ public class SegmentLoaderConfig
            ", numThreadsToLoadSegmentsIntoPageCacheOnBootstrap=" + 
numThreadsToLoadSegmentsIntoPageCacheOnBootstrap +
            ", infoDir=" + infoDir +
            ", statusQueueMaxSize=" + statusQueueMaxSize +
-           ", useVirtualStorageFabric=" + virtualStorage +
-           ", virtualStorageFabricLoadThreads=" + virtualStorageLoadThreads +
-           ", virtualStorageFabricEvictImmediatelyOnHoldRelease=" + 
virtualStorageFabricEvictImmediatelyOnHoldRelease +
+           ", virtualStorage=" + virtualStorage +
+           ", virtualStorageLoadThreads=" + virtualStorageLoadThreads +
+           ", virtualStorageIsEphemeral=" + virtualStorageIsEphemeral +
            ", combinedMaxSize=" + combinedMaxSize +
            '}';
   }
diff --git 
a/server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
 
b/server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
index 2103cc0aade..bd6d4878395 100644
--- 
a/server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
+++ 
b/server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
@@ -145,9 +145,9 @@ public class SegmentLocalCacheManager implements 
SegmentCacheManager
       if (config.getNumThreadsToLoadSegmentsIntoPageCacheOnBootstrap() > 0) {
         throw DruidException.defensive("Invalid configuration: virtualStorage 
is incompatible with numThreadsToLoadSegmentsIntoPageCacheOnBootstrap");
       }
-      if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
+      if (config.isVirtualStorageEphemeral()) {
         for (StorageLocation location : locations) {
-          location.setEvictImmediatelyOnHoldRelease(true);
+          location.setAreWeakEntriesEphemeral(true);
         }
       }
       virtualStorageLoadOnDemandExec =
@@ -496,9 +496,9 @@ public class SegmentLocalCacheManager implements 
SegmentCacheManager
   public void load(final DataSegment dataSegment) throws 
SegmentLoadingException
   {
     if (config.isVirtualStorage()) {
-      if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
+      if (config.isVirtualStorageEphemeral()) {
         throw DruidException.defensive(
-            "load() should not be called when 
virtualStorageFabricEvictImmediatelyOnHoldRelease is enabled"
+            "load() should not be called when virtualStorageIsEphemeral is 
true"
         );
       }
       // virtual storage doesn't do anything with loading immediately, but 
check to see if the segment is already cached
@@ -542,9 +542,9 @@ public class SegmentLocalCacheManager implements 
SegmentCacheManager
   ) throws SegmentLoadingException
   {
     if (config.isVirtualStorage()) {
-      if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
+      if (config.isVirtualStorageEphemeral()) {
         throw DruidException.defensive(
-            "bootstrap() should not be called when 
virtualStorageFabricEvictImmediatelyOnHoldRelease is enabled"
+            "bootstrap() should not be called when virtualStorageIsEphemeral 
is true"
         );
       }
       // during bootstrap, check if the segment exists in a location and mount 
it, getCachedSegments already
@@ -1046,7 +1046,7 @@ public class SegmentLocalCacheManager implements 
SegmentCacheManager
           unmount();
         }
 
-        if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
+        if (config.isVirtualStorageEphemeral()) {
           setDeleteInfoFileOnUnmount();
         }
       }
diff --git 
a/server/src/main/java/org/apache/druid/segment/loading/StorageLocation.java 
b/server/src/main/java/org/apache/druid/segment/loading/StorageLocation.java
index 06ce140dc56..0b98ae65385 100644
--- a/server/src/main/java/org/apache/druid/segment/loading/StorageLocation.java
+++ b/server/src/main/java/org/apache/druid/segment/loading/StorageLocation.java
@@ -80,6 +80,11 @@ import java.util.function.Supplier;
  * is repeated until either a sufficient amount of space has been reclaimed, 
or no additional space is able to be
  * reclaimed, in which case the new reservation fails.
  * <p>
+ * There is an auxilary mode for weak references when {@link 
#areWeakEntriesEphemeral} is set to true. In this mode, weak
+ * entries are short-lived entries that only exist while one or more 
reservation hold are active, and are unmounted when
+ * the holds are released. This is useful in cases where entries are unlikely 
to be re-used such as in asynchronous
+ * tasks.
+ * <p>
  * This class is thread-safe, so that multiple threads can update its state at 
the same time.
  * One example usage is that a historical server can use multiple threads to 
load different segments in parallel
  * from deep storage.
@@ -106,7 +111,7 @@ public class StorageLocation
   @GuardedBy("lock")
   private WeakCacheEntry hand;
 
-  private volatile boolean evictImmediatelyOnHoldRelease = false;
+  private volatile boolean areWeakEntriesEphemeral = false;
 
   /**
    * Current total size of files in bytes, including weak entries.
@@ -170,11 +175,12 @@ public class StorageLocation
   }
 
   /**
-   * Sets whether weak cache entries should be immediately evicted once all 
holds are released.
+   * Sets whether weak cache entries should be retained after all holds are 
released. If true, weak references are
+   * removed and unmounted immediately after all holds are released
    */
-  public void setEvictImmediatelyOnHoldRelease(final boolean 
evictImmediatelyOnHoldRelease)
+  public void setAreWeakEntriesEphemeral(final boolean areWeakEntriesEphemeral)
   {
-    this.evictImmediatelyOnHoldRelease = evictImmediatelyOnHoldRelease;
+    this.areWeakEntriesEphemeral = areWeakEntriesEphemeral;
   }
 
   public <T extends CacheEntry> T getStaticCacheEntry(CacheEntryIdentifier 
entryId)
@@ -448,7 +454,7 @@ public class StorageLocation
     return () -> {
       weakEntry.release();
 
-      if (!isNewEntry && !evictImmediatelyOnHoldRelease) {
+      if (!isNewEntry && !areWeakEntriesEphemeral) {
         // No need to consider removal from weakCacheEntries on hold release.
         return;
       }
@@ -462,7 +468,7 @@ public class StorageLocation
               // Furthermore, if evictImmediatelyOnHoldRelease is set, evict 
on release if all holds are gone.
               final boolean isMounted = weakCacheEntry.cacheEntry.isMounted();
               if ((isNewEntry && !isMounted)
-                  || (evictImmediatelyOnHoldRelease && 
!weakCacheEntry.isHeld())) {
+                  || (areWeakEntriesEphemeral && !weakCacheEntry.isHeld())) {
                 unlinkWeakEntry(weakCacheEntry);
                 weakCacheEntry.unmount(); // call even if never mounted, to 
terminate the phaser
                 if (isMounted) {
diff --git 
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLoaderConfigTest.java
 
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLoaderConfigTest.java
index d0d51a6d3b0..bd9c8c65def 100644
--- 
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLoaderConfigTest.java
+++ 
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLoaderConfigTest.java
@@ -31,13 +31,13 @@ public class SegmentLoaderConfigTest
 
     // Verify default values
     Assert.assertFalse(config.isVirtualStorage());
-    
Assert.assertFalse(config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease());
+    Assert.assertFalse(config.isVirtualStorageEphemeral());
 
     // Set both to true
     config.setVirtualStorage(true, true);
 
     // Verify both fields are set
     Assert.assertTrue(config.isVirtualStorage());
-    
Assert.assertTrue(config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease());
+    Assert.assertTrue(config.isVirtualStorageEphemeral());
   }
 }
diff --git 
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
 
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
index 0af544e59a4..0c48ac62793 100644
--- 
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
+++ 
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java
@@ -1197,7 +1197,7 @@ public class SegmentLocalCacheManagerTest extends 
InitializedNullHandlingTest
       }
 
       @Override
-      public boolean isVirtualStorageFabricEvictImmediatelyOnHoldRelease()
+      public boolean isVirtualStorageEphemeral()
       {
         return true;
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to