From 774ffd939c793e2f477d1de785aed1e9db656fe2 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 12 May 2021 10:52:30 +0100 Subject: [PATCH] Annotations: Prevent orphaned annotation tags cleanup when no annotations were cleaned (#33957) (#33975) Fixes #33948 Co-authored-by: Anatoly Fayngelerin (cherry picked from commit b0094b325e292aaa89e1be35b86858194a41e02d) Co-authored-by: afayngelerindbx <38990103+afayngelerindbx@users.noreply.github.com> --- pkg/services/sqlstore/annotation_cleanup.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/services/sqlstore/annotation_cleanup.go b/pkg/services/sqlstore/annotation_cleanup.go index 78227366530..0f9a181777b 100644 --- a/pkg/services/sqlstore/annotation_cleanup.go +++ b/pkg/services/sqlstore/annotation_cleanup.go @@ -47,8 +47,9 @@ func (acs *AnnotationCleanupService) CleanAnnotations(ctx context.Context, cfg * if err != nil { return totalCleanedAnnotations, 0, err } - - affected, err = acs.cleanOrphanedAnnotationTags(ctx) + if totalCleanedAnnotations > 0 { + affected, err = acs.cleanOrphanedAnnotationTags(ctx) + } return totalCleanedAnnotations, affected, err }