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 panic when stopping the nats #10363

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Conversation

2403905
Copy link
Contributor

@2403905 2403905 commented Oct 21, 2024

Description

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@2403905 2403905 requested review from kobergj and wkloucek October 21, 2024 16:22
@@ -44,6 +45,8 @@ func (n *NATSServer) ListenAndServe() (err error) {
return nil
}

// Shutdown stops the NATSServer gracefully
// The NATS server itself runs the signal handling. Set `natsOpts.NoSigs = true` if you want to handle signals ourselves
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the natsOpts.NoSigs = true option. The nats signal handler calls os.Exit() which might cause an unclean shutdown for the rest of ocis when running as a single binary.

I guess you'll have to add a n.server.WaitForShutdown() call below as well then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

@2403905 2403905 force-pushed the issue-10360 branch 2 times, most recently from 60a3578 to c1b9c72 Compare October 22, 2024 07:15
@2403905 2403905 requested a review from rhafer October 22, 2024 07:15
@@ -44,6 +47,7 @@ func (n *NATSServer) ListenAndServe() (err error) {
return nil
}

// Shutdown stops the NATSServer gracefully
func (n *NATSServer) Shutdown() {
n.server.Shutdown()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should add

 n.server.WaitForShutdown()

here. (Similar to what the signal handler in nats does)

Copy link

@2403905 2403905 merged commit 09ee725 into owncloud:master Oct 22, 2024
4 checks passed
ownclouders pushed a commit that referenced this pull request Oct 22, 2024
Fix panic when stopping the nats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The dedicated service ocis nats server runs panic when stopping.
2 participants