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

storage,kv: don't return errors with the WriteTooOld flag set #45102

Merged
merged 3 commits into from
Feb 14, 2020

Conversation

andreimatei
Copy link
Contributor

The span refresher interceptor is supposed to terminate the
txn.WriteTooOld flag. For that, it asserts that the request doesn't not
have that flag set on it; only responses should have it. There was,
however, a case where terminating the flag was not happening as
intended: when a non-retriable error was coming back with the
WriteTooOld flag set, the flag made its way into the client's txn,
slipping past the interceptor. This was causing further requests to fail
the aforementioned assertion. (Since errors are at play here, the only
further request should be a Rollback).

This patch fixes this by having servers never return errors with this
flag set. Setting this flag on an error does not make sense anyway.

Touches #40786

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

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:

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


pkg/kv/txn_interceptor_span_refresher.go, line 387 at r2 (raw file):

}

func (sr *txnSpanRefresher) sendHelper(

What is the point of this?

PR cockroachdb#44507 has left an unnecessary check in place. The check tolerates
requests with the WriteTooOld flag set for leaf txn, even though the
same commit makes sure that leaves reset that flag.

Release note: None
The span refresher interceptor is supposed to terminate the
txn.WriteTooOld flag. For that, it asserts that the request doesn't not
have that flag set on it; only responses should have it. There was,
however, a case where terminating the flag was not happening as
intended: when a non-retriable error was coming back with the
WriteTooOld flag set, the flag made its way into the client's txn,
slipping past the interceptor. This was causing further requests to fail
the aforementioned assertion. (Since errors are at play here, the only
further request should be a Rollback).

This patch fixes this by having servers never return errors with this
flag set. Setting this flag on an error does not make sense anyway.

Touches cockroachdb#40786

Release note: None
@andreimatei andreimatei force-pushed the txn.fix-write-too-old branch from 5c8b219 to 189151d Compare February 14, 2020 22:23
Copy link
Contributor Author

@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.

bors r+

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


pkg/kv/txn_interceptor_span_refresher.go, line 387 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

What is the point of this?

apparently none. Removed in the next commit.

craig bot pushed a commit that referenced this pull request Feb 14, 2020
45102: storage,kv: don't return errors with the WriteTooOld flag set r=andreimatei a=andreimatei

The span refresher interceptor is supposed to terminate the
txn.WriteTooOld flag. For that, it asserts that the request doesn't not
have that flag set on it; only responses should have it. There was,
however, a case where terminating the flag was not happening as
intended: when a non-retriable error was coming back with the
WriteTooOld flag set, the flag made its way into the client's txn,
slipping past the interceptor. This was causing further requests to fail
the aforementioned assertion. (Since errors are at play here, the only
further request should be a Rollback).

This patch fixes this by having servers never return errors with this
flag set. Setting this flag on an error does not make sense anyway.

Touches #40786

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Feb 14, 2020

Build succeeded

@craig craig bot merged commit 189151d into cockroachdb:master Feb 14, 2020
@andreimatei andreimatei deleted the txn.fix-write-too-old branch March 2, 2020 19:27
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