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

allow 1PC txns #2818

Closed
wants to merge 5 commits into from
Closed

allow 1PC txns #2818

wants to merge 5 commits into from

Conversation

tbg
Copy link
Member

@tbg tbg commented Oct 12, 2015

This change enables 1PC txns for transaction contained in a single batch and sent to a single Range.
I'm going to add some tests for this, but the meat is ready for review.

The interplay introduced around sendChunk in DistSender and is somewhat weird and passes back an extra boolean (avoiding the need for a new proto error). I'm open to suggestions for making that prettier.

Review on Reviewable

add a new flag that simply keeps EndTransaction in
its current chunk when set.
in preparation for allowing 1pc txns.
ba is not a pointer any more.
if ba.Txn == nil && ba.ReadConsistency != roachpb.INCONSISTENT {
return nil, roachpb.NewError(&roachpb.OpRequiresTxnError{}), false
}
// If the request is more than but ends with EndTransaction, we
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment is missing some words

@bdarnell
Copy link
Contributor

My suggestion for clarity is a more substantial refactoring. We split batches for two reasons, by type (formerly in chunkingSender) and by key range (always in DistSender). The former is a "move"; the latter is a "copy", but EndTransaction is uncopyable. Now that the type-based splitting is moved into DistSender as well, I think it would end up cleaner to handle the two types of splits in the reverse order.

For each request in the batch:

  • Split the request if it spans multiple ranges
  • If the next request is compatible, try to add it to the same set of splits.
  • If the next request is incompatible, send the previous set of splits and proceed with a new set.
  • An EndTransactionRequest is compatible with any split that resulted in exactly one sub-batch; otherwise it is incompatible.

@tbg
Copy link
Member Author

tbg commented Oct 12, 2015

I'll give it a try. Agreed that the current code isn't clean enough. The refactor will be substantial, but I think it's overdue anyway.

@tbg
Copy link
Member Author

tbg commented Oct 28, 2015

don't see this making progress soon, so will close this to declutter.

@tbg tbg closed this Oct 28, 2015
@tbg tbg mentioned this pull request Dec 9, 2015
tbg added a commit to tbg/cockroach that referenced this pull request Dec 9, 2015
resuscitation of cockroachdb#2818.

This change enables 1PC txns for transaction contained in a single batch and
sent to a single Range.

Contrary to the previous incarnation, now the chunk of batch
containing EndTransaction is split and re-sent before any other
redundant requests have been made.

More improvement is possible: If the EndTransaction request were to end up in
the last Batch sent over the course of the multi-range request anyway, it would
not need to be split up into its own chunk. There's no way of knowing that
until the last range descriptor has been looked up though, at which point in
time we've already sent requests, complicating the code. Hence, this
optimization (which amounts to @bdarnell's suggestion in cockroachdb#2818) has been
omitted for now due to the amount of code changes required.

Unfortunately, the improvements here don't directly reflect in SQL
benchmarks because of the way the Txn is used there.
We need to optimize the SQL server to batch up as many commands as it
can (basically until it reads data) and commit in the same round-trip
if possible. Currently the Txn object is used deep down in the individual
operations (for example `(*planner).Insert()`) so this isn't trivial.
I will file an issue.
tbg added a commit to tbg/cockroach that referenced this pull request Dec 9, 2015
resuscitation of cockroachdb#2818.

This change enables 1PC txns for transaction contained in a single batch and
sent to a single Range.

Contrary to the previous incarnation, now the chunk of batch
containing EndTransaction is split and re-sent before any other
redundant requests have been made.

More improvement is possible: If the EndTransaction request were to end up in
the last Batch sent over the course of the multi-range request anyway, it would
not need to be split up into its own chunk. There's no way of knowing that
until the last range descriptor has been looked up though, at which point in
time we've already sent requests, complicating the code. Hence, this
optimization (which amounts to @bdarnell's suggestion in cockroachdb#2818) has been
omitted for now due to the amount of code changes required.

Unfortunately, the improvements here don't directly reflect in SQL
benchmarks because of the way the Txn is used there.
We need to optimize the SQL server to batch up as many commands as it
can (basically until it reads data) and commit in the same round-trip
if possible. Currently the Txn object is used deep down in the individual
operations (for example `(*planner).Insert()`) so this isn't trivial.
I will file an issue.
@tbg tbg deleted the 1pc_txn branch May 8, 2018 15:03
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