You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by cw...@apache.org on 2025/10/21 22:07:59 UTC
(druid) branch 35.0.0 updated: fix bug in SegmentLocalCacheManager to only attempt download in acquireSegment if virtual storage is enabled (#18659) (#18676)
This is an automated email from the ASF dual-hosted git repository.
cwylie pushed a commit to branch 35.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/35.0.0 by this push:
new daae72220f1 fix bug in SegmentLocalCacheManager to only attempt download in acquireSegment if virtual storage is enabled (#18659) (#18676)
daae72220f1 is described below
commit daae72220f18cfde0afec9d10398fa2e550633cd
Author: Clint Wylie <cw...@apache.org>
AuthorDate: Tue Oct 21 15:07:54 2025 -0700
fix bug in SegmentLocalCacheManager to only attempt download in acquireSegment if virtual storage is enabled (#18659) (#18676)
---
.../segment/loading/SegmentLocalCacheManager.java | 5 +++++
.../loading/SegmentLocalCacheManagerTest.java | 25 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
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 7a61329b8e8..162e20a28d1 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
@@ -336,6 +336,11 @@ public class SegmentLocalCacheManager implements SegmentCacheManager
if (retryAcquireExisting != null) {
return retryAcquireExisting;
}
+
+ if (!config.isVirtualStorage()) {
+ return AcquireSegmentAction.missingSegment();
+ }
+
final Iterator<StorageLocation> iterator = strategy.getLocations();
while (iterator.hasNext()) {
final StorageLocation location = iterator.next();
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 0ac4796cd3f..04eafa41ed7 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
@@ -1047,6 +1047,31 @@ public class SegmentLocalCacheManagerTest extends InitializedNullHandlingTest
Assert.assertNotNull(manager.getSegmentFiles(segmentToBootstrap));
}
+ @Test
+ public void testGetSegmentAfterDroppedWithNoVirtualStorageEnabled() throws Exception
+ {
+ SegmentLocalCacheManager manager = makeDefaultManager(jsonMapper);
+
+ final DataSegment segmentToLoad = makeTestDataSegment(segmentDeepStorageDir);
+ createSegmentZipInLocation(segmentDeepStorageDir, TEST_DATA_RELATIVE_PATH);
+
+ manager.load(segmentToLoad);
+ Assert.assertNotNull(manager.getSegmentFiles(segmentToLoad));
+ manager.drop(segmentToLoad);
+ Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
+
+ // ensure that if virtual storage is not enabled, we do not download the segment (callers might have a DataSegment
+ // reference which was originally cached and then dropped before attempting to acquire a segment. if virtual storage
+ // is not enabled, this should return a missing segment instead of downloading
+ AcquireSegmentAction segmentAction = manager.acquireSegment(segmentToLoad);
+ ReferenceCountedObjectProvider<Segment> referenceProvider = segmentAction.getSegmentFuture().get();
+ Optional<Segment> theSegment = referenceProvider.acquireReference();
+ Assert.assertFalse(theSegment.isPresent());
+ segmentAction.close();
+
+ Assert.assertNull(manager.getSegmentFiles(segmentToLoad));
+ }
+
@Test
public void testIfTombstoneIsLoaded() throws IOException, SegmentLoadingException
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org