Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
76168: ui,server: Table stats collection details added to Database pages r=ericharmeling a=ericharmeling

Closes: cockroachdb#67510

Release justification: low-risk, high benefit changes to
existing functionality

Release note (ui change):
- Added status of automatic statistics collection to the Database
and Database table pages on the DB Console.
- Added timestamp of last statistics collection to the Database
details and Database table pages on the DB Console.

Here's a video of the changes in the UI:

https://user-images.githubusercontent.com/27286675/153521703-9ed19ed0-5fe9-4cb6-a537-1d227aeb0a0b.mov

Co-authored-by: Eric Harmeling <[email protected]>
  • Loading branch information
2 people authored and ajstorm committed Feb 15, 2022
2 parents 762ccdb + 366bf32 commit 78d1079
Show file tree
Hide file tree
Showing 103 changed files with 1,608 additions and 204 deletions.
1 change: 1 addition & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -4603,6 +4603,7 @@ a table.
| zone_config_level | [ZoneConfigurationLevel](#cockroach.server.serverpb.TableDetailsResponse-cockroach.server.serverpb.ZoneConfigurationLevel) | | The level at which this object's zone configuration is set. | [reserved](#support-status) |
| descriptor_id | [int64](#cockroach.server.serverpb.TableDetailsResponse-int64) | | descriptor_id is an identifier used to uniquely identify this table. It can be used to find events pertaining to this table by filtering on the 'target_id' field of events. | [reserved](#support-status) |
| configure_zone_statement | [string](#cockroach.server.serverpb.TableDetailsResponse-string) | | configure_zone_statement is the output of "SHOW ZONE CONFIGURATION FOR TABLE" for this table. It is a SQL statement that would re-configure the table's current zone if executed. | [reserved](#support-status) |
| stats_last_created_at | [google.protobuf.Timestamp](#cockroach.server.serverpb.TableDetailsResponse-google.protobuf.Timestamp) | | stats_last_created_at is the time at which statistics were last created. | [reserved](#support-status) |



Expand Down
6 changes: 6 additions & 0 deletions docs/generated/swagger/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,12 @@
"format": "int64",
"x-go-name": "RangeCount"
},
"stats_last_created_at": {
"description": "stats_last_created_at is the time at which statistics were last created.",
"type": "string",
"format": "date-time",
"x-go-name": "StatsLastCreatedAt"
},
"zone_config": {
"$ref": "#/definitions/ZoneConfig"
},
Expand Down
12 changes: 9 additions & 3 deletions pkg/base/test_server_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ type TestServerArgs struct {
// TODO(irfansharif): Remove all uses of this when we rip out the system
// config span.
DisableSpanConfigs bool

// TestServer will probabilistically start a single SQL server on each
// node for multi-tenant testing, and default all connections to that
// SQL server. Use this flag to disable that behavior.
DisableDefaultSQLServer bool
}

// TestClusterArgs contains the parameters one can set when creating a test
Expand Down Expand Up @@ -244,9 +249,10 @@ const (
type TestTenantArgs struct {
TenantID roachpb.TenantID

// Existing, if true, indicates an existing tenant, rather than a new tenant
// to be created by StartTenant.
Existing bool
// DisableCreateTenant disables the explicit creation of a tenant when
// StartTenant is attempted. It's used in cases where we want to validate
// that a tenant doesn't start if it isn't existing.
DisableCreateTenant bool

// Settings allows the caller to control the settings object used for the
// tenant cluster.
Expand Down
78 changes: 64 additions & 14 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (d *datadrivenTestState) addServer(
var cleanup func()
params := base.TestClusterArgs{}
params.ServerArgs.ExternalIODirConfig = ioConf
// Unfortunately, we have to disable the default SQL server here because
// of numerous failures in the data driven test suite when it's enabled.
// This should be investigated. Tracked with #76378.
params.ServerArgs.DisableDefaultSQLServer = true
if tempCleanupFrequency != "" {
duration, err := time.ParseDuration(tempCleanupFrequency)
if err != nil {
Expand Down Expand Up @@ -1180,7 +1184,12 @@ func backupAndRestore(
t.Fatal(err)
}
}
args := base.TestServerArgs{ExternalIODir: tc.Servers[backupNodeID].ClusterSettings().ExternalIODir}
args := base.TestServerArgs{
ExternalIODir: tc.Servers[backupNodeID].ClusterSettings().ExternalIODir,
// Test fails when run under a SQL server. More investigation is
// required. Tracked with #76378.
DisableDefaultSQLServer: tc.Servers[backupNodeID].Cfg.DisableDefaultSQLServer,
}
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(ctx)
sqlDBRestore := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
Expand Down Expand Up @@ -5777,7 +5786,9 @@ func TestBackupRestoreSequenceOwnership(t *testing.T) {
const numAccounts = 1
_, origDB, dir, cleanupFn := backupRestoreTestSetup(t, singleNode, numAccounts, InitManualReplication)
defer cleanupFn()
args := base.TestServerArgs{ExternalIODir: dir}
// Test fails when run under a SQL server. More investigation is
// required. Tracked with #76378.
args := base.TestServerArgs{ExternalIODir: dir, DisableDefaultSQLServer: true}

// Setup for sequence ownership backup/restore tests in the same database.
backupLoc := localFoo + `/d`
Expand Down Expand Up @@ -6342,6 +6353,9 @@ func TestProtectedTimestampsDuringBackup(t *testing.T) {
defer dirCleanupFn()
params := base.TestClusterArgs{}
params.ServerArgs.ExternalIODir = dir
// This test hangs when run from a SQL server. More investigation is
// required. Tracked with #76378.
params.ServerArgs.DisableDefaultSQLServer = true
params.ServerArgs.Knobs.Store = &kvserver.StoreTestingKnobs{
TestingRequestFilter: func(ctx context.Context, ba roachpb.BatchRequest) *roachpb.Error {
for _, ru := range ba.Requests {
Expand Down Expand Up @@ -6792,6 +6806,9 @@ func TestRestoreErrorPropagates(t *testing.T) {
defer dirCleanupFn()
params := base.TestClusterArgs{}
params.ServerArgs.ExternalIODir = dir
// This test fails when run from a SQL server. More investigation is
// required. Tracked with #76378.
params.ServerArgs.DisableDefaultSQLServer = true
jobsTableKey := keys.SystemSQLCodec.TablePrefix(uint32(systemschema.JobsTable.GetID()))
var shouldFail, failures int64
params.ServerArgs.Knobs.Store = &kvserver.StoreTestingKnobs{
Expand Down Expand Up @@ -6843,6 +6860,9 @@ func TestProtectedTimestampsFailDueToLimits(t *testing.T) {
defer dirCleanupFn()
params := base.TestClusterArgs{}
params.ServerArgs.ExternalIODir = dir
// This test fails when run from a SQL server. More investigation is
// required. Tracked with #76378.
params.ServerArgs.DisableDefaultSQLServer = true
tc := testcluster.StartTestCluster(t, 1, params)
defer tc.Stopper().Stop(ctx)
db := tc.ServerConn(0)
Expand Down Expand Up @@ -7248,7 +7268,10 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreTC := testcluster.StartTestCluster(
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: dir,
Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()},
// This test fails when run from a SQL server as it assumes that
// it's not running in SQL server. Tracked with #76378.
DisableDefaultSQLServer: true,
Knobs: base.TestingKnobs{JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals()},
}},
)
defer restoreTC.Stopper().Stop(ctx)
Expand All @@ -7269,7 +7292,7 @@ func TestBackupRestoreTenant(t *testing.T) {
ten10Stopper := stop.NewStopper()
_, restoreConn10 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{
TenantID: roachpb.MakeTenantID(10), Existing: true, Stopper: ten10Stopper,
TenantID: roachpb.MakeTenantID(10), Stopper: ten10Stopper,
},
)
restoreTenant10 := sqlutils.MakeSQLRunner(restoreConn10)
Expand Down Expand Up @@ -7311,7 +7334,7 @@ func TestBackupRestoreTenant(t *testing.T) {
)

_, restoreConn10 = serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10)},
)
defer restoreConn10.Close()
restoreTenant10 = sqlutils.MakeSQLRunner(restoreConn10)
Expand All @@ -7337,7 +7360,12 @@ func TestBackupRestoreTenant(t *testing.T) {

t.Run("restore-t10-from-cluster-backup", func(t *testing.T) {
restoreTC := testcluster.StartTestCluster(
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{ExternalIODir: dir}},
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: dir,
// This test fails when run from a SQL server as it assumes that
// it's not running in SQL server. Tracked with #76378.
DisableDefaultSQLServer: true,
}},
)
defer restoreTC.Stopper().Stop(ctx)
restoreDB := sqlutils.MakeSQLRunner(restoreTC.Conns[0])
Expand All @@ -7350,7 +7378,7 @@ func TestBackupRestoreTenant(t *testing.T) {
)

_, restoreConn10 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10)},
)
defer restoreConn10.Close()
restoreTenant10 := sqlutils.MakeSQLRunner(restoreConn10)
Expand All @@ -7361,7 +7389,12 @@ func TestBackupRestoreTenant(t *testing.T) {

t.Run("restore-all-from-cluster-backup", func(t *testing.T) {
restoreTC := testcluster.StartTestCluster(
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{ExternalIODir: dir}},
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: dir,
// This test fails when run from a SQL server as it assumes that
// it's not running in SQL server. Tracked with #76378.
DisableDefaultSQLServer: true,
}},
)

defer restoreTC.Stopper().Stop(ctx)
Expand All @@ -7379,7 +7412,7 @@ func TestBackupRestoreTenant(t *testing.T) {
)

_, restoreConn10 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10)},
)
defer restoreConn10.Close()
restoreTenant10 := sqlutils.MakeSQLRunner(restoreConn10)
Expand All @@ -7388,7 +7421,7 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreTenant10.CheckQueryResults(t, `select * from foo.bar2`, tenant10.QueryStr(t, `select * from foo.bar2`))

_, restoreConn11 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(11), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(11)},
)
defer restoreConn11.Close()
restoreTenant11 := sqlutils.MakeSQLRunner(restoreConn11)
Expand All @@ -7398,15 +7431,20 @@ func TestBackupRestoreTenant(t *testing.T) {

t.Run("restore-tenant10-to-ts1", func(t *testing.T) {
restoreTC := testcluster.StartTestCluster(
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{ExternalIODir: dir}},
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: dir,
// This test fails when run from a SQL server as it assumes that
// it's not running in SQL server. Tracked with #76378.
DisableDefaultSQLServer: true,
}},
)
defer restoreTC.Stopper().Stop(ctx)
restoreDB := sqlutils.MakeSQLRunner(restoreTC.Conns[0])

restoreDB.Exec(t, `RESTORE TENANT 10 FROM 'nodelocal://1/t10' AS OF SYSTEM TIME `+ts1)

_, restoreConn10 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(10)},
)
defer restoreConn10.Close()
restoreTenant10 := sqlutils.MakeSQLRunner(restoreConn10)
Expand All @@ -7416,15 +7454,20 @@ func TestBackupRestoreTenant(t *testing.T) {

t.Run("restore-tenant20-to-latest", func(t *testing.T) {
restoreTC := testcluster.StartTestCluster(
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{ExternalIODir: dir}},
t, singleNode, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: dir,
// This test fails when run from a SQL server as it assumes that
// it's not running in SQL server. Tracked with #76378.
DisableDefaultSQLServer: true,
}},
)
defer restoreTC.Stopper().Stop(ctx)
restoreDB := sqlutils.MakeSQLRunner(restoreTC.Conns[0])

