Skip to content

Use Dropwizard Managed Pooled Data Source for Quartz and Flowable #21379

Description

@mohityadav766

Problem

Quartz and Flowable each build their own connection pool from raw JDBC settings instead of using the application's Dropwizard-managed HikariCP pool. Four pools exist per pod, three of them outside Dropwizard's lifecycle, metrics, and most of its configuration:

Subsystem Pool it builds Size
REST / Jdbi ManagedHikariDataSource (Dropwizard-managed, instrumented) maxSize 100
AppScheduler (Quartz) c3p0 ComboPooledDataSource 5
EventSubscriptionScheduler (Quartz) c3p0 ComboPooledDataSource 5
WorkflowHandler (Flowable) MyBatis PooledDataSource 10 (library default)

Because these pools are constructed from config.getDataSourceFactory() getters rather than the managed pool, they silently drop everything the yaml configures — driver tuning, timeouts, metrics and credential handling. Four concrete consequences, worst first:

1. The two Quartz schedulers clobber each other's pool. DBConnectionManager is a process-wide singleton holding a plain HashMap<String, ConnectionProvider>, and addConnectionProvider is an unguarded put. Both schedulers register under the name "myDS". Whichever getScheduler() runs second overwrites the first, so one c3p0 pool is orphaned — still open, unreachable by Quartz, never shut down — and both clustered job stores share the survivor. JobStoreSupport.shutdown() then calls DBConnectionManager.shutdown("myDS"), so the first scheduler to stop closes the pool out from under the other. A starved cluster check-in makes a healthy node look dead to its peers, whose jobs get recovered and re-fired elsewhere.

2. AWS RDS IAM / Azure AD auth is broken for both. JdbiUtils.createAndSetupJDBI mutates the shared factory with dbFactory.setPassword(token). HikariCP does not use that value under IAM — it substitutes AwsRdsIamAwareDataSource, which mints a fresh token per physical connection. Quartz and Flowable initialize after JDBI and read getDataSourceFactory().getPassword(), capturing that one-shot token into a pool with no refresh path. RDS IAM tokens live 15 minutes. Existing connections keep working (the token only gates connect), so this degrades rather than fails outright — scheduling and workflows quietly stop recovering from connection churn.

3. Flowable's pool is undersized against its own executor. The async executor defaults to maxPoolSize 20 against MyBatis' default of 10 connections. The MAX_CONCURRENT_TASK_RESOLUTIONS semaphore in WorkflowHandler is already a workaround for this; its comment reads "an unbounded approval burst … stampedes that pool — excess threads block in MyBatis popConnection past the client timeout and strand tasks in review."

4. Nothing is observable or tunable. DB_CONNECTION_POOL_MAX_SIZE moves 100 of roughly 120 sessions per pod; the rest are hardcoded. Only the request pool is instrumented, so exhaustion in Quartz or Flowable surfaces as job latency with no metric behind it. ProcessEngines.destroy() is never called on server shutdown, so the Flowable pool and its async-executor threads leak on stop.

How to reproduce

The collision in (1) is the easiest to observe directly:

  1. Start the server normally, so both AppScheduler and EventSubscriptionScheduler initialize.
  2. Inspect DBConnectionManager.getInstance() — a single provider is registered under "myDS", not two.
  3. Count physical connections from the pod (SHOW PROCESSLIST on MySQL, or pg_stat_activity on Postgres): five belong to the orphaned pool no scheduler can reach and nothing will ever close.
  4. Stop the server and watch the second job store fail against an already-closed pool.

For (2), run against RDS with IAM auth (awsRegion + allowPublicKeyRetrieval in the JDBC URL) and leave the pod idle past the 15-minute token lifetime: new physical connections from the Quartz and Flowable pools fail authentication while request traffic, which mints fresh tokens, is unaffected.

For (4), compare DB_CONNECTION_POOL_MAX_SIZE against the pod's actual session count.

Expected behaviour

Every subsystem that needs database connections should get them from a Dropwizard-managed HikariCP pool built from the same openmetadata.yaml configuration as the request pool, so that driver tuning, timeouts, metrics, IAM token refresh and shutdown all apply uniformly and every connection a pod opens is accounted for and tunable.

Pools should stay separate but centrally configured rather than literally shared: Flowable holds a connection for an entire command, including synchronous service tasks that call the REST API and search, so sharing the request pool would let workflow work starve API traffic and vice versa — reintroducing (1) one layer down.

Activity

  1. added this to August - 2025 and removed this from Roadmapon Aug 10, 2025
  2. moved this to Platform in August - 2025on Aug 10, 2025
  3. harshach commented on Aug 10, 2025

    @harshach
    Collaborator

    @mohityadav766 who can take this up?

  4. added this to November - 2025 and removed this from August - 2025on Oct 1, 2025
  5. moved this to Platform in November - 2025on Oct 1, 2025
  6. moved this from Done ✅ to No status in November - 2025on Oct 8, 2025
  7. added this to Jan - 2026 and removed this from November - 2025on Dec 4, 2025
  8. added theissue type on Dec 4, 2025
  9. added this to March - 2026 and removed this from Jan - 2026on Jan 5, 2026
  10. moved this to Release Backlog 🚧 in Shippingon Aug 25, 2026
  11. moved this from Release Backlog 🚧 to In Progress 🏗️ in Shippingon Sep 8, 2026
  12. moved this from In Progress 🏗️ to In Review / QA 👀 in Shippingon Sep 10, 2026
  13. moved this from In Review / QA 👀 to Done ✅ in Shippingon Sep 18, 2026
  14. added a commit that references this issue on Sep 19, 2026
    c50cee5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

  • Status
    Done ✅
  • Status
    Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions