cockroachdb / cockroachdb/cockroach

span: btreeFrontier iterator protection should use counter

Open
#151,219 2 comments 0 reactions 0 assignees View on GitHub
A-cdc C-bug P-3 T-cdc
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.