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

Closing syncer causes panics #9

Open
janekolszak opened this issue Dec 19, 2022 · 6 comments
Open

Closing syncer causes panics #9

janekolszak opened this issue Dec 19, 2022 · 6 comments

Comments

@janekolszak
Copy link

Hi!
Calling Close() closes internal channels, but it doesn't prevent sends on those internal channels.
Because of that I randomly see:

panic: send on closed channel

goroutine 68 [running]:
github.com/everFinance/arsyncer.(*Syncer).pollingBlock(0xc000178180)
        /home/jan/work/redstone/syncer/.gopath~/pkg/mod/github.com/ever!finance/arsyncer@v1.1.4/syncer.go:138 +0x506
created by github.com/everFinance/arsyncer.(*Syncer).Run
        /home/jan/work/redstone/syncer/.gopath~/pkg/mod/github.com/ever!finance/arsyncer@v1.1.4/syncer.go:83 +0x97

@zyjblockchain
Copy link
Member

This is normal, close must be closed channel

@janekolszak
Copy link
Author

Could you check if arsyncer.Close() was called and avoid writing to a closed channel?

@zyjblockchain
Copy link
Member

Could you check if arsyncer.Close() was called and avoid writing to a closed channel?
It's just an exit process, we don't expect this method to be called during the code run, this method is only applicable inside the program exit process

@zyjblockchain
Copy link
Member

You cannot call this method to pause arsyncer, arsyncer does not have a pause function

@janekolszak
Copy link
Author

Yes, I'm calling Close() only when our service is closing, but this isn't the problem.

The problem is that arsyncer is crashing the service when Close() is called.
I call Close() and wait till the SubscribeTx channel is closed. This way I'm sure all transactions pending in the channel get processed before our service is stopped.

Right now I call Close(), arsyncer is crashing and all pending data is lost.

Would you accept a PR?

@zyjblockchain
Copy link
Member

yes you can push a PR about this problem

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

No branches or pull requests

2 participants