riverqueue / river

Fast and reliable background jobs in Go
https://riverqueue.com
Mozilla Public License 2.0
3.37k stars 89 forks source link

Intermittent test failure: `TestRequireInsertedTx/FailsOnInsertOpts` #225

Closed bgentry closed 6 months ago

bgentry commented 7 months ago

New test failure on this run:

--- FAIL: TestRequireInsertedTx (0.00s)
    --- FAIL: TestRequireInsertedTx/FailsOnInsertOpts (0.23s)
        rivertest_test.go:908: 
                River assertion failure:
                Job with kind 'job2' max attempts 78 not equal to expected 77

        rivertest_test.go:908: 
                River assertion failure:
                Job with kind 'job2' priority 2 not equal to expected 3

        rivertest_test.go:908: 
                River assertion failure:
                Job with kind 'job2' queue 'another_queue' not equal to expected 'wrong-queue'

        rivertest_test.go:908: 
                River assertion failure:
                Job with kind 'job2' scheduled at 2023-10-30T10:[45](https://github.com/riverqueue/river/actions/runs/8033452341/job/21943962479#step:8:46):23.000123Z not equal to expected 2023-10-30T10:48:46.000246Z

        rivertest_test.go:908: 
                River assertion failure:
                Job with kind 'job2' state 'available' not equal to expected 'cancelled'

        rivertest_test.go:374: 
                Error Trace:    /home/runner/work/river/river/rivertest/rivertest_test.go:374
                Error:          Not equal: 
                                expected: "\n    River assertion failure:\n    Job with kind 'job2' state 'scheduled' not equal to expected 'cancelled'\n\n"
                                actual  : "\n    River assertion failure:\n    Job with kind 'job2' state 'available' not equal to expected 'cancelled'\n\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,3 @@
                                     River assertion failure:
                                -    Job with kind 'job2' state 'scheduled' not equal to expected 'cancelled'
                                +    Job with kind 'job2' state 'available' not equal to expected 'cancelled'

                Test:           TestRequireInsertedTx/FailsOnInsertOpts
FAIL
FAIL    github.com/riverqueue/river/rivertest   1.2[57](https://github.com/riverqueue/river/actions/runs/8033452341/job/21943962479#step:8:58)s

Just reporting this for now because I'm on a plane. You may also be more familiar with these tests and able to diagnose the failure quickly @brandur.

brandur commented 7 months ago

Oh man, okay yeah I see what happened here: we inserted a scheduled job and it was made available by the queue maintainer's scheduler before the tests could verify the job was cancelled. Luckily: super easy fix. We just need to make sure that the insert is using the same tx that the requires are using, and that'll mean the job is hidden from the queue maintainer.

I'll take the fix.