This is an automated email from the ASF dual-hosted git repository.
FrankChen021 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 45668be3e1c test: fix flaky
QueryVirtualStorageTest.testQueryTooMuchData (#20552)
45668be3e1c is described below
commit 45668be3e1c4571a29d1244687699db502175eb8
Author: Yahya Kisana <[email protected]>
AuthorDate: Sat Oct 10 21:03:35 2026 -0600
test: fix flaky QueryVirtualStorageTest.testQueryTooMuchData (#20552)
testQueryTooMuchData only accepted the bundle-reservation capacity error,
but which reservation runs out of space first depends on load thread
timing. When the space left after the bundles that fit is smaller than
the metadata reservation estimate, the partial metadata reservation
fails first with "Unable to reserve partial metadata for segment[...]",
which failed both assertions.
Assert on the text shared by every virtual storage capacity error and
include the actual message in the assertion failure. Add a unit test in
SegmentLocalCacheManagerPartialAcquireTest covering the partial metadata
CAPACITY_EXCEEDED path.
Fixes #20550
---
.../embedded/query/QueryVirtualStorageTest.java | 8 ++--
...SegmentLocalCacheManagerPartialAcquireTest.java | 45 ++++++++++++++++++++++
2 files changed, 49 insertions(+), 4 deletions(-)
diff --git
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java
index bf054bc3063..3c07cfc2419 100644
---
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java
+++
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java
@@ -163,10 +163,10 @@ class QueryVirtualStorageTest extends
EmbeddedClusterTestBase
RuntimeException.class,
() -> cluster.runSql("select count(*) from \"%s\"", dataSource)
);
- Assertions.assertTrue(t.getMessage().contains("Unable to reserve bundle"));
- Assertions.assertTrue(t.getMessage()
- .contains(
- "ensure enough disk space has been allocated to
load all segments involved in the query"));
+ Assertions.assertTrue(
+ t.getMessage().contains("ensure enough disk space has been allocated"),
+ t.getMessage()
+ );
}
@Test
diff --git
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerPartialAcquireTest.java
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerPartialAcquireTest.java
index 90cba8d2f9a..99651490779 100644
---
a/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerPartialAcquireTest.java
+++
b/server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerPartialAcquireTest.java
@@ -34,6 +34,7 @@ import org.apache.druid.data.input.impl.DimensionsSpec;
import org.apache.druid.data.input.impl.LongDimensionSchema;
import org.apache.druid.data.input.impl.StringDimensionSchema;
import org.apache.druid.data.input.impl.TimestampSpec;
+import org.apache.druid.error.DruidException;
import org.apache.druid.guice.LocalDataStorageDruidModule;
import org.apache.druid.jackson.SegmentizerModule;
import org.apache.druid.java.util.common.DateTimes;
@@ -882,6 +883,50 @@ class SegmentLocalCacheManagerPartialAcquireTest
}
}
+ @Test
+ void testFullAcquireFailsWhenPartialMetadataCannotBeReserved()
+ {
+ // A location smaller than the metadata reservation estimate can't take
the partial metadata entry, so
+ // acquireSegment fails before any bundle is reserved. Callers that check
for the "not enough disk space" failure
+ // (e.g. QueryVirtualStorageTest) must accept this message as well as the
bundle-reservation one.
+ final StorageLocationConfig locConfig = new
StorageLocationConfig(cacheRoot, 1024L, null);
+ final SegmentLoaderConfig tinyConfig = SegmentLoaderConfig.builder()
+ .locations(locConfig)
+ .virtualStorage(true)
+ .virtualStoragePartialDownloadsEnabled(true)
+ .virtualStorageMetadataReservationEstimate(2048L)
+ .build();
+ final List<StorageLocation> storageLocations =
tinyConfig.toStorageLocations();
+ final SegmentLocalCacheManager tinyManager = new SegmentLocalCacheManager(
+ storageLocations,
+ tinyConfig,
+ StorageLoadingThreadPool.createFromConfig(tinyConfig),
+ new LeastBytesUsedStorageLocationSelectorStrategy(storageLocations),
+ TestHelper.getTestIndexIO(jsonMapper, ColumnConfig.DEFAULT),
+ jsonMapper
+ );
+
+ try {
+ final DruidException e = Assertions.assertThrows(
+ DruidException.class,
+ () -> tinyManager.acquireSegment(partialSegment, AcquireMode.FULL)
+ );
+ Assertions.assertEquals(DruidException.Category.CAPACITY_EXCEEDED,
e.getCategory());
+ Assertions.assertTrue(
+ e.getMessage().startsWith("Unable to reserve partial metadata for
segment[" + SEGMENT_ID + "]"),
+ e.getMessage()
+ );
+ Assertions.assertTrue(e.getMessage().contains("ensure enough disk space
has been allocated"), e.getMessage());
+ Assertions.assertNull(
+ tinyManager.getLocations().get(0).getCacheEntry(new
SegmentCacheEntryIdentifier(SEGMENT_ID)),
+ "failed reservation must not leave a cache entry behind"
+ );
+ }
+ finally {
+ tinyManager.shutdown();
+ }
+ }
+
@Test
void testGetCachedSegmentsThenBootstrapMountsPartialEntry()
throws IOException, SegmentLoadingException
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]