GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — RedisSentinel: native multi-host failover (refs #2819) by nikamodis · Pull Request #2832 · phpredis/phpredis ConversationSummaryAdds native multi-host support to Partially addresses #2819. Related prior discussion: #2132. API$sentinel = new RedisSentinel([ 'hosts' => [ ['host' => '10.0.0.1', 'port' => 26379], ['host' => '10.0.0.2', 'port' => 26379], ['host' => '10.0.0.3', 'port' => 26379], ], 'connectTimeout' => 0.1, 'auth' => 'secret', ]); // Auto-falls-back to the next Sentinel on network failure. $master = $sentinel->getMasterAddrByName('mymaster'); Semantics
Not in this PR (deferred)To keep scope reviewable, the following are deferred to a follow-up:
The supporting infrastructure introduced here ( Implementation notes
Testing
Open questionsHappy to adjust any of these based on maintainer preference:
Opened as Draft to invite design discussion before marking ready for review.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAdds a 'hosts' array option to RedisSentinel::__construct so the client
transparently falls back to the next Sentinel endpoint on network failure,
eliminating the need for userland workarounds in HA deployments.
$sentinel = new RedisSentinel(['hosts' => [
['host' => '10.0.0.1', 'port' => 26379],
['host' => '10.0.0.2', 'port' => 26379],
['host' => '10.0.0.3', 'port' => 26379],
]]);
Semantics:
- Sticky connection: the first reachable host is used until it fails.
- One command-level retry per call; a bounded linear scan inside
sentinel_try_next_host iterates remaining hosts on a failed attempt.
- Skipped hosts are not revisited for the instance lifetime.
- Network error detection inspects RedisSock state (status, stream),
not exception message strings.
- Zero BC risk: when 'hosts' is absent, behavior is identical to today.
Host list is stored on RedisSock as three new fields; sentinel_host_entry
is forward-declared in common.h with the full struct in sentinel_library.h
so redis_object / Redis / RedisCluster layouts are untouched.
All 11 RedisSentinel methods wrap their REDIS_PROCESS_KW_CMD call in a
new SENTINEL_METHOD macro that implements the retry. No-op on single-host.
Refs phpredis#2819
- Stub phpdoc on __construct describes the 'hosts' option alongside the existing single-host parameters. - sentinel.md gains a 'Multi-host support' section covering API, semantics (sticky, bounded retry, no rehydration), and error handling (RedisException on validation and exhaustion). - Regenerated arginfo reflects only the new stub hash; method signatures are unchanged. Refs phpredis#2819 Adds 17 integration tests (tests/RedisSentinelMultiHostTest.php) covering: - Construction with 'hosts' array - Connect-time fallback through dead hosts - Exhaustion throwing RedisException with host count in message - Validation errors (empty, missing 'host' key, wrong types, oversized) - DoS guard (>1024 hosts rejected) - Default port (26379) when omitted - Single-host BC path unchanged - Auth propagation (skipped unless SENTINEL_AUTH_PASS is set) - Sticky behavior verified via call-time comparison - Bounded retry elapsed-time check Tests mark themselves skipped when the local Sentinel env isn't reachable, so existing local test runs are unaffected. The env itself (tests/sentinel-multihost/) is a minimal docker-compose cluster with 1 master + 2 replicas + 3 Sentinels on ports 26379/80/81. Refs phpredis#2819 Runs the RedisSentinelMultiHostTest integration tests across PHP 8.1-8.4 against the docker-compose cluster in tests/sentinel-multihost/. - docker compose up, wait for Sentinels via 'nc -z' - phpize + configure --enable-redis + make - php tests/TestRedis.php --class redissentinelmultihost - Dumps docker logs on failure for triage - Tears down the cluster in all outcomes Refs phpredis#2819 This branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |