Skip to content

x/sync/singleflight: occasional failures in TestForget #42092

@bcmills

Description

@bcmills
--- FAIL: TestForget (0.00s)
    singleflight_test.go:160: Third call should not be started because was started during second execution
    singleflight_test.go:163: We should receive result produced by second call, expected: 2, got 3
FAIL
FAIL	golang.org/x/sync/singleflight	61.958s

The failing test is the regression test added for #31420 (CC @cuonglm @bradfitz).

The bug appears to be in the test:
https://github.com/golang/sync/blob/b3e1573b75205f2905c4b27986413d2e2be9803c/singleflight/singleflight_test.go#L153-L157

In that section, nothing guarantees that the second invocation is still running when g.Do is evaluated. (The second goroutine can complete immediately after close(secondCh), causing the third invocation to be evaluated.)

2020-10-08T14:14:35-b3e1573/android-386-emu
2019-09-11T18:51:00-cd5d95a/freebsd-amd64-race
2019-04-23T02:48:10-1122301/freebsd-amd64-race
2019-04-23T02:48:10-1122301/windows-amd64-race

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.TestingAn issue that has been verified to require only test changes, not just a test failure.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions