Skip to content

kv: generalize lease stasis, accept future-time requests under valid lease#58904

Merged
craig[bot] merged 7 commits intocockroachdb:masterfrom
nvb:nvanbenschoten/leaseStatusUnusable
Jan 29, 2021
Merged

kv: generalize lease stasis, accept future-time requests under valid lease#58904
craig[bot] merged 7 commits intocockroachdb:masterfrom
nvb:nvanbenschoten/leaseStatusUnusable

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Jan 13, 2021

Relates to #57688.

This PR performs a series of cleanup steps and eventually generalizes the
replica lease check to consult a request's specific timestamp instead of
assuming that all requests operate at or below time.Now(). It then adds to this
generalization some safeguards to ensure that future-time requests don't get
themselves into infinite lease extension/acquisition loops or cause other kinds
of problems due to the requests being too far into the future.

It doesn't go as far as properly handling lease transfers or merged in the case
that a leaseholder has served future-time operations, but that will follow
shortly in another PR.

@nvb nvb requested review from andreimatei and tbg January 13, 2021 02:21
@nvb nvb requested a review from a team as a code owner January 13, 2021 02:21
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Jan 13, 2021

This is currently failing CI due to the last commit, but that's not actually meant to be part of this PR. Please ignore that.

@nvb nvb force-pushed the nvanbenschoten/leaseStatusUnusable branch 6 times, most recently from 27fb126 to b437722 Compare January 16, 2021 17:41
Copy link
Copy Markdown
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r1, 63 of 63 files at r2, 14 of 14 files at r3, 5 of 5 files at r4, 4 of 4 files at r5, 2 of 2 files at r6.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @nvanbenschoten, and @tbg)


