Add DependsOnDatabaseInitializationDetector so engines wait for database initializers - #4222
Conversation
…ase initializers Flowable engines create/validate their own schema on engine build, but Spring Boot gave no ordering guarantee between engine beans and managed database initializers (Flyway, Liquibase, spring.sql.init). Register a FlowableDependsOnDatabaseInitializationDetector for all Engine beans via the DependsOnDatabaseInitializationDetector SPI, with an opt-out property (flowable.depends-on-database-initialization-detection), following the approach outlined by @filiphr in flowable#4213.
filiphr
left a comment
There was a problem hiding this comment.
Thanks @nikhiln64. This looks good, I've only left some comments for the tests
|
@filiphr just a gentle nudge on this one. All the review comments were addressed back on July 15 and the branch is current with main, so whenever you get a moment for another look I believe it is ready. |
filiphr
left a comment
There was a problem hiding this comment.
Thanks @nikhiln64. I've let the CI run one more time and I'll merge it afterwards
|
Quick note on the JDK 25 run since you mentioned merging after CI. The only failure is KafkaChannelDefinitionProcessorTest.fixedBackOffMultiTopicRetry in the event registry module, which errored with Topic(s) [fixed-backoff-multi-retry-topic-0] is/are not present and missingTopicsFatal is true, so the Kafka topic was not created in time on the CI broker. The JDK 17 and JDK 21 runs on the same commit are green and this PR only touches the spring boot autoconfigure module, so it looks like an infra timing flake rather than anything from the change. |
Implements #4213, following the approach @filiphr outlined there ("You can go ahead and create a PR for this").
What: a
FlowableDependsOnDatabaseInitializationDetectorextending Spring Boot'sAbstractBeansOfTypeDependsOnDatabaseInitializationDetectorfororg.flowable.common.engine.api.Engine(covering process/cmmn/dmn/app/idm engines through the shared interface, no bean names), registered under theDependsOnDatabaseInitializationDetectorSPI inspring.factories. Spring Boot'sDatabaseInitializationDependencyConfigurerthen orders every engine bean after Flyway/Liquibase/spring.sql.initinitializers.Opt-out:
flowable.depends-on-database-initialization-detection=false(defaulttrue), mirroring the JPA detector's opt-out pattern per the issue discussion; documented inadditional-spring-configuration-metadata.json.Testing:
FlowableDependsOnDatabaseInitializationDetectorTestusesApplicationContextRunnerwithspring.sql.initand asserts theprocessEnginebean definition gainsdependsOnondataSourceScriptDatabaseInitializer, plus the opt-out case. Verified the assertion goes red when thespring.factoriesregistration is removed. I can add a Flyway-based sample underflowable-spring-boot-samplesas a follow-up if you'd prefer that shape of test as well.Developed with AI assistance (Claude Code), reviewed and driven by a human.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.