fts: serialize concurrent mutations of QFTSEdgeCompute scores map - #69
Merged
Conversation
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.
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.
Summary
QFTSEdgeCompute::copy()(used to give each worker thread in a scheduled parallel frontier task its own edge compute) shares the samescoresmap by reference, butedgeCompute()mutated it with no synchronization. Concurrentemplace/at()can rehash the map while other threads mutate it, corrupting the heap — observed asmalloc(): invalid next size (unsorted)aborts under concurrentQUERY_FTS_INDEXscans (see LadybugDB/ladybug#840).Guard all mutations with a shared mutex owned via
std::shared_ptrso copies share the same lock, mirroring the existingMatchTermsVertexCompute::resDfsMutexpattern in the same file.Companion PR: LadybugDB/ladybug#845 (bumps the submodule to this commit).