Repository navigation
Conversation
…enant transaction. ### Changes - Removed the existing guard’s `flush: true` bypass. - Preserved its method signature. - Extended existing in-memory and MongoDB tests for flushed writes and already-bound sessions. - Corrected the exception message, 9.0 upgrade guide, and matching upgrade guidance. ### Validation All affected suites passed with zero failures: - Datamapping core: 2,694 tests - Datamapping CLI: 213 tests - Datamapping TCK: 765 tests - MongoDB core: 1,329 tests
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A flushed save inside a failed tenant block is refused. A save of a plain class with no tenant transaction is now refused too.
…tenant datastore lookup: - Skip the write guard before tenant lookup when no transaction is active. - Preserve rejection of unsafe writes during an active tenant transaction, including `flush: true`. - Add regression coverage for unregistered tenant IDs and bound sessions in the in-memory and MongoDB suites. - Clarify the upgrade guide.
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A save of a plain class with no tenant transaction still throws when another transaction is active.
… unrelated active transactions. - Plain-class writes still reach the default datastore with an unregistered tenant ID bound. - Unsafe writes during a real tenant transaction remain rejected, including `flush: true`. - Added regression tests and updated the upgrade guide.
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A save inside a tenant transaction is allowed when that transaction does not use synchronization.
…that transaction does not use synchronization: - Removed the thread-level transaction flag shortcut; active tenant transactions are now detected through session holders even when synchronization is disabled. - Added regression coverage and expanded the database/schema tenancy tests. - Updated the upgrade guide.
jamesfredley
left a comment
There was a problem hiding this comment.
The items this review found have been addressed. A save inside a tenant transaction is refused even when that transaction does not use synchronization, and a save with no tenant transaction is not refused because another transaction is active.
Description
Fixes #17031
Root Cause
flush: trueinAbstractGormApi.requireTransactionForWriteincorrectly bypassed the transaction-safety check.In DATABASE or SCHEMA multi-tenancy, a plain domain class—one that does not implement
MultiTenant—writes to its own datastore, typically the default database. A transaction running for a tenant belongs to a different datastore and cannot roll back that plain class’s writes.The guard in
AbstractGormApi.requireTransactionForWritewas intended to reject those writes unless the plain class had a transaction in its own datastore. However, it returned immediately when flushing was requested:Consequently,
save(flush: true)could write the row immediately outside the tenant’s transaction. When the tenant transaction subsequently failed, the row remained.Changes
flush: truebypass.Validation
All affected suites passed with zero failures:
Assisted with GPT 6 Sol
Contributor Checklist
Please review the following checklist before submitting your pull request. Pull requests that do not meet these requirements may be closed without review.
Issue and Scope
7.0.x): Bug fixes only. No new features or API changes.7.1.x): New features are welcome, but breaking existing APIs must be avoided.8.0.x): Reserved for major changes. Breaking API changes are permitted.Code Quality
./gradlew build --rerun-tasks../gradlew codeStyleand resolved any violations. See Code Style for details.Licensing and Attribution
Documentation