-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let the controller getTableInstance() call to return the list of live brokers of a table. #7556
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7556 +/- ##
============================================
- Coverage 72.67% 70.39% -2.28%
- Complexity 3413 4021 +608
============================================
Files 1524 1578 +54
Lines 75702 80219 +4517
Branches 11039 11908 +869
============================================
+ Hits 55017 56473 +1456
- Misses 16995 19878 +2883
- Partials 3690 3868 +178
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments. LGTM otherwise
return getTableToBrokersMapFromExternalView(true, false); | ||
} | ||
|
||
private Map<String, List<String>> getTableToBrokersMapFromExternalView(boolean tableWithType, boolean useUrlFormat) { | ||
Map<String, Set<String>> brokerUrlsMap = new HashMap<>(); | ||
try { | ||
byte[] brokerResourceNodeData = _zkClient.readData("/EXTERNALVIEW/brokerResource", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can reuse the BROKER_EXTERNAL_VIEW_PATH constant to replace String "/EXTERNALVIEW/brokerResource" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
public Map<String, List<String>> getTableToBrokersMap() { | ||
return getTableToBrokersMapFromExternalView(false, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil: newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
public List<String> getLiveBrokersForTable(String tableNameWithType) { | ||
ExternalViewReader externalViewReader = new ExternalViewReader(new ZkClient(_helixZkURL)); | ||
Map<String, List<String>> tableToBrokersMap = externalViewReader.getTableWithTypeToRawBrokerInstanceIdsMap(); | ||
return tableToBrokersMap == null ? null : tableToBrokersMap.get(tableNameWithType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we return empty map other than null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revised to return empty map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not modify the existing API and change its behavior. Users might rely on it for other purpose other than routing the queries.
I'd suggest adding another API to get the live brokers for a given table
...-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableInstances.java
Outdated
Show resolved
Hide resolved
...-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableInstances.java
Outdated
Show resolved
Hide resolved
...-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableInstances.java
Outdated
Show resolved
Hide resolved
@ApiResponse(code = 500, message = "Internal server error")}) | ||
public String getTableBrokers( | ||
@ApiParam(value = "Table name without type", required = true) @PathParam("tableName") String tableName) { | ||
ObjectNode ret = JsonUtils.newObjectNode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not reuse the response format for this new API. Would suggest just returning an array of live brokers.
- If the input is a table name with type, returns the live brokers for the table, or 404 if table is not found
- If the input is a raw table name, if both offline and realtime table exist, return the brokers live for both tables (we should only route query to the broker with both tables online); if only one table exist, return the live brokers for the single table; if no table is found, return 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this API to return as close to what the zookeeper stores as possible. Today the zk stores one typed table entries. It is better to returns the typed table entries as well. In this way this API can serve multiple purposes than just querying routing. For example, one may even use it to detect if there is any problem with hybrid table's broker assignment. We can leave it to the client to do what they want to do with the returned results -- they can do intersection if they want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, 99% of the usage for this API would be to find the brokers to route the query, and returning brokers for each individual table and let the user do the intersection is not easy to use, and can confuse the user. If we do want to get the brokers for the individual table, we can put the table name with type. This way, the API is easy to use, and it can also achieve the debugging purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to return the list of live brokers given a tablename with type.
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/pinot/controller/helix/core/util/BrokerResourceExternalViewReader.java
Outdated
Show resolved
Hide resolved
.../main/java/org/apache/pinot/controller/helix/core/util/BrokerResourceExternalViewReader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
...-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableInstances.java
Outdated
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Outdated
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Show resolved
Hide resolved
… brokers of a table. (apache#7556) * Let getTableInstance() call to return the list of live brokers. * Fix lint errors. * Fix lint errors. * Fix unit tests * Revise based on comments. * Fix based on comments. * Add a new controller end point. * Fix linters. * Revise based on comments * Revise based on comments * Revised based on comments.
Description
Fix the issue described in #7491. Today the controller getTableInstance api gets the brokers serving a table based on the table's broker tenant config. It fetches the brokers list based only on the tenant info. Some of the brokers in the returned list may not in fact serve the table if they are just added to the tenant. This PR fixes the issue by fetching the brokers from the broker external view.
Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
backward-incompat
, and complete the section below on Release Notes)Does this PR fix a zero-downtime upgrade introduced earlier?
backward-incompat
, and complete the section below on Release Notes)Does this PR otherwise need attention when creating release notes? Things to consider:
release-notes
and complete the section on Release Notes)Release Notes
Documentation