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/batcheval: declare intent resolution at txn MinTimestamp #45232

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

nvanbenschoten
Copy link
Member

This prevents the hazard described in:

// Note that even the conservative behavior of dropping locks requires

I've been trying to (starting with #45085) clean up spanset.Batch to the point where it would have been able to detect this unlatched key access, but getting that all the way over the fence is a little tricky due to:

  • GCRequest span declaration - should this even latch?
  • transactional Put span declaration - does this need to declare a write span all the way back to txn.MinTimestamp because it might move an existing intent forward?
  • spanset.Iterator semantics and its interaction with pebbleMVCCScanner - what can the spanset.Iterator even assert here, given that the scanner itself is determining whether to ignore values or not.

Unfortunately, without a rework, the current attempt at asserting correct timestamp access in spanset.Batch is hopelessly broken. Not only does the verification not encode the correct rules for declared timestamps (e.g. a write at time 10 should permit writing at any time >= 10), but the timestamp it works with isn't even the correct timestamp. It compares the declared span timestamps against the batch header timestamp, which completely misses the point. It should be comparing the declared span timestamps against the timestamps of actual uses of the spanset.Batch so that we're actually asserting that the batch is being used correctly.

I'd like to fix all of this, but not here.

This prevents the hazard described in
https://github.com/cockroachdb/cockroach/blob/5f63ac527becd4aae5cfbdaa76b7de28e07b8767/pkg/storage/concurrency/concurrency_control.go#L480.

I've been trying to (starting with cockroachdb#45085) clean up `spanset.Batch`
to the point where it would have been able to detect this unlatched
key access, but getting that all the way over the fence is a little
tricky due to:
- `GCRequest` span declaration - should this even latch?
- transactional `Put` span declaration - does this need to declare a
  write span all the way back to txn.MinTimestamp because it might move
  an existing intent forward?
- `spanset.Iterator` semantics and its interaction with `pebbleMVCCScanner` -
  what can the `spanset.Iterator` even assert here, given that the scanner
  itself is determining whether to ignore values or not.

Unfortunately, without a rework, the current attempt at asserting
correct timestamp access in `spanset.Batch` is hopelessly broken.
Not only does the verification not encode the correct rules for
declared timestamps (e.g. a write at time 10 should permit writing at
any time >= 10), but the timestamp it works with isn't even the correct
timestamp. It compares the declared span timestamps against the batch
header timestamp, which completely misses the point. It should be
comparing the declared span timestamps against the timestamps of actual
uses of the `spanset.Batch` so that we're actually asserting that the
batch is being used correctly.

I'd like to fix all of this, but not here.
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner 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 5 of 5 files at r1, 3 of 3 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@nvanbenschoten
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 26, 2020

Build succeeded

@craig craig bot merged commit c331fae into cockroachdb:master Feb 26, 2020
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/declSpanMin branch February 26, 2020 22:31
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