hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

Investigating Update outside transition 2lc

Open dreab8 opened this issue 1 year ago • 4 comments

bulk query execution inside a Transaction

  1. cacheAccess.lockRegion;
  2. cacheAccess.removeAll;
  3. schedule after transaction opertaion (cacheAccess.unlockRegion)
  4. SQL query execution
  5. after transaction triggers cacheAccess.unlockRegion

what happens now for a bulk native query executed ouside a Transaction :

  1. cacheAccess.lockRegion;
  2. cacheAccess.removeAll;
  3. schedule after transaction opertaion (cacheAccess.unlockRegion)
  4. SQL query execution

bulk native query update execution outside Transaction with https://github.com/hibernate/hibernate-orm/pull/8849#issuecomment-2318789193

  1. cacheAccess.lockRegion;
  2. cacheAccess.removeAll;
  3. cacheAccess.unlockRegion
  4. SQL query execution

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion. For more information on licensing, please check here.


dreab8 avatar Aug 29 '24 15:08 dreab8

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+     ↳ Offending commits: [e30e4163c378800efcd6ed7678fa104d822f09ab, de379ffd21952f99c4c27df50027403d70c85f28]

› This message was automatically generated.

We talked about this approach as an alternative to https://hibernate.atlassian.net/browse/HHH-18546

@yrodiere had some concerns with the approach in regards to some things done in Hibernate Search. Let's see if he can demonstrate that and we should incorporate his findings, if so.

sebersole avatar Aug 29 '24 19:08 sebersole

We talked about this approach as an alternative to https://hibernate.atlassian.net/browse/HHH-18546

@yrodiere had some concerns with the approach in regards to some things done in Hibernate Search. Let's see if he can demonstrate that and we should incorporate his findings, if so.

My concern regarding Hibernate Search was if we generalize the approach of executing "after transaction" operations immediately, since Hibernate Search does that itself. If we do that (which we aren't in this PR), then we'll just have to run Hibernate Search integration tests against the Hibernate ORM snapshots to see if tests still pass, and improvise.

Regarding this patch specifically, I'm discussing it with Andrea right now (though just to give this another pair of eyeballs; you sure know what this implies better than I do).

yrodiere avatar Aug 30 '24 07:08 yrodiere

as suggested by @sebersole probably better to provide a logging in case the operation is executed outside a TX so something like

 if ( !session.isEventSource() ) {
            action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
        }
        else if ( ! session.isTransactionInProgress() ) {
            LOGGING....
            action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
        }
        else {
            session.asEventSource().getActionQueue().addAction( action );
        }

dreab8 avatar Aug 30 '24 08:08 dreab8

Just for reference, I believe this was fixed via https://github.com/hibernate/hibernate-orm/pull/9812

beikov avatar Oct 21 '25 11:10 beikov