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 GitHub
commit 6ecf3b72ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
} }