Skip to content
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

HIVE-28238: Open Hive ACID txn only for transactional resources #5216

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

deniskuzZ
Copy link
Member

@deniskuzZ deniskuzZ commented Apr 25, 2024

What changes were proposed in this pull request?

Open ACID txn only when transactional resources are present in a query

Why are the changes needed?

Backend db calls optimization

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

mvn test -Dtest=ITestDbTxnManager -Dtest.metastore.db=postgres

@kasakrisz
Copy link
Contributor

Is there an apache jira about this change?

Comment on lines 692 to 694
if (dbProduct.isDERBY()) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that a txn has to be always opened if the backend db is derby? Even if there are no transactional tables in the statement.

Copy link
Member Author

@deniskuzZ deniskuzZ Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no one is using derby in production, but the main reason is that derby doesn't support multi-column IN construct.
https://stackoverflow.com/questions/48175692/multiple-columns-in-in-clause-apache-derby
tested so far on Postgres, MySQL, Oracle

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should consider moving to H2 in tests

@deniskuzZ deniskuzZ changed the title Open Hive ACID txn only for transactional resources HIVE-28238: Open Hive ACID txn only for transactional resources Apr 30, 2024
@deniskuzZ
Copy link
Member Author

Is there an apache jira about this change?

created https://issues.apache.org/jira/browse/HIVE-28238

Copy link

sonarcloud bot commented May 25, 2024

Quality Gate Passed Quality Gate passed

Issues
30 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@Override
public boolean hasAcidResourcesInQuery() {
// check DB tags once supported (i.e. ICEBERG_ONLY, ACID_ONLY, EXTERNAL_ONLY)
return true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need txn here?

import org.apache.hadoop.mapred.InputFormat;
import org.apache.hadoop.mapred.InputSplit;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.lib.CombineFileSplit;

import static jodd.util.ClassUtil.isAssignableFrom;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup

@@ -330,7 +329,7 @@ private void markExplicitTransaction(QueryPlan queryPlan) throws LockException {
* @throws LockException
*/
private void verifyState(QueryPlan queryPlan) throws LockException {
if(!isTxnOpen()) {
if(!isTxnOpen() && queryPlan.hasAcidResourcesInQuery()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to support external tables without need of open txn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants