Skip to content

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

@nailcui

Description

@nailcui

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/Configkind/bugCategory issues or prs related to bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions