StackExchange / StackExchange/StackExchange.Redis
Redis Sentinel / Connection Leak
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.6k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
Redis Sentinel / Connection Leak
StackExchange.Redis (2.8.24) / OpenTelemetry.Instrumentation.StackExchangeRedis (1.9.0-beta.1)
Description
We are observing a connection leak in our production servers running redis sentinel.
First of all, we checked that there is no ConnectionMultiplexer instance leak in our code base and in the dump.
It turns out that when switching primary, the ConnectionMultiplexer's servers are cleared but the _serverSnapshot is not which causes duplicates (see below 1. figure) in the _serverSnapshot which pins PhysicalBridges (see below 2. and 3. figures).
-
Duplicates in _serverSnapshot
-
Leak of PhysicalBridge : 338
-
Similar Retention (max 204) with a common path:
It seems that when adding a new endpoint to the _serverSnapshot the servers field has been previously cleared and duplicates appear in the _serverSnapshot field.
How to reproduce
- Setup a redis sentinel
- Create a ConnectionMultiplexer with StackExchange.Redis (2.8.24)
- Instrument with OpenTelemetry.Instrumentation.StackExchangeRedis (1.9.0-beta.1)
- Switch primary / replica over and over
- Observe the number of connections.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ConnectionMultiplexer.Sentinel.cs around line 415 and ConnectionMultiplexer.cs around line 905, then reproduce repeated Sentinel primary/replica switches using the listed StackExchange.Redis and OpenTelemetry versions. Trace how clearing servers and adding endpoints updates _serverSnapshot and retains PhysicalBridges. Done means repeated failovers no longer create duplicate snapshot entries or growing retained connections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100