Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-20.2: kvserver: avoid bootstrapping closedTS state with the lease start time #65823

Conversation

aayushshah15
Copy link
Contributor

@aayushshah15 aayushshah15 commented May 28, 2021

This commit reverts the main change introduced in #35130. That change made it
such that each replica could bootstrap its maxClosed timestamp value with the
start time of the latest lease that it knew about. However, it doesn't consider
the fact that when the lease transfer occurred, the range may have been in a
subsumed state and thus, is not allowed to serve any requests past the
subsumption time. Bumping a replica's closed timestamp by the lease start time
allows for a bug where the closed timestamp of a replica may be advanced past
the subsumption time of a range, which would allow the range's non-leaseholder
replicas to serve follower reads past its subsumption time.

Such a sequence of events would in turn allow follower reads queries to serve
results that could be invalidated by future writes on the keyspan owned by the
subsumed range.

Release note (bug fix): A rare bug in 20.2 that manifested itself when a lease
change occured during a range merge has been resolved. This bug allowed AS OF SYSTEM TIME queries to serve inconsistent results.

@aayushshah15 aayushshah15 changed the title kvserver: avoid bootstrapping closedTS state with the lease start time release-20.2: kvserver: avoid bootstrapping closedTS state with the lease start time May 28, 2021
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@aayushshah15 aayushshah15 force-pushed the stopForwardingClosedTSToLeaseStartTime branch from 94fd3ce to c3441f0 Compare May 28, 2021 00:11
@aayushshah15 aayushshah15 force-pushed the stopForwardingClosedTSToLeaseStartTime branch from c3441f0 to ac60e52 Compare May 28, 2021 00:13
Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

:lgtm:

Release note (bug fix): A rare bug present in 20.2 that allowed AS OF SYSTEM TIME queries to serve inconsistent results has been resolved.

Consider saying a bit more here about what makes this bug "rare" (i.e. the necessary timing with a range merge and a lease change).

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

@aayushshah15
Copy link
Contributor Author

Hey @nvanbenschoten, @andreimatei and I were talking about this PR today and I was wondering how you feel about the regression in follower read availability that this PR concedes. After a lease transfer, follower reads on the range will be unavailable until the first closed timestamp update from the new leaseholder. Are we okay with that regression?

@nvanbenschoten
Copy link
Member

After a lease transfer, follower reads on the range will be unavailable until the first closed timestamp update from the new leaseholder. Are we okay with that regression?

This is a good point. It was the reason why we didn't make this change in v21.1 before the new closed timestamp system started to be used. @andreimatei should also weigh-in, but I think this regression is ok, given the correctness issues that this change is solving. Also, lease transfers are already disruptive to all other traffic.

@erikgrinaker
Copy link
Contributor

Would be nice to get this merged, since it can cause panics as well (due to a race condition with CDC, closed timestamps, and range merges). What's your take @andreimatei?

Copy link
Contributor

@andreimatei andreimatei 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! 2 of 0 LGTMs obtained (waiting on @aayushshah15)

@aayushshah15 aayushshah15 force-pushed the stopForwardingClosedTSToLeaseStartTime branch 3 times, most recently from 4dc0424 to 8ecea13 Compare July 9, 2021 03:39
This commit reverts the main change introduced in cockroachdb#35130. That change made it
such that each replica could bootstrap its `maxClosed` timestamp value with the
start time of the latest lease that it knew about. However, it doesn't consider
the fact that when the lease transfer occurred, the range may have been in a
subsumed state and thus, is not allowed to serve any requests past the
subsumption time. Bumping a replica's closed timestamp by the lease start time
allows for a bug where the closed timestamp of a replica may be advanced past
the subsumption time of a range, which would allow the range's non-leaseholder
replicas to serve follower reads past its subsumption time.

Such a sequence of events would in turn allow follower reads queries to serve
results that could be invalidated by future writes on the keyspan owned by the
subsumed range.

Release note (bug fix): A rare bug in 20.2 that manifested itself when a lease
change occured during a range merge has been resolved. This bug allowed `AS OF
SYSTEM TIME` queries to serve inconsistent results.
@aayushshah15 aayushshah15 force-pushed the stopForwardingClosedTSToLeaseStartTime branch from 8ecea13 to c2a08bd Compare July 9, 2021 06:38
@aayushshah15 aayushshah15 merged commit 8dad4d7 into cockroachdb:release-20.2 Jul 20, 2021
@aayushshah15 aayushshah15 deleted the stopForwardingClosedTSToLeaseStartTime branch July 20, 2021 20:50
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.

5 participants