Skip to content
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

Data inconsistency (a-b-a) caused by concurrent execution of DumpAllProcessor and DumpProcessor #7780

Closed
nailcui opened this issue Feb 17, 2022 · 5 comments
Labels
area/Config kind/bug Category issues or prs related to bug.
Milestone

Comments

@nailcui
Copy link
Contributor

nailcui commented Feb 17, 2022

DumpAllProcessor和DumpProcessor 并发执行导致的数据不一致(a-b-a)问题

Describe the bug

  1. At the beginning, configure group: test, dataid: test, content: a
  2. During the execution of dumpallprocessor, the old version data a is queried from DB; Then start dump; Content: a
  3. At this time, the configuration change triggered from the console will change a to B (at this time, DB, memory and disk have been changed); Content: B
  4. The dump of step 1 starts to execute, changing B to a; Content: a
  5. At this time, the configuration goes through a - > b - > A; The final configuration is a
    Due to the above logic of parallel execution, the data A-B-A on the single machine; And data inconsistency between cluster nodes

0、开始时候,配置group: test,dataId: test,content: a
1、DumpAllProcessor 执行时候从db查询到了旧版本的数据a;此时content:a
2、此时从控制台触发的配置变更将a改为了b(此时db、内存、磁盘都已变更);此时content:b
3、步骤一的dump开始执行,将b改为了a;此时content:a
4、此时配置经历了 a->b->a;最终配置是a
由于上面这种并行执行的逻辑,导致了单机上的数据a-b-a;以及集群节点间的数据不一致

Expected behavior

The last thing you want to query about this configuration is b
希望最后查询到此配置的内容是 b

Acutally behavior

The content of this configuration is a
查询到此配置的内容是a

How to Reproduce
Steps to reproduce the behavior:

  1. Modify the logic of dumpallprocessor to make this case easier to reproduce. After querying the data from DB, sleep for a period of time, and then execute the next step

  2. Modify the configuration to a new value and query to get a new value

  3. Wait for dumpallprocessor to finish executing, and query the old value

  4. 修改下DumpAllProcessor的逻辑使得此case更容易复现,从db查询到数据后sleep一段时间,sleep时候执行下一步骤

  5. 修改配置为新值,查询可以得到新值

  6. 等待DumpAllProcessor执行完毕,查询得到旧值

Desktop (please complete the following information):

  • OS: [e.g. Centos]
  • Version [nacos-server 2.0.4]
  • Module [e.g. config]
@nailcui
Copy link
Contributor Author

nailcui commented Feb 17, 2022

image

@onewe
Copy link
Collaborator

onewe commented Feb 17, 2022

加上最后修改时间对比逻辑 应该能解决

@onewe
Copy link
Collaborator

onewe commented Feb 17, 2022

@onewe will solve it@

@nailcui
Copy link
Contributor Author

nailcui commented Feb 17, 2022

@onewe “加上最后修改时间对比逻辑 应该能解决”,如果这种方案可以的话,那我提交一个pr来解决可以吗

@onewe
Copy link
Collaborator

onewe commented Feb 17, 2022

我感觉可以哈 😂 欢迎提PR

@KomachiSion KomachiSion added this to the 2.1.0 milestone Apr 27, 2022
@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Config kind/bug Category issues or prs related to bug.
Projects
None yet
Development

No branches or pull requests

3 participants