You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/06 17:28:17 UTC
[GitHub] [hive] maheshk114 opened a new pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
maheshk114 opened a new pull request #1834:
URL: https://github.com/apache/hive/pull/1834
…
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
3. Ensure you have added or run the appropriate tests for your PR:
4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX: Your PR title ...'.
5. Be sure to keep the PR description updated to reflect all changes.
6. Please write your PR title to summarize what this PR proposes.
7. If possible, provide a concise example to reproduce the issue for a faster review.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
If no, write 'No'.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r555698743
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java
##########
@@ -412,12 +419,27 @@ private String extractTableFullName(StatsTask tsk) throws SemanticException {
.getInputFormatClass();
Table table = tableScan.getConf().getTableMetadata();
List<Partition> partitions = new ArrayList<>();
+ AcidUtils.TableSnapshot tableSnapshot = null;
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_STATS_TASK_OPTIMIZE)) {
+ tableSnapshot = AcidUtils.getTableSnapshot(conf, table, true);
+ }
if (table.isPartitioned()) {
- partitions.addAll(parseContext.getPrunedPartitions(tableScan).getPartitions());
- for (Partition partn : partitions) {
+ for (Partition partn : parseContext.getPrunedPartitions(tableScan).getPartitions()) {
LOG.trace("adding part: " + partn);
+ if (tableSnapshot != null && ColStatsProcessor.canSkipStatsGeneration(table.getDbName(), table.getTableName(),
+ FileUtils.makePartName(table.getPartColNames(), partn.getTPartition().getValues()),
+ partn.getTPartition().getWriteId(), tableSnapshot.getValidWriteIdList())) {
+ continue;
+ }
+ partitions.add(partn);
outputs.add(new WriteEntity(partn, WriteEntity.WriteType.DDL_NO_LOCK));
}
+ if (partitions.isEmpty()) {
+ return null;
Review comment:
could we refactor to return Optional here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r556362110
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java
##########
@@ -204,6 +206,54 @@ public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaExce
public void setDpPartSpecs(Collection<Partition> dpPartSpecs) {
}
+ public static boolean canSkipStatsGeneration(String dbName, String tblName, String partName,
+ long statsWriteId, String queryValidWriteIdList) {
+ if (queryValidWriteIdList != null) { // Can be null if its not an ACID table.
+ ValidWriteIdList validWriteIdList = new ValidReaderWriteIdList(queryValidWriteIdList);
+ // Just check if the write ID is valid. If it's valid (i.e. we are allowed to see it),
+ // that means it cannot possibly be a concurrent write. As stats optimization is enabled
+ // only in case auto gather is enabled. Thus the stats must be updated by a valid committed
+ // transaction and stats generation can be skipped.
+ if (validWriteIdList.isWriteIdValid(statsWriteId)) {
+ try {
+ IMetaStoreClient msc = Hive.get().getMSC();
+ TxnState state = msc.findStatStatusByWriteId(dbName, tblName, partName, statsWriteId);
Review comment:
can't we just check here if there a newer commited writeId for table/partition and if yes - stats recompute is needed?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] jcamachor commented on pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
jcamachor commented on pull request #1834:
URL: https://github.com/apache/hive/pull/1834#issuecomment-773502117
@maheshk114 , can we rebase to trigger tests again and merge the changes? Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] maheshk114 commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
maheshk114 commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r558397066
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java
##########
@@ -204,6 +206,54 @@ public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaExce
public void setDpPartSpecs(Collection<Partition> dpPartSpecs) {
}
+ public static boolean canSkipStatsGeneration(String dbName, String tblName, String partName,
+ long statsWriteId, String queryValidWriteIdList) {
+ if (queryValidWriteIdList != null) { // Can be null if its not an ACID table.
+ ValidWriteIdList validWriteIdList = new ValidReaderWriteIdList(queryValidWriteIdList);
+ // Just check if the write ID is valid. If it's valid (i.e. we are allowed to see it),
+ // that means it cannot possibly be a concurrent write. As stats optimization is enabled
+ // only in case auto gather is enabled. Thus the stats must be updated by a valid committed
+ // transaction and stats generation can be skipped.
+ if (validWriteIdList.isWriteIdValid(statsWriteId)) {
+ try {
+ IMetaStoreClient msc = Hive.get().getMSC();
+ TxnState state = msc.findStatStatusByWriteId(dbName, tblName, partName, statsWriteId);
Review comment:
There is 2 cases where we need to compute stats again
1. If the table is updated by a txn with auto gather stats set to false. In that case, we can find a txn with id greater than the stats write id (txn) in the completed txn table. That is done in findStatStatusByWriteId method.
2. If the table stats is updated by an aborted txn. That can be. checked using valid write id list. But if the compaction has cleaned up the txn info, we can not judge that. So we have to check the completed txn table.That is done in findStatStatusByWriteId method.
If the stat is updated by a read only txn (that is stats updater), then also we need not compute the stats again. The info about read only txns is not present in the valid write id list. That is done in findStatStatusByWriteId method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r570556176
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
Review comment:
you do not need db and table filters as txnid is unique across them, see findTxnState
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r570552213
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
Review comment:
I think, it's better to use WRITE_SET table here as you are only interested in committed txnId.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] jcamachor commented on pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
jcamachor commented on pull request #1834:
URL: https://github.com/apache/hive/pull/1834#issuecomment-773502117
@maheshk114 , can we rebase to trigger tests again and merge the changes? Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r556064953
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java
##########
@@ -204,6 +206,54 @@ public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaExce
public void setDpPartSpecs(Collection<Partition> dpPartSpecs) {
}
+ public static boolean canSkipStatsGeneration(String dbName, String tblName, String partName,
+ long statsWriteId, String queryValidWriteIdList) {
+ if (queryValidWriteIdList != null) { // Can be null if its not an ACID table.
+ ValidWriteIdList validWriteIdList = new ValidReaderWriteIdList(queryValidWriteIdList);
+ // Just check if the write ID is valid. If it's valid (i.e. we are allowed to see it),
+ // that means it cannot possibly be a concurrent write. As stats optimization is enabled
+ // only in case auto gather is enabled. Thus the stats must be updated by a valid committed
+ // transaction and stats generation can be skipped.
+ if (validWriteIdList.isWriteIdValid(statsWriteId)) {
+ try {
+ IMetaStoreClient msc = Hive.get().getMSC();
+ TxnState state = msc.findStatStatusByWriteId(dbName, tblName, partName, statsWriteId);
Review comment:
why is this needed? if writeId is valid -> txn is commited
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r556043868
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java
##########
@@ -204,6 +206,54 @@ public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaExce
public void setDpPartSpecs(Collection<Partition> dpPartSpecs) {
}
+ public static boolean canSkipStatsGeneration(String dbName, String tblName, String partName,
+ long statsWriteId, String queryValidWriteIdList) {
+ if (queryValidWriteIdList != null) { // Can be null if its not an ACID table.
+ ValidWriteIdList validWriteIdList = new ValidReaderWriteIdList(queryValidWriteIdList);
+ // Just check if the write ID is valid. If it's valid (i.e. we are allowed to see it),
+ // that means it cannot possibly be a concurrent write. As stats optimization is enabled
+ // only in case auto gather is enabled. Thus the stats must be updated by a valid committed
+ // transaction and stats generation can be skipped.
+ if (validWriteIdList.isWriteIdValid(statsWriteId)) {
+ try {
+ IMetaStoreClient msc = Hive.get().getMSC();
Review comment:
I don't see that you are closing the client.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r570552213
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
Review comment:
I think, it's better to use WRITE_SET table here as you are only interested in committed txnId.
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
Review comment:
you do not need db and table filters as txnid is unique across them, see findTxnState
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
Review comment:
You do not need db and table filters as txnid is unique across them, see findTxnState(). Same query is duplicated in many other places like getCommittedTxns(), see if you could extract it.
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
+ if (rqst.getPartName() != null) {
+ s += " AND \"CTC_PARTITION\" = ?";
+ }
+
+ try (PreparedStatement pStmt =
+ sqlGenerator.prepareStmtWithParameters(dbConn, s, Arrays.asList(rqst.getDbName(), rqst.getTblName()))) {
+ if (rqst.getPartName() != null) {
+ pStmt.setString(3, rqst.getPartName());
+ }
+ LOG.debug("Going to execute query <" + s + ">");
+ try (ResultSet rs2 = pStmt.executeQuery()) {
+ if (rs2.next()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ @RetrySemantics.Idempotent
+ public FindStatStatusByWriteIdResponse findStatStatusByWriteId(FindStatStatusByWriteIdRequest rqst)
+ throws SQLException, MetaException {
+ try {
+ Connection dbConn = null;
+ Statement stmt = null;
+ try {
+ lockInternal();
+ dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
+ stmt = dbConn.createStatement();
+ TxnState state;
+ long txnId = getTxnIdForWriteId(rqst.getDbName(), rqst.getTblName(), rqst.getWriteId());
+ TxnStatus txnStatus = findTxnState(txnId, stmt);
+ if (txnStatus == TxnStatus.ABORTED) {
+ state = TxnState.ABORTED;
+ } else if (txnStatus == TxnStatus.OPEN) {
+ state = TxnState.OPEN;
+ } else if (foundCommittedTransaction(dbConn, txnId, rqst, ">")) {
Review comment:
That's not entirely correct. Txn with higher txnId might be commited before txn with lower id. See how WRITE_SET table works. It has 2 properties WS_TXNID and WS_COMMIT_ID. This table only tracks update/delete operations, that are conflicting, insert doesn't belong to this category, so you cannot rely on it as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] github-actions[bot] commented on pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #1834:
URL: https://github.com/apache/hive/pull/1834#issuecomment-813736181
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] github-actions[bot] commented on pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #1834:
URL: https://github.com/apache/hive/pull/1834#issuecomment-855489364
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] maheshk114 commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
maheshk114 commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r556266918
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java
##########
@@ -204,6 +206,54 @@ public int persistColumnStats(Hive db, Table tbl) throws HiveException, MetaExce
public void setDpPartSpecs(Collection<Partition> dpPartSpecs) {
}
+ public static boolean canSkipStatsGeneration(String dbName, String tblName, String partName,
+ long statsWriteId, String queryValidWriteIdList) {
+ if (queryValidWriteIdList != null) { // Can be null if its not an ACID table.
+ ValidWriteIdList validWriteIdList = new ValidReaderWriteIdList(queryValidWriteIdList);
+ // Just check if the write ID is valid. If it's valid (i.e. we are allowed to see it),
+ // that means it cannot possibly be a concurrent write. As stats optimization is enabled
+ // only in case auto gather is enabled. Thus the stats must be updated by a valid committed
+ // transaction and stats generation can be skipped.
+ if (validWriteIdList.isWriteIdValid(statsWriteId)) {
+ try {
+ IMetaStoreClient msc = Hive.get().getMSC();
+ TxnState state = msc.findStatStatusByWriteId(dbName, tblName, partName, statsWriteId);
Review comment:
this is to make sure that the txn is not cleaned up by compactor.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] github-actions[bot] closed pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #1834:
URL: https://github.com/apache/hive/pull/1834
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r570556176
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
Review comment:
You do not need db and table filters as txnid is unique across them, see findTxnState(). Same query is duplicated in many other places like getCommittedTxns(), see if you could extract it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] jcamachor commented on pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
jcamachor commented on pull request #1834:
URL: https://github.com/apache/hive/pull/1834#issuecomment-813793441
@maheshk114 , this has been marked as stale. It would be great to push it to the finish line though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] deniskuzZ commented on a change in pull request #1834: HIVE-24515 : Analyze table job can be skipped when stats populated are already accurate.
Posted by GitBox <gi...@apache.org>.
deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r570565029
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -4797,6 +4800,84 @@ private void heartbeatTxn(Connection dbConn, long txnid)
}
}
+ private boolean foundCommittedTransaction(Connection dbConn, long txnId, FindStatStatusByWriteIdRequest rqst,
+ String condition) throws SQLException, MetaException {
+ String s = sqlGenerator.addLimitClause(1,
+ "1 FROM \"COMPLETED_TXN_COMPONENTS\" WHERE \"CTC_TXNID\" " + condition + " " + txnId +
+ " AND \"CTC_DATABASE\" = ? AND \"CTC_TABLE\" = ?");
+ if (rqst.getPartName() != null) {
+ s += " AND \"CTC_PARTITION\" = ?";
+ }
+
+ try (PreparedStatement pStmt =
+ sqlGenerator.prepareStmtWithParameters(dbConn, s, Arrays.asList(rqst.getDbName(), rqst.getTblName()))) {
+ if (rqst.getPartName() != null) {
+ pStmt.setString(3, rqst.getPartName());
+ }
+ LOG.debug("Going to execute query <" + s + ">");
+ try (ResultSet rs2 = pStmt.executeQuery()) {
+ if (rs2.next()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ @RetrySemantics.Idempotent
+ public FindStatStatusByWriteIdResponse findStatStatusByWriteId(FindStatStatusByWriteIdRequest rqst)
+ throws SQLException, MetaException {
+ try {
+ Connection dbConn = null;
+ Statement stmt = null;
+ try {
+ lockInternal();
+ dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
+ stmt = dbConn.createStatement();
+ TxnState state;
+ long txnId = getTxnIdForWriteId(rqst.getDbName(), rqst.getTblName(), rqst.getWriteId());
+ TxnStatus txnStatus = findTxnState(txnId, stmt);
+ if (txnStatus == TxnStatus.ABORTED) {
+ state = TxnState.ABORTED;
+ } else if (txnStatus == TxnStatus.OPEN) {
+ state = TxnState.OPEN;
+ } else if (foundCommittedTransaction(dbConn, txnId, rqst, ">")) {
Review comment:
That's not entirely correct. Txn with higher txnId might be commited before txn with lower id. See how WRITE_SET table works. It has 2 properties WS_TXNID and WS_COMMIT_ID. This table only tracks update/delete operations, that are conflicting, insert doesn't belong to this category, so you cannot rely on it as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org