Repository navigation
fix(seaweedfs): stop the master crashing on the crowded volume map - #5308
Conversation
SeaweedFS 4.45 updates the crowded-volume map of a volume layout under the read lock, while Assign reads that map under the same read lock to count writable volumes. Under a steady write load the Go runtime aborts the master with "concurrent map read and map write", a fatal error that recover cannot catch, and the S3 gateway answers 500 until a master is elected again. Taking the write lock for the update, as every other mutation of the map already does, removes the race. Upstream fixed it in seaweedfs/seaweedfs#11216, released in 4.46. The patch carries that change and its regression test unchanged, so the build runs the test and the patch stops applying, and is dropped, once the vendored release carries the fix. Signed-off-by: Mattia Eleuteri <[email protected]> Assisted-by: LLM
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
mattia-eleuteri LGTM, E2E is green on this head. #4879 now has to drop this patch when it bumps past 4.46.
What this PR does
Backports seaweedfs/seaweedfs#11216 ("topology: fix fatal concurrent map read/write on VolumeLayout.crowded", released in 4.46) as a patch on the in-tree 4.45 image, next to
reader-cache-prefetch-window.diff.In 4.45,
(*VolumeLayout).SetVolumeCrowdedmutates thecrowdedmap underaccessLock.RLock(), while(*VolumeLayout).GetWritableVolumeCountreads the same map underRLock()on theAssignpath. Two read-lock holders, one writing and one reading the map, make the Go runtime abort the master withfatal error: concurrent map read and map write. This cannot be recovered, so the process exits and S3 requests that need an assign fail until a master is back. The fix takes the write lock inSetVolumeCrowded; every other mutation ofcrowdedalready holds it.patches/volume-layout-crowded-lock.diffis the upstream squash commit 5d5ea18287cfbf9e274f4b78be40a0ae220cb55d (files underweed/topology/), regenerated against the 4.45 source so it applies without offset. Its content is unchanged, including the regression testTestSetVolumeCrowdedNoRaceWithGetWritableVolumeCount, which the Dockerfile's existinggo teststep runs on every build.Seen in production
On a production platform running Cozystack v1.7.0 (in-tree SeaweedFS 4.45), with a dedicated S3 cluster used as the Velero backup target:
InternalErrorfrom the S3 gateway, and the nightly backups endFailedorPartiallyFailed(4Failedand 3PartiallyFailedon the night of 2026-11-12 to 13).Upstream issue: seaweedfs/seaweedfs#11211.
Testing
git apply --checkof both patches against the 4.45 source archive (SOURCE_SHA256in the Dockerfile matches).CGO_ENABLED=0as in the image build:fatal error: concurrent map writes, FAIL. With the fix:go test ./weed/topology/passes, and the new test passes under-racetoo.docker buildx build images/seaweedfs --platform linux/amd64builds, running the patched packages' tests.make testinpackages/system/seaweedfs: 107 helm unit tests, the naming-guard check and the image/chart version check pass.Lifecycle
The patch is dropped once the vendored chart reaches 4.46 or later, for example with #4879 (4.48 bump). From that release on it no longer applies, and
make update-imagefails until it is removed, as the Dockerfile header says. This PR is kept small so that it does not wait for #4879.Backport
This is a
fixwith no CRD, migration or API change, andrelease-1.7carries the sameimages/seaweedfs/asmain, so the backport batch should take it ontorelease-1.7with a clean cherry-pick for the next v1.7.x. Clusters on v1.7 are the ones that crash today.Downstream repositories
The diff touches only
packages/system/seaweedfs/images/seaweedfs/(a Go patch and a Dockerfile comment): no package added or renamed, no values, schema, CRD,hack/or installer change, so no entry of the trigger map applies.Release note
Summary by CodeRabbit