[OpenSIPS-Devel] [OpenSIPS/opensips] 7b8fe7: cachedb_redis: add dynamic cluster topology manage...
Liviu Chircu
noreply at github.com
Wed Apr 22 13:18:44 UTC 2026
Branch: refs/heads/master
Home: https://github.com/OpenSIPS/opensips
Commit: 7b8fe71ffdeaa9f534b8680182c059044f079efe
https://github.com/OpenSIPS/opensips/commit/7b8fe71ffdeaa9f534b8680182c059044f079efe
Author: Debian <gator at opensips-1.goes.com>
Date: 2026-03-30 (Mon, 30 Mar 2026)
Changed paths:
M modules/cachedb_redis/README
M modules/cachedb_redis/cachedb_redis.c
M modules/cachedb_redis/cachedb_redis_dbase.c
M modules/cachedb_redis/cachedb_redis_dbase.h
A modules/cachedb_redis/cachedb_redis_mi.c
A modules/cachedb_redis/cachedb_redis_mi.h
M modules/cachedb_redis/cachedb_redis_utils.c
M modules/cachedb_redis/cachedb_redis_utils.h
M modules/cachedb_redis/doc/cachedb_redis_admin.xml
A modules/cachedb_redis/test/.gitignore
A modules/cachedb_redis/test/Makefile
A modules/cachedb_redis/test/README.md
A modules/cachedb_redis/test/hash_under_test.c
A modules/cachedb_redis/test/test_edge_cases.sh
A modules/cachedb_redis/test/test_hash.c
A modules/cachedb_redis/test/test_load.sh
A modules/cachedb_redis/test/test_mi_commands.sh
A modules/cachedb_redis/test/test_mi_counters
A modules/cachedb_redis/test/test_mi_counters.c
A modules/cachedb_redis/test/test_topology_refresh.sh
A modules/cachedb_redis/test/test_topology_startup.sh
Log Message:
-----------
cachedb_redis: add dynamic cluster topology management and observability
Replace the static cluster topology (built once at startup, never
refreshed) with runtime discovery and automatic refresh:
Topology discovery and refresh:
- Probe CLUSTER SHARDS (Redis 7+) with fallback to CLUSTER SLOTS
(Redis 3+) for backward compatibility
- O(1) slot_table[16384] lookup replaces per-query linked-list scan
- Automatic topology refresh on MOVED redirect, connection failure,
or query targeting an unmapped slot (rate-limited to 1/sec)
- Dynamic node creation when MOVED points to an unknown endpoint
- Stale node pruning during refresh with safe connection cleanup
- Cap redirect loop at 5 max redirects to prevent worker hang on
pathological cluster state
Cluster observability via MI commands:
- redis_cluster_info: full topology dump including per-node connection
status, slot assignments, query/error/moved/ask counters, and
last activity timestamp
- redis_cluster_refresh: trigger manual topology refresh (bypasses
rate limit)
- redis_ping_nodes: per-node PING with microsecond latency reporting
- All MI commands support optional group filter parameter
Statistics:
- redis_queries, redis_queries_failed, redis_moved, redis_ask,
redis_topology_refreshes (module-level stat counters)
- Per-node query, error, moved, ask counters in redis_cluster_info
Hash slot correctness:
- Hash tag {…} extraction per Redis Cluster specification
- CRC16 modulo 16384 replaces bitwise AND with slots_assigned
ASK redirect handling:
- Detect ASK responses alongside existing MOVED handling
- Send ASKING command to target node before retrying original query
- Do not update slot map (ASK is a temporary mid-migration redirect)
- Refactor parse_moved_reply into parse_redirect_reply with prefix
parameter; inline wrappers for backward compatibility
Connection reliability:
- TCP keepalive via redis_keepalive parameter (default 10s)
- Stack allocation for redis_moved structs (eliminates OOM paths)
- NULL guards on malformed CLUSTER SHARDS/SLOTS reply elements
- Integer overflow protection in slot and port parsing
- NULL guards in MI command handlers for group_name/initial_url
Documentation:
- New section: Redis Cluster Support (topology discovery, automatic
refresh, MOVED/ASK handling, hash tags)
- MI command reference: redis_cluster_info, redis_cluster_refresh,
redis_ping_nodes
- Authentication URL format documentation (classic, ACL, no-auth)
- New parameter: redis_keepalive
Test suite (186 tests):
- C unit tests: hash slot calculation (37), MI counter helpers (41)
- Integration: topology startup (12), ASK redirect (16), topology
refresh (13), MI commands (50), edge cases (16)
- Trap EXIT handlers for safe cluster state restoration
- python3 preflight checks for JSON-dependent tests
Depends on: #3815 (hash tag + modulo fix), #3852 (ASK redirect)
Commit: 58741ce3a2de80351235d795a9ca579c1ae6f68a
https://github.com/OpenSIPS/opensips/commit/58741ce3a2de80351235d795a9ca579c1ae6f68a
Author: Norm Brandinger <n.brandinger at gmail.com>
Date: 2026-04-01 (Wed, 01 Apr 2026)
Changed paths:
M modules/cachedb_redis/Makefile
M modules/cachedb_redis/test/.gitignore
R modules/cachedb_redis/test/test_mi_counters
Log Message:
-----------
cachedb_redis: fix UNIT_TESTS build and remove committed binary
Exclude standalone test binaries (test_hash, test_mi_counters,
hash_under_test) from the UNIT_TESTS auto-discovery in Makefile.modules.
These files have their own main() and are built via test/Makefile;
pulling them into the module .so causes multiple-definition linker
errors.
Also remove the accidentally committed test/test_mi_counters ELF
binary and add it to .gitignore alongside test_hash.
Reported-by: dondetir <dondetir at users.noreply.github.com>
Commit: 67e4d3e445a5797595faa91541a354533928a249
https://github.com/OpenSIPS/opensips/commit/67e4d3e445a5797595faa91541a354533928a249
Author: Norm Brandinger <n.brandinger at gmail.com>
Date: 2026-04-01 (Wed, 01 Apr 2026)
Changed paths:
M modules/cachedb_redis/cachedb_redis_dbase.c
Log Message:
-----------
cachedb_redis: guard redisEnableKeepAliveWithInterval for hiredis < 1.0
redisEnableKeepAliveWithInterval() was added in hiredis 1.0.0.
Ubuntu 20.04 ships hiredis 0.14, causing an implicit-function-declaration
error with -Werror. Gate on HIREDIS_MAJOR >= 1, falling back to
redisEnableKeepAlive() (no interval parameter) on older versions.
Commit: 624ef5b61195ef8eff93fd1c2d9f54b8c50678de
https://github.com/OpenSIPS/opensips/commit/624ef5b61195ef8eff93fd1c2d9f54b8c50678de
Author: Liviu Chircu <liviu at opensips.org>
Date: 2026-04-22 (Wed, 22 Apr 2026)
Changed paths:
M modules/cachedb_redis/Makefile
M modules/cachedb_redis/README
M modules/cachedb_redis/cachedb_redis.c
M modules/cachedb_redis/cachedb_redis_dbase.c
M modules/cachedb_redis/cachedb_redis_dbase.h
A modules/cachedb_redis/cachedb_redis_mi.c
A modules/cachedb_redis/cachedb_redis_mi.h
M modules/cachedb_redis/cachedb_redis_utils.c
M modules/cachedb_redis/cachedb_redis_utils.h
M modules/cachedb_redis/doc/cachedb_redis_admin.xml
A modules/cachedb_redis/test/.gitignore
A modules/cachedb_redis/test/Makefile
A modules/cachedb_redis/test/README.md
A modules/cachedb_redis/test/hash_under_test.c
A modules/cachedb_redis/test/test_edge_cases.sh
A modules/cachedb_redis/test/test_hash.c
A modules/cachedb_redis/test/test_load.sh
A modules/cachedb_redis/test/test_mi_commands.sh
A modules/cachedb_redis/test/test_mi_counters.c
A modules/cachedb_redis/test/test_topology_refresh.sh
A modules/cachedb_redis/test/test_topology_startup.sh
Log Message:
-----------
Merge branch 'mr/feature-redis-cluster-management' of github.com:NormB/opensips into NormB-mr/feature-redis-cluster-management
Compare: https://github.com/OpenSIPS/opensips/compare/2b88be443fcd...624ef5b61195
To unsubscribe from these emails, change your notification settings at https://github.com/OpenSIPS/opensips/settings/notifications
More information about the Devel
mailing list