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

[DNM] mcs: refine delete resource group logic to avoid corner case of tiflash #7191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions pkg/mcs/resourcemanager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,25 @@
if name == reservedDefaultGroupName {
return errs.ErrDeleteReservedGroup
}
if err := m.storage.DeleteResourceGroupSetting(name); err != nil {
return err
}

// First delete meta info from memory, then storage.
// This is to avoid an corner case of tiflash.
// 1. tiflash received etcd watch to delete resource group.
// 2. queries of that deleted resource group come, and tiflash ask PD to check,
// PD may not have deleted the meta info of the group in memory yet. So tiflash will setup the meta info of the group.
// And the meta info of the deleted group will stay in tiflash forever.
m.Lock()
group, ok := m.groups[name]
if !ok {
return errors.Errorf("resource group %s not found", name)

Check warning on line 281 in pkg/mcs/resourcemanager/server/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/mcs/resourcemanager/server/manager.go#L281

Added line #L281 was not covered by tests
}
delete(m.groups, name)
m.Unlock()

if err := m.storage.DeleteResourceGroupSetting(name); err != nil {
m.groups[name] = group
return err

Check warning on line 288 in pkg/mcs/resourcemanager/server/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/mcs/resourcemanager/server/manager.go#L287-L288

Added lines #L287 - L288 were not covered by tests
}
return nil
}

Expand Down
Loading