adityaanikam opened a new pull request, #19653: URL: https://github.com/apache/hudi/pull/19653
### Describe the issue this Pull Request addresses Closes #19619. `ClientIds#nextId` sorts heartbeat client-id files with `Comparator.comparing(Path::getName)`, a plain lexicographic string sort. Once double-digit ids exist, `_10` sorts before `_2` (comparing `'1'` vs `'2'` at the second character), so the file the code treats as "largest" (the last one after sorting) is wrong. `nextId()` then reissues an id that's already in use — for example it returns `10` again instead of `11` when `_1` through `_10` already exist. ### Summary and Changelog Replaced the comparator with one that parses each heartbeat file's numeric client id and compares on that, and added a `getClientIdSortKey` helper that returns `-1` for the base file (empty id) so it still sorts first, matching the existing `INIT_CLIENT_ID` handling a few lines below. This also corrects the zombie-reuse branch just above the auto-increment logic, which reads from the same sorted list and could pick the wrong "smallest" zombie once double-digit ids existed. Added `TestClientIds` with two cases: the exact repro from the issue (heartbeat files `_`, `_1`...`_10`, asserting `nextId()` returns `"11"`) and a sanity check that ordinary single-digit ids still work as before. ### Impact No public API change. User-facing effect is limited to correct next-client-id generation under Flink multi-writer mode once more than 9 concurrent writers have registered — previously this could silently assign a duplicate id. No performance impact: same O(n log n) sort, only the comparator changed. ### Risk Level low. The change is isolated to the sort comparator used internally by `ClientIds#nextId`; the id-generation and zombie-cleanup logic downstream of the sort is unchanged. ### Documentation Update none. ### Contributor's checklist - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [x] Enough context is provided in the sections above - [x] Adequate tests were added if applicable -- 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]
