jadami10 commented on code in PR #13488:
URL: https://github.com/apache/pinot/pull/13488#discussion_r1667762881


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -677,14 +678,30 @@ public RebalanceResult rebalance(
         if (dryRunResult.getStatus() == RebalanceResult.Status.DONE) {
           // If dry-run succeeded, run rebalance asynchronously
           rebalanceConfig.setDryRun(false);
-          _executorService.submit(() -> {
+          Future<RebalanceResult> rebalanceResultFuture = 
_executorService.submit(() -> {
             try {
-              _pinotHelixResourceManager.rebalanceTable(tableNameWithType, 
rebalanceConfig, rebalanceJobId, true);
+              return _pinotHelixResourceManager.rebalanceTable(
+                  tableNameWithType, rebalanceConfig, rebalanceJobId, true);
             } catch (Throwable t) {
-              LOGGER.error("Caught exception/error while rebalancing table: 
{}", tableNameWithType, t);
+              String errorMsg = String.format("Caught exception/error while 
rebalancing table: %s", tableNameWithType);
+              LOGGER.error(errorMsg, t);
+              return new RebalanceResult(rebalanceJobId, 
RebalanceResult.Status.FAILED, errorMsg, null, null, null);
             }
           });
-          waitForJobIdToPersist(dryRunResult.getJobId(), tableNameWithType);
+          boolean isJobIdPersisted = 
waitForJobIdToPersist(dryRunResult.getJobId(), tableNameWithType);
+
+          // It's possible the dryRun indicates a rebalance is needed, but 
next rebalance is not.
+          // In that case, we never persist the jobId, but will already have a 
rebalanceResult.
+          // Return the actual rebalanceResult in this case.
+          if (!isJobIdPersisted && rebalanceResultFuture.isDone()) {

Review Comment:
   ya, i figured I'd leave the old behavior. But we might as well just return 
if done.



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to