Skip to content

Commit

Permalink
Remove unused code for old START_GTID logic (#17265)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink authored Nov 20, 2024
1 parent c5d0ecc commit 9094b55
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 38 deletions.
15 changes: 2 additions & 13 deletions go/vt/vttablet/tabletserver/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ import (
)

const (
txLogInterval = 1 * time.Minute
beginWithCSRO = "start transaction with consistent snapshot, read only"
trackGtidQuery = "set session session_track_gtids = START_GTID"
txLogInterval = 1 * time.Minute
beginWithCSRO = "start transaction with consistent snapshot, read only"
)

var txIsolations = map[querypb.ExecuteOptions_TransactionIsolation]string{
Expand Down Expand Up @@ -394,16 +393,6 @@ func createStartTxStmt(options *querypb.ExecuteOptions, readOnly bool) (string,
}

func handleConsistentSnapshotCase(ctx context.Context, conn *StatefulConnection) (beginSQL string, sessionStateChanges string, err error) {
_, err = conn.execWithRetry(ctx, trackGtidQuery, 1, false)
// We allow this to fail since this is a custom MySQL extension, but we return
// then if this query was executed or not.
//
// Callers also can know because the sessionStateChanges will be empty for a snapshot
// transaction and get GTID information in another (less efficient) way.
if err == nil {
beginSQL = trackGtidQuery + "; "
}

isolationLevel := txIsolations[querypb.ExecuteOptions_CONSISTENT_SNAPSHOT_READ_ONLY]

execSQL, err := setIsolationLevel(ctx, conn, isolationLevel)
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,11 @@ func TestTxPoolBeginStatements(t *testing.T) {
expBeginSQL: "set transaction isolation level serializable; start transaction read only",
}, {
txIsolationLevel: querypb.ExecuteOptions_CONSISTENT_SNAPSHOT_READ_ONLY,
expBeginSQL: "set session session_track_gtids = START_GTID; set transaction isolation level repeatable read; start transaction with consistent snapshot, read only",
expBeginSQL: "set transaction isolation level repeatable read; start transaction with consistent snapshot, read only",
}, {
txIsolationLevel: querypb.ExecuteOptions_CONSISTENT_SNAPSHOT_READ_ONLY,
readOnly: true,
expBeginSQL: "set session session_track_gtids = START_GTID; set transaction isolation level repeatable read; start transaction with consistent snapshot, read only",
expBeginSQL: "set transaction isolation level repeatable read; start transaction with consistent snapshot, read only",
}, {
txIsolationLevel: querypb.ExecuteOptions_AUTOCOMMIT,
expBeginSQL: "",
Expand Down
23 changes: 0 additions & 23 deletions go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,6 @@ func (conn *snapshotConn) startSnapshot(ctx context.Context, table string) (gtid
return replication.EncodePosition(mpos), nil
}

// startSnapshotWithConsistentGTID performs the snapshotting without locking tables. This assumes
// session_track_gtids = START_GTID, which is a contribution to MySQL and is not in vanilla MySQL at the
// time of this writing.
func (conn *snapshotConn) startSnapshotWithConsistentGTID(ctx context.Context) (gtid string, err error) {
if _, err := conn.ExecuteFetch("set transaction isolation level repeatable read", 1, false); err != nil {
return "", err
}
result, err := conn.ExecuteFetch("start transaction with consistent snapshot, read only", 1, false)
if err != nil {
return "", err
}
// The "session_track_gtids = START_GTID" patch is only applicable to MySQL56 GTID, which is
// why we hardcode the position as mysql.Mysql56FlavorID
mpos, err := replication.ParsePosition(replication.Mysql56FlavorID, result.SessionStateChanges)
if err != nil {
return "", err
}
if _, err := conn.ExecuteFetch("set @@session.time_zone = '+00:00'", 1, false); err != nil {
return "", err
}
return replication.EncodePosition(mpos), nil
}

// Close rolls back any open transactions and closes the connection.
func (conn *snapshotConn) Close() {
_, _ = conn.ExecuteFetch("rollback", 1, false)
Expand Down

0 comments on commit 9094b55

Please sign in to comment.