Backend's Redisson connection pool silently goes stale after periods of low traffic, breaking trace ingestion (WriteRedisConnectionException / StacklessClosedChannelException)
Opik version: 1.10.44 (backend server)
Component: Opik Server (backend)
Describe the bug
After a period of relatively low traffic (observed recurring on a multi-day cycle, roughly every 2-5 days in our environment), opik-backend's Redis connections start failing with:
io.netty.channel.StacklessClosedChannelException: null
! Causing: org.redisson.client.WriteRedisConnectionException: Unable to write command into connection! Check CPU usage of the JVM. Try to increase nettyThreads setting. Netty pending tasks: 0, ...This affects two separate code paths:
- Background stream consumers (online scoring, webhooks, trace-thread-closing) — logged as
Error reading from Redis stream/Error claiming pending messages. - The OTel trace-ingestion endpoint itself (
OpenTelemetryResource.handleOtelTraceRequest) — it performs a blockingGETEX otelTraceId:...Redis call (apparently a dedup/idempotency check) synchronously per request. When the pooled connection is stale, this call fails and the entire trace-ingestion request returns HTTP 500. This silently drops incoming traces with no retry — the client observing this sees the trace vanish with no server-side indication of why.
Impact observed
- A single production incident: a customer call's trace never appeared in Opik because its span-flush attempt hit this exact failure at call end (
voice_agent.services.tracing:flush_spansloggedsuccess=False), and the trace was permanently unrecoverable. - A separate, more severe incident on a different environment:
opik-backendran for ~45 hours without any successful trace ingestion for a given project (100% failure rate on/api/v1/private/otel/v1/tracesduring that window), and went unnoticed until a customer reported a missing trace days later. Restarting the backend pod immediately resolved it.
What we've ruled out
- Redis server itself:
CONFIG GET timeoutreturns0— Redis is not proactively closing idle client connections. opik-backendresource pressure: CPU and memory usage were both well under their configured limits when the errors occurred (not throttled).- Redis pod health: 0 restarts, low resource usage, no errors in its own logs during the incident window.
This points to the connection going stale from the client (Redisson) side without being detected/refreshed before reuse — consistent with pingConnectionInterval not being enabled/tuned, so Redisson never validates an idle pooled connection is still alive before writing to it.
Kubernetes health check doesn't catch it either
Dropwizard's /health-check admin endpoint (which the liveness/readiness probes are wired to) reports a redis health check, and it reported "healthy": true continuously throughout a live 45-hour outage where the actual trace-ingestion path was failing 100% of requests. This suggests the registered health check doesn't exercise the same pooled connections used by the stream consumers / trace endpoint, so Kubernetes' own self-healing never triggers on this failure mode.
What we found is not configurable today
config.yml exposes many Redis-stream-level settings (poll intervals, batch sizes, retry counts) but no low-level Redisson connection-pool settings — no idleConnectionTimeout, pingConnectionInterval, or nettyThreads (the exact parameter the error message itself suggests tuning). These appear to be hardcoded in the RedissonClient construction rather than exposed via config.yml or environment variables.
Suggested fix
- Enable/tune
pingConnectionIntervalon the Redisson client config so stale pooled connections are detected and refreshed before reuse, rather than failing on write. - Expose Redisson's connection-pool health settings (
idleConnectionTimeout,pingConnectionInterval,nettyThreads,connectionMinimumIdleSize) viaconfig.yml/env vars so operators can tune them without a code change. - Make the
redishealth check actually exercise the pooled connections used by the stream consumers/trace endpoint, so Kubernetes can self-heal on this failure automatically. - Consider a retry-on-stale-connection wrapper specifically around the trace-ingestion endpoint's Redis dedup check, since failing the entire trace write over an internal cache lookup seems disproportionate — a transient Redis hiccup shouldn't cost the trace itself.
Environment
- Deployment: Kubernetes (AKS), via the official Helm chart, Altinity-managed ClickHouse
- Redis: single-node, in-cluster
- Recurrence: observed independently on two separate environments, same symptom both times
Current workaround
We've deployed a CronJob that watches opik-backend's own logs for the WriteRedisConnectionException pattern and restarts the deployment automatically when detected, to bound outage duration to minutes instead of days. This is a stopgap, not a fix.
Source: comet-ml/opik