private boolean checkRetryable(SQLException e, SqlRetryCallProperties properties) {

    LOG.error("Execution error, checking if retry is possible", e);
    
    // If you change this function, remove the @Ignore from TestTxnHandler.deadlockIsDetected()
    // to test these changes.
    // MySQL and MSSQL use 40001 as the state code for rollback.  Postgres uses 40001 and 40P01.
    // Oracle seems to return different SQLStates and messages each time,
    // so I've tried to capture the different error messages (there appear to be fewer different
    // error messages than SQL states).
    // Derby and newer MySQL driver use the new SQLTransactionRollbackException
    boolean retry = false;
    if (isRetryable(conf, e)) {
      //in MSSQL this means Communication Link Failure
      retry = waitForRetry(properties.getCaller(), e.getMessage(), properties.getRetryCount());
    } else if (properties.isRetryOnDuplicateKey() && databaseProduct.isDuplicateKeyError(e)) {
      retry = waitForRetry(properties.getCaller(), e.getMessage(), properties.getRetryCount());
    } else {
      //make sure we know we saw an error that we don't recognize
      LOG.info("Non-retryable error in {} : {}", properties.getCaller(), getMessage(e));
    }
    return retry;
  }
Determine if an exception was such that it makes sense to retry.  Unfortunately there is no standard way to do
this, so we have to inspect the error messages and catch the telltale signs for each
different database.
if the error is retry-able.
@param e exception that was thrown.
@param properties {@link SqlRetryCallProperties} instance containing the rety call settings
@return True if retry is possible, false otherwise.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/retry/SqlRetryHandler.java