Skip to content

fix: parse DB number from redis-sentinel URI path#1100

Open
ljluestc wants to merge 1 commit intohibiken:masterfrom
ljluestc:fix/669-sentinel-db-parsing
Open

fix: parse DB number from redis-sentinel URI path#1100
ljluestc wants to merge 1 commit intohibiken:masterfrom
ljluestc:fix/669-sentinel-db-parsing

Conversation

@ljluestc
Copy link
Copy Markdown

fix: parse DB number from redis-sentinel URI path (#669)

Problem

parseRedisSentinelURI ignored the /dbnumber path segment, making it impossible to connect to any DB other than 0 via sentinel URIs. For example:
text
would silently drop the /3 and always use DB 0.

The redis:// and rediss:// schemes already supported this via parseRedisURI.

Changes

• asynq.go: Extract the DB number from the URI path in parseRedisSentinelURI, using the same strconv.Atoi(xs[0]) pattern as parseRedisURI. Pass the parsed DB into RedisFailoverClientOpt. Return a descriptive error if the path segment is not a valid integer.
• asynq.go doc comment: Updated the ParseRedisURI godoc to show /dbnumber in the sentinel URI format:
text
• asynq_test.go: Added test cases:
◦ redis-sentinel://...5002/3?master=mymaster → DB 3
◦ redis-sentinel://:mypassword@...5002/7?master=mymaster → DB 7 with password
◦ redis-sentinel://localhost:5000/abc?master=mymaster → error (non-integer)

Previously, parseRedisSentinelURI ignored the /dbnumber path segment,
making it impossible to connect to any DB other than 0 via sentinel URIs.

This adds DB extraction from the URI path, consistent with how
parseRedisURI already handles it for redis:// and rediss:// schemes.

Closes hibiken#669
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.39%. Comparing base (4f00f52) to head (07898ea).
⚠️ Report is 36 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1100      +/-   ##
==========================================
- Coverage   67.13%   63.39%   -3.75%     
==========================================
  Files          29       29              
  Lines        4300     4991     +691     
==========================================
+ Hits         2887     3164     +277     
- Misses       1135     1549     +414     
  Partials      278      278              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kamikazechaser kamikazechaser marked this pull request as ready for review April 9, 2026 08:52
@kamikazechaser
Copy link
Copy Markdown
Collaborator

@ljluestc Let me know if you want to add something else to it cause it was marked as draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants