wasphin opened a new pull request, #3585:
URL: https://github.com/apache/brpc/pull/3585
### What problem does this PR solve?
Issue Number: N/A
Problem Summary:
The consistent hashing replica builders use the length returned by
`snprintf` even when the formatted key does not fit the buffer. Oversized
server tags can therefore produce an invalid key length for hashing.
### What is changed and the side effects?
Changed:
- Validate formatting results before hashing in the default and Ketama
replica policies, rejecting formatting errors and truncated keys.
- Add regression coverage for Murmur3, MD5, and Ketama: key-length
boundaries, rejection without partial ring updates, mixed batch additions,
and oversized tags when tag hashing is disabled.
Side effects:
- Performance effects: adds a length check when building each replica key.
Request selection is unchanged.
- Breaking backward compatibility: keys that fit the buffer retain their
existing mappings. When server tags participate in hashing, servers whose
generated keys exceed the existing buffer capacity are rejected rather
than hashing an invalid length. Batch additions still retain valid servers.
---
### 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).
--
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]