-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1687] Fix race condition in ReactiveUpdateCoordinator
Hibernate ORM can use the same update coordinator among multiple update operations. In Hibernate Reactive, the reactive update coordinator has a state that cannot be shared. So, we decided to create a new scoped coordinator for each update operation. Right now, we want to merge a fix for the issue that doesn't require us to copy or change code from Hibernate ORM. The plan is to find a more efficient solution as a separate issue. And, possible add some infrastructure to make it easier to track these type of issues.
- Loading branch information
Showing
9 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...bernate/reactive/persister/entity/impl/ReactiveUpdateCoordinatorStandardScopeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.reactive.persister.entity.impl; | ||
|
||
import org.hibernate.engine.spi.SessionFactoryImplementor; | ||
import org.hibernate.persister.entity.AbstractEntityPersister; | ||
import org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard; | ||
import org.hibernate.reactive.persister.entity.mutation.ReactiveScopedUpdateCoordinator; | ||
import org.hibernate.reactive.persister.entity.mutation.ReactiveUpdateCoordinator; | ||
import org.hibernate.reactive.persister.entity.mutation.ReactiveUpdateCoordinatorStandard; | ||
|
||
public class ReactiveUpdateCoordinatorStandardScopeFactory extends UpdateCoordinatorStandard implements ReactiveUpdateCoordinator { | ||
|
||
private final AbstractEntityPersister entityPersister; | ||
private final SessionFactoryImplementor factory; | ||
|
||
public ReactiveUpdateCoordinatorStandardScopeFactory( | ||
AbstractEntityPersister entityPersister, | ||
SessionFactoryImplementor factory) { | ||
super( entityPersister, factory ); | ||
this.entityPersister = entityPersister; | ||
this.factory = factory; | ||
} | ||
|
||
@Override | ||
public ReactiveScopedUpdateCoordinator makeScopedCoordinator() { | ||
return new ReactiveUpdateCoordinatorStandard( entityPersister, factory ); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...ava/org/hibernate/reactive/persister/entity/mutation/ReactiveScopedUpdateCoordinator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright: Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.reactive.persister.entity.mutation; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
|
||
import org.hibernate.engine.spi.SharedSessionContractImplementor; | ||
|
||
/** | ||
* Scoped to a single operation, so that we can keep | ||
* instance scoped state. | ||
* | ||
* @see org.hibernate.persister.entity.mutation.UpdateCoordinator | ||
* @see ReactiveUpdateCoordinator | ||
*/ | ||
public interface ReactiveScopedUpdateCoordinator { | ||
|
||
CompletionStage<Void> coordinateReactiveUpdate( | ||
Object entity, | ||
Object id, | ||
Object rowId, | ||
Object[] values, | ||
Object oldVersion, | ||
Object[] incomingOldValues, | ||
int[] dirtyAttributeIndexes, | ||
boolean hasDirtyCollection, | ||
SharedSessionContractImplementor session); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters