From 9094b55b2a5889271f86b5a4bf51340092b171c6 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Wed, 20 Nov 2024 16:42:02 +0100 Subject: [PATCH] Remove unused code for old START_GTID logic (#17265) Signed-off-by: Dirkjan Bussink --- go/vt/vttablet/tabletserver/tx_pool.go | 15 ++---------- go/vt/vttablet/tabletserver/tx_pool_test.go | 4 ++-- .../tabletserver/vstreamer/snapshot_conn.go | 23 ------------------- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/go/vt/vttablet/tabletserver/tx_pool.go b/go/vt/vttablet/tabletserver/tx_pool.go index ca8a0ea34b2..302a3d41050 100644 --- a/go/vt/vttablet/tabletserver/tx_pool.go +++ b/go/vt/vttablet/tabletserver/tx_pool.go @@ -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{ @@ -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) diff --git a/go/vt/vttablet/tabletserver/tx_pool_test.go b/go/vt/vttablet/tabletserver/tx_pool_test.go index c03cac92878..22810d4c422 100644 --- a/go/vt/vttablet/tabletserver/tx_pool_test.go +++ b/go/vt/vttablet/tabletserver/tx_pool_test.go @@ -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: "", diff --git a/go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go b/go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go index ec326cc4159..ee141ce9859 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go +++ b/go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go @@ -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)