-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix rule id conflict #2967
Open
garroshh
wants to merge
6
commits into
alibaba:master
Choose a base branch
from
garroshh:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix rule id conflict #2967
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sczyh30
added
kind/enhancement
Category issues or prs related to enhancement.
to-review
To review
area/dashboard
Issues or PRs about Sentinel Dashboard
labels
Nov 22, 2022
Confirmed this is already working in our private version of sentinel dashboard. |
jnan806
reviewed
Dec 22, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
采用时间戳的话,在多副本情况下,会存在时钟回拨
引起 id 重复问题😃
是的,这个之前也考虑到有风险,所以加了一个随机数,由于创建规则的频率和密度通常是非常低的,所以觉得这个问题被触发的几率极低,我认为可以接受,如果真的要完全唯一的id,不借助额外组件是不能实现的,所以权衡了一下觉得这个方式是性价比最高的,可以听听你的建议。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/dashboard
Issues or PRs about Sentinel Dashboard
kind/enhancement
Category issues or prs related to enhancement.
to-review
To review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
dashboard 接入外接数据源后,当dashboard重启后id自增会被重置,或dashboard为多副本时规则id会出现相同的自增数字id,导致生成重复的规则id。
Does this pull request fix one issue?
Fixes #2932
Describe how you did it
采用雪花算法,做到尽可能小的概率id冲突。
尽可能小的原因是雪花算法中间的机器位数,需要借助中间件如mysql或zk来分配机房,机器等ID,或者借助配置文件自己分配,为了不引入中间件,所以机器位数这里采用了随机数,为了不超出long的限制,这里取了0-999随机数。