Skip to content

Commit

Permalink
store/gcworker: reduce "full config reset" log on pd side (#44331) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot committed Jun 1, 2023
1 parent 064a4e5 commit 3a40ddb
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions store/gcworker/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2008,20 +2008,20 @@ func (w *GCWorker) doGCPlacementRules(se session.Session, safePoint uint64, dr u
}
}

if len(physicalTableIDs) == 0 {
return
// Skip table ids that's already successfully handled.
tmp := physicalTableIDs[:0]
for _, id := range physicalTableIDs {
if _, ok := gcPlacementRuleCache[id]; !ok {
tmp = append(tmp, id)
}
}
physicalTableIDs = tmp

bundles := make([]*placement.Bundle, 0, len(physicalTableIDs))
for _, id := range physicalTableIDs {
bundles = append(bundles, placement.NewBundle(id))
if len(physicalTableIDs) == 0 {
return
}

for _, id := range physicalTableIDs {
// Skip table ids that's already successfully deleted.
if _, ok := gcPlacementRuleCache[id]; ok {
continue
}
// Delete pd rule
failpoint.Inject("gcDeletePlacementRuleCounter", func() {})
logutil.BgLogger().Info("try delete TiFlash pd rule",
Expand All @@ -2030,12 +2030,22 @@ func (w *GCWorker) doGCPlacementRules(se session.Session, safePoint uint64, dr u
if err := infosync.DeleteTiFlashPlacementRule(context.Background(), "tiflash", ruleID); err != nil {
logutil.BgLogger().Error("delete TiFlash pd rule failed when gc",
zap.Error(err), zap.String("ruleID", ruleID), zap.Uint64("safePoint", safePoint))
} else {
// Cache the table id if its related rule are deleted successfully.
gcPlacementRuleCache[id] = struct{}{}
}
}
return infosync.PutRuleBundlesWithDefaultRetry(context.TODO(), bundles)
bundles := make([]*placement.Bundle, 0, len(physicalTableIDs))
for _, id := range physicalTableIDs {
bundles = append(bundles, placement.NewBundle(id))
}
err = infosync.PutRuleBundlesWithDefaultRetry(context.TODO(), bundles)
if err != nil {
return
}

// Cache the table id if its related rule are deleted successfully.
for _, id := range physicalTableIDs {
gcPlacementRuleCache[id] = struct{}{}
}
return nil
}

func (w *GCWorker) doGCLabelRules(dr util.DelRangeTask) (err error) {
Expand Down

0 comments on commit 3a40ddb

Please sign in to comment.