Skip to content

Static topic mapping may select a stale epoch when the epoch delta overflows #10849

Description

@yuluo-yx

Description

Static topic mapping sorts long epoch values by subtracting them and narrowing the result to int. When two epochs differ by more than Integer.MAX_VALUE, the comparator can reverse their order. In replacement mode, checkAndBuildMappingItems then keeps the stale broker mapping instead of the latest one.

Expected behavior

Epochs should be ordered with Long.compare so the newest mapping always wins without arithmetic overflow.

Reproduction

Create two mapping details for the same logical queue with epochs 0 and Long.MAX_VALUE, call checkAndBuildMappingItems with replace enabled, and observe that the epoch-0 mapping is selected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions