Jackie-Jiang commented on code in PR #20291:
URL: https://github.com/apache/pinot/pull/20291#discussion_r4622264031
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -661,16 +661,27 @@ private void deleteSegmentsInternal(String
tableNameWithType, List<String> segme
@Authorize(targetType = TargetType.TABLE, paramName = "tableName", action =
Actions.Table.GET_METADATA)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get the server metadata for all table segments",
- notes = "Get the server metadata for all table segments")
+ notes = "Get the server metadata for all table segments. Rejected when
segments x columns x replicas exceeds "
+ + "maxSegmentColumns")
public String getServerMetadata(
@ApiParam(value = "Name of the table", required = true)
@PathParam("tableName") String tableName,
@ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String
tableTypeStr,
@ApiParam(value = "Segments to include (all if not specified)",
allowMultiple = true) @QueryParam("segments")
List<String> segments,
@ApiParam(value = "Columns to include (use '*' to include all)",
allowMultiple = true) @QueryParam("columns")
List<String> columns,
+ @ApiParam(value = "Max (segment, column) entries, replicas included, to
fetch. Capped by "
+ + "controller.segment.metadata.maxSegmentColumns.limit")
+ @DefaultValue("50000")
+ @QueryParam("maxSegmentColumns") int maxSegmentColumns,
@Context HttpHeaders headers) {
tableName = DatabaseUtils.translateTableName(tableName, headers);
+ int limit = _controllerConf.getSegmentMetadataMaxSegmentColumnsLimit();
+ if (maxSegmentColumns <= 0 || maxSegmentColumns > limit) {
Review Comment:
Could we make both the default request budget and the hard cap controller
configs, using lowercase, dot-separated keys?
```properties
controller.segment.metadata.default.entry.limit=50000
controller.segment.metadata.max.entry.limit=100000
```
With the fixed `@DefaultValue("50000")`, lowering the configured cap to
10,000 makes every request that omits `maxSegmentColumns` fail HTTP 400 before
its actual size is checked, even a request for one segment and one column. The
existing Java admin client overloads omit this parameter, so narrowing their
segment/column selection cannot recover these calls.
Two configs let operators tune the normal budget independently of the
maximum callers can request, and also let them adjust the default for clients
that do not expose the query parameter. Validate `0 < defaultEntryLimit <=
maxEntryLimit` once at controller startup, with a clear error naming both keys
and values. Equality should be allowed. An omitted query parameter should use
the configured default; an explicit value should retain the positive-value and
cap checks. This requires resolving the default in code rather than through a
fixed `@DefaultValue`.
The parallel `default.entry.limit` / `max.entry.limit` names also make the
policy clearer than a limit on `maxSegmentColumns`.
##########
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.maxSegmentColumns.limit` (segment, column) 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_SEGMENT_COLUMNS_LIMIT);
+ }
+
+ /// Same as above, but rejects the request before calling any server when it
would fetch more than
+ /// `maxSegmentColumns` (segment, column) entries, replicas included.
+ public JsonNode getSegmentsMetadata(String tableNameWithType, @Nullable
List<String> columns,
+ @Nullable List<String> segments, int timeoutMs, int maxSegmentColumns)
+ throws InvalidConfigException, IOException {
Map<String, List<String>> serverToSegs =
_pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType);
+ long numSegments = countSegmentReplicas(serverToSegs, segments);
+ int numColumns = getNumColumns(tableNameWithType, columns);
+ long numEntries = numSegments * numColumns;
Review Comment:
Could we count the segment-level metadata itself as one entry, in addition
to the requested column metadata?
```text
entries = segmentReplicaCount * (1 + columnCount)
```
The server returns base segment metadata even when columns are requested.
Currently, no columns and one column have the same weight, although the
one-column response contains both the base metadata and the column metadata.
Adding one gives the estimate a consistent baseline while keeping it simple;
the schema count is sufficient for `*`.
With this formula, `getNumColumns()` should return 0 when columns are
omitted, and return the schema column count directly for `*` without
`Math.max(..., 1)`. For one segment with three replicas, no columns would count
as 3 entries, one column as 6, and five columns as 18. The no-column budget
remains unchanged; one-column requests count twice as much as before, while
wide requests change only slightly.
Document an entry as either a segment metadata entry or a column metadata
entry, with replicas included, and cover these cases in the boundary tests.
--
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]