@Override
  public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperationException, MetaException {
    if (timeoutSecs < 0) {
      LOG.debug("scheduled executions - time_out mark is disabled");
      return 0;
    }
    boolean committed = false;
    Query q = null;
    try {
      openTransaction();
      int maxLastUpdateTime = (int) (System.currentTimeMillis() / 1000) - timeoutSecs;
      q = pm.newQuery(MScheduledExecution.class);
      q.setFilter("lastUpdateTime <= maxLastUpdateTime && (state == 'INITED' || state == 'EXECUTING')");
      q.declareParameters("int maxLastUpdateTime");

      List<MScheduledExecution> results = (List<MScheduledExecution>) q.execute(maxLastUpdateTime);
      for (MScheduledExecution e : results) {

        ScheduledQueryProgressInfo info = new ScheduledQueryProgressInfo();
        info.setScheduledExecutionId(e.getScheduledExecutionId());
        info.setState(QueryState.TIMED_OUT);
        info.setErrorMessage(
            "Query stuck in: " + e.getState() + " state for >" + timeoutSecs + " seconds. Execution timed out.");
        //        info.set
        scheduledQueryProgress(info);
      }

      recoverInvalidScheduledQueryState(timeoutSecs);
      committed = commitTransaction();
      return results.size();
    } finally {
      rollbackAndCleanup(committed, q);
    }
  }
Abbreviates the error message to the given size.

There might be error messages which may also contain a stack trace.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java