Skip to content

[Server] Report database connection pool usage in /metrics #2257

Closed

Description

@shba24

Is your feature request related to a problem? Please describe.

UC runs all database work through one HikariCP pool, 20 connections by default:

# 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:

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:

| 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 MetricsRegistries that takes the registry and the HikariDataSource and registers these gauges from dataSource.getHikariPoolMXBean().
  • Call it from initializeObservability, next to where the registry is created:

// 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:

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:

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

  1. added
    enhancement
    good first issue
    on Nov 16, 2026
  2. sakshi-bhasin commented on Nov 16, 2026

    @sakshi-bhasin
    Contributor

    Hi, I’d like to work on this. Could you assign it to me?

  3. added a commit that references this issue on Nov 20, 2026
    9b94065
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions