-
-
Notifications
You must be signed in to change notification settings - Fork 102
[wip/4.2] Implemented Reactive versions of PostAction, PreAction and JdbcSelectWithActions #2732
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
base: wip/4.2
Are you sure you want to change the base?
Conversation
| public String name; | ||
|
|
||
| @ManyToOne | ||
| @ManyToOne(fetch = FetchType.LAZY) |
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.
I don't think you should change the mapping of an existing test. ALso, does it matter if you use lazy here?
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.
With the new Lock implementation in ORM, it affects the number of queries executed.
I'm going to revert this change and modify the testFindUpgradeNoWait assertions accrdingly
…ction` and `JdbcSelectWithActions`
4189a5f to
229542e
Compare
229542e to
a48c3b8
Compare
b0fdbef to
b543eb0
Compare
|
We need to wait for the next ORM 7.2 release |
DavideD
left a comment
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.
Thanks @dreab8,
it looks good overall, but there some small things to change.
| * Reactive version of {@link ConnectionLockTimeoutStrategy} | ||
| */ | ||
| public interface ReactiveConnectionLockTimeoutStrategy extends ConnectionLockTimeoutStrategy { | ||
| Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() ); |
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.
I know that we use this pattern in some places, but
I think it's better if we don't put the LOG in the interface and override the method in the implemetations instead, even if it means we have some duplication.
|
|
||
| @FunctionalInterface | ||
| public interface TimeoutExtractor { | ||
| CompletionStage<Timeout> extractFrom(ReactiveConnection.Result resultSet); |
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.
Are you sure this needs to return a CompletionStage? All the implementations I see return a constant.
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.
I did a little refactoring and it seems you can just return a Timeout object: DavideD@f76290d
Feel free to squash the commit in your PR, if you agree with the changes
| return LockHelper.getLockTimeout( | ||
| "show lock_timeout", | ||
| (resultSet) -> { | ||
| // see https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout |
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.
I think you copied and paste the link: it links to the MySQL docs but it's in the code for the Cockroach strategy
The same error happens in all the other implementations
| Timeout timeout, | ||
| ReactiveConnection connection, | ||
| SessionFactoryImplementor factory) { | ||
| return LockHelper.setLockTimeout( |
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.
This code is the same as the one in Postgres. If Cockroach calls the one in Postgres, we remove some duplicated code.
| * Reactive version of {@link TableLock} | ||
| */ | ||
| public class ReactiveTableLock extends TableLock { | ||
| Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() ); |
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.
this LOG should be private static final
| ReactiveListResultsConsumer.UniqueSemantic.ALLOW | ||
| ).thenCompose( results -> { | ||
| if ( isEmpty( results ) ) { | ||
| throw new AssertionFailure( "Expecting results" ); |
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.
Can't we add anything else to the error message? What should have the query returned? Something related to a lock I imagine.
| reference = null; | ||
| } | ||
| applyLoadedState( entityDetails, statePosition, reference ); | ||
| applyModelState( entityDetails, statePosition, reference ); |
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.
reference is always null
| } | ||
|
|
||
| @Override | ||
| public CompletionStage<Void> reactiveApplyResult( |
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.
Unless I'm missing something, nothing in this method seems reactive. Do you need to return a CompletionStage?
| if ( stateValue == null ) { | ||
| if ( !toOne.isNullable() ) { | ||
| throw new IllegalStateException( "Retrieved key was null, but to-one is not nullable : " + toOne.getNavigableRole() | ||
| .getFullPath() ); |
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.
Shouldn't this have a error code in the Log?
Fix #2651
The PR implements the Reactive version of
JdbcSelectWithActionsand of the newPostActionandPreAction(ReactiveLockTimeoutHandlerandReactiveLockTimeoutHandler).The PR does not implement the Reactive version of
CollectionLockingActionbut in order to use it a Reactive version oforg.hibernate.query.SelectionQuery#setLockScope(Locking.Scope lockScope);method need to be added.