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/engine: expose FailOnMoreRecent MVCC{Get/Scan}Option #44473

Merged
merged 3 commits into from
Feb 1, 2020

Commits on Jan 30, 2020

  1. c-deps/libroach: run clang-format

    This commit commits the changes from `make c-deps-fmt`. This hadn't been
    done in a while. I don't want the diff leaking into the next commit.
    
    I was surprised to see that we don't lint against this.
    nvanbenschoten committed Jan 30, 2020
    Configuration menu
    Copy the full SHA
    6e7fa8f View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2020

  1. storage/engine: expose FailOnMoreRecent MVCC{Get/Scan}Option

    Relates to cockroachdb#40205.
    
    This change introduces a new option to `MVCCGetOptions` and `MVCCScanOptions`
    that causes reads to throw an error if they observe an MVCC version at a
    timestamp above their read timestamp. Specifically, when the option is enabled,
    a `WriteTooOldError` will be returned if a scan observes an MVCC version with a
    timestamp above the read. Similarly, a `WriteIntentError` will be returned if a
    scan observes another transaction's intent, even if that intent has a timestamp
    above the scan's read timestamp.
    
    This option will be used in the future by `ScanRequests` and `ReverseScanRequests`
    that intend to acquire unreplicated key-level locks, which will power `SELECT FOR
    UPDATE`. These scans do not want to ignore existing MVCC versions at higher timestamps
    like traditional scans do. Instead, they want to throw errors and force their
    transaction to increase its timestamp through either a refresh or a retry. This was
    previously prototyped in 4a8e8dc.
    
    Interestingly, this is not new logic to the MVCC layer. This behavior is exactly
    the same as that of the initial key-value lookup performed during MVCC writes
    (see `mvccPutInternal`). It's fitting that behavior needed for `SELECT FOR UPDATE`
    would mirror that already exhibited by the read portion of read-write operations.
    This also hints at an opportunity to potentially use this option to merge the two
    implementations and get rid of custom logic like `mvccGetInternal` that only exists
    on the write path. We'd need to be careful about doing so though, as this code is
    heavily tuned.
    
    Release note: None
    nvanbenschoten committed Jan 31, 2020
    Configuration menu
    Copy the full SHA
    a25a9c9 View commit details
    Browse the repository at this point in the history
  2. storage/engine: output result even on cmdGet error

    cmdScan was already doing this, so we should be consistent or it becomes
    confusing why scan results show up on errors cases but not get results.
    nvanbenschoten committed Jan 31, 2020
    Configuration menu
    Copy the full SHA
    7759868 View commit details
    Browse the repository at this point in the history