Document DNS cache bypass limitation for resolution_family#5558
Document DNS cache bypass limitation for resolution_family#5558renecannao wants to merge 1 commit intov3.0from
Conversation
When the DNS cache misses, the hostname is passed directly to mysql_real_connect which uses the MariaDB client library's own getaddrinfo with AF_UNSPEC. The mysql-resolution_family setting only applies to the DNS cache resolver thread, not this fallback path. Add a comment documenting this known limitation.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (3)**/*.{cpp,h,hpp}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.cpp📄 CodeRabbit inference engine (CLAUDE.md)
Files:
lib/**/*.cpp📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📓 Common learnings📚 Learning: 2026-03-26T16:38:58.553ZApplied to files:
🔇 Additional comments (1)
📝 WalkthroughWalkthroughA clarifying comment is added to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds a documentation comment to lib/mysql_connection.cpp to clarify DNS resolution behavior during cache misses. However, the feedback points out that the added comment is misleading because it incorrectly attributes the use of the mysql-resolution_family setting to the DNS cache resolver thread, which actually uses a hardcoded AF_UNSPEC value.
| // NOTE: DNS cache miss — hostname is passed directly to | ||
| // mysql_real_connect which resolves via the MariaDB client library | ||
| // using AF_UNSPEC. The mysql-resolution_family setting does NOT | ||
| // apply here; it only governs the DNS cache resolver thread. |
There was a problem hiding this comment.
The comment states that mysql-resolution_family governs the DNS cache resolver thread. However, the implementation of monitor_dns_resolver_thread in lib/MySQL_Monitor.cpp appears to use a hardcoded AF_UNSPEC for the address family:
// lib/MySQL_Monitor.cpp:4675
hints.ai_family = AF_UNSPEC;This makes the comment potentially misleading as it suggests mysql-resolution_family is being used by the resolver thread when it is not. To avoid confusion, the comment should be updated to accurately reflect the current implementation.
There was a problem hiding this comment.
Pull request overview
Adds an inline code comment in the MySQL backend connection path to document a limitation around hostname resolution behavior when the DNS cache does not return an IP (fallback to the MariaDB client library resolver).
Changes:
- Document the DNS-cache-miss fallback behavior in
MySQL_Connection::connect_start_DNS_lookup(). - Clarify (via comment) when
AF_UNSPECis used for resolution in the fallback path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // NOTE: DNS cache miss — hostname is passed directly to | ||
| // mysql_real_connect which resolves via the MariaDB client library | ||
| // using AF_UNSPEC. The mysql-resolution_family setting does NOT | ||
| // apply here; it only governs the DNS cache resolver thread. |
There was a problem hiding this comment.
The new comment refers to a mysql-resolution_family setting and says it “only governs the DNS cache resolver thread”, but in this branch the DNS resolver thread still hardcodes hints.ai_family = AF_UNSPEC (see lib/MySQL_Monitor.cpp:4676) and there are no other references to mysql-resolution_family in the repo. Either stack this PR on top of the change that introduces that setting, or reword this note to avoid documenting a config option that doesn’t exist here. Also consider naming the actual async API used here (mysql_real_connect_start) to match the code path.
|



Summary
mysql_connection.cppdocumenting thatmysql-resolution_familydoes not apply when the DNS cache misses and the hostname falls through tomysql_real_connect(which uses the MariaDB client library's hardcodedAF_UNSPEC)Follow-up to #5554. Tracked in #5555 for future enhancement.
Summary by CodeRabbit
Note: This release contains no user-visible changes or functional updates.