Skip to content

Commit

Permalink
refine delete resource group logic to avoid corner case of tiflash
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <[email protected]>
  • Loading branch information
guo-shaoge committed Oct 11, 2023
1 parent 3c632b1 commit ed1e5c6
Showing 1 changed file with 16 additions and 3 deletions.
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 @@ func (m *Manager) DeleteResourceGroup(name string) error {
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

0 comments on commit ed1e5c6

Please sign in to comment.