Skip to content

Gracefully handle shutdown in worker pool #107

@calbera

Description

@calbera

When shutting down an application, may see a panic like below

panic: context canceled

goroutine 1 [running]:
github.com/berachain/offchain-sdk/baseapp.(*JobManager).RunProducers(0xc00050f0b0, {0x1609860, 0xc000338ac0})
    /go/pkg/mod/github.com/berachain/offchain-sdk@v0.0.0-20240530213602-4f6189f6c32f/baseapp/job_manager.go:147 +0xb98
github.com/berachain/offchain-sdk/baseapp.(*BaseApp).Start(0xc00050f1a0, {0x1609860, 0xc000338ac0})
    /go/pkg/mod/github.com/berachain/offchain-sdk@v0.0.0-20240530213602-4f6189f6c32f/baseapp/baseapp.go:65 +0x18c
github.com/berachain/offchain-sdk/cmd.StartCmdWithOptions[...].func1({0x12eac5e, 0x4?, 0x12eab66?})
    /go/pkg/mod/github.com/berachain/offchain-sdk@v0.0.0-20240530213602-4f6189f6c32f/cmd/start.go:104 +0x504
github.com/spf13/cobra.(*Command).execute(0xc000328308, {0xc0003e4980, 0x2, 0x2})
    /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000328008)
    /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x15f8190?)
    /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
    /runner/mod/distributor/cmd/main.go:14 +0x4a

For any routines that are still ongoing, gracefully wait for completion to prevent unwanted panics.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions