Skip to content

Commit

Permalink
sql: add tenant_usage system table
Browse files Browse the repository at this point in the history
Add the system table described in the RFC (cockroachdb#66436).

The table is only created for the system tenant.

Release note: None
  • Loading branch information
RaduBerinde committed Jul 28, 2021
1 parent c4702ef commit 513857c
Show file tree
Hide file tree
Showing 32 changed files with 402 additions and 101 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ trace.datadog.project string CockroachDB the project under which traces will be
trace.debug.enable boolean false if set, traces for recent requests can be seen at https://<ui>/debug/requests
trace.lightstep.token string if set, traces go to Lightstep using this token
trace.zipkin.collector string if set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time.
version version 21.1-118 set the active cluster version in the format '<major>.<minor>'
version version 21.1-120 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@
<tr><td><code>trace.debug.enable</code></td><td>boolean</td><td><code>false</code></td><td>if set, traces for recent requests can be seen at https://<ui>/debug/requests</td></tr>
<tr><td><code>trace.lightstep.token</code></td><td>string</td><td><code></code></td><td>if set, traces go to Lightstep using this token</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>if set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.1-118</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.1-120</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
systemschema.DatabaseRoleSettingsTable.GetName(): {
shouldIncludeInClusterBackup: optInToClusterBackup,
},
systemschema.TenantUsageTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
}

// GetSystemTablesToIncludeInClusterBackup returns a set of system table names that
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/testdata/doctor/test_examine_cluster
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
debug doctor examine cluster
----
debug doctor examine cluster
Examining 38 descriptors and 39 namespace entries...
Examining 39 descriptors and 40 namespace entries...
ParentID 50, ParentSchemaID 29: relation "foo" (53): expected matching namespace entry, found none
Examining 3 jobs...
ERROR: validation failed
9 changes: 6 additions & 3 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting ranges... received response... done
[node 1] 40 ranges found
[node 1] 41 ranges found
[node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done
[node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done
[node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done
Expand Down Expand Up @@ -107,6 +107,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done
[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done
[node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done
[node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done
[node 2] node status... converting to JSON... writing binary output: debug/nodes/2/status.json... done
[node 2] using SQL connection URL: postgresql://...
[node 2] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/2/crdb_internal.feature_usage.txt...
Expand Down Expand Up @@ -225,7 +226,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting ranges... received response... done
[node 3] 40 ranges found
[node 3] 41 ranges found
[node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done
[node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done
[node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done
Expand Down Expand Up @@ -266,6 +267,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done
[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done
[node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done
[node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done
[cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done
[cluster] requesting list of SQL databases... received response... done
[cluster] 3 databases found
Expand All @@ -274,7 +276,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: postgres] 0 tables found
[cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: system] 33 tables found
[cluster] [database: system] 34 tables found
[cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done
[cluster] [database: system] [table: public.database_role_settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_database_role_settings.json... done
[cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done
Expand Down Expand Up @@ -302,6 +304,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[cluster] [database: system] [table: public.statement_diagnostics_requests] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics_requests.json... done
[cluster] [database: system] [table: public.statement_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_statistics.json... done
[cluster] [database: system] [table: public.table_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_table_statistics.json... done
[cluster] [database: system] [table: public.tenant_usage] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenant_usage.json... done
[cluster] [database: system] [table: public.tenants] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenants.json... done
[cluster] [database: system] [table: public.transaction_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_transaction_statistics.json... done
[cluster] [database: system] [table: public.ui] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_ui.json... done
Expand Down
9 changes: 6 additions & 3 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting ranges... received response... done
[node 1] 40 ranges found
[node 1] 41 ranges found
[node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done
[node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done
[node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done
Expand Down Expand Up @@ -107,6 +107,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done
[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done
[node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done
[node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done
[node 2] skipping node... writing binary output: debug/nodes/2.skipped... done
[node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done
[node 3] using SQL connection URL: postgresql://...
Expand Down Expand Up @@ -143,7 +144,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting ranges... received response... done
[node 3] 40 ranges found
[node 3] 41 ranges found
[node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done
[node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done
[node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done
Expand Down Expand Up @@ -184,6 +185,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done
[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done
[node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done
[node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done
[cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done
[cluster] requesting list of SQL databases... received response... done
[cluster] 3 databases found
Expand All @@ -192,7 +194,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: postgres] 0 tables found
[cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: system] 33 tables found
[cluster] [database: system] 34 tables found
[cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done
[cluster] [database: system] [table: public.database_role_settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_database_role_settings.json... done
[cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done
Expand Down Expand Up @@ -220,6 +222,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[cluster] [database: system] [table: public.statement_diagnostics_requests] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics_requests.json... done
[cluster] [database: system] [table: public.statement_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_statistics.json... done
[cluster] [database: system] [table: public.table_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_table_statistics.json... done
[cluster] [database: system] [table: public.tenant_usage] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenant_usage.json... done
[cluster] [database: system] [table: public.tenants] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenants.json... done
[cluster] [database: system] [table: public.transaction_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_transaction_statistics.json... done
[cluster] [database: system] [table: public.ui] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_ui.json... done
Expand Down
9 changes: 6 additions & 3 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting ranges... received response... done
[node 1] 40 ranges found
[node 1] 41 ranges found
[node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done
[node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done
[node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done
Expand Down Expand Up @@ -107,6 +107,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 1] writing range 38... converting to JSON... writing binary output: debug/nodes/1/ranges/38.json... done
[node 1] writing range 39... converting to JSON... writing binary output: debug/nodes/1/ranges/39.json... done
[node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done
[node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done
[node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done
[node 3] using SQL connection URL: postgresql://...
[node 3] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/3/crdb_internal.feature_usage.txt... done
Expand Down Expand Up @@ -142,7 +143,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting ranges... received response... done
[node 3] 40 ranges found
[node 3] 41 ranges found
[node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done
[node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done
[node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done
Expand Down Expand Up @@ -183,6 +184,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 3] writing range 38... converting to JSON... writing binary output: debug/nodes/3/ranges/38.json... done
[node 3] writing range 39... converting to JSON... writing binary output: debug/nodes/3/ranges/39.json... done
[node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done
[node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done
[cluster] doctor examining cluster...... writing binary output: debug/reports/doctor.txt... done
[cluster] requesting list of SQL databases... received response... done
[cluster] 3 databases found
Expand All @@ -191,7 +193,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[cluster] [database: postgres] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: postgres] 0 tables found
[cluster] [database: system] requesting database details... received response... converting to JSON... writing binary output: debug/schema/[email protected]... done
[cluster] [database: system] 33 tables found
[cluster] [database: system] 34 tables found
[cluster] [database: system] [table: public.comments] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_comments.json... done
[cluster] [database: system] [table: public.database_role_settings] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_database_role_settings.json... done
[cluster] [database: system] [table: public.descriptor] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_descriptor.json... done
Expand Down Expand Up @@ -219,6 +221,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[cluster] [database: system] [table: public.statement_diagnostics_requests] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_diagnostics_requests.json... done
[cluster] [database: system] [table: public.statement_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_statement_statistics.json... done
[cluster] [database: system] [table: public.table_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_table_statistics.json... done
[cluster] [database: system] [table: public.tenant_usage] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenant_usage.json... done
[cluster] [database: system] [table: public.tenants] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_tenants.json... done
[cluster] [database: system] [table: public.transaction_statistics] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_transaction_statistics.json... done
[cluster] [database: system] [table: public.ui] requesting table details... received response... converting to JSON... writing binary output: debug/schema/system/public_ui.json... done
Expand Down
Loading

0 comments on commit 513857c

Please sign in to comment.