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

Transaction synchronization #212

Merged
merged 72 commits into from
Jul 8, 2021

Conversation

felixscheinost
Copy link
Contributor

@felixscheinost felixscheinost commented Jan 19, 2021

Up to 4.x AuditTrail were written immediately e.g. when using save(flush: true) even when afterwards the transaction failed or was rolled back.

This PR is based on @longwa's work in feature/4.0.0_wip to queue the AuditTrails and batch-commit them AFTER the surrounding transaction is comitted.

We added further tests that revealed edge cases when using nested transactions.
Unfortunately we didn't find a way to fix those edge cases in a GORM agnostic way yet.

Additionally, this supports using hibernate.allow_update_outside_transaction: true. This is handy when upgrading an old Grails 3 application to Grails 4 where hibernate.allow_update_outside_transaction defaults to false.

For now we added a provided dependency on org.grails.plugins:hibernate5. This must be moved to a separate dependency to support e.g. using solely MongoDB.

This fixes #173 and #175.

longwa and others added 30 commits February 28, 2019 10:54
… each DataSource being managed within an application
Added usePersistentDirtyPropertyValues
When including this project in another project as inline plugin $rootDir is the directory of the project that this plugin is included in.

Using project.file we always get the correct path
GormEntity#ident has a similar if with these two branches:
- PersistentEntity#identity is not null => Return value of this PersistentProperty
- otherwise use PersistentEntity#compositeIdentity which is a list
   of properties that make up the composite key

The default format of the string returned by getLogEntityId() is supposed to look like a map of the properties that make up the composite ID. For GormEntity only the ident is logged.

# Conflicts:
#	plugin/src/main/groovy/grails/plugins/orm/auditable/Auditable.groovy
felixscheinost and others added 17 commits January 18, 2021 17:26
We decided that we wont fix the unexpected behaviour this test shows (for now)
„Test rollback behaviour“ and „Test nested transactions“ uncovered two new bugs with the previous implementation.

Change AuditLogQueueManager to fix them.

„test nested transactions different datastores“ is still an open problem and fails. Need to fix.
See comment in test for explanation.
We didn’t find a way to achieve a good transaction synchronization using only GORM agnostic APIs.

So for now this code is platform dependent on Hibernate.
Ensure that AuditTrails are always cleaned up BEFORE test runs
This ensures that the test environment is consistent
Leave makedoc.sh and travis-build.sh as release process has yet to be moved over to Github Actions
@robertoschwald robertoschwald merged commit 1bbf888 into gpc:master Jul 8, 2021
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.

Changes to withNewSession semantics make it useless for audit log listener
4 participants