0z5a opened a new pull request, #3735: URL: https://github.com/apache/brpc/pull/3735
### What problem does this PR solve? Issue Number: resolve #3733 Problem Summary: A line in a `file://` naming service file that has an address and a comment but no tag, for example ``` 10.24.234.18:8080 # a comment without tag ``` produces a server whose tag is `# a comment without tag`. `docs/en/client.md` says "contents after \# are comments and ignored", and the comment is cut correctly when a tag is present. `SplitIntoServerAndTag()` takes the first non-blank character after the address as the first character of the tag and only looks for `#` from the second character on. Since a server is identified by address + tag, one address listed with two different comments becomes two instances, and `NamingServiceFilter` and the tag-aware load balancers (`wrr`, `wr`, consistent hashing with `-consistent_hashing_enable_server_tag`) see the comment as tag. `list://` and remote file lists use the same function. ### What is changed and the side effects? Changed: - `SplitIntoServerAndTag()` treats a `#` at the place where the tag would start as the beginning of a comment, so the server gets an empty tag. - New test `NamingServiceTest.comment_after_address_is_not_tag`. It fails on master (5 servers instead of 4) and passes with this change. - Tested: `brpc_naming_service_unittest` passes (14 tests) with gcc 13.3, CMake build, protobuf 28.3, on Linux x86_64. The make and bazel builds, clang, macOS and the older protobuf versions of the CI matrix were not run locally. - AI disclosure: Claude Code, model claude-fable-5-2; AI was used to find the bug, write the reproducer, the fix and the test, run the tests listed above, and write the first draft of this description; AI-generated code: the changed condition and comment in `src/brpc/policy/file_naming_service.cpp` and the new test in `test/brpc_naming_service_unittest.cpp`. The commit carries `Generated-by:` as the ASF generative tooling guidance recommends. Side effects: - Performance effects: none. - Breaking backward compatibility: a server line that so far got a tag starting with `#` now has an empty tag. Lines that differ only in such a comment are one instance instead of several. --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
