Skip to content

[FIXED] #4789 to allow a restart of a shutdown server instance.#4792

Open
derekcollison wants to merge 1 commit intomainfrom
issue-4789
Open

[FIXED] #4789 to allow a restart of a shutdown server instance.#4792
derekcollison wants to merge 1 commit intomainfrom
issue-4789

Conversation

@derekcollison
Copy link
Member

Resolves: #4789

Signed-off-by: Derek Collison derek@nats.io

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison derekcollison requested a review from a team as a code owner November 13, 2023 18:29
defer s.Noticef("Server is ready")

// Check is this may be a restart.
if s.startupComplete == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think one should ask if we want to support calling s.Start() after a s.Shutdown(). If yes, then I think it is a bit more than that, that needs to be done. I believe that there are others things that are created/setup in NewServer() whose state may be changed during Shutdown() and that Start() will not take into account.

s.Shutdown()
s.WaitForShutdown()
s.Start()
defer s.Shutdown()
Copy link
Member

Choose a reason for hiding this comment

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

Case in point, would s.Shutdown() not panic because channel shutdownComplete has already been closed in previous Shutdown()? My point is that I believe that there way more state that would need to be recreated/reset on a Start() after a Shutdown() that we can think of.

Copy link
Member

Choose a reason for hiding this comment

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

If it does not panic, it means that the second Shutdown() is actually not shutting down, likely because the code thinks it is already shutdown...

Copy link
Member Author

Choose a reason for hiding this comment

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

Meaning we should expand the test to make sure the server is usable? Or are you suggesting that the second start should fail and you can not re-use servers that have been shutdown?

Copy link
Member

Choose a reason for hiding this comment

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

The latter. I think that there is a lot of "state" that would need to be recreated/reset if we wanted to support a Start() after a Shutdown() (and therefore subsequent Shutdown() calls..). The only issue I have with that is Start() does not return an error, so that would leave the user not knowing that it is not started again. We could add a StartServer() or something like that, that would return an error (similar to what we did with NewServer vs New).

@github-actions github-actions bot added the stale This issue has had no activity in a while label Mar 18, 2024
@neilalexander
Copy link
Member

This one worth rebasing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue has had no activity in a while

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic when calling server.Start() after shutting down the server.

3 participants