From d738be6aa8976e6a138dadf5e9aa0bd6f5e545eb Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Wed, 23 Aug 2023 09:59:25 -0500 Subject: [PATCH] Backport of bug: prevent go routine leakage due to existing DeferCheck into release/1.15.x (#18564) * backport of commit 06d4c72f682881c78265248fb749ebfd5cc365b8 * backport of commit 42c37bb2c1e4d8eac8078f17c16b8e6797baa446 --------- Co-authored-by: cskh --- .changelog/18558.txt | 3 +++ agent/local/state.go | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 .changelog/18558.txt diff --git a/.changelog/18558.txt b/.changelog/18558.txt new file mode 100644 index 0000000000..9c2b9b44bb --- /dev/null +++ b/.changelog/18558.txt @@ -0,0 +1,3 @@ +```release-note:bug +check: prevent go routine leakage when existing Defercheck of same check id is not nil +``` diff --git a/agent/local/state.go b/agent/local/state.go index 5a037313b3..efccdaf681 100644 --- a/agent/local/state.go +++ b/agent/local/state.go @@ -834,6 +834,12 @@ func (l *State) setCheckStateLocked(c *CheckState) { existing := l.checks[id] if existing != nil { c.InSync = c.Check.IsSame(existing.Check) + // If the existing check has a Defercheck, it needs to be + // assigned to the new check + if existing.DeferCheck != nil && c.DeferCheck == nil { + c.DeferCheck = existing.DeferCheck + c.InSync = false + } } l.checks[id] = c