Skip to content

fix: prevent data race on FSCompressedFileSuffixes map#2300

Merged
erikdubbelboer merged 1 commit into
valyala:masterfrom
xbrxr03:fix/fs-compressed-suffixes-race
Jun 22, 2026
Merged

fix: prevent data race on FSCompressedFileSuffixes map#2300
erikdubbelboer merged 1 commit into
valyala:masterfrom
xbrxr03:fix/fs-compressed-suffixes-race

Conversation

@xbrxr03

@xbrxr03 xbrxr03 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Update

Per maintainer feedback, simplified this to documentation only. The original approach added SetCompressedFileSuffix() and a sync.RWMutex, but @erikdubbelboer pointed out that FSCompressedFileSuffixes is meant to be set once at startup and not modified concurrently.

The fix is now just a doc comment clarifying that the map should be set in init() or before the first FS.NewRequestHandler call, and not modified afterwards.

Fixes #2223

@erikdubbelboer erikdubbelboer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I don't really like changing the API like this. This is something that you're supposed to set in an init() or at the start of main() and then don't change anymore. Instead of all these changes lets just document that. Can you please change this.

…dification

FSCompressedFileSuffixes is read during FSHandler initialization
(inside a sync.Once). It is not safe for concurrent modification.
Add documentation clarifying that custom suffixes should be set in
an init() function or before the first FS.NewRequestHandler call,
and the map should not be modified afterwards.

Fixes valyala#2223
@xbrxr03 xbrxr03 force-pushed the fix/fs-compressed-suffixes-race branch from b6e2877 to fffcb62 Compare June 22, 2026 16:28
@xbrxr03

xbrxr03 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated per your feedback — removed the API changes and just added documentation. The map should be set in init() and not modified afterwards. Thanks for the guidance!

@erikdubbelboer erikdubbelboer merged commit 9ee3c15 into valyala:master Jun 22, 2026
11 checks passed
@erikdubbelboer

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: FSCompressedFileSuffixes is a mutable exported map — data race risk

3 participants