Skip to content

DO NOT MERGE: replica transaction#62

Closed
deepthi wants to merge 25 commits intomasterfrom
ds-replica-transaction
Closed

DO NOT MERGE: replica transaction#62
deepthi wants to merge 25 commits intomasterfrom
ds-replica-transaction

Conversation

@deepthi
Copy link
Copy Markdown

@deepthi deepthi commented May 22, 2020

creating a PR to get feedback

@deepthi deepthi requested a review from sougou as a code owner May 22, 2020 22:55
@deepthi deepthi requested review from harshit-gangal and systay May 22, 2020 23:01
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@sougou we need a TODO to clean this up. Wha't s the best way to word it?

@deepthi
Copy link
Copy Markdown
Author

deepthi commented May 22, 2020

I removed the checks that were preventing replica transactions in various places. However, I believe we need some other checks to ensure that we are allowing replica transactions only if we have a pinned tablet to route the subsequent queries to.

@deepthi deepthi force-pushed the ds-replica-transaction branch from 903fd9a to fc7c11e Compare May 24, 2020 00:39
deepthi and others added 3 commits May 25, 2020 15:18
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>

Signed-off-by: deepthi <deepthi@planetscale.com>
@deepthi deepthi force-pushed the ds-replica-transaction branch from 2d1aaf1 to 65a8a5c Compare May 25, 2020 22:22
deepthi and others added 5 commits May 25, 2020 15:41
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay force-pushed the ds-replica-transaction branch 2 times, most recently from 5cf4cba to 031527c Compare May 26, 2020 14:29
systay and others added 2 commits May 26, 2020 21:07
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
@systay systay changed the base branch from ds-new-healthcheck to master May 27, 2020 09:49
systay and others added 2 commits May 27, 2020 12:27
…ction

Signed-off-by: Andres Taylor <andres@planetscale.com>
…orrect tablet

Signed-off-by: deepthi <deepthi@planetscale.com>
return err
}
}
// TODO(deepthi): TransactionId should be set to 0 only if the commit succeeded
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't feel this is correct. If we tried and failed to commit, we should not trust that we still have an open transaction on this connection. I think we should set the tx_id to 0 and close the connection, since we can't trust it

Copy link
Copy Markdown
Author

@deepthi deepthi May 28, 2020

Choose a reason for hiding this comment

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

That is valid. I think we got it exactly backwards in the first attempt to fix it.
The way this should work is:

  1. Commit is successful. All shardSession transactions have ended, so set all TransactionID = 0
  2. There was an error from one or more shards. Rollback the other shards. Rollback should only operate on the shards that did not fail. So set TransactionID=0 on failed shards so that we attempt rollback only on successful shards. There is no need to explicitly set TransactionID = 0 on the successful shards at the end of rollback. the defer call to session.Reset takes care of that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM

Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay force-pushed the ds-replica-transaction branch from ff85a4a to be11233 Compare May 28, 2020 08:20
systay added 2 commits May 28, 2020 15:12
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
deepthi added 3 commits May 28, 2020 10:46
… shards if a subset fails

Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
@@ -132,7 +132,7 @@ func TestTxConnCommitOrderFailure1(t *testing.T) {
utils.MustMatch(t, &wantSession, session.Session, "Session")
assert.EqualValues(t, 1, sbc0.CommitCount.Get(), "sbc0.CommitCount")
// When the commit fails, we try to clean up by issuing a rollback
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add assertions about sbc1.CommitCount here, and sbc0.RollbackCount in the next test to make it clearer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added assertions though I'm not sure I understand them :)

}

var qs queryservice.QueryService
if UsingLegacyGateway() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We really need to remove the legacy gateway, or add more capabilities to it. these checks are really not good to spread out like this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agreed :(

qr, err := conn.ExecuteFetch(query, 1000, true)
require.Nil(t, err)
if expectError == "" {
require.Nil(t, err)
Copy link
Copy Markdown
Member

@systay systay May 29, 2020

Choose a reason for hiding this comment

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

When checking for errors, we get better assertion error messages if we use require.NoError instead of require.Nil

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

+1. I was looking for this, but thought it was something like NilError.

systay added 2 commits May 29, 2020 09:50
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay force-pushed the ds-replica-transaction branch from 7a73eab to f13b506 Compare May 29, 2020 07:51
Signed-off-by: Andres Taylor <andres@planetscale.com>
return shardVars
}

func allowOnlyMaster(rss ...*srvtopo.ResolvedShard) error {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

+1

deepthi added 4 commits May 29, 2020 12:19
Signed-off-by: deepthi <deepthi@planetscale.com>
…nd works

Signed-off-by: deepthi <deepthi@planetscale.com>
…st healthcheck

Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
@deepthi
Copy link
Copy Markdown
Author

deepthi commented May 29, 2020

opened vitessio#6244. closing this one.

@deepthi deepthi closed this May 29, 2020
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