shu-chen-dot-ca opened a new pull request, #20395:
URL: https://github.com/apache/pinot/pull/20395
Fixes #20388.
## Problem
A stage that requires a singleton instance (for example a `FULL` join
without equi keys) fails to plan when one of its children is a table with
`tableOptions(is_replicated='true')`:
```
java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because
"senderServerMap" is null
at
org.apache.pinot.query.planner.physical.MailboxAssignmentVisitor.process(MailboxAssignmentVisitor.java:60)
```
`WorkerManager.assignWorkersToIntermediateFragment()` assigns the workers of
replicated leaf children in the loop at the end of the method. The
`isRequiresSingletonInstance()` branch returns before that loop, so the
replicated leaf never gets a worker map.
## Fix
The singleton branch now also assigns its replicated leaf children. Each
gets exactly one worker, which scans the whole table. More than one leaf worker
would each send the whole table to the single worker of the stage and duplicate
the rows.
The server of that worker comes from
`getCandidateServersForReplicatedLeaf(context, List.of(singletonServer))`, the
same hook the non-singleton path uses. By default the leaf runs on the same
server as the singleton stage. A subclass that runs intermediate stages on
instances that cannot scan segments still gets a server from its override; the
first one of the returned list is used. An empty list fails with a clear
message instead of an `IndexOutOfBoundsException`.
## Testing
- New `WorkerManagerTest#testSingletonJoinWithReplicatedLeaf`, with
`useLeafServerForIntermediateStage` off and on, over 4 servers: the join has
one worker, the replicated leaf has one worker on the same server with all
segments of the table, and the other side keeps its assignment. Both cases fail
on master with the NPE above.
- New
`WorkerManagerTest#testSingletonJoinWithReplicatedLeafUsesReplicatedLeafServers`:
with a `WorkerManager` that runs intermediate stages on a broker-like
instance, the replicated leaf gets one worker on a server that hosts the table.
- `./mvnw -pl pinot-query-planner,pinot-query-runtime checkstyle:check
license:check test` passes (5672 tests, 191 skipped). I did not run the full
reactor build.
- `spotless:apply` and `license:format` on `pinot-query-planner` changed
nothing.
- Manual check on a batch quickstart cluster (one server), multi-stage
engine. The query below fails with the NPE before the change and returns rows
after it:
```sql
SELECT a.playerName, dimBaseballTeams.teamName
FROM (SELECT playerName, teamID FROM baseballStats WHERE homeRuns > 60) a
FULL JOIN dimBaseballTeams /*+ tableOptions(is_replicated='true') */ ON
a.teamID > dimBaseballTeams.teamID
ORDER BY 1, 2 LIMIT 5
```
`COUNT(*)`, `COUNT(a.playerName)` and `COUNT(dimBaseballTeams.teamName)`
of this join are 214 / 209 / 214 both with and without the hint. Also checked
on the cluster: the hint on the left side, the hint on both sides (same count
as without hints), `ON true`, an empty non-replicated side, and
`useLeafServerForIntermediateStage=true`.
| Before | After |
| --- | --- |
|

|

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