Skip to content

If the autoid service node is not leader, save the cached ids back would cause potential 'Duplicate entry' error #46444

@tiancaiamao

Description

@tiancaiamao

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

By read the code logic ... not easy to reproduce without special hack.

Imagine that tidb5 is autoid service leader.
It allocates id to 30000
Then tidb1 become leader, it continue to provide service.
tidb1 allocates to 34000
Then tidb5 exit, it doesn't know it's not leader anymore, and store 30000 the current max autoid
Later, there would be duplicated entry in range [30000, 34000)

2. What did you expect to see? (Required)

If the autoid service is not leader, it should not store the max autoid back when it exit.

3. What did you see instead (Required)

This line has bug!

if s.leaderShip != nil {

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions