Repository navigation
Description
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:
- Start the server normally, so both
AppSchedulerandEventSubscriptionSchedulerinitialize. - Inspect
DBConnectionManager.getInstance()— a single provider is registered under"myDS", not two. - Count physical connections from the pod (
SHOW PROCESSLISTon MySQL, orpg_stat_activityon Postgres): five belong to the orphaned pool no scheduler can reach and nothing will ever close. - 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
- StatusShow more project fieldsDone ✅
- StatusShow more project fieldsNo status
Activity
harshach commentedon Aug 10, 2025
@mohityadav766 who can take this up?
Fixes open-metadata#21379: use Dropwizard-managed pooled data sources…