Fix alignment bug on 32-bit platforms in new rackAwareRR
code
#1666
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When updating Debian packaging to 1.3.0, we noticed that tests were failing on 32-bit systems e.g. on 32-bit ARM [1] or i386 [2]:
Further investigation on affected platforms showed that this issue was related to a Go problem regarding the use of
atomic.*64*
functions [3]:This problem surfaces in https://github.com/gocql/gocql/blob/fe55d80b186e16ef11ea79c0cd98065d85886cbe/policies.go#L956 where the last item in a struct is accessed, triggering the unaligned access.
An obvious workaround is moving
lastUsedHostIdx
to the beginning of therackAwareRR
struct (also see [4]), which indeed solves the problem for me. Tests complete on such these platforms now as well. Hence I am proposing this PR as a low-impact solution for that issue.My email address is already in the
AUTHORS
file as I apparently have contributed before :)[1] https://ci.debian.net/data/autopkgtest/testing/armhf/g/golang-github-gocql-gocql/29281221/log.gz
[2] https://ci.debian.net/data/autopkgtest/testing/i386/g/golang-github-gocql-gocql/29271590/log.gz
[3] https://pkg.go.dev/sync/atomic#pkg-note-BUG
[4] golang/go#11891 (comment)