Repository navigation
cache/upstream: Create an upstream cache package - #3
Merged
Merged
Conversation
* main: devbox: install golangci-lint at its latest version GitHub: Configure action to run golangci-lint
* main: GitHub: Disable build for multiple platforms golangci-lint: Enable many of the linters (#4)
* main: GitHub: Improve the CI test
* main: GitHub: Remove dead code GitHub: Use the same Go version as we have in Nix
* main: devbox: Prefer double quotes
* main: nixcacheinfo: Create a parser to parse NixCacheInfo (#5)
kalbasit
added a commit
that referenced
this pull request
Dec 1, 2024
* main: cache/upstream: Create an upstream cache package (#3) nixcacheinfo: Create a parser to parse NixCacheInfo (#5) devbox: Prefer double quotes GitHub: Remove dead code GitHub: Use the same Go version as we have in Nix GitHub: Improve the CI test GitHub: Disable build for multiple platforms golangci-lint: Enable many of the linters (#4) devbox: install golangci-lint at its latest version GitHub: Configure action to run golangci-lint
3 tasks done
kalbasit
added a commit
that referenced
this pull request
May 24, 2026
## Summary Three pre-existing `pkg/cache` flakes from #1247 share one root cause: assertions that race against absolute wall-clock time and break under CI load even when the production code is correct. Surfaced repeatedly during the lean-flake-check measurement runs in #1249 (which sits stacked on top of this branch). All three fixes are **test-only**. No production code is touched. ## What changed | Flake (from #1247) | Test | Before | After | | --- | --- | --- | --- | | #5 | `TestCDCBackends/{SQLite,MySQL}/first_pull_completes_before_CDC_chunking_finishes` | `assert.Less(elapsed, 500ms)` racing the slow chunker | Happens-before check: `select { case <-chunkingStarted: t.Fatal(…) }` after `io.ReadAll`. `slowChunker` grew an optional `started chan struct{}` closed when its delay expires. Delay bumped 500 ms → 10 s (only matters under regression). | | #1 | `TestCacheBackends/MySQL/PutNarInfoDeadlock` | `context.WithTimeout(2s)` then `assert.NoError`. Could not distinguish "deadlock" from "MariaDB slow." | Timeout bumped 2 s → 60 s. A real deadlock still fails fast; non-deadlocked slow path now passes. | | #2 | Six instances of `assert.WithinDuration(CreatedAt, LastAccessedAt, 2s)` across `TestCacheBackends` | 2 s tolerance was tight enough that two CLOSE-TO-NOW() timestamps from different SQL operations under MariaDB load could fall outside it (observed -3 s spread). | Tolerance bumped 2 s → 30 s. Still tight enough to catch a genuinely broken "set both timestamps at row creation" semantic. | ## Why "test-only" and not "fix the production bug" These three are *measurement bugs*: the assertions encode an assumption ("operation X completes within Y milliseconds") that's an artifact of the dev host's speed, not a property the codebase ever promised. The behavior the tests *want* to verify (no deadlock, timestamps set close together at creation, GetNar doesn't block on chunking) is still being verified — the encoding is just no longer wall-clock-dependent. Flakes #3 and #4 from #1247 are NOT addressed here because they are not the same shape: - **#3** (`ConcurrentDownloadCancelOneClientOthersContinue`, 20-min hang) is a real hang in `io.ReadAll(readerB)` or `wg.Wait()` after all the existing 5–10 s guards have passed — almost certainly a production-code bug in the shared-reader-fanout path. Filed as **#1252** for separate investigation. - **#4** (`GetNarInfoConcurrentPutNarInfoDuringMigration`) exercises the same concurrent-migration-vs-PutNarInfo window that the next test (`testGetNarInfoMultipleConcurrentPutsDuringMigration`) explicitly `t.Skip`s with `"blocked on pgx transaction-abort cascade in PutNarInfo re-fetch path"`. That tracked production bug is the actual root cause; this test exercising it less reliably isn't a separate issue. ## Stack This PR is stacked under #1249 (`improve-flake-check-time`); landing this first should unblock #1249's CI by eliminating three of the five flakes that were causing intermittent reds. ``` main → fix-cache-test-timing-assertions (this PR, #1253) → improve-flake-check-time (#1249) ``` ## Test plan - [x] `nix develop -- go test -race -count=1 -run "TestCDCBackends/SQLite/first_pull_completes_before_CDC_chunking_finishes" ./pkg/cache/` passes locally. - [x] `nix develop -- go test -race -count=1 -run "TestCacheBackends/SQLite/(PutNarInfoDeadlock|GetNarInfo/narinfo_exists_upstream/nar_does_exist)" ./pkg/cache/` passes locally. - [x] `golangci-lint run` clean (run inside `nix develop` so the toolchain resolves). --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
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.
The upstream package will be used to pull narinfos and nars to the local cache.