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

Replica transactions #6244

Merged
merged 33 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
99faad4
replica transactions: initial implementation
deepthi May 22, 2020
b97066b
replica transactions: do not allow if using discoverygateway
deepthi May 23, 2020
65a8a5c
replica transactions: fixed endtoend test
systay May 24, 2020
2e647fc
replica transactions: tabletHealthCheck no longer has a mu
deepthi May 25, 2020
3c14906
Cleaned up test
systay May 26, 2020
8438053
Renamed fake test methods to include legacy
systay May 26, 2020
dccd6b6
Made TabletGateWay use an interface for the HealthCheck
systay May 26, 2020
031527c
Clean up of test
systay May 26, 2020
0b7bc39
replica transaction: fixed tests
systay May 26, 2020
77a274f
replica transactions: protect tabletHealthCheck.Conn with mutex
deepthi May 27, 2020
abf30b7
Merge remote-tracking branch 'upstream/master' into ds-replica-transa…
systay May 27, 2020
72ae94d
replica transactions: commit and rollback should be executed on the c…
deepthi May 28, 2020
be11233
Make tx_engine use read only transactions when in replica mode
systay May 28, 2020
c5cffda
Test cleanup
systay May 28, 2020
ab38d4a
Update test assertions
systay May 28, 2020
c14319a
replica transactions: tx_conn.commitNormal should rollback successful…
deepthi May 28, 2020
015849a
replica transactions: allow with prepared statements, fix commit2PC
deepthi May 28, 2020
a8915b1
replica transactions: disallow DMLs on non-master tablets
deepthi May 29, 2020
7900711
replica transactions: test cleanup
systay May 29, 2020
f13b506
replica transactions: refactor check so it's done in one place
systay May 29, 2020
e149589
replica-transactions: updated tests to work with the new master checking
systay May 29, 2020
a79abb3
test framework: rename funcs, replica tablet type should be set
deepthi May 29, 2020
bb7ac34
replica transaction: test tablet down and up produces correct error a…
deepthi May 29, 2020
bc2d19b
replica transactions: move test up one level since it is no longer ju…
deepthi May 29, 2020
8caab43
add more assertions to commit order tests
deepthi May 29, 2020
935af38
replica transactions: prepared statement test
deepthi May 29, 2020
79e068d
Merge remote-tracking branch 'upstream/master' into ds-replica-transa…
systay May 31, 2020
c123179
fix vtexplain breakage due to replica transaction changes
deepthi Jun 1, 2020
3f85942
Merge remote-tracking branch 'upstream/master' into ds-replica-transa…
systay Jun 3, 2020
e7887c4
Address PR reviews
systay Jun 3, 2020
96d0d0f
replica transactions: add TabletAlias to the grpc Request/Response. g…
deepthi Jun 3, 2020
96aad32
replica transactions: commitNormal should attempt rollback even if co…
deepthi Jun 3, 2020
a7cb8e2
Merge remote-tracking branch 'upstream/master' into ds-replica-transa…
systay Jun 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replica transaction: fixed tests
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed May 26, 2020
commit 0b7bc398672130217b0abaa24868520b26662aaf
5 changes: 3 additions & 2 deletions go/test/endtoend/tabletgateway/healthcheck/vtgate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ func TestReplicaTransactions(t *testing.T) {

// insert a row using master
exec(t, masterConn, "insert into customer(id, email) values(1,'email1')")

time.Sleep(1 * time.Second)
time.Sleep(1 * time.Second) // we sleep for a bit to make sure that the replication catches up

// after a short pause, SELECT the data inside a tx on a replica
_ = exec(t, replicaConn, "use @replica")
Expand All @@ -107,13 +106,15 @@ func TestReplicaTransactions(t *testing.T) {

// insert more data on master
exec(t, masterConn, "insert into customer(id, email) values(2,'email2')")
time.Sleep(1 * time.Second)

// replica doesn't see new row because it is in a transaction
qr2 := exec(t, replicaConn, "select id, email from customer")
assert.Equal(t, qr.Rows, qr2.Rows)

// replica should see new row after closing the transaction
_ = exec(t, replicaConn, "commit")

qr3 := exec(t, replicaConn, "select id, email from customer")
assert.Equal(t, `[[INT64(1) VARCHAR("email1")] [INT64(2) VARCHAR("email2")]]`, fmt.Sprintf("%v", qr3.Rows), "we are not seeing the updates after closing the replica transaction")
}
Expand Down
6 changes: 4 additions & 2 deletions go/vt/vttablet/tabletserver/tabletserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,10 @@ func TestBeginOnReplica(t *testing.T) {
options = querypb.ExecuteOptions{
TransactionIsolation: querypb.ExecuteOptions_DEFAULT,
}
_, _, err = tsv.Begin(ctx, &target1, &options)
require.Error(t, err, "expected write tx to be refused")
txID, _, err = tsv.Begin(ctx, &target1, &options)
require.NoError(t, err, "expected write tx to be allowed")
err = tsv.Rollback(ctx, &target1, txID)
require.NoError(t, err)
}

func TestTabletServerMasterToReplica(t *testing.T) {
Expand Down
7 changes: 0 additions & 7 deletions go/vt/vttablet/tabletserver/tx_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ func (te *TxEngine) Begin(ctx context.Context, options *querypb.ExecuteOptions)
return 0, "", vterrors.Errorf(vtrpc.Code_UNAVAILABLE, "tx engine can't accept new transactions in state %v", te.state)
}

// TODO(deepthi): Can this be deleted now that we do allow replica transactions?
//isWriteTransaction := options == nil || options.TransactionIsolation != querypb.ExecuteOptions_CONSISTENT_SNAPSHOT_READ_ONLY
//if te.state == AcceptingReadOnly && isWriteTransaction {
// te.stateLock.Unlock()
// return 0, "", vterrors.Errorf(vtrpc.Code_UNAVAILABLE, "tx engine can only accept read-only transactions in current state")
//}

// By Add() to beginRequests, we block others from initiating state
// changes until we have finished adding this transaction
te.beginRequests.Add(1)
Expand Down