mirror of https://github.com/hashicorp/terraform
All production state implementations copy the given state when storing it to temporary or permanent storage, either explicitly with DeepCopy, or implicitly by serializing the state. Since `updateStateHook` is called with every state change, a second call to `DeepCopy` with that hook doubles the overhead of `PostStateUpdate`. Since all Hook implementations which handle `PostStateUpdate` (which is exactly 1 in non-test code) only call state methods that eventually copy the state, we can remove the extra copy from the `updateStateHook` itself. The state was already locked for the duration of the `PostStateUpdate` call previously, so no additional delay should result. For consistency this also updates the documentation for `PostStateUpdate` to record the new caller and callee expectations based on the existing implementation. The Hook interface predated the `statemgr` which provides a better interface for synchronizing state access and therefor required extra copying at that time, while now we can more easily declare that the method requires concurrent access be locked for the duration of the call.pull/35164/head
parent
3845aa1a7d
commit
e8119cced3
Loading…
Reference in new issue