pkg/kv/kvserver/queue.go, line 652 at r3 (raw file):

		if st.IsValid() && !st.OwnedBy(repl.StoreID()) {
			if log.V(1) {
				log.Infof(ctx, "needs lease; not adding: %s", st.Lease.String())

We shouldn't have to call .String() here. Does st.Lease implement the wrong fmt.Stringer on the value type? Can we fix that instead?


pkg/kv/kvserver/replica_proposal_buf.go, line 489 at r7 (raw file):

		if !iAmTheLeader && p.Request.IsLeaseRequest() {
			// TODO DURING REVIEW: I needed this to deflake a test. But is
			// generally seems like a good idea.

Hmm, yes, it does.


pkg/kv/kvserver/replica_range_lease.go, line 507 at r3 (raw file):

// its state, unless state == leaseError.
//
// - The lease is considered valid if the current timestamp (now) is

"considered valid" suggests that the returned lease state would be valid. I think what this really tells me is that VALID is no longer a good name for the lease state. How about "usable", which indicates the intersection of "not expired at current clock yet" and "can actually serve that particular request"?


pkg/kv/kvserver/replica_range_lease.go, line 556 at r3 (raw file):

//   * the client fails to read their own write.
//
// - The lease is considered expired in all other cases.

This misses the proscribed case.


pkg/kv/kvserver/store_snapshot.go, line 669 at r3 (raw file):

					return true
				}
				// TODO(benesch): this check does detect inactivity on replicas with

while you're here, add the missing "not"


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 29 at r1 (raw file):

  // UNUSABLE indicates that a lease has not expired at the present time
  // (i.e. it is VALID), but cannot be used to serve a given request. A
  // lease may be unusable for one of two reason.

reasons


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 70 at r1 (raw file):

  // PROSCRIBED indicates that the lease's proposed timestamp is earlier
  // than allowed and can't be used to serve a request. This is used to
  // detect node restarts: a node that has restarted will see its former

Isn't it also used in transfers?

@tbg tbg self-requested a review January 19, 2021 12:52
Copy link
Copy Markdown
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! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten and @tbg)


pkg/kv/kvserver/queue.go, line 652 at r3 (raw file):

Previously, tbg (Tobias Grieger) wrote…

We shouldn't have to call .String() here. Does st.Lease implement the wrong fmt.Stringer on the value type? Can we fix that instead?

I think he might be trying to avoid st escaping


pkg/kv/kvserver/replica_range_lease.go, line 507 at r3 (raw file):

// its state, unless state == leaseError.
//
// - The lease is considered valid if the current timestamp (now) is

I appreciate the effort to make this comment good.
One thing that I think is not sufficiently clear is the explanation about "now", and why anything about the present time is necessary. One might reasonably ask why the reqTS is not sufficient - like it is for sql schema leases, for example. Like, if I'm querying about yesterday, why does the relationship of whatever lease the replica has to the "present time" matter? I could articulate some stuff, but I think you can do it better.


pkg/kv/kvserver/replica_range_lease.go, line 562 at r3 (raw file):

	lease roachpb.Lease,
	now hlc.ClockTimestamp,
	minProposedTS hlc.ClockTimestamp,

not new, but since you're all up in here: minProposedTS is always r.mu.minProposedTS. Let's remove the argument.


pkg/kv/kvserver/replica_range_lease.go, line 613 at r3 (raw file):

//
// Common operations to perform on the resulting status are to check if
// is is valid using the IsValid method and to check whether the lease

is is


pkg/kv/kvserver/replica_range_lease.go, line 871 at r4 (raw file):

// its output should be completely determined by its parameters.
func newNotLeaseHolderError(
	l roachpb.Lease, proposerStoreID roachpb.StoreID, rangeDesc *roachpb.RangeDescriptor, msg string,

this makes me sad. Have you tried making a deep copy when assigning err.Lease? I'm thinking that should be enough to keep l from escaping.
Or, perhaps LeaseStatus.Lease should be a pointer. It's nice to make it non-nullable in the proto, but there's no good reason why LeaseStatus is even a proto. If it wasn't a proto, then the leases in it would probably always be on the heap anyway - and we might save some copying. No?


pkg/kv/kvserver/replica_range_lease.go, line 930 at r5 (raw file):

}

// checkRequestTimeRLocked checks that the provided request timestamp is not

have you done the math about what the timestamp of non-blocking txns will be, and how it relates to the lease renewal policy? Will these requests generally encounter a lease that is good for them?


pkg/kv/kvserver/replica_range_lease.go, line 942 at r5 (raw file):

func (r *Replica) checkRequestTimeRLocked(
	now hlc.ClockTimestamp, reqTS hlc.Timestamp,
) *roachpb.Error {

consider returning error here


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 24 at r1 (raw file):

  // ERROR indicates that the lease can't be used or acquired.
  ERROR = 0;
  // VALID indicates that the lease is valid at the present time and can

consider moving away from talking about "present time", and describe these statuses in relationship to an explicit query time - namely the one in LeaseStatus.Timestamp.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 78 at r2 (raw file):

// LeaseStatus holds the lease state, the timestamp at which the state
// is accurate, the timestamp of the request, the lease, and optionally

the comment change makes it sound like there's now two different timestamps in here, but there aren't. In the next commit you can put a link to Replica.leaseStatus though, and explain something a request's timestamp.

@nvb nvb force-pushed the nvanbenschoten/leaseStatusUnusable branch from b437722 to 16b3579 Compare January 20, 2021 17:50
Copy link
Copy Markdown
Contributor Author

@nvb nvb left a comment

Choose a reason for hiding this comment

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

Thanks for the reviews!

One thing I wanted to get both of your opinions on is this BatchRequest.Timestamp (and by extension, BatchResponse.Timestamp) field. For non-transactional requests, it holds the request's timestamp, which is fine. But for transactional requests, it holds the transaction's read timestamp. This is kind of strange, since as of #32487, we write intents all the way at the transaction's write timestamp. So I think that means two things, independent of this PR:

  1. it is possible to write an intent at a timestamp past a leaseholder's current clock
  2. it is possible to write an intent at a timestamp past the expiration of a lease

Both of these seem bad, for a few reasons. First, we occasionally bump the timestamp cache to a time based on an intent/value in a range due to server-side retries, and until #59086, it is completely illegal to bump the timestamp cache past a leaseholder's clock. This could result in lost timestamp cache updates on a lease transfer. Second, if a leaseholder can perform intent writes above its local HLC clock then our current proposal to address #36431 is not complete, because even an intent resolved at its write time may violate observed timestamps.

This was all obscured by the fact that lease checks were consulting the local HLC clock, not the BatchRequest.Timestamp directly (though the BatchRequest.Timestamp was used to update the HLC clock). Now that we're being explicit about the request timestamp and its timestamp, I wonder if there's more we can do here. Maybe we should get rid of this BatchRequest.Timestamp/BatchResponse.Timestamp field or never set it for transaction requests and then be more explicit about when we want Txn.ReadTimestamp (e.g. to pass to MVCCScan) vs. when we want max(Txn.ReadTimestamp, Txn.WriteTimestamp) (e.g. to compare against a lease)?

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


pkg/kv/kvserver/queue.go, line 652 at r3 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I think he might be trying to avoid st escaping

Right, that was the intention. But even without the .String(), it doesn't seem to be escaping. So I removed it.


pkg/kv/kvserver/replica_proposal_buf.go, line 489 at r7 (raw file):

Previously, tbg (Tobias Grieger) wrote…

Hmm, yes, it does.

I opened #59179 to track this and removed this commit.


pkg/kv/kvserver/replica_range_lease.go, line 507 at r3 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I appreciate the effort to make this comment good.
One thing that I think is not sufficiently clear is the explanation about "now", and why anything about the present time is necessary. One might reasonably ask why the reqTS is not sufficient - like it is for sql schema leases, for example. Like, if I'm querying about yesterday, why does the relationship of whatever lease the replica has to the "present time" matter? I could articulate some stuff, but I think you can do it better.

I've made this change 3 times now before realizing it's unsafe, so that pretty clearly indicates that we need some better comments around here. The reason why we need both a reqTS and current clock reading is so that we can differentiate between EXPIRED and UNUSABLE. Only an EXPIRED lease can be non-cooperatively acquired by another node. If a node attempted to grab away an UNUSABLE lease (previously STASIS), it could violate reads served on the existing leaseholder.

I've added some additional assertions and some more documentation to make this clearer. What do you think?


pkg/kv/kvserver/replica_range_lease.go, line 507 at r3 (raw file):

Previously, tbg (Tobias Grieger) wrote…

"considered valid" suggests that the returned lease state would be valid. I think what this really tells me is that VALID is no longer a good name for the lease state. How about "usable", which indicates the intersection of "not expired at current clock yet" and "can actually serve that particular request"?

Good point. I reworded a few comments to better indicate this. I didn't get quite as far as renaming valid to usable because I think they both work.


pkg/kv/kvserver/replica_range_lease.go, line 556 at r3 (raw file):

Previously, tbg (Tobias Grieger) wrote…

This misses the proscribed case.

Done.


pkg/kv/kvserver/replica_range_lease.go, line 562 at r3 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

not new, but since you're all up in here: minProposedTS is always r.mu.minProposedTS. Let's remove the argument.

Eh, I think the idea is that the status is fully resolved by these arguments, so there are no hidden dependencies. That's also why we accept the lease. But that's also not quite true, because liveness is a dependency. Regardless, I don't feel strongly about this but will save additional refactoring for later.


pkg/kv/kvserver/replica_range_lease.go, line 613 at r3 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

is is

Done.


pkg/kv/kvserver/replica_range_lease.go, line 871 at r4 (raw file):

Or, perhaps LeaseStatus.Lease should be a pointer. It's nice to make it non-nullable in the proto, but there's no good reason why LeaseStatus is even a proto. If it wasn't a proto, then the leases in it would probably always be on the heap anyway - and we might save some copying. No?

I looked into this and I think the issue is that we don't have any guarantee that the reference (r.mu.state.Lease) won't change once we drop the replica mutex. In practice, I think this would be safe because we only ever replace the reference wholesale. But I don't want to pull on that while making the rest of this change.


pkg/kv/kvserver/replica_range_lease.go, line 930 at r5 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

have you done the math about what the timestamp of non-blocking txns will be, and how it relates to the lease renewal policy? Will these requests generally encounter a lease that is good for them?

Non-blocking txns will never need to write/commit more than 1s in the future. Leases are 9 seconds long and renew every 4.5 seconds, as does node liveness. So we should be good here.


pkg/kv/kvserver/replica_range_lease.go, line 942 at r5 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

consider returning error here

This change is made in #59086. I'll leave this as-is for now.


pkg/kv/kvserver/store_snapshot.go, line 669 at r3 (raw file):

Previously, tbg (Tobias Grieger) wrote…

while you're here, add the missing "not"

Done.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 24 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

consider moving away from talking about "present time", and describe these statuses in relationship to an explicit query time - namely the one in LeaseStatus.Timestamp.

See discussion above.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 29 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

reasons

Done.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 70 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

Isn't it also used in transfers?

Yes, done.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 78 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

the comment change makes it sound like there's now two different timestamps in here, but there aren't. In the next commit you can put a link to Replica.leaseStatus though, and explain something a request's timestamp.

Done.

@tbg tbg requested a review from andreimatei January 28, 2021 11:30
Copy link
Copy Markdown
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Yeah, we should clean this up. It's likely too hard to remove the .Timestamp field completely (what about all of those non-transactional requests like QueryTxn, Increment, etc?) in the short term, but at the very least we should be forwarding it to the write timestamp to avoid the issues you pointed out.
It's always bothered me that too many timestamps were floating around in the lower levels of KV - txn read timestamp, txn write timestamp, batch.Timestamp - perhaps we can avoid any direct access to these timestamps and instead use .ReadTimestamp(), .WriteTimestamp() getters that can coalesce from these three sources. Not sure, I haven't looked at these code paths in a while.

Reviewed 73 of 73 files at r8, 63 of 63 files at r9, 14 of 14 files at r10, 5 of 5 files at r11, 4 of 4 files at r12, 2 of 2 files at r13, 3 of 3 files at r14.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @nvanbenschoten, and @tbg)


pkg/kv/kvserver/replica_range_lease.go, line 562 at r3 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Eh, I think the idea is that the status is fully resolved by these arguments, so there are no hidden dependencies. That's also why we accept the lease. But that's also not quite true, because liveness is a dependency. Regardless, I don't feel strongly about this but will save additional refactoring for later.

I'd leave as is, if anything this method should eventually become standalone rather than more tightly coupled with the Replica behemoth.


pkg/kv/kvserver/replica_range_lease.go, line 529 at r14 (raw file):

// - The lease is considered valid if the current timestamp (now) is
//   covered by the supplied lease and the lease can be used to serve a
//   request at the specified time. This is determined differently

I'm still not convinced by the structure of this comment and the notion of "validity". There are really two questions we ask about leases:

  1. can I safely request a non-cooperative lease following the current lease? This is linked to the (lease or epoch) expiration and the now timestamp.
  2. can the lease serve an operation at timestamp T? The answer is no if the lease has been relinquished at a timestamp >= T (minProposedTS, i.e. lease transfer or a restart), or if T >= stasis.

You didn't bite at my suggestion to rename VALID, but can I coax you into consistently upper-casing the enum variants in the comments to avoid confusion?

Strawman comment rewrite from my input above:

The lease status is linked to the desire to serve a request at a specific timestamp (which may be a future timestamp) under the lease, as well as a notion of the current hlc time (now).

A status of ERROR indicates a failure to determine the correct lease status, and should not occur under normal operations. The caller's only recourse is to give up or to retry.

If the lease is expired according to the now timestamp (and, in the case of epoch-based leases, the epoch), a status of EXPIRED is returned. Note that this ignores the timestamp of the request, which may well technically be eligible to be served under the lease. The key feature of an EXPIRED status is that it reflects that a new lease with a start timestamp greater than or equal to now can be acquired non-cooperatively.

If the lease is not EXPIRED, the request timestamp is taken into account. The expiration timestamp is adjusted for clock offset; if the request timestamp falls into the so-called stasis period at the end of the lifetime of the lease, the status is UNUSABLE, which callers typically want to react to by extending the lease, if they are in a position to do so.

Finally, for request timestamps falling before the stasis period, the request timestamp is additionally checked against the minProposedTimestamp. This timestamp determines the earliest timestamp the lease can be used for, and is set both in cooperative lease transfers and to prevent reuse of leases across node restarts (which would result in latching violations). Requests preceding this timestamp are assigned a status of PROSCRIBED and should be retried at a higher timestamp, or the lease transfer target, depending on the scenario.

On the surface, ...


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 81 at r14 (raw file):

// LeaseStatus holds the lease state, the current clock time at which the
// state is accurate, the request time at which the stats is accurate, the

stats?

@tbg tbg self-requested a review January 28, 2021 11:30
nvb added 7 commits January 28, 2021 17:08
This commit renames the STASIS LeaseState to UNUSABLE and updates
comments to distinguish between the impact that the current time
has on a lease status vs. the impact that a given request's time
has on a lease status. It doesn't yet make any code changes.
This commit updates the Go type of the `Lease.Start` and `LeaseStatus.Now`
fields to be more strictly typed. Instead of being a `Timestamp` type, they now
are `ClockTimestamp` types, which more effectively ensures that they come from a
real clock. This prevents mistakes and makes their role in the leasing protocol
more clear. For instance, it makes it clear that it is not possible to create a
lease that starts in the future.

This results in a large amount of plumbing, which is all fine.
This commit restructures the methods in `replica_range_lease.go`
to prepare for time when we will pass a request timestamp into
Replica.leaseStatus. For now, we don't actually pass the request
time in, but we will in a future commit.
This was causing Lease / LeaseStatus objects to escape to the heap at a few
of its callers, even if the error path was never hit. It was generally a
footgun, so avoid it.
This commit generalizes the replica lease check to consult a request's
specific timestamp instead of assuming that all requests operate at or
below time.Now(). It then adds to this generalization some safeguards to
ensure that future-time requests don't get themselves into infinite
lease extension/acquisition loops or cause other kinds of problems due
to the requests being too far into the future.
…Lease

When evaluating RequestLease / TransferLease requests, we compare against the
range's current lease, not the provided PrevLease in the request. This was
confusing and looked like a mistake. I now think it was deliberate, but it
deserved a comment.
Only expired leases may be acquired by other nodes.
@nvb nvb force-pushed the nvanbenschoten/leaseStatusUnusable branch from 16b3579 to 73b15ad Compare January 28, 2021 23:26
Copy link
Copy Markdown
Contributor Author

@nvb nvb left a comment

Choose a reason for hiding this comment

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

Yeah, we should clean this up. ...

Sounds like a plan. I'll address this in a follow-up PR.

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


pkg/kv/kvserver/replica_range_lease.go, line 529 at r14 (raw file):

Previously, tbg (Tobias Grieger) wrote…

I'm still not convinced by the structure of this comment and the notion of "validity". There are really two questions we ask about leases:

  1. can I safely request a non-cooperative lease following the current lease? This is linked to the (lease or epoch) expiration and the now timestamp.
  2. can the lease serve an operation at timestamp T? The answer is no if the lease has been relinquished at a timestamp >= T (minProposedTS, i.e. lease transfer or a restart), or if T >= stasis.

You didn't bite at my suggestion to rename VALID, but can I coax you into consistently upper-casing the enum variants in the comments to avoid confusion?

Strawman comment rewrite from my input above:

The lease status is linked to the desire to serve a request at a specific timestamp (which may be a future timestamp) under the lease, as well as a notion of the current hlc time (now).

A status of ERROR indicates a failure to determine the correct lease status, and should not occur under normal operations. The caller's only recourse is to give up or to retry.

If the lease is expired according to the now timestamp (and, in the case of epoch-based leases, the epoch), a status of EXPIRED is returned. Note that this ignores the timestamp of the request, which may well technically be eligible to be served under the lease. The key feature of an EXPIRED status is that it reflects that a new lease with a start timestamp greater than or equal to now can be acquired non-cooperatively.

If the lease is not EXPIRED, the request timestamp is taken into account. The expiration timestamp is adjusted for clock offset; if the request timestamp falls into the so-called stasis period at the end of the lifetime of the lease, the status is UNUSABLE, which callers typically want to react to by extending the lease, if they are in a position to do so.

Finally, for request timestamps falling before the stasis period, the request timestamp is additionally checked against the minProposedTimestamp. This timestamp determines the earliest timestamp the lease can be used for, and is set both in cooperative lease transfers and to prevent reuse of leases across node restarts (which would result in latching violations). Requests preceding this timestamp are assigned a status of PROSCRIBED and should be retried at a higher timestamp, or the lease transfer target, depending on the scenario.

On the surface, ...

Done. Thanks for the strawman 😄 I just made minor modifications.


pkg/kv/kvserver/kvserverpb/lease_status.proto, line 81 at r14 (raw file):

Previously, tbg (Tobias Grieger) wrote…

stats?

Done.

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Jan 29, 2021

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 29, 2021

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 29, 2021

Build succeeded:

@craig craig bot merged commit 1413f68 into cockroachdb:master Jan 29, 2021
@nvb nvb deleted the nvanbenschoten/leaseStatusUnusable branch February 1, 2021 02:25
andreimatei pushed a commit to andreimatei/cockroach that referenced this pull request Feb 9, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
nvb added a commit to nvb/cockroach that referenced this pull request Feb 11, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
andreimatei pushed a commit to andreimatei/cockroach that referenced this pull request Feb 12, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
nvb added a commit to nvb/cockroach that referenced this pull request Feb 12, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
nvb added a commit to nvb/cockroach that referenced this pull request Feb 12, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
craig bot pushed a commit that referenced this pull request Feb 13, 2021
59693: kv: handle future-time operations for conflict resolution requests r=nvanbenschoten a=nvanbenschoten

Relates to #57688.

This PR updates the following four requests types to properly handle future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all timestamp cache updates are safe, based on the batch header timestamps of the requests. This is coupled with a stricter, more comprehensive assertion when updating the timestamp cache that all updates are performed below the expiration time of the active lease. This ensures that timestamp cache updates are not lost during non-cooperative lease change.

In doing so, the PR also updates the replica lease check to test against the batch's read or write timestamp, whichever is later. This addresses the concerns raised in #58904 (review).

60503: kvserver: add some logscopes r=andreimatei a=andreimatei

These are the last in this package I think.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
andreimatei pushed a commit to andreimatei/cockroach that referenced this pull request Feb 13, 2021
Relates to cockroachdb#57688.

This commit updates the following four requests types to properly handle
future-time operations:
- `PushTxnRequest`
- `QueryTxnRequest`
- `QueryIntentRequest`
- `RecoverTxnRequest`

It also updates the request evaluation code to properly check that all
timestamp cache updates are safe, based on the batch header timestamps
of the requests. The next commit will be adding a more strict assertion
about proper timestamp cache use, so it's better that we catch these
violations early.

In doing so, the commit also updates the replica lease check to test
against the batch's read or write timestamp, whichever is later. This
addresses the concerns raised in cockroachdb#58904 (review).
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.

4 participants