This repository was archived by the owner on Oct 9, 2026. It is now read-only.
Repository navigation
Conversation
Contributor
Author
|
Superseded by #63, which includes this change or replaces it. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
TestAssemblerLazyInitRacefailed CI'sgo test -racejob four times on 2026-10-07: twice on main (runs 37561008993 and 37568246076) and twice on PR branches (37652983718 and 37662881723). The race detector reported a real race, not a timing problem.Engine.initAssemblerOnceandinitCompactionOnce(pkg/seahorse/short_engine.go) checked the field before taking the mutex. That's double-checked locking, which Go's memory model doesn't allow. The read outside the lock races with the write inside it. A caller that saw the new pointer could also use theAssemblerbefore its fields were visible to it, which can happen on arm64.Now
loadAssemblerandloadCompactionread the field, and create it if needed, under their mutex every time, and return it.Assemble,CompactandCompactUntilUndercall them. After the first use the lock is uncontended, and its cost is nothing next to the database work around it.Closealready readcompactionunder the lock.Tests:
TestCompactionLazyInitRacedoes for the compaction engine whatTestAssemblerLazyInitRacedoes for the assembler. Under-racein a Linux container (golang:1.26.6):TestAssemblerLazyInitRaceonce in 5 runs;loadCompaction, the new test reported the race within 10 runs;-race.Internal only; no CHANGELOG line.