Skip to content

Fix BC break with env DSN & explicit aggregate - #765

Merged
ostrolucky merged 2 commits into
snc:masterfrom
HypeMC:fix-single-dsn-with-explicite-replication
Aug 2, 2026
Merged

ostrolucky merged 2 commits into
snc:masterfrom
HypeMC:fix-single-dsn-with-explicite-replication

Conversation

@HypeMC

@HypeMC HypeMC commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Since #759, a client configured with a single %env()% DSN and an explicit aggregate mode (replication: sentinel, replication: predis, or cluster) no longer works correctly. The aggregate option is silently ignored, and Predis connects to the configured host as if it were a standalone Redis server.

This is a significant BC break. In my case, this affects a Kubernetes deployment where the DSN points to a single Sentinel Service that load-balances traffic across the Sentinel pods:

snc_redis:
    clients:
        default:
            type: predis
            dsn: '%env(REDIS_DSN)%' # redis://redis-sentinel:26379
            options:
                replication: sentinel
                service: mymaster

There is only one address in the DSN, so after #759, Sentinel mode is no longer applied and the client attempts to communicate with the Sentinel endpoint as if it were a regular Redis server.

This PR ensures that an explicitly configured replication or cluster mode is always honored, regardless of whether the environment DSN expands to one or multiple addresses.

The behavior introduced in #759, which allows an environment DSN to expand to multiple connections, remains unchanged.

HypeMC and others added 2 commits August 1, 2026 22:40
Factor out the repeated single-env-DSN check into one named local and add
comments distinguishing the pre-normalization ($userDefinedAggregate) and
post-normalization ($isAggregate) reads of the cluster/replication options so
the two identical-looking expressions aren't mistaken for redundant duplication.
No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RBgT2MSur2tf8nxCzkCFni
@ostrolucky
ostrolucky merged commit 5763f8c into snc:master Aug 2, 2026
7 checks passed
@HypeMC
HypeMC deleted the fix-single-dsn-with-explicite-replication branch August 3, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants