codewithsruthi opened a new pull request, #20380:
URL: https://github.com/apache/pinot/pull/20380

   Fixes #19853
   
   ### Summary
   Adds a new controller REST endpoint `GET 
/segments/{tableNameWithType}/serverCrcs` that fans out to servers hosting a 
table and returns the **server-loaded CRC of every segment per replica**, 
preserving per-replica visibility without requiring direct access to server 
admin APIs.
   
   ### Motivation
   When offline ingestion jobs re-upload (refresh) existing segments, the 
controller updates ZK metadata and sends a fire-and-forget `REFRESH_SEGMENT` 
message without a completion signal or IdealState/ExternalView transition. 
Existing controller APIs cannot verify cluster-wide refresh completion:
   - `GET /segments/{tableName}/crc` returns ZK CRCs only (`OFFLINE` tables 
only).
   - `GET /segments/{tableName}/metadata` collapses responses by segment name 
across servers, losing per-replica visibility.
   - `GET /segments/{tableNameWithType}/isStale` checks table config / schema / 
index drift rather than loaded CRC vs. ZK CRC.
   - Server `GET /tables/{tableName}/segments/crc` already exposes loaded CRCs 
per server, but server admin endpoints are often unreachable from offline 
validation jobs.
   
   ### API Details
   ```http
   GET /segments/{tableNameWithType}/serverCrcs?segments=seg_A&segments=seg_B
   ```
   
   **Response (`200 OK`, `application/json`):**
   ```json
   {
     "seg_A": {
       "Server_host1_8098": "111",
       "Server_host2_8098": "999"
     },
     "seg_B": {
       "Server_host1_8098": "222",
       "Server_host3_8098": "222"
     }
   }
   ```
   
   - **Path parameter**: `tableNameWithType` (required, e.g. `myTable_OFFLINE` 
or `myTable_REALTIME`); returns `400` if type suffix is omitted and `404` if 
the table does not exist. Supports `database` header translation.
   - **Query parameter**: `segments` (optional, repeatable). When provided, the 
controller narrows fan-out to only servers hosting the requested segments and 
filters the returned map on the controller side (requiring no `pinot-server` 
changes and preserving full mixed-version rolling upgrade compatibility).
   - **Authorization**: `Actions.Table.GET_SEGMENT_MAP` (matching `GET 
/segments/{tableName}/crc`).
   - **Failure semantics**: Fails fast with `500` if any queried server fails, 
times out, or returns invalid/null JSON, so a `200 OK` response never silently 
drops an unreachable server.
   - **Realtime note**: Mutable (`CONSUMING`) segments report `"-1"` from 
`SegmentDataManager.getCrc()`.
   
   ### Changes
   - `ServerSegmentMetadataReader`: Added `getSegmentCrcsFromServers(...)` and 
`generateSegmentsCrcServerURL(...)` to fan out to 
`/tables/{tableNameWithType}/segments/crc`, fail fast on server errors, filter 
optional segments, and transpose into `Map<segment, Map<server, crc>>`.
   - `TableMetadataReader`: Added `getSegmentCrcs(...)` using IdealState 
assignments (`getServerToSegmentsMap`) with target-server narrowing when 
`segments` is specified.
   - `PinotSegmentRestletResource`: Added `GET 
/segments/{tableNameWithType}/serverCrcs` and updated class-level API docs to 
distinguish ZK CRCs (`/crc`) from server-loaded CRCs (`/serverCrcs`).
   - Unit tests in `TableMetadataReaderTest` and 
`PinotSegmentRestletResourceTest`.
   
   ### Testing
   - Added unit tests covering:
     - Per-replica transposition, including divergent CRCs across replicas 
mid-refresh
     - `segments` filtering and narrowed server fan-out (uninvolved servers are 
not queried)
     - Empty tables and unmatched segment filters
     - Healthy server missing an assigned segment
     - Fail-fast error handling (`404`, `500`, malformed JSON, `null` JSON, 
`InvalidConfigException`)
     - Table type / existence validation (`400` / `404`) and `database` header 
translation
   - Ran:
     - `./mvnw -pl pinot-controller spotless:apply license:format 
checkstyle:check license:check`
     - `./mvnw -pl pinot-controller -am 
-Dtest=TableMetadataReaderTest,org.apache.pinot.controller.api.resources.PinotSegmentRestletResourceTest
 -Dsurefire.failIfNoSpecifiedTests=false test` (28 tests run, 0 failures, 0 
errors)


-- 
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]

Reply via email to