Skip to content

kv: don't serve non-locking, read-write requests on followers#60765

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/followerReadReadOnly
Feb 19, 2021
Merged

kv: don't serve non-locking, read-write requests on followers#60765
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/followerReadReadOnly

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Feb 19, 2021

Discovered while investigating a test failure in #59566.

In 278a21b, we shifted from talking about read and write requests to
locking and non-locking requests when deciding whether a request could
be served on a follower. This prevented locking scans and gets from
being served on followers. However, it began letting lone HeartbeatTxn
and EndTxn requests past the old !IsReadOnly() check. Luckily, these
were still prevented from being served on followers because they are
only sent in read-write transactions, which were also prevented from
performing follower reads.

Yesterday, in 0ac8ab9, we lifted this second limitation, allowing
read-write transactions to perform follower reads for non-locking
batches. However, this no longer prevented HeartbeatTxn and EndTxn
requests from being routed and served on follower replicas. This
resulted in a pretty disastrous situation where in very rare cases, a
follower was proposing a write under a lease that it did not own.
Luckily, new assertions added in #59566 caught this.

This commit fixes this oversight be re-introducing "read-only" as a
condition for serving follower reads.

Release note: None

@nvb nvb requested review from a team and andreimatei February 19, 2021 02:34
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Discovered while investigating a test failure in cockroachdb#59566.

In 278a21b, we shifted from talking about read and write requests to
locking and non-locking requests when deciding whether a request could
be served on a follower. This prevented locking scans and gets from
being served on followers. However, it began letting lone HeartbeatTxn
and EndTxn requests past the old `!IsReadOnly()` check. Luckily, these
were still prevented from being served on followers because they are
only sent in read-write transactions, which were also prevented from
performing follower reads.

Yesterday, in 0ac8ab9, we lifted this second limitation, allowing
read-write transactions to perform follower reads for non-locking
batches. However, this no longer prevented HeartbeatTxn and EndTxn
requests from being routed and served on follower replicas. This
resulted in a pretty disastrous situation where in very rare cases, a
follower was proposing a write under a lease that it did not own.
Luckily, new assertions added in cockroachdb#59566 caught this.

This commit fixes this oversight be re-introducing "read-only" as a
condition for serving follower reads.

Release note: None
@nvb nvb force-pushed the nvanbenschoten/followerReadReadOnly branch from 1e8ad6b to 9fc00c3 Compare February 19, 2021 03:30
Copy link
Copy Markdown
Contributor

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Feb 19, 2021

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 19, 2021

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 19, 2021

Build succeeded:

@craig craig bot merged commit 98f1479 into cockroachdb:master Feb 19, 2021
@nvb nvb deleted the nvanbenschoten/followerReadReadOnly branch February 21, 2021 04:05
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.

3 participants