cockroachdb / cockroachdb/cockroach
span: btreeFrontier iterator protection should use counter
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
The `btreeFrontier` currently uses an atomic bool to prevent writers from modifying the frontier while an iterator on it is open. However, if there are multiple readers (which is theoretically possible in a single-threaded application via pull iterators), the bool could be reset back to false after the first reader completes at which point, writers would be allowed.
https://github.com/cockroachdb/cockroach/blob/3fb64cbd7e030b004b4bba20fd2a6d1da3b2a4f7/pkg/util/span/frontier.go#L538-L557
We could replace the bool with a counter if we want to allow multiple readers or we could simply disallow multiple readers.
Related to #151217
Jira issue: CRDB-53123
Contributor guide
Research direction
Read pkg/util/span/frontier.go around lines 538-557 and review the related issue #151217. Determine whether multiple pull-iterator readers should be supported or disallowed, then ensure writers remain blocked for the full lifetime of any open iterator. The issue does not name a test to run or add.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100