From 0985f96f8dbf91b088fdda294eae2d5726cf27b9 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 12 Feb 2024 08:59:04 -0500 Subject: [PATCH] state: fix state store corruption in plan apply (#19937) The state store's `UpsertPlanResults` method canonicalizes allocations in order to upgrade them to a new version. But the method does not copy the allocation before doing so, which can potentially corrupt the state store. This hasn't been implicated in any known user-facing bugs, but was detected when running Nomad under a build with Go toolchains data race detection enabled. --- nomad/state/state_store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 0b4541c12..bc91aaa5d 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -466,6 +466,7 @@ func (s *StateStore) UpsertPlanResults(msgType structs.MessageType, index uint64 // handle upgrade path for _, alloc := range allocsToUpsert { + alloc = alloc.Copy() alloc.Canonicalize() }