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

Avoid creation of multiple connections during schema migration #1928

Merged
merged 3 commits into from
Jun 3, 2024

Conversation

DavideD
Copy link
Member

@DavideD DavideD commented May 29, 2024

Fix #1909

I'm not sure if it strictly necessary anymore to run the queries outside of the current transaction, but I think this way the code is simpler and consistent to what we were doing before. And the code is cleaner.

Basically, I moved the method we used to run the query in the pool.

}

@Override
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
return delegate.getBigDecimal(columnIndex, scale);
return delegate.getBigDecimal( columnIndex, scale );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
ResultSet.getBigDecimal
should be avoided because it has been deprecated.
}

@Override
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
return delegate.getUnicodeStream(columnIndex);
return delegate.getUnicodeStream( columnIndex );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
ResultSet.getUnicodeStream
should be avoided because it has been deprecated.
}

@Override
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
return delegate.getBigDecimal(columnLabel, scale);
return delegate.getBigDecimal( columnLabel, scale );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
ResultSet.getBigDecimal
should be avoided because it has been deprecated.
}

@Override
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
return delegate.getUnicodeStream(columnLabel);
return delegate.getUnicodeStream( columnLabel );

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
ResultSet.getUnicodeStream
should be avoided because it has been deprecated.
*
* @return the CompletionStage<ResultSet> from executing the query.
*/
public CompletionStage<ResultSet> selectJdbcOutsideTransaction(String sql, Object[] paramValues) {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
ReactiveConnectionPool.selectJdbcOutsideTransaction
; it is advisable to add an Override annotation.
@gavinking
Copy link
Member

I'm not sure if it strictly necessary anymore to run the queries outside of the current transaction

WDYM?

@DavideD
Copy link
Member Author

DavideD commented May 29, 2024

I was referring to this comment: quarkusio/quarkus#39930 (comment)

It made me think we don't actually need to do it. But now that I re-read it, it seems that we need to do it but it's a bit unclear why.

Can you shed some light about this?

@gavinking
Copy link
Member

gavinking commented May 29, 2024

I mean there are various reasons we might want to do that.

For example, increment on a table-based id generator should happen outside the current tx.

For DDL execution, well, IIRC that's something we've always done non-transactionally. I know there are some databases (Postgres, IIRC) which do support transactional DDL, but I doubt that this is something we need/want.

@DavideD
Copy link
Member Author

DavideD commented May 29, 2024

Thanks

Before we were creating a connection and then ignoring it for each
query required to update the schema or collect metatada.

Now the method for running queries outside the "current" transaction
is in the SqlClientPool.
Copy link
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

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

Thanks.

As far as I understand this would indeed solve the problem, though I do not quite understand why you chose to keep selectJdbcOutsideTransaction instead of simply retrieving and using the connection the way it's done everywhere else.

@yrodiere
Copy link
Member

yrodiere commented Jun 3, 2024

As far as I understand this would indeed solve the problem [...]

So maybe let's merge and improve later if necessary? Assuming the breaking change gets documented somewhere. EDIT: No need for that, it's incubating API anyway.

@yrodiere
Copy link
Member

yrodiere commented Jun 3, 2024

Alright then, let's merge. Thanks @DavideD!

@yrodiere yrodiere merged commit 3ace16f into hibernate:main Jun 3, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acquisition of multiple connections for schema management
3 participants