Repository navigation
Description
Is your feature request related to a problem? Please describe.
UC runs all database work through one HikariCP pool, 20 connections by default:
unitycatalog/etc/conf/hibernate.properties
Lines 7 to 11 in 2f41e34
| # One HikariCP pool for Hibernate and Casbin (a single maximumPoolSize cap). | |
| # Autocommit defaults to false. jdbc-adapter 2.7.0 still holds one pooled connection; | |
| # Casbin enables autocommit on that checkout only. | |
| hibernate.hikari.maximumPoolSize=20 | |
| hibernate.hikari.minimumIdle=2 |
The pool is built without any metrics:
unitycatalog/server/src/main/java/io/unitycatalog/server/persist/utils/HibernateConfigurator.java
Lines 152 to 154 in 2f41e34
| private static HikariDataSource createDataSource(Properties hibernateProperties) { | |
| return new HikariDataSource(hikariConfig(hibernateProperties)); | |
| } |
/metrics lists JVM, Armeria, HTTP request and UC counters, and nothing about the pool:
unitycatalog/docs/server/observability.md
Lines 97 to 105 in 2f41e34
| | Family | Description | | |
| |---|---| | |
| | `jvm_memory_used_bytes`, `jvm_gc_*`, `jvm_threads_*` | JVM heap and non-heap memory, GC pause, and thread counts | | |
| | `process_cpu_usage`, `system_cpu_usage` | Process and host CPU utilisation | | |
| | `armeria_server_*`, `armeria_executor_*` | Armeria server and executor internals | | |
| | `http_server_requests_total` | Completed HTTP requests on the API listener, tagged by `hostname_pattern`, `service`, `method`, and `http_status`; includes authentication and authorization rejections | | |
| | `uc_securable_table_creations_total` | Table securables created after their database transactions commit through UC, Delta, or Iceberg REST, including tables, views, and metric views | | |
| | `uc_storage_credential_cache_requests_total` | Credential requests to the [storage credential cache](configuration.md#storage-credential-cache), tagged by `result`: `hit` for a credential served from the cache, `miss` for a request the cache could not serve, which vends a new credential; a vend that fails also counts as a miss. Both series are exposed from startup and stay at zero while the cache is disabled | | |
| | `uc_storage_cleanup_attempts_total` | Attempts by the storage cleanup worker to delete a dropped managed resource's files, tagged by `result` and `resource_type`. `success` means the attempt deleted the files; `failure` means the attempt failed, either deleting the files or saving the result to the database, and the task will be retried. It counts attempts, not dropped resources: when a lease expires and another attempt runs, one resource can record more than one success. `resource_type` is `table`, `volume`, `registered_model`, `model_version`, or `staging_table`. Every series is exposed from startup | |
For example, when all 20 connections are busy, each new request waits up to 30 seconds (HikariCP's default connectionTimeout) for a connection. The operator sees slow requests but can't tell that the pool is exhausted.
Describe the solution you would like
Register pool gauges in the server's registry when observability is on, using HikariCP's standard metric names so existing dashboards work:
| Metric | Source on HikariPoolMXBean |
|---|---|
hikaricp.connections.active |
getActiveConnections() |
hikaricp.connections.idle |
getIdleConnections() |
hikaricp.connections.pending |
getThreadsAwaitingConnection() |
hikaricp.connections |
getTotalConnections() |
hikaricp.connections.max |
the pool's getMaximumPoolSize() |
Where to start:
- Add a static method to
MetricsRegistriesthat takes the registry and theHikariDataSourceand registers these gauges fromdataSource.getHikariPoolMXBean(). - Call it from
initializeObservability, next to where the registry is created:
unitycatalog/server/src/main/java/io/unitycatalog/server/UnityCatalogServer.java
Lines 297 to 301 in 2f41e34
| // This server owns the registry and releases its JVM/GC binders on close(). | |
| metrics = MetricsRegistries.createPrometheus(); | |
| PrometheusMeterRegistry meterRegistry = metrics.registry(); | |
| armeriaServerBuilder.observabilityService( | |
| "/metrics", PrometheusExpositionService.of(meterRegistry.getPrometheusRegistry())); |
Use gauges rather than HikariDataSource.setMetricRegistry. HikariCP accepts a registry only once per pool, and tests can start more than one server with the same HibernateConfigurator:
unitycatalog/server/src/test/java/io/unitycatalog/server/base/BaseServerTest.java
Lines 161 to 172 in 2f41e34
| UnityCatalogServer.Builder serverBuilder = | |
| UnityCatalogServer.builder() | |
| .port(port) | |
| .serverProperties(initServerProperties) | |
| .hibernateConfigurator(hibernateConfigurator) | |
| .credentialOperations(cloudCredentialVendor) | |
| .fileOperationsDecorator(this::decorateFileOperations) | |
| .configurationFolder(configurationFolder); | |
| if (observabilityEnabled) { | |
| serverBuilder.observabilityPort(observabilityPort); | |
| } | |
| unityCatalogServer = serverBuilder.build(); |
Add a row to the metric families table in docs/server/observability.md.
Tests go into the existing ObservabilityEndpointsIntegrationTest: add hikaricp_connections_active and hikaricp_connections_max to the strings its scrape must contain:
Lines 205 to 219 in 2f41e34
| assertThat(response.body()) | |
| .contains( | |
| "jvm_memory_used_bytes", | |
| "process_cpu_usage", | |
| "system_cpu_usage", | |
| "armeria_server_", | |
| "uc_securable_table_creations_total", | |
| // Both series are registered at startup and stay at zero because the cache is disabled | |
| // here. | |
| "uc_storage_credential_cache_requests_total{result=\"hit\"} 0.0", | |
| "uc_storage_credential_cache_requests_total{result=\"miss\"} 0.0", | |
| // Every cleanup series is registered at startup too. | |
| "uc_storage_cleanup_attempts_total{resource_type=\"staging_table\",result=\"failure\"}" | |
| + " 0.0", | |
| "http_server_requests_total"); |
Run:
build/sbt "server/testOnly io.unitycatalog.server.observability.ObservabilityEndpointsIntegrationTest io.unitycatalog.server.UnityCatalogServerTest"
Done when a scrape shows the five pool series, the docs list them, and these tests pass.
Additional context
This issue covers only the pool. Timing STS, Azure and GCS calls is a separate change. Endpoint latency is in #2256.
Activity
sakshi-bhasin commentedon Nov 16, 2026
Hi, I’d like to work on this. Could you assign it to me?
[Server] Report database connection pool usage in /metrics (unitycata…