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

Make Subchannel internal state handling clearer #1949

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Jun 24, 2024

Motivation:

The subchannel conflates closing (recoverable) with shutting down (terminal). Shutting down is initiated by a higher level (load-balancer, user) while closing happens when the subchannel closes unexpectedtly or is no longer required (i.e. becomes idle). A closed subchannel can be re-opeend, a shutdown subchannel can't. This distinction isn't clear enough in the state handling.

Modifications:

  • Rename 'close' to 'shutDown' where applicable
  • Add a new 'shutting down' state and renaming the 'closing' state to 'going away'.
  • Add a state machine diagram
  • Fix up a few state transitions

Result:

More robust state handling

Motivation:

The subchannel conflates closing (recoverable) with shutting down
(terminal). Shutting down is initiated by a higher level (load-balancer,
user) while closing happens when the subchannel closes unexpectedtly or
is no longer required (i.e. becomes idle). A closed subchannel can be
re-opeend, a shutdown subchannel can't. This distinction isn't clear
enough in the state handling.

Modifications:

- Rename 'close' to 'shutDown' where applicable
- Add a new 'shutting down' state and renaming the 'closing' state to
  'going away'.
- Add a state machine diagram
- Fix up a few state transitions

Result:

More robust state handling
@glbrntt glbrntt requested a review from gjcairo June 24, 2024 09:22
@glbrntt glbrntt added the v2 A change for v2 label Jun 24, 2024
Copy link
Collaborator

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 373 to 396
/// ┌───────────────┐
/// ┌───────▶│ NOT CONNECTED │───────────shutDown─────────────┐
/// │ └───────────────┘ │
/// │ │ │
/// │ connFailed──┤connect │
/// │ /backedOff │ │
/// │ │ ▼ │
/// │ │ ┌───────────────┐ │
/// │ └──│ CONNECTING │──────┐ │
/// │ └───────────────┘ │ │
/// │ │ │ │
/// closed connSucceeded │ │
/// │ │ │ │
/// │ ▼ │ │
/// │ ┌───────────────┐ │ ┌───────────────┐ │
/// │ │ CONNECTED │──shutDown──▶│ SHUTTING DOWN │ │
/// │ └───────────────┘ │ └───────────────┘ │
/// │ │ │ │ │
/// │ goAway │ closed │
/// │ │ │ │ │
/// │ ▼ │ ▼ │
/// │ ┌───────────────┐ │ ┌───────────────┐ │
/// └────────│ GOING AWAY │──────┘ │ SHUT DOWN │◀─┘
/// └───────────────┘ └───────────────┘
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for this :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

np, it was helpful for me too! 😅

@glbrntt glbrntt enabled auto-merge (squash) June 24, 2024 15:23
@glbrntt glbrntt merged commit 621bcf2 into grpc:main Jun 24, 2024
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 A change for v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants