-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29291: Use minHistoryWriteId by default #6154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,6 @@ | |
| import org.apache.hadoop.hive.metastore.txn.entities.CompactionInfo; | ||
| import org.apache.hadoop.hive.metastore.txn.entities.OperationType; | ||
| import org.apache.hadoop.hive.metastore.txn.TxnErrorMsg; | ||
| import org.apache.hadoop.hive.metastore.txn.TxnHandler; | ||
| import org.apache.hadoop.hive.metastore.txn.entities.TxnStatus; | ||
| import org.apache.hadoop.hive.metastore.txn.TxnStore; | ||
| import org.apache.hadoop.hive.metastore.txn.TxnUtils; | ||
|
|
@@ -74,6 +73,7 @@ | |
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| import static org.apache.hadoop.hive.metastore.txn.TxnHandler.ConfVars; | ||
| import static org.apache.hadoop.hive.metastore.txn.TxnHandler.notifyCommitOrAbortEvent; | ||
| import static org.apache.hadoop.hive.metastore.txn.TxnUtils.getEpochFn; | ||
| import static org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier; | ||
|
|
@@ -159,7 +159,9 @@ public TxnType execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExce | |
| long tempCommitId = TxnUtils.generateTemporaryId(); | ||
|
|
||
| if (txnType == TxnType.SOFT_DELETE || txnType == TxnType.COMPACTION) { | ||
| new AcquireTxnLockFunction(false).execute(jdbcResource); | ||
| if (!ConfVars.useMinHistoryWriteId()) { | ||
| new AcquireTxnLockFunction(false).execute(jdbcResource); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nextTxnId hwm is not used with MinHistoryWriteId, so no need to lock in oder to get accurate value |
||
| } | ||
| commitId = jdbcResource.execute(new GetHighWaterMarkHandler()); | ||
|
|
||
| } else if (txnType != TxnType.READ_ONLY && !isReplayedReplTxn) { | ||
|
|
@@ -188,8 +190,9 @@ public TxnType execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExce | |
| */ | ||
| Object undoWriteSetForCurrentTxn = context.createSavepoint(); | ||
| jdbcResource.getJdbcTemplate().update( | ||
| writeSetInsertSql + (TxnHandler.ConfVars.useMinHistoryLevel() ? conflictSQLSuffix : | ||
| "FROM \"TXN_COMPONENTS\" WHERE \"TC_TXNID\"= :txnId AND \"TC_OPERATION_TYPE\" <> :type"), | ||
| writeSetInsertSql + (ConfVars.useMinHistoryLevel() ? conflictSQLSuffix : | ||
| "FROM \"TXN_COMPONENTS\" WHERE \"TC_TXNID\"= :txnId" + ( | ||
| (txnType != TxnType.REBALANCE_COMPACTION) ? "" : " AND \"TC_OPERATION_TYPE\" <> :type")), | ||
|
||
| new MapSqlParameterSource() | ||
| .addValue("txnId", txnid) | ||
| .addValue("type", OperationType.COMPACT.getSqlConst())); | ||
|
|
@@ -235,11 +238,10 @@ public TxnType execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExce | |
| throw new TxnAbortedException(msg); | ||
| } | ||
| } | ||
| } else if (!TxnHandler.ConfVars.useMinHistoryLevel()) { | ||
| jdbcResource.getJdbcTemplate().update(writeSetInsertSql + "FROM \"TXN_COMPONENTS\" WHERE \"TC_TXNID\" = :txnId AND \"TC_OPERATION_TYPE\" <> :type", | ||
| } else if (!ConfVars.useMinHistoryLevel()) { | ||
| jdbcResource.getJdbcTemplate().update(writeSetInsertSql + "FROM \"TXN_COMPONENTS\" WHERE \"TC_TXNID\" = :txnId", | ||
| new MapSqlParameterSource() | ||
| .addValue("txnId", txnid) | ||
| .addValue("type", OperationType.COMPACT.getSqlConst())); | ||
| .addValue("txnId", txnid)); | ||
| commitId = jdbcResource.execute(new GetHighWaterMarkHandler()); | ||
| } | ||
| } else { | ||
|
|
@@ -256,7 +258,6 @@ public TxnType execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExce | |
| assert true; | ||
| } | ||
|
|
||
|
|
||
| if (txnType != TxnType.READ_ONLY && !isReplayedReplTxn && !MetaStoreServerUtils.isCompactionTxn(txnType)) { | ||
| moveTxnComponentsToCompleted(jdbcResource, txnid, isUpdateDelete); | ||
| } else if (isReplayedReplTxn) { | ||
|
|
@@ -575,7 +576,7 @@ private void updateWSCommitIdAndCleanUpMetadata(MultiDataSourceJdbcResource jdbc | |
| if (txnType == TxnType.MATER_VIEW_REBUILD) { | ||
| queryBatch.add("DELETE FROM \"MATERIALIZATION_REBUILD_LOCKS\" WHERE \"MRL_TXN_ID\" = " + txnid); | ||
| } | ||
| if (txnType == TxnType.SOFT_DELETE || txnType == TxnType.COMPACTION) { | ||
| if (txnType == TxnType.SOFT_DELETE || MetaStoreServerUtils.isCompactionTxn(txnType)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no idea why REBALANCE_COMPACTION was excluded, looks like a bug |
||
| queryBatch.add("UPDATE \"COMPACTION_QUEUE\" SET \"CQ_NEXT_TXN_ID\" = " + commitId + ", \"CQ_COMMIT_TIME\" = " + | ||
| getEpochFn(jdbcResource.getDatabaseProduct()) + " WHERE \"CQ_TXN_ID\" = " + txnid); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing
MinUncommittedTxnIdHandlerwasn't used for unknown reason