Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); long latestValidStart = getDbTime(dbConn) - timeout; stmt = dbConn.createStatement(); String s = "update COMPACTION_QUEUE set cq_worker_id = null, cq_start = null, cq_state = '" e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "revokeTimedoutWorkers(timeout:" + timeout + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeStmt(stmt); closeDbConn(dbConn); revokeTimedoutWorkers(timeout);
dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "select txn_id from TXNS where " + List<Long> txnids = new ArrayList<>(); while (rs.next()) txnids.add(rs.getLong(1)); close(rs); if(txnids.size() <= 0) { return; LOG.error("Unable to delete from txns table " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "cleanEmptyAbortedTxns"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, stmt, dbConn); cleanEmptyAbortedTxns();
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); String quote = getIdentifierQuoteString(dbConn); StringBuilder bldr = new StringBuilder(); bldr.append("SELECT ").append(quote).append("COLUMN_NAME").append(quote) return columns; } catch (SQLException e) { rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findColumnsWithStats(" + ci.tableName + (ci.partName == null ? "" : "/" + ci.partName) + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, pStmt, dbConn); return findColumnsWithStats(ci);
@Override public long findMinOpenTxnId() throws MetaException { Connection dbConn = null; Statement stmt = null; ResultSet rs = null; try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); return findMinOpenTxnGLB(stmt); } catch (SQLException e) { LOG.error("Unable to findMinOpenTxnId() due to:" + e.getMessage()); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findMinOpenTxnId"); throw new MetaException("Unable to execute findMinOpenTxnId() " + StringUtils.stringifyException(e)); } finally { close(rs, stmt, dbConn); } } catch (RetryException e) { return findMinOpenTxnId(); } }
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "update COMPACTION_QUEUE set CQ_HADOOP_JOB_ID = " + quoteString(hadoopJobId) + " WHERE CQ_ID = " + id; LOG.debug("Going to execute <" + s + ">"); int updateCount = stmt.executeUpdate(s); LOG.debug("Going to commit"); closeStmt(stmt); dbConn.commit(); } catch (SQLException e) { LOG.warn("setHadoopJobId(" + hadoopJobId + "," + id + "):" + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); try { checkRetryable(dbConn, e, "setHadoopJobId(" + hadoopJobId + "," + id + ")"); close(null, stmt, dbConn); setHadoopJobId(hadoopJobId, id);
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "update COMPACTION_QUEUE set cq_state = '" + READY_FOR_CLEANING + "', " + LOG.error("Unable to update compaction queue " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "markCompacted(" + info + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeStmt(stmt); closeDbConn(dbConn); markCompacted(info);
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "update COMPACTION_QUEUE set cq_worker_id = null, cq_start = null, cq_state = '" e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "revokeFromLocalWorkers(hostname:" + hostname +")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeStmt(stmt); closeDbConn(dbConn); revokeFromLocalWorkers(hostname);
dbConn = getDbConn(Connection.TRANSACTION_SERIALIZABLE); stmt = dbConn.createStatement(); String s = "select cq_id, cq_database, cq_table, cq_partition, " + long now = getDbTime(dbConn); s = "update COMPACTION_QUEUE set cq_worker_id = '" + workerId + "', " + "cq_start = " + now + ", cq_state = '" + WORKING_STATE + "' where cq_id = " + info.id; LOG.error("Unable to select next element for compaction, " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findNextToCompact(workerId:" + workerId + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); closeStmt(stmt); return findNextToCompact(workerId);
ResultSet rs = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "select cq_id, cq_database, cq_table, cq_partition, " + info.tableName = rs.getString(3); info.partName = rs.getString(4); info.type = dbCompactionType2ThriftType(rs.getString(5).charAt(0)); info.properties = rs.getString(6); long now = getDbTime(dbConn); s = "update COMPACTION_QUEUE set cq_worker_id = '" + workerId + "', " + "cq_start = " + now + ", cq_state = '" + WORKING_STATE + "' where cq_id = " + info.id + LOG.error("Unable to select next element for compaction, " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findNextToCompact(workerId:" + workerId + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeStmt(updStmt); close(rs, stmt, dbConn); return findNextToCompact(workerId);
ResultSet rs = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); pStmt = dbConn.prepareStatement("select CQ_ID, CQ_DATABASE, CQ_TABLE, CQ_PARTITION, CQ_STATE, CQ_TYPE, CQ_TBLPROPERTIES, CQ_WORKER_ID, CQ_START, CQ_RUN_AS, CQ_HIGHEST_WRITE_ID, CQ_META_INFO, CQ_HADOOP_JOB_ID from COMPACTION_QUEUE WHERE CQ_ID = ?"); ci.id = generateCompactionQueueId(stmt); ci.start = getDbTime(dbConn); close(rs, stmt, null); closeStmt(pStmt); CompactionInfo.insertIntoCompletedCompactions(pStmt, ci, getDbTime(dbConn)); int updCount = pStmt.executeUpdate(); LOG.debug("Going to commit"); closeStmt(pStmt); dbConn.commit(); } catch (SQLException e) { LOG.warn("markFailed(" + ci.id + "):" + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); try { checkRetryable(dbConn, e, "markFailed(" + ci + ")"); close(rs, stmt, null); close(null, pStmt, dbConn); markFailed(ci);
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_SERIALIZABLE); stmt = dbConn.createStatement(); String s = "select txn_id from TXNS where " + LOG.error("Unable to delete from txns table " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "cleanEmptyAbortedTxns"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); closeStmt(stmt); cleanEmptyAbortedTxns();
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "select cq_id, cq_database, cq_table, cq_partition, " + LOG.error("Unable to select next element for cleaning, " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findReadyToClean"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); closeStmt(stmt); return findReadyToClean();
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_SERIALIZABLE); stmt = dbConn.createStatement(); String s = "delete from COMPACTION_QUEUE where cq_id = " + info.id; LOG.error("Unable to delete from compaction queue " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "markCleaned(" + info + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { closeDbConn(dbConn); closeStmt(stmt); markCleaned(info);
Statement stmt = null; try { dbConn = getDbConn(Connection.TRANSACTION_SERIALIZABLE); stmt = dbConn.createStatement(); String s = "update COMPACTION_QUEUE set cq_run_as = '" + user + "' where cq_id = " + cq_id; LOG.error("Unable to update compaction queue, " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "setRunAs(cq_id:" + cq_id + ",user:" + user +")"); } finally { closeDbConn(dbConn); closeStmt(stmt); setRunAs(cq_id, user);
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); lastCompactedEntity = ci.getFullPartitionName(); rc = new RetentionCounters(MetastoreConf.getIntVar(conf, ConfVars.COMPACTOR_HISTORY_RETENTION_ATTEMPTED), getFailedCompactionRetention(), MetastoreConf.getIntVar(conf, ConfVars.COMPACTOR_HISTORY_RETENTION_SUCCEEDED)); checkForDeletion(deleteSet, ci, rc); close(rs); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "purgeCompactionHistory()"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, stmt, dbConn); closeStmt(pStmt); purgeCompactionHistory();
ResultSet rs = null; try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); pStmt = dbConn.prepareStatement("select CQ_ID, CQ_DATABASE, CQ_TABLE, CQ_PARTITION, CQ_STATE, CQ_TYPE, CQ_TBLPROPERTIES, CQ_WORKER_ID, CQ_START, CQ_RUN_AS, CQ_HIGHEST_WRITE_ID, CQ_META_INFO, CQ_HADOOP_JOB_ID from COMPACTION_QUEUE WHERE CQ_ID = ?"); pStmt.setLong(1, info.id); throw new IllegalStateException("No record with CQ_ID=" + info.id + " found in COMPACTION_QUEUE"); close(rs); String s = "delete from COMPACTION_QUEUE where cq_id = ?"; pStmt = dbConn.prepareStatement(s); CompactionInfo.insertIntoCompletedCompactions(pStmt, info, getDbTime(dbConn)); updCount = pStmt.executeUpdate(); LOG.error("Unable to delete from compaction queue " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "markCleaned(" + info + ")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, pStmt, dbConn); markCleaned(info);
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); } catch (SQLException e) { LOG.error("Unable to connect to transaction database " + e.getMessage()); checkRetryable(dbConn, e, "findPotentialCompactions(maxAborted:" + maxAborted + ")"); } finally { closeDbConn(dbConn); closeStmt(stmt); return findPotentialCompactions(maxAborted);
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String sqlText = "UPDATE COMPACTION_QUEUE SET CQ_HIGHEST_WRITE_ID = " + ci.highestWriteId + ", cq_run_as = " + quoteString(ci.runAs) + " WHERE CQ_ID = " + ci.id; if(LOG.isDebugEnabled()) { " VALUES(" + compactionTxnId + "," + quoteString(ci.dbname) + "," + quoteString(ci.tableName) + "," + (ci.partName == null ? "" : quoteString(ci.partName) + ",") + ci.highestWriteId + ", " + quoteChar(OperationType.COMPACT.getSqlConst()) + ")"; if(LOG.isDebugEnabled()) { LOG.debug("About to execute: " + sqlText); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "updateCompactorState(" + ci + "," + compactionTxnId +")"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(null, stmt, dbConn); updateCompactorState(ci, compactionTxnId);
dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); long minUncommittedTxnId = findMinOpenTxnGLB(stmt); String s = "select min(txn_id) from TXNS where txn_state = " + quoteChar(TXN_ABORTED); LOG.debug("Going to execute query <" + s + ">"); rs = stmt.executeQuery(s); LOG.error("Unable to delete from txns table " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "cleanTxnToWriteIdTable"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, stmt, dbConn); cleanTxnToWriteIdTable();
try { try { dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED); stmt = dbConn.createStatement(); String s = "select cq_id, cq_database, cq_table, cq_partition, " LOG.error("Unable to select next element for cleaning, " + e.getMessage()); LOG.debug("Going to rollback"); rollbackDBConn(dbConn); checkRetryable(dbConn, e, "findReadyToClean"); throw new MetaException("Unable to connect to transaction database " + StringUtils.stringifyException(e)); } finally { close(rs, stmt, dbConn); return findReadyToClean();