diff --git a/go/test/endtoend/vtgate/setstatement/sysvar_test.go b/go/test/endtoend/vtgate/setstatement/sysvar_test.go index 9a7e98bafc3..424e2f65e3f 100644 --- a/go/test/endtoend/vtgate/setstatement/sysvar_test.go +++ b/go/test/endtoend/vtgate/setstatement/sysvar_test.go @@ -210,11 +210,11 @@ func TestSetSystemVariableAndThenSuccessfulAutocommitDML(t *testing.T) { assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`) checkedExec(t, conn, `update test set val2 = 2 where val1 is null`) - assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) NULL INT64(2)]]`) + assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) NULL INT32(2)]]`) assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`) checkedExec(t, conn, `update test set val1 = 'text' where val1 is null`) - assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) VARCHAR("text") INT64(2)]]`) + assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) VARCHAR("text") INT32(2)]]`) assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`) checkedExec(t, conn, `delete from test where val1 = 'text'`) diff --git a/go/vt/vtgate/safe_session.go b/go/vt/vtgate/safe_session.go index a4de83364ee..ea386da1fc5 100644 --- a/go/vt/vtgate/safe_session.go +++ b/go/vt/vtgate/safe_session.go @@ -214,7 +214,10 @@ func (session *SafeSession) AppendOrUpdate(shardSession *vtgatepb.Session_ShardS session.mu.Lock() defer session.mu.Unlock() - if session.autocommitState == autocommitted { + // additional check of transaction id is required + // as now in autocommit mode there can be session due to reserved connection + // that needs to be stored as shard session. + if session.autocommitState == autocommitted && shardSession.TransactionId != 0 { // Should be unreachable return vterrors.New(vtrpcpb.Code_INTERNAL, "BUG: SafeSession.AppendOrUpdate: unexpected autocommit state") }