fix: TSI concurrent write and iteration fatal errors#27344
Merged
gwossum merged 1 commit intomaster-1.xfrom Apr 9, 2026
Merged
fix: TSI concurrent write and iteration fatal errors#27344gwossum merged 1 commit intomaster-1.xfrom
gwossum merged 1 commit intomaster-1.xfrom
Conversation
Fix `fatal error: concurrent map iteration and map write` errors in TSI code. This appears to have been introduced with #27343. This was a backport from main-2.x. A PR comment in #27343 indicates this PR is not necessary for correctness in master-1.x at this time. To fix the issue, #27343 is rolled back. A test (TestLogFile_TagValueIterator_ConcurrentWrite) is able consistently reproduce the error when #27343 is present. This bug was introduced in v1.12.3 and does impact previous versions. Closes: #27343
There was a problem hiding this comment.
Pull request overview
Fixes a fatal error: concurrent map iteration and map write panic in TSI log file tag value iteration by ensuring the relevant read lock is held during snapshot creation, and adds a regression test that reliably reproduces the issue when the lock is released too early.
Changes:
- Hold
LogFile’sRLockfor the full duration ofTagValueIterator()’s snapshot/iterator creation. - Add a concurrent writer/reader regression test for
TagValueIterator()vsAddSeriesList().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tsdb/index/tsi1/log_file.go |
Keeps RLock held while building the tag value iterator snapshot to prevent concurrent map iteration/write panics. |
tsdb/index/tsi1/log_file_test.go |
Adds a regression test that concurrently mutates and iterates tag values to catch the panic reliably. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+401
to
+406
| // Ensure TagValueIterator is safe to call concurrently with AddSeriesList. | ||
| // Regression test for a "concurrent map iteration and map write" fatal | ||
| // introduced when LogFile.TagValueIterator released its RLock before the | ||
| // underlying logTagKey.tagValues map was snapshotted. This is able to | ||
| // consistently reproduce the fatal error introduced by #26372. | ||
| func TestLogFile_TagValueIterator_ConcurrentWrite(t *testing.T) { |
There was a problem hiding this comment.
Contributor
davidby-influx
left a comment
There was a problem hiding this comment.
If the test fails, it panics, and the test harness recovers?
Member
Author
Yes, the Go |
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.
Fix
fatal error: concurrent map iteration and map writeerrors in TSI code. This appears to have been introduced with #27343. This was a backport from main-2.x. A PR comment in #27343 indicates this PR is not necessary for correctness in master-1.x at this time.To fix the issue, #27343 is rolled back. A test
(TestLogFile_TagValueIterator_ConcurrentWrite) is able consistently reproduce the error when #27343 is present.
This bug was introduced in v1.12.3 and does impact previous versions.
Closes: #27343