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

raft: return non-nil Inflights in raft status #10903

Merged
merged 3 commits into from
Jul 18, 2019
Merged

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Jul 17, 2019

Recent refactoring to the String() method of Progress hit an NPE
because we return nil Inflights as part of the Raft status. Just
fix this at the source and properly populate the Raft status instead
of teaching String() to ignore nil. A real Progress always has a
non-nil Inflights.

tbg added 2 commits July 17, 2019 12:53
Recent refactoring to the String() method of `Progress` hit an NPE
because we return nil Inflights as part of the Raft status. Just
fix this at the source and properly populate the Raft status instead
of teaching String() to ignore nil. A real Progress always has a
non-nil Inflights.
This is useful for debug purposes, and more so once we support joint
quorums.
@bdarnell
Copy link
Contributor

Aren't we concerned about allocations on this code path? I think I'd rather make it nil-safe than add another copy if we don't need the data.

@nvanbenschoten
Copy link
Contributor

Agreed. I think we should avoid making Status even more expensive and allocation-heavy than it already is unless there's a good reason to do so.

@tbg
Copy link
Contributor Author

tbg commented Jul 17, 2019

It turns out that there's a good reason. A nil Inflights is a very annoying gotcha. For example, IsPaused() also calls a method on Inflights and causes another NPE. I don't want to play whack-a-mole with this, I'd rather fix the allocations in CRDB. But for the newly added *Config, this is similarly unfortunate.
I think it's time to change the Status API a bit more holistically, will do that tomorrow.

Copy link
Contributor

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

LGTM

@tbg
Copy link
Contributor Author

tbg commented Jul 18, 2019

I added a commit that splits up Status into a BasicStatus plus the fields that we need to allocate for. RawNode can now return a BasicStatus. As I pull this into CRDB, I'll make sure to watch out for allocation heavy paths. Interestingly, at first glance there weren't any -- there might be a lot of small ones that add up mostly from the queues (frequently in shouldQueue, which we call a lot) but I'm relatively certain there isn't anything in the hot paths.

Now that a Config is also added to the full status, the old name
did not convey the intention, which was to get a Status without
an associated allocation.
@tbg tbg merged commit 62f4fb3 into etcd-io:master Jul 18, 2019
@tbg tbg deleted the inflights branch July 18, 2019 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants