$ the-wire · showcase
Mongo sequence increments exit transactions, Moments gains finer granularity
By RepoJournal · Filed · About Spring
Spring Batch's MongoSequenceIncrementer no longer runs inside an ongoing transaction, and Spring Modulith's Moments now supports seconds and hours with programmatic scheduling.
Spring Batch changed MongoSequenceIncrementer to perform its findAndModify increment outside any ongoing transaction on the calling thread [1]. Previously it ran inside the REQUIRES_NEW/SERIALIZABLE transaction that the job repository opens for createJobInstance, but single-document updates are already atomic in MongoDB, so the enclosing multi-document transaction only added write-conflict risk under concurrent job launches. Concurrent job launches should now avoid those conflicts.
Spring Modulith's Moments now supports seconds and hours in addition to the existing granularities [2]. To avoid unnecessary invocations of the new fine-grained methods, Moments now programmatically schedules event-producing method invocations rather than relying on the previous mechanism [3]. Also, the WorkingDirectoryChangesDetector now resolves the repository-relative working directory from the git work tree instead of the git directory parent, fixing detection for git submodule work trees [4]. Tests were adjusted to assert from the outside by faking changes [5].
Spring Tools for Eclipse fixed additional NullPointerExceptions caused by unresolvable method bindings in broken source code, with new test coverage [6][7][8]. Spring Modulith also fixed a link to examples in a blog post source document [9], and spring-grpc added a timestamp to ensure unique builds [10].
Action items
- → Review concurrent job launches against MongoDB write conflicts; the MongoSequenceIncrementer change may alter transactional behavior spring-projects/spring-batch [plan]
- → If you use Moments with git submodule work trees, verify WorkingDirectoryChangesDetector now reports changes correctly spring-projects/spring-modulith [monitor]
References
- [1] Increment Mongo sequences outside of any ongoing transaction ↗ spring-projects/spring-batch
- [2] GH-1688 - Add seconds and hours to moment granularity ↗ spring-projects/spring-modulith
- [3] GH-1688 - Avoid scheduling of Moments method invocations not needed. ↗ spring-projects/spring-modulith
- [4] GH-1849 - Fix WorkingDirectoryChangesDetector for git submodule work trees. ↗ spring-projects/spring-modulith
- [5] GH-1849 - Polishing. ↗ spring-projects/spring-modulith
- [6] GH-1980: fix more NPEs when bindings cannot be resolved in broken source code ↗ spring-projects/spring-tools
- [7] GH-1980: fix NPE when method binding cannot be resolved, e.g. in broken code ↗ spring-projects/spring-tools
- [8] GH-1980: add test coverage for unresolvable method bindings in broken source code ↗ spring-projects/spring-tools
- [9] GH-925 - Fix link to examples in blog post source document. ↗ spring-projects/spring-modulith
- [10] Add timestamp for unique builds ↗ spring-projects/spring-grpc