Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Fix rabbitio out panic 'send on closed channel'#38

Open
abc94e4f31 wants to merge 1 commit intoMeltwaterArchive:masterfrom
abc94e4f31:fixpanic
Open

Fix rabbitio out panic 'send on closed channel'#38
abc94e4f31 wants to merge 1 commit intoMeltwaterArchive:masterfrom
abc94e4f31:fixpanic

Conversation

@abc94e4f31
Copy link
Copy Markdown

#36

Comment thread cmd/out.go
<-c
fmt.Println(" Interruption, saving last memory bits..")
fmt.Println("Interruption, saving last memory bits..")
rabbit.SafeStop()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so this is about graceful shutdown on sigterm right? What's the consequence of not doing the SafeStop? Some stale channel on the broker?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes. It provides a graceful pause of AMQP-messages consuming before the closing go-channel, which writes messages on disk. The consequence of not doing the SafeStop is panic: send on closed channel on SIGTERM.

Comment thread rmq/consume.go
if err != nil {
log.Fatalf("rabbit channel cancel failed %s", err)
} else {
for _ = range time.Tick(2 * time.Second) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need the time tick here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's a "crutch", to allow for all AMQP-messages to be put into the write channel before it closes. I'm not so familiar with the golang, to avoid time tick/sleep usage, but it looks like a better approach exists.

Comment thread rmq/consume.go
Comment on lines +112 to +117
r.tag, // consumer
false, // noAck
false, // exclusive
false, // noLocal
false, // noWait
nil, // arguments
nil, // args
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to change these

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, you're right.

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.

2 participants