Skip to content

Conversation

@eofedorov
Copy link

@eofedorov eofedorov commented Feb 9, 2026

Rutor search was crashing with "fatal error: concurrent map writes" when
the index was updated (loadDB/updateDB) while Search or other readers
accessed shared state (torrs slice and torrsearch index) from other goroutines.

  • Introduce a package-level sync.RWMutex and hold it around all reads and
    writes of torrs, isStop, and torrsearch index in Start, Stop, updateDB,
    loadDB, and Search.
  • Ensure index is built and assigned under the same lock so no goroutine
    sees a half-updated state.

Add TestConcurrentSearchAndLoadDB to verify there is no data race between
concurrent loadDB and Search; run with: go test -race -count=3.

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.

2 participants