Skip to content

(9.17) Leaked goroutine caused by GlobalTimeCache #3616

@rverdile

Description

@rverdile

It looks like GlobalTimeCache was removed on master due to a separate issue, but I wanted to highlight another problem I’ve run into in case it is re-added. And this issue might just be a misunderstanding on my part, so feel free to treat it as a discussion point.

I discovered the issue through a unit test of mine that checks for leaked goroutines. GlobalTimeCache starts a goroutine in an init() function, which means the goroutine is launched as soon as the package is imported. What’s unclear to me is how this goroutine is supposed to be stopped.

If I create a client and call client.Close(), that does stop the goroutine — but that feels odd, because calling Close() on a single client shouldn’t be responsible for shutting down what is intended to be a global resource.

And in the case of my unit test, I wasn't evening using redis in the scope of the test, but because redis was imported by a package this test imports, the goroutine was spawned.

Metadata

Metadata

Assignees

No one assigned

    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