Skip to content

C版本的TurnBackId计算有误 #124

@lns0303

Description

@lns0303
static inline int64_t CalcTurnBackId(SnowFlakeWorker *worker) {
    uint64_t result = (worker->_LastTimeTick << worker->_TimestampShift) | (worker->WorkerId << worker->SeqBitLength) |
                      (worker->_TurnBackIndex);
    worker->_TurnBackTimeTick--;
    return result;
}

时间戳部分应该是使用worker->_TurnBackTimeTick进行计算吧,master分支目前是使用worker->_LastTimeTick. 应修改为以下:

static inline int64_t CalcTurnBackId(SnowFlakeWorker *worker) {
    uint64_t result = (worker->_TurnBackTimeTick << worker->_TimestampShift) | (worker->WorkerId << worker->SeqBitLength) |
                      (worker->_TurnBackIndex);
    worker->_TurnBackTimeTick--;
    return result;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions