You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "dengzhhu653 (via GitHub)" <gi...@apache.org> on 2024/08/20 09:54:00 UTC
[PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
dengzhhu653 opened a new pull request, #5398:
URL: https://github.com/apache/hive/pull/5398
…use connection starvation
<!--
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?
Make the time consuming API request the connection from primary connection pool
<!--
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?
No
<!--
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'.
-->
### Is the change a dependency upgrade?
No
<!--
If yes, please attach a file with output from mvn dependency:tree to validate a complete upgrade of dependency.
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 merged PR #5398:
URL: https://github.com/apache/hive/pull/5398
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728036400
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
If the exception throws from https://github.com/apache/hive/blob/c6965423da67515c4fc8ba70a1d10ba15624789d/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java#L563-L586 , we still need to close the `jdoConn` at the outer finally,
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727467342
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
why not wrap query execution in try-finally and close db connection there?
````
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
} finally {
closeDbConn(jdoConn);
}
tx.commit();
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727476984
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
````
} finally {
if (tx.isActive()) {
tx.rollback();
}
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727394574
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
````!dbConn.isClosed()````
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
can we check in `closeDbConn` if jdoConn is closed and if not attempt to close 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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5398:
URL: https://github.com/apache/hive/pull/5398#issuecomment-2307197323
## [](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5398) **Quality Gate passed**
Issues
 [5 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5398&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5398&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5398&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5398&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5398&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5398)
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1726983536
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
We have a `closeDbConn(jdoConn)` before tx commits, if the `jdoConn` is being closed twice, a NucleusUserException is thrown from https://github.com/datanucleus/datanucleus-core/blob/master/src/main/java/org/datanucleus/store/NucleusConnectionImpl.java#L54-L62, then we log the exception at`closeDbConn(jdoConn);`, it could be misleading however.
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727381732
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
can we check in `closeDbConn` if jdoConn is closed and if not attempt to close 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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1726832470
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
should it be
````
closeDbConn(jdoConn);
if (tx.isActive()) {
tx.rollback();
}
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1723502826
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -526,18 +519,18 @@ public Map<String, Map<String, String>> updatePartitionColumnStatistics(Map<Stri
MetaStoreListenerNotifier.notifyEventWithDirectSql(transactionalListeners,
EventMessage.EventType.UPDATE_PARTITION_COLUMN_STAT_BATCH, eventBatch, dbConn, sqlGenerator);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
Review Comment:
this won't close the underlying connection because the current active is active, see
https://github.com/datanucleus/datanucleus-core/blob/efba3bd0e8345e1171d5fe529cae693293f178ae/src/main/java/org/datanucleus/store/AbstractStoreManager.java#L378-L392
It tells we have reached the end of `transaction` and is able to commit now, until the `tx.commit()` the underlying connection will return back to the connection pool.
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728502013
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
ok, back to the prev approach, can't we check if jdoConn is not already closed?
````
closeDbConn(jdoConn);
if (tx.isActive()) {
tx.rollback();
}
...
void closeDbConn(JDOConnection jdoConn) {
try {
if (dbConn != null && !dbConn.isClosed()) {
jdoConn.close();
}
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728548195
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
sounds the `JDOConnection` doesn't provide the method `isClosed()` to check the state...
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #5398:
URL: https://github.com/apache/hive/pull/5398#issuecomment-2298576254
## [](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5398) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5398&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=5398&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=5398&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5398&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=5398&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=5398)
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1724673173
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -526,18 +519,18 @@ public Map<String, Map<String, String>> updatePartitionColumnStatistics(Map<Stri
MetaStoreListenerNotifier.notifyEventWithDirectSql(transactionalListeners,
EventMessage.EventType.UPDATE_PARTITION_COLUMN_STAT_BATCH, eventBatch, dbConn, sqlGenerator);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
Review Comment:
If the `tx.commit()` happens before the `closeDbConn(jdoConn)`, a JDOUserException cloud see when commit the change:
`The Connection was acquired by the developer and must be closed before using the persistence API`.
https://www.datanucleus.org/products/accessplatform_6_0/jdo/persistence.html#_user_connection
> You must return the connection back to the PersistenceManager before performing any PersistenceManager operation. You do this by calling conn.close(). If you don’t return the connection and try to perform an PersistenceManager operation which requires the connection then a JDOUserException is thrown.
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728763063
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
how about a nested try, since it doesn't implement auto-closeble
````
try {
dbType.lockInternal();
tx.begin();
try {
jdoConn = pm.getDataStoreConnection();
....
} finally {
closeDbConn(jdoConn);
}
tx.commit();
}
````
finally {
if (tx.isActive()) {
tx.rollback();
}
}
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
how about a nested try, since it doesn't implement auto-closeble
````
try {
dbType.lockInternal();
tx.begin();
try {
jdoConn = pm.getDataStoreConnection();
....
} finally {
closeDbConn(jdoConn);
}
tx.commit();
}
..
finally {
if (tx.isActive()) {
tx.rollback();
}
}
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728763063
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
how about a nested try, since it doesn't implement auto-closeble
````
try {
jdoConn = pm.getDataStoreConnection();
....
} finally {
closeDbConn(jdoConn);
}
tx.commit();
````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727394574
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
````!dbConn.isClosed()````
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1727424568
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -484,14 +477,14 @@ public Map<String, Map<String, String>> updatePartitionColumnStatistics(Map<Stri
String validWriteIds, long writeId,
List<TransactionalMetaStoreEventListener> transactionalListeners)
throws MetaException {
+
JDOConnection jdoConn = null;
- Connection dbConn = null;
- boolean committed = false;
+ Transaction tx = pm.currentTransaction();
Review Comment:
why do we need txn 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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728041850
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -484,14 +477,14 @@ public Map<String, Map<String, String>> updatePartitionColumnStatistics(Map<Stri
String validWriteIds, long writeId,
List<TransactionalMetaStoreEventListener> transactionalListeners)
throws MetaException {
+
JDOConnection jdoConn = null;
- Connection dbConn = null;
- boolean committed = false;
+ Transaction tx = pm.currentTransaction();
Review Comment:
It's used to mark we have opened a transaction explicitly, when `jdoConn = pm.getDataStoreConnection()`, it will get the connection from the primary connection pool, https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java#L307
https://github.com/datanucleus/datanucleus-core/blob/master/src/main/java/org/datanucleus/store/AbstractStoreManager.java#L373
https://github.com/datanucleus/datanucleus-core/blob/master/src/main/java/org/datanucleus/store/connection/ConnectionManager.java#L92
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728727784
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
what do you mean? check the rollback method that was removed
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728727784
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
what do you mean? check the rollback method that was removed
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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
Re: [PR] HIVE-28456: ObjectStore updatePartitionColumnStatisticsInBatch can ca… [hive]
Posted by "dengzhhu653 (via GitHub)" <gi...@apache.org>.
dengzhhu653 commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728811975
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long numStats) throws MetaE
try (Statement statement = dbConn.createStatement()) {
statement.executeUpdate(query);
}
- dbConn.commit();
- committed = true;
+ closeDbConn(jdoConn);
+ tx.commit();
return maxCsId;
} catch (Exception e) {
LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
throw new MetaException("Unable to getNextCSIdForMPartitionColumnStatistics "
+ " due to: " + e.getMessage());
} finally {
- if (!committed) {
- rollbackDBConn(dbConn);
+ if (tx.isActive()) {
+ closeDbConn(jdoConn);
Review Comment:
ack, thank you for the suggestion!
--
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.
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
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