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 data distribution tracker memory bugs #4076

Conversation

sfc-gh-tclinkenbeard
Copy link
Collaborator

Changes in this PR:

  • Fixes memory errors that can occur when the data distribution tracker is cancelled

Style

  • All variable and function names make sense.
  • The code is properly formatted (consider running git clang-format).

Performance

  • All CPU-hot paths are well optimized.
  • The proper containers are used (for example std::vector vs VectorRef).
  • There are no new known SlowTask traces.

Testing

  • The code was sufficiently tested in simulation.
  • If there are new parameters or knobs, different values are tested in simulation.
  • ASSERT, ASSERT_WE_THINK, and TEST macros are added in appropriate places.
  • Unit tests were added for new algorithms and data structure that make sense to unit-test
  • If this is a bugfix: there is a test that can easily reproduce the bug.

Copy link
Collaborator

@sfc-gh-anoyes sfc-gh-anoyes left a comment

Choose a reason for hiding this comment

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

I like this general approach

state DataDistributionTracker self(cx, distributorId, readyToStart, output, shardsAffectedByTeamFailure,
anyZeroHealthyTeams, *shards);
anyZeroHealthyTeams, *shards, *trackerCancelled);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we pass a copy of GetTracker to child actors here instead of a pointer to self? I think that would make it harder to accidentally dereference self after it's freed

// Ideally this would be implemented with a lambda instead, but the actor compiler does not do
// type deduction.
class GetTracker {
bool const& trackerCancelled;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is easier to reason about for me if the members are pointers /shrug

@@ -658,8 +658,7 @@ ACTOR Future<Void> shardTracker(DataDistributionTracker::SafeAccessor self, KeyR
}
} catch (Error& e) {
// If e is broken_promise then self may have already been deleted
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is stale too now

@sfc-gh-tclinkenbeard sfc-gh-tclinkenbeard marked this pull request as ready for review November 18, 2020 20:41
@sfc-gh-anoyes sfc-gh-anoyes self-assigned this Nov 18, 2020
@sfc-gh-anoyes sfc-gh-anoyes merged commit 1401304 into apple:release-6.2 Nov 18, 2020
@sfc-gh-tclinkenbeard sfc-gh-tclinkenbeard mentioned this pull request Nov 18, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants