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-23.2: workload/tpcc: support Read Committed isolation #117749

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

blathers-crl[bot]
Copy link

@blathers-crl blathers-crl bot commented Jan 12, 2024

Backport 4/4 commits from #113834 on behalf of @nvanbenschoten.

/cc @cockroachdb/release


Closes #100176.

This PR consists of a series of commits which together add support for Read Committed isolation to the TPC-C workload and then use it to add new roachtest variants.

See individual commits, including an interesting change to explicit row-level locking in TPC-C transactions to avoid concurrency anomalies.

Release note: None


Release justification: workload-only change, to help people test out the read committed public preview.

Addresses a TODO.

This query has been supported by the optimizer since at least 526b4e5,
which is when it was rewritten in the optimizer's test suite.

Epic: None
Release note: None
Informs #100176.

This commit adds an `--isolation-level` flag to tpcc, which controls the
isolation level to run the workload transactions under. If unset, the
workload will run with the default isolation level of the database.

Release note: None
Informs #100176.

This commit adds SELECT FOR UPDATE locking in two places to ensure that
the workload avoids anomalies when run under Read Committed isolation.

The first of these is in the NewOrder transaction, when querying the
"stock" table in preparation for updating quantities and order counts
for the items in an order. There are no consistency checks which fail
without this, but the locking is present in benchbase (https://github.com/cmu-db/benchbase/blob/546afa60dae4f8a6b00b84b77c77ff7684e494ad/src/main/java/com/oltpbenchmark/benchmarks/tpcc/procedures/NewOrder.java#L88)
and makes sense to do.

The second of these is in the Delivery transaction, when querying the
"new_order" table to select an order to deliver. The order selected is
processed by the transaction, including updating counters in the
corresponding "customer" row, so it's important to have full isolation.
Without this, consistency checks `3.3.2.10` and `3.3.2.12` (`workload
check tpcc --expensive-checks`) do fail, presumably because a customer's
row is updated twice for a single order.

This use of SELECT FOR UPDATE in the Delivery transaction is an
alternative to a patch like 36709df, which would probably be more
efficient than the approach we have here, but would not exercise the
database in an interesting way. We opt to use SELECT FOR UPDATE.

Release note: None
@blathers-crl blathers-crl bot requested review from a team as code owners January 12, 2024 21:49
@blathers-crl blathers-crl bot requested review from DarrylWong and renatolabs and removed request for a team January 12, 2024 21:49
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Jan 12, 2024
@blathers-crl blathers-crl bot requested review from rytaft and removed request for a team January 12, 2024 21:49
Copy link
Author

blathers-crl bot commented Jan 12, 2024

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Backports should only be created for serious
    issues
    or test-only changes.
  • Backports should not break backwards-compatibility.
  • Backports should change as little code as possible.
  • Backports should not change on-disk formats or node communication protocols.
  • Backports should not add new functionality (except as defined
    here).
  • Backports must not add, edit, or otherwise modify cluster versions; or add version gates.
  • All backports must be reviewed by the owning areas TL and one additional
    TL. For more information as to how that review should be conducted, please consult the backport
    policy
    .
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters. State changes must be further protected such that nodes running old binaries will not be negatively impacted by the new state (with a mixed version test added).
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.
  • Your backport must be accompanied by a post to the appropriate Slack
    channel (#db-backports-point-releases or #db-backports-XX-X-release) for awareness and discussion.

Also, please add a brief release justification to the body of your PR to justify this
backport.

@blathers-crl blathers-crl bot added the backport Label PR's that are backports to older release branches label Jan 12, 2024
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

LGTM

Closes #100176.

This commit adds the following two roachtest variants:
```
tpcc-nowait/isolation-level=read-committed/nodes=3/w=1
tpcc/headroom/isolation-level=read-committed/n4cpu16
```

It also ensures that the `tpcc-nowait` tests runs the full set of expensive
consistency checks at the end. The "nowait" variant run a more heavily
contended version of tpcc, but with few warehouses, so the checks should
still be fast.

Release note: None
@nvanbenschoten nvanbenschoten force-pushed the blathers/backport-release-23.2-113834 branch from 112182f to 204f658 Compare January 17, 2024 14:38
@nvanbenschoten nvanbenschoten merged commit 8d245a9 into release-23.2 Jan 17, 2024
5 of 6 checks passed
@nvanbenschoten nvanbenschoten deleted the blathers/backport-release-23.2-113834 branch January 17, 2024 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants