InvisibleProgrammer commented on code in PR #6766:
URL: https://github.com/apache/hive/pull/6766#discussion_r3987615478


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java:
##########
@@ -395,6 +396,98 @@ public void testSkip2() throws Exception {
     }
 
   }
+
+  /**
+   * Simulates the HA scenario where MScheduledExecution#scheduledExecutionId 
values (assigned by
+   * DataNucleus's per-instance pre-allocated "native" id blocks) do not 
correlate with true
+   * completion order (tracked by endTime).
+   *
+   * Three executions are created for a single scheduled query with ids 
assigned in natural,
+   * increasing creation order (exec1 < exec2 < exec3). exec1's and 
exec2's endTime are then
+   * rewritten directly (through the same PersistenceManager machinery 
ObjectStore itself uses) so
+   * their completion order is the reverse of their id order -- exactly the 
symptom of the HA id
+   * pre-allocation bug -- without needing an actual multi-instance cluster.
+   *
+   * With autoDisableCount=2, skipCount=0 (lastN=2):
+   * - Ordering by id descending (the old, buggy behavior) picks {exec3 
FAILED, exec2 FAILED} as
+   *   the "last 2 executions" -> 2 consecutive failures -> incorrectly 
disabled.
+   * - Ordering by endTime (the fix) picks {exec1 FINISHED, exec3 FAILED} as 
the "last 2
+   *   executions" -> the FINISHED row breaks the failure streak -> 
correctly NOT disabled.
+   *
+   * This test asserts the correct outcome, so it fails against the unfixed
+   * ObjectStore#processScheduledQueryPolicies and passes once its ordering 
uses endTime instead
+   * of scheduledExecutionId.

Review Comment:
   Also refactored the test itself. 



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