Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in computing whether checkpoint write is necessary #3860

Merged
merged 3 commits into from
Feb 5, 2020

Conversation

lukehoban
Copy link
Member

We were seeing that ~all same steps were requiring checkpoint writes due to percieving a difference between Dependencies being nil and []URN{} - which should be considered the same for this purpose.

We were seeing that ~all same steps were requiring checkpoint writes due to percieving a difference between `Dependencies` being `nil` and `[]URN{}` - which should be considered the same for this purpose.
sortDeps := func(deps []resource.URN) {
sort.Slice(deps, func(i, j int) bool { return deps[i] < deps[j] })
}
sortDeps(old.Dependencies)
sortDeps(new.Dependencies)
return !reflect.DeepEqual(old.Dependencies, new.Dependencies)
// reflect.DeepEqual does not treat `nil` and `[]URN{}` as equal, so we must check for both
// lists being empty ourselves.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed - and I do worry that effectively all our uses of reflect.DeepEqual are potentially prone to being "wrong" relative to our expectations due to this. We may need to do an audit of our use of this API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants