Reimplement driver tests for PGAdvisoryXactLock so they don't involve clock timing#885
Merged
Merged
Conversation
e100a8d to
118a116
Compare
bgentry
approved these changes
May 8, 2025
Comment on lines
+2694
to
+2713
| // It's possible for multiple versions of this test to be running at the | ||
| // same time (from different drivers), so make sure the lock we're | ||
| // acquiring per test is unique by using the complete test name. | ||
| lockHash := hashutil.NewAdvisoryLockHash(0) | ||
| lockHash.Write([]byte(t.Name())) | ||
| lockHash.Write([]byte("123456")) | ||
| key := lockHash.Key() |
…ve clock timing
I've gotten a failure a couple times in the driver tests for
`PGAdvisoryXactLock` in that it times out when trying to use another
transaction to acquire or release the lock:
--- FAIL: TestDriverDatabaseSQLLibPQ (19.44s)
driver_test.go:40: Generated schema "river_2025_05_08t01_05_22_schema_08" with migrations [1 2 3 4 5 6] on line "main" in 53.591381ms [9 generated] [5 reused]
driver_test.go:40: Driver does not support listener; skipping listener tests
--- FAIL: TestDriverDatabaseSQLLibPQ/PGAdvisoryXactLock (0.21s)
riverdrivertest.go:2691: TestTx using schema: river_2025_05_08t01_05_22_schema_06
riverdrivertest.go:2701: TestTx using schema: river_2025_05_08t01_05_22_schema_06
riverdrivertest.go:2727:
Error Trace: /home/runner/work/river/river/internal/riverinternaltest/riverdrivertest/riverdrivertest.go:2727
Error: Goroutine didn't finish in a timely manner
Test: TestDriverDatabaseSQLLibPQ/PGAdvisoryXactLock
riverdbtest.go:277: Checked in schema "river_2025_05_08t01_05_22_schema_08"; 1 idle schema(s) [137 generated] [133 reused]
FAIL
FAIL github.com/riverqueue/river 27.844s
Here, reimplement this test wholesale, moving away from dependency on
clock timing and over to having the other test transaction use the
non-blocking `pg_try_advisory_lock `instead. This should eliminate all
intermittency from this test case.
[1] https://github.com/riverqueue/river/actions/runs/14896356386/job/41839541488
3ec8b5d to
4d6abbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've gotten a failure a couple times in the driver tests for
PGAdvisoryXactLockin that it times out when trying to use anothertransaction to acquire or release the lock:
Here, reimplement this test wholesale, moving away from dependency on
clock timing and over to having the other test transaction use the
non-blocking
pg_try_advisory_lockinstead. This should eliminate allintermittency from this test case.
[1] https://github.com/riverqueue/river/actions/runs/14896356386/job/41839541488