Skip to content

TimingWheel中currentTime和overflowWheel变量存在竞争问题 #33

@juine

Description

@juine

TimingWheel结构体中currentTime变量同时为多个goroutine访问,其中 add方法是只读,addvanceClock则是先去读currentTime变量,再判断,然后写入。使用了atomic只保证了读写currentTime变量那一个操作原子化,但是advanceClock则是先读再判断最后再写入, 会与add函数发生竞争,同理overflow变量也是一样好。粗略看了一下,kafka源码里面采用了是读写锁临时保护了这些变量

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