Skip to content

Conversation

YifeiZhuang
Copy link
Member

fixes #9721

@YifeiZhuang YifeiZhuang requested a review from ejona86 March 21, 2023 01:16
}
if (GRACEFUL_SHUTDOWN_PING == payload) {
triggerGracefulSecondGoaway();
triggerGracefulSecondGoaway(null);
Copy link
Member

Choose a reason for hiding this comment

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

This is actually the primary flow. secondGoawayTimer is just in case the ping takes too long, we still want to continue the shutdown process. So using null here means that shutdown(void) is correct, but the max connection age won't have a grace time.

Copy link
Member Author

@YifeiZhuang YifeiZhuang Mar 22, 2023

Choose a reason for hiding this comment

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

Ah right that's true.
So after the first goaway and ping, the secondGoawayTimer is set with 1s ping timeout.
A normal successful ping ack within 1s cancels the timer and trigger second goAway and graceful shutdown. No ping after 1s also triggers the same path.

The ping method does not take any more parameter, as it implements frame handler interface. So I made the grace time a field. And it is synchronized on the lock to allow read and write to be thread safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ejona86 wdyt?

@YifeiZhuang YifeiZhuang force-pushed the okhttp-grace-shutdown branch from f653807 to e3c5690 Compare March 22, 2023 19:24
@YifeiZhuang YifeiZhuang requested a review from ejona86 March 22, 2023 19:24
}
if (gracefulShutdownPeriod != null) {
forcefulCloseTimer = scheduledExecutorService.schedule(
this::triggerForcefulClose, gracefulShutdownPeriod, TimeUnit.NANOSECONDS);
Copy link
Member

Choose a reason for hiding this comment

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

This changes the behavior when someone is doing:

server.shutdown();
server.awaitTerminated(10000, TimeUnit.SECONDS);

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to mention that #9649 changed the behavior of this. So I put it back.
So sound like we should do graceful shutdown when server.shutdown?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any change to triggerGracefulSecondGoaway() in #9649. We will do "double GOAWAY" graceful shutdown when server.shutdown(). That's what the code is doing already. server.shutdown() doesn't have a forceful close though.

Copy link
Member Author

Choose a reason for hiding this comment

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

never mind about #9649.
I updated server.shutdown() to avoid forceful close.

@YifeiZhuang YifeiZhuang merged commit 046e02b into grpc:master Mar 27, 2023
@YifeiZhuang YifeiZhuang deleted the okhttp-grace-shutdown branch March 27, 2023 22:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAX_CONNECTION_AGE_GRACE not really implemented

2 participants