@Test
  public void testOutdatedCleanup() throws Exception {
    String namespace = "outdatedcleanup";
    ObjectStore objStore = new ObjectStore();
    objStore.setConf(metaStore.getConf());
    objStore.deleteScheduledExecutions(0);

    ScheduledQuery schq = createScheduledQuery(new ScheduledQueryKey("q1", namespace));
    ScheduledQueryMaintenanceRequest r = new ScheduledQueryMaintenanceRequest();
    r.setType(ScheduledQueryMaintenanceRequestType.CREATE);
    r.setScheduledQuery(schq);
    objStore.scheduledQueryMaintenance(r);

    Thread.sleep(1000);
    ScheduledQueryPollRequest request = new ScheduledQueryPollRequest(namespace);
    ScheduledQueryPollResponse pollResult = objStore.scheduledQueryPoll(request);
    // will add q1 as a query being executed

    Thread.sleep(1000);
    objStore.markScheduledExecutionsTimedOut(0);

    try (PersistenceManager pm = PersistenceManagerProvider.getPersistenceManager()) {
      MScheduledExecution execution = pm.getObjectById(MScheduledExecution.class, pollResult.getExecutionId());
      assertEquals(QueryState.TIMED_OUT, execution.getState());
    }
  }
Simulates some schq failure scenario.

Q1 is executed correctly 1 time; but every further executions are end with failures
Q2 should be executed without without issues even thru Q1 will be disabled at some point
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java