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

9 Intermittent missing quadkey value #10

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

matthewscottgordon
Copy link
Collaborator

@matthewscottgordon matthewscottgordon commented Jul 9, 2024

Closes #9

I was not able to duplicate this issue but I did find a race condition the definitely could have produced the observed issue.

allIdentifiers[:] does not copy the underlying array like [:] does in Python, it just creates a new slice that points the same underlying array as allIdentifiers. So identifiers.SortIdentifiers() was still sorting the elements in allIdentifiers despite the apparent attempt to make a copy.

This could definitely cause keys to go missing if requests are handled concurrently. You would have multiple handlers attempting to sort the same array at the same time.

The identifiers.SortIdentifiers() function is passed a list of strings
which it sorts internally, creating a race condition when this
function is called concurrently with the same list. (And it would be
called concurrently in practice, and is always passed the same list.)

The author of the function appears to have intended to make a copy of
the list to avoid this, but the "copy" was just a new slice pointing
into the old slice.
Copy link
Collaborator

@captaincoordinates captaincoordinates left a comment

Choose a reason for hiding this comment

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

Nice! Good catch

@captaincoordinates captaincoordinates merged commit 93b6cfe into main Jul 9, 2024
2 checks passed
@captaincoordinates captaincoordinates deleted the 9-Intermittent-missing-quadkey-value branch July 9, 2024 21:43
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.

Intermittent missing quadkey value
2 participants