Skip to content

fts: serialize concurrent mutations of QFTSEdgeCompute scores map - #69

Merged
adsharma merged 1 commit into
mainfrom
fix-fts-query-scores-map-race
Aug 28, 2026
Merged

fts: serialize concurrent mutations of QFTSEdgeCompute scores map#69
adsharma merged 1 commit into
mainfrom
fix-fts-query-scores-map-race

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Summary

QFTSEdgeCompute::copy() (used to give each worker thread in a scheduled parallel frontier task its own edge compute) shares the same scores map by reference, but edgeCompute() mutated it with no synchronization. Concurrent emplace/at() can rehash the map while other threads mutate it, corrupting the heap — observed as malloc(): invalid next size (unsorted) aborts under concurrent QUERY_FTS_INDEX scans (see LadybugDB/ladybug#840).

Guard all mutations with a shared mutex owned via std::shared_ptr so copies share the same lock, mirroring the existing MatchTermsVertexCompute::resDfsMutex pattern in the same file.

Companion PR: LadybugDB/ladybug#845 (bumps the submodule to this commit).

QFTSEdgeCompute copies share the same scores map by reference (one copy
per worker thread in a scheduled parallel frontier task), but edgeCompute
mutated the map with no synchronization. Concurrent emplace/at() can
rehash the map while other threads mutate it, corrupting the heap.

Guard all mutations with a shared mutex, mirroring the existing
MatchTermsVertexCompute::resDfsMutex pattern.

Related to LadybugDB/ladybug#840.
@adsharma
adsharma merged commit 1bbddaf into main Aug 28, 2026
2 checks passed
@adsharma
adsharma deleted the fix-fts-query-scores-map-race branch August 28, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant