test(air): fix flaky TestSyncEmails_DoesNotHoldRuntimeLockAcrossFetch CI failure#120
Open
qasim-nylas wants to merge 1 commit into
Open
test(air): fix flaky TestSyncEmails_DoesNotHoldRuntimeLockAcrossFetch CI failure#120qasim-nylas wants to merge 1 commit into
qasim-nylas wants to merge 1 commit into
Conversation
TestSyncEmails_DoesNotHoldRuntimeLockAcrossFetch raced a 20s wall-clock deadline against the post-fetch sync goroutine finishing. Under the full -race suite on a saturated CI runner the goroutine gets starved past 20s, so the timer fired and failed the test even though the sync completes correctly (~3s locally). The test's real assertion (lock not held across the fetch) is verified earlier via the lockReleased probe; this deadline only reaps the goroutine before cleanup. Bump to 90s for headroom.
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.
What
Bumps the completion deadline in
TestSyncEmails_DoesNotHoldRuntimeLockAcrossFetchfrom 20s → 90s (internal/air/handlers_email_cache_runtime_test.go:598).Why
The test starts
syncEmailsin a goroutine, verifies the runtime lock is not held across the remote fetch (via thelockReleasedprobe), then waits for the goroutine to finish. That final wait raced a hard-coded 20s wall-clock deadline.Under the full
go test ./... -racesuite on a saturated GitHub runner (keyring ~96s, nylas ~120s, air/cache ~24s all overlapping under the race detector's ~10x slowdown), the post-fetch sync goroutine gets CPU-starved past 20s, so the timer fired and failed the test — even though the sync completes correctly. It reproduced twice on post-mergemainCI (run 1, run 2) then passed on retry with zero code changes — classic load-dependent flake. Locally it finishes in ~3s.The fix
The test's real assertion (lock not held across the fetch) is already verified earlier by
lockReleased— that passed in both failures. The deadline only exists to reap the goroutine before cleanup closes the cache DB. Bumping to 90s gives ~30x headroom over the real ~3s runtime, well clear of any realistic runner starvation.Testing
go test ./internal/air/ -run TestSyncEmails_DoesNotHoldRuntimeLockAcrossFetch -race— passes (~3.4s).Related docs
None — test-only change, no user-facing command, flag, or behavior is affected.