alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.18k stars 7.96k forks source link

[Dashboard Bug] oncurrent operator(add rule) multi application's same type rule will lose at least one application's rules #1820

Open kitdine opened 3 years ago

kitdine commented 3 years ago

Issue Description

Type: bug report

Describe what happened (or what feature you want)

when someone A operator one application's flowrule, just wanna add one, at the same time, aonther person B just review the page about the flowrule by another application, after B reivewed, A just submit the form data, then refresh the page just find flowrules just have onlyone rule that he just added , the other rules just gone.

Describe what you expected to happen

after add one rules, A will see all flowrules in the page

How to reproduce it (as minimally and precisely as possible)

  1. open A application's flowrule page such as http://sentinel.xxx.com/#/dashboard/v2/flow/A
  2. add one flow rule
  3. open aothner browser tabpage such as http://sentinel.xxx.com/#/dashboard/v2/flow/B
  4. do not refresh the page in step 1, and just add aother flowrule in the same page open by the step 1.
  5. when finish you will only see the flow rule add by step 4 and the rule add by step 1 was gone

Tell us your environment

sentinel dashboard 1.7.2
datasource zookeeper

Anything else we need to know?

maybe the reason is in the codes : InMemoryRuleRepositoryAdapter

    @Override
    public List<T> saveAll(List<T> rules) {
        // TODO: check here.
        allRules.clear();
        machineRules.clear();
        appRules.clear();

        if (rules == null) {
            return null;
        }
        List<T> savedRules = new ArrayList<>(rules.size());
        for (T rule : rules) {
            savedRules.add(save(rule));
        }
        return savedRules;
    }

the clear() method not only clear current application's rule,but also all application's rules

linlinisme commented 3 years ago

@kitdine would you post some screen shot here? make sure our conversation is on the same page

kitdine commented 3 years ago

@kitdine would you post some screen shot here? make sure our conversation is on the same page

image

is that ok?