restoreDB.Exec(t, `RESTORE TENANT 20 FROM 'nodelocal://1/t20'`)

_, restoreConn20 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(20), Existing: true},
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(20)},
)
defer restoreConn20.Close()
restoreTenant20 := sqlutils.MakeSQLRunner(restoreConn20)
Expand Down Expand Up @@ -8333,6 +8376,8 @@ func TestFullClusterTemporaryBackupAndRestore(t *testing.T) {
defer dirCleanupFn()
params := base.TestClusterArgs{}
params.ServerArgs.ExternalIODir = dir
// This test fails when run from a SQL server. Tracked with #76378.
params.ServerArgs.DisableDefaultSQLServer = true
params.ServerArgs.UseDatabase = "defaultdb"
params.ServerArgs.Settings = settings
knobs := base.TestingKnobs{
Expand Down Expand Up @@ -9095,6 +9140,11 @@ func TestGCDropIndexSpanExpansion(t *testing.T) {
ctx := context.Background()
tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{ServerArgs: base.TestServerArgs{
ExternalIODir: baseDir,
// This test hangs when run from a SQL server. It's likely that
// the cause of the hang is the fact that we're waiting on the GC to
// complete, and we don't have visibility into the GC completing from
// the tenant. More investigation is required. Tracked with #76378.
DisableDefaultSQLServer: true,
Knobs: base.TestingKnobs{
GCJob: &sql.GCJobTestingKnobs{RunBeforePerformGC: func(id jobspb.JobID) error {
gcJobID = id
Expand Down
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/create_scheduled_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func newTestHelper(t *testing.T) (*testHelper, func()) {

args := base.TestServerArgs{
ExternalIODir: dir,
// Some scheduled backup tests fail when run from a SQL server. More
// investigation is required. Tracked with #76378.
DisableDefaultSQLServer: true,
Knobs: base.TestingKnobs{
JobsTestingKnobs: knobs,
},
Expand Down
10 changes: 8 additions & 2 deletions pkg/ccl/backupccl/full_cluster_backup_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,10 @@ func TestRestoreWithRecreatedDefaultDB(t *testing.T) {
defer log.Scope(t).Close(t)

sqlDB, tempDir, cleanupFn := createEmptyCluster(t, singleNode)
_, sqlDBRestore, cleanupEmptyCluster := backupRestoreTestSetupEmpty(t, singleNode, tempDir, InitManualReplication, base.TestClusterArgs{})
_, sqlDBRestore, cleanupEmptyCluster := backupRestoreTestSetupEmpty(t, singleNode, tempDir, InitManualReplication,
// Disabling the default SQL server due to test failures. More
// investigation is required. Tracked with #76378.
base.TestClusterArgs{ServerArgs: base.TestServerArgs{DisableDefaultSQLServer: true}})
defer cleanupFn()
defer cleanupEmptyCluster()

Expand All @@ -1081,7 +1084,10 @@ func TestRestoreWithDroppedDefaultDB(t *testing.T) {
defer log.Scope(t).Close(t)

sqlDB, tempDir, cleanupFn := createEmptyCluster(t, singleNode)
_, sqlDBRestore, cleanupEmptyCluster := backupRestoreTestSetupEmpty(t, singleNode, tempDir, InitManualReplication, base.TestClusterArgs{})
_, sqlDBRestore, cleanupEmptyCluster := backupRestoreTestSetupEmpty(t, singleNode, tempDir, InitManualReplication,
// Disabling the default SQL server due to test failures. More
// investigation is required. Tracked with #76378.
base.TestClusterArgs{ServerArgs: base.TestServerArgs{DisableDefaultSQLServer: true}})
defer cleanupFn()
defer cleanupEmptyCluster()

Expand Down
Loading

0 comments on commit 78d1079

Please sign in to comment.