Merge pull request #9591 from hashicorp/dnephin/state-store-coordinates-iter

state: do not delete from inside an iteration (coordinates)
This commit is contained in:
Daniel Nephin 2021-01-19 18:16:49 -05:00 committed by hashicorp-ci
parent 5f3a185cb0
commit 7f14ce7a7e
1 changed files with 4 additions and 0 deletions

View File

@ -740,7 +740,11 @@ func (s *Store) deleteNodeTxn(tx WriteTxn, idx uint64, nodeName string) error {
if err != nil { if err != nil {
return fmt.Errorf("failed coordinate lookup: %s", err) return fmt.Errorf("failed coordinate lookup: %s", err)
} }
var coordsToDelete []interface{}
for coord := coords.Next(); coord != nil; coord = coords.Next() { for coord := coords.Next(); coord != nil; coord = coords.Next() {
coordsToDelete = append(coordsToDelete, coord)
}
for _, coord := range coordsToDelete {
if err := tx.Delete("coordinates", coord); err != nil { if err := tx.Delete("coordinates", coord); err != nil {
return fmt.Errorf("failed deleting coordinate: %s", err) return fmt.Errorf("failed deleting coordinate: %s", err)
} }