diff --git a/pkg/sql/opt/exec/execbuilder/testdata/observability b/pkg/sql/opt/exec/execbuilder/testdata/observability index d2d0d5735159..aa06a115808e 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/observability +++ b/pkg/sql/opt/exec/execbuilder/testdata/observability @@ -12,6 +12,12 @@ INSERT INTO system.users VALUES ('node', NULL, true, 3) statement ok GRANT node TO root +statement ok +SELECT * FROM crdb_internal.transaction_activity + +statement ok +SELECT * FROM crdb_internal.statement_activity + # Upsert all transaction_activity query T retry EXPLAIN (VERBOSE) UPSERT INTO system.public.transaction_activity diff --git a/pkg/sql/sql_activity_update_job_test.go b/pkg/sql/sql_activity_update_job_test.go index 97023983f2a1..545fc46af1d1 100644 --- a/pkg/sql/sql_activity_update_job_test.go +++ b/pkg/sql/sql_activity_update_job_test.go @@ -81,6 +81,16 @@ func TestSqlActivityUpdateJob(t *testing.T) { require.NoError(t, err) require.Equal(t, 0, count, "statement_statistics: expect:0, actual:%d", count) + row = db.QueryRowContext(ctx, "SELECT count_rows() FROM crdb_internal.transaction_activity") + err = row.Scan(&count) + require.NoError(t, err) + require.Equal(t, 0, count, "crdb_internal.transaction_activity: expect:0, actual:%d", count) + + row = db.QueryRowContext(ctx, "SELECT count_rows() FROM crdb_internal.statement_activity") + err = row.Scan(&count) + require.NoError(t, err) + require.Equal(t, 0, count, "crdb_internal.statement_activity: expect:0, actual:%d", count) + execCfg := srv.ExecutorConfig().(ExecutorConfig) st := cluster.MakeTestingClusterSettings() updater := newSqlActivityUpdater(st, execCfg.InternalDB) @@ -164,6 +174,18 @@ func TestSqlActivityUpdateJob(t *testing.T) { err = row.Scan(&count) require.NoError(t, err) require.Equal(t, count, 1, "statement_activity after transfer: expect:1, actual:%d", count) + + row = db.QueryRowContext(ctx, "SELECT count_rows() "+ + "FROM crdb_internal.transaction_activity WHERE app_name = $1", appName) + err = row.Scan(&count) + require.NoError(t, err) + require.Equal(t, count, 1, "transaction_activity after transfer: expect:1, actual:%d", count) + + row = db.QueryRowContext(ctx, "SELECT count_rows() "+ + "FROM crdb_internal.statement_activity WHERE app_name = $1", appName) + err = row.Scan(&count) + require.NoError(t, err) + require.Equal(t, count, 1, "statement_activity after transfer: expect:1, actual:%d", count) } // TestSqlActivityUpdateJob verifies that the