Skip to content

Enhance BrokerResourceValidationManager to support logical table partitions in resource validation#17842

Open
abhishekbafna wants to merge 8 commits intoapache:masterfrom
abhishekbafna:logocal_table/broker_resources
Open

Enhance BrokerResourceValidationManager to support logical table partitions in resource validation#17842
abhishekbafna wants to merge 8 commits intoapache:masterfrom
abhishekbafna:logocal_table/broker_resources

Conversation

@abhishekbafna
Copy link
Collaborator

@abhishekbafna abhishekbafna commented Mar 9, 2026

Summary

This PR updates BrokerResourceValidationManager so that the periodic broker resource validation runs for logical table partitions in the broker resource in addition to physical tables. It closes the gap identified in Issue #15751: after PR #15726, the broker resource includes logical tables, but the validation/repair logic only considered physical tables, so logical table broker assignments were never corrected when brokers were added or removed.

Problem

  • The broker resource ideal state holds both physical table partitions (tableName_OFFLINE / tableName_REALTIME) and logical table partition names.
  • BrokerResourceValidationManager previously only used getAllTables() (physical tables), so logical table partitions were never validated or repaired.
  • When new brokers were added, logical table entries could remain out of sync (missing the new broker); the periodic task did not fix them.

Solution

  1. getTablesToProcess
    In addition to physical tables from the base implementation, the task now includes partition names for logical tables by calling PinotHelixResourceManager.getBrokerResourceLogicalTablePartitions(), so both physical and logical broker-resource partitions are processed.

  2. processTable
    For each partition name, type is determined by config presence (not by name): look up table config first; if present, treat as physical and resolve broker instances from the table config's broker tenant; otherwise look up logical table config and, if present, resolve from LogicalTableConfig.getBrokerTenant(). Then rebuildBrokerResource is invoked. If neither config exists, the partition is skipped with a warning.

  3. Tests

    • BrokerResourceValidationManagerTest (new): unit tests that getTablesToProcess returns both physical tables and logical table partitions, and that the table-name property still restricts to a single table.
    • PinotHelixResourceManagerStatelessTest: testUpdateBrokerResourceWithLogicalTable (broker add + rebuild for logical table), testRebuildBrokerResourceFromHelixTagsForLogicalTable (rebuild API for logical table name).
    • ValidationManagerStatelessTest: testRebuildBrokerResourceWhenBrokerAddedForLogicalTable (rebuild for logical table after broker add).
    • ControllerPeriodicTasksIntegrationTest: testBrokerResourceValidationManagerRepairsLogicalTable (periodic task repairs logical table partition when a new broker is added).

Result

  • Logical table partitions in the broker resource are now included in the periodic validation and repaired when broker sets change (e.g. new brokers added).
  • Backward compatible: when PROPERTY_KEY_TABLE_NAME is set, only that table/partition is processed; otherwise physical tables plus logical table partitions are processed.

Related

  • Issue: #15751 – Broker resource management for logical tables
  • Context: PR #15726 added logical tables to the broker resource; this PR ensures the validation manager handles them.

@abhishekbafna abhishekbafna requested review from Jackie-Jiang and Copilot and removed request for Copilot March 9, 2026 16:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates broker-resource validation so it also processes logical-table partitions, ensuring broker assignments for logical tables are periodically repaired when broker membership changes (Issue #15751).

Changes:

  • Extend controller periodic-task plumbing to allow subclasses to customize the table/partition list and processing filter.
  • Enhance BrokerResourceValidationManager to include logical-table broker-resource partitions and rebuild them using LogicalTableConfig.
  • Add unit, stateless, and integration tests covering logical-table broker-resource rebuild and periodic repair.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ControllerPeriodicTasksIntegrationTest.java Adds an integration test verifying periodic validation repairs logical-table broker partitions after adding a broker.
pinot-controller/src/test/java/org/apache/pinot/controller/validation/ValidationManagerStatelessTest.java Adds stateless test for rebuilding broker resource for a logical table after manual broker addition.
pinot-controller/src/test/java/org/apache/pinot/controller/validation/BrokerResourceValidationManagerTest.java New unit tests validating logical partitions are included in getTablesToProcess behavior.
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManagerStatelessTest.java Adds stateless tests for rebuild/update paths involving logical-table partitions.
pinot-controller/src/main/java/org/apache/pinot/controller/validation/BrokerResourceValidationManager.java Includes logical-table partitions in periodic validation and resolves broker tenants for logical tables.
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java Introduces overridable hooks for “tables to process” and “should process” filtering.
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java Adds logical-partition discovery, supports rebuild-by-tags for logical tables, and updates broker ideal state atomically.
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java Includes logical tables when mapping broker tags to tables.

@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 56.89655% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.25%. Comparing base (079206a) to head (4f0a013).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ntroller/helix/core/PinotHelixResourceManager.java 50.00% 12 Missing and 1 partial ⚠️
...er/validation/BrokerResourceValidationManager.java 35.29% 11 Missing ⚠️
...g/apache/pinot/common/utils/helix/HelixHelper.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17842      +/-   ##
============================================
- Coverage     63.27%   63.25%   -0.02%     
- Complexity     1468     1481      +13     
============================================
  Files          3190     3190              
  Lines        192197   192282      +85     
  Branches      29456    29474      +18     
============================================
+ Hits         121612   121628      +16     
- Misses        61060    61120      +60     
- Partials       9525     9534       +9     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 63.20% <56.89%> (-0.02%) ⬇️
java-21 63.22% <56.89%> (-0.01%) ⬇️
temurin 63.25% <56.89%> (-0.02%) ⬇️
unittests 63.25% <56.89%> (-0.02%) ⬇️
unittests1 55.57% <0.00%> (-0.01%) ⬇️
unittests2 34.27% <56.89%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

return tables;
}
List<String> combined = new ArrayList<>(tables);
combined.addAll(_pinotHelixResourceManager.getBrokerResourceLogicalTablePartitions());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can / Should this task run on non-leaders for logical tables ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Running on the non-leader would get the update from all the controllers.

_pinotHelixResourceManager.rebuildBrokerResource(tableNameWithType, brokerInstances);
LogicalTableConfig logicalTableConfig = _pinotHelixResourceManager.getLogicalTableConfig(tableNameWithType);
if (logicalTableConfig != null) {
Set<String> brokerInstances = _pinotHelixResourceManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does logical table config have a broker tenant? What happens if a physical table's broker tenant is different from a logical table's broker tenant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brokerTenant in the logical table is used to identity the broker node which should be used for the querying. For a logical table, the broker tenant of the physical table can be different and it would not be used, as much I remember.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.


You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants