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: Fix flaky blocklist test #52

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

yizzlez
Copy link
Contributor

@yizzlez yizzlez commented Mar 10, 2023

Which problem is this PR solving?

This is re: #45 (comment)

The original code has a rare race condition:

  1. On line 180, the currentIndex is loaded
  2. Context switch to where currentIndex is incremented
  3. IncrementKey is called on the updated index
  4. AggregateCounts is called on an old currentIndex. This is undefined behavior, as currentIndex is assumed to be monotonically increasing.

To validate that this race condition was fixed, I wrote a script that ran the test 100 times.

With the previous code, I observed 7 failures out of 100 runs.

With the new code, I observed 0 failures out of 100 runs.

Short description of the changes

Small change to unit tests.

@yizzlez yizzlez requested a review from a team as a code owner March 10, 2023 18:36
Copy link
Contributor

@kentquirk kentquirk left a comment

Choose a reason for hiding this comment

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

Thank you for this!

@kentquirk kentquirk merged commit 1e7ae5a into honeycombio:main Mar 10, 2023
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.

3 participants