Jackie-Jiang commented on code in PR #20291:
URL: https://github.com/apache/pinot/pull/20291#discussion_r4650964979
##########
pinot-controller/src/test/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResourceTest.java:
##########
@@ -217,6 +226,37 @@ public void
testGetSegmentsWithInvalidPartitionMetadataWithColumnFilter()
assertTrue(result.containsKey("seg3"));
}
+ /// 1 segment x 3 replicas without columns is 3 entries. Every case is
rejected before any server is contacted.
+ @Test
+ public void testGetServerMetadataEntryLimits()
+ throws Exception {
+ ControllerConf controllerConf = new ControllerConf();
+
controllerConf.setProperty(ControllerConf.SEGMENT_METADATA_DEFAULT_ENTRY_LIMIT,
2);
+
controllerConf.setProperty(ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT, 10);
+ _pinotSegmentRestletResource._controllerConf = controllerConf;
+
when(_pinotHelixResourceManager.getExistingTableNamesWithType(eq("testTable"),
any()))
+ .thenReturn(List.of("testTable_OFFLINE"));
+
when(_pinotHelixResourceManager.getServerToSegmentsMap("testTable_OFFLINE"))
+ .thenReturn(Map.of("server0", List.of("seg0"), "server1",
List.of("seg0"), "server2", List.of("seg0")));
+
+ // Omitted: the configured default applies
+ assertServerMetadataRejected(null, "above the limit of 2");
+ // Explicit: overrides the default, so a smaller value applies too
+ assertServerMetadataRejected(1, "above the limit of 1");
+ // Explicit: must be positive and at most the configured max
+ assertServerMetadataRejected(0,
ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT);
+ assertServerMetadataRejected(11,
ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT);
Review Comment:
Could we add one successful REST-resource case as well? With default entry
limit 2, maximum 3, and three segment replicas without columns, an explicit
`maxEntries=3` should succeed.
The current cases all reject. This positive case would verify that callers
can raise the budget above the configured default and that the maximum is
inclusive. A lightweight fake-server setup should be enough; no new integration
cluster is needed.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/TableMetadataReader.java:
##########
@@ -128,11 +133,29 @@ private TableReloadJsonResponse
processSegmentMetadataReloadResponse(
/// This api takes in list of segments for which we need the metadata.
/// This calls the server to get the metadata for all segments instead of
making a call per segment.
+ /// Fetches at most the default
`controller.segment.metadata.max.entry.limit` entries.
public JsonNode getSegmentsMetadata(String tableNameWithType, @Nullable
List<String> columns,
@Nullable List<String> segments, int timeoutMs)
throws InvalidConfigException, IOException {
+ return getSegmentsMetadata(tableNameWithType, columns, segments, timeoutMs,
+ ControllerConf.DEFAULT_SEGMENT_METADATA_MAX_ENTRY_LIMIT);
Review Comment:
Could we preserve the existing four-argument overload's behavior and apply
the new limit through the explicit-budget overload used by the REST endpoint?
This overload has downstream callers, and it now introduces a fixed
100,000-entry limit that is independent of both controller configs. For
example, 1,000 segments with three replicas and 40 columns count as 123,000
entries, so a previously successful call now fails; raising
`controller.segment.metadata.max.entry.limit` cannot restore it because this
path uses the constant.
I would retain the overload for compatibility and preserve its previous
behavior, unless we deliberately migrate downstream callers to the
explicit-budget overload. Keeping the signature alone does not preserve the
existing behavior.
##########
pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java:
##########
@@ -299,6 +300,40 @@ public void testSegmentReplaceConvergenceCustomValues() {
Assert.assertEquals(conf.getSegmentReplaceMaxRetryAttempts(), 2);
}
+ @DataProvider
+ public Object[][] segmentMetadataEntryLimits() {
+ return new Object[][]{
+ // default, max, valid
+ {10_001, 10_000, false},
+ {10_000, 10_000, true},
+ {1, 10_000, true},
+ {0, 10_000, false},
+ {-1, 10_000, false}
+ };
+ }
+
+ @Test(dataProvider = "segmentMetadataEntryLimits")
+ public void testSegmentMetadataEntryLimitsValidation(int defaultLimit, int
maxLimit, boolean valid) {
+ ControllerConf conf = new ControllerConf();
+ conf.setProperty(ControllerConf.SEGMENT_METADATA_DEFAULT_ENTRY_LIMIT,
defaultLimit);
+ conf.setProperty(ControllerConf.SEGMENT_METADATA_MAX_ENTRY_LIMIT,
maxLimit);
+
+ if (valid) {
+ conf.validateSegmentMetadataEntryLimits();
+ } else {
+ Assert.expectThrows(IllegalStateException.class,
conf::validateSegmentMetadataEntryLimits);
Review Comment:
Small style cleanup: please statically import `expectThrows` and use it
directly in both new assertions here and in
`testSegmentMetadataMaxEntryLimitBelowDefault`, following the repository
convention for TestNG assertions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]