Skip to content

Commit

Permalink
tablemetadatacache: use store ids from response when updating cache
Browse files Browse the repository at this point in the history
Now that cockroachdb#129060 is done we can use the StoreIDs from the span
stats response when updating systme.table_metadata.

Epic: CRDB-37558
Release note: None
  • Loading branch information
xinhaoz committed Sep 13, 2024
1 parent a463cb3 commit 9159c85
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 60 deletions.
5 changes: 4 additions & 1 deletion pkg/sql/tablemetadatacache/table_metadata_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ func (q *tableMetadataBatchUpsertQuery) addRow(row *tableMetadataIterRow) error

// TODO (xinhaoz): Get store ids from span stats after
// https://github.com/cockroachdb/cockroach/issues/129060 is complete.
storeIds := make([]int, 0)
storeIds := make([]int, len(stats.StoreIDs))
for i, id := range stats.StoreIDs {
storeIds[i] = int(id)
}

args := []interface{}{
row.dbID, // db_id
Expand Down
118 changes: 59 additions & 59 deletions pkg/sql/tablemetadatacache/testdata/update_table_metadata
Original file line number Diff line number Diff line change
Expand Up @@ -38,65 +38,65 @@ SELECT
FROM system.table_metadata
ORDER BY (db_name, table_name)
----
mytable defaultdb public 100 104 3 0 {} 1 <nil>
mytable2 defaultdb public 100 105 4 0 {} 1 <nil>
comments system public 1 24 4 0 {} 1 <nil>
database_role_settings system public 1 44 4 1 {} 1 <nil>
descriptor system public 1 3 2 0 {} 1 <nil>
descriptor_id_seq system public 1 7 1 0 {} 1 <nil>
eventlog system public 1 12 6 0 {} 1 <nil>
external_connections system public 1 53 7 0 {} 1 <nil>
job_info system public 1 54 4 0 {} 1 <nil>
jobs system public 1 15 12 4 {} 1 <nil>
join_tokens system public 1 41 3 0 {} 1 <nil>
lease system public 1 11 5 0 {} 1 <nil>
locations system public 1 21 4 0 {} 1 <nil>
migrations system public 1 40 5 0 {} 1 <nil>
mvcc_statistics system public 1 64 6 0 {} 1 <nil>
namespace system public 1 30 4 0 {} 1 <nil>
privileges system public 1 52 5 2 {} 1 <nil>
protected_ts_meta system public 1 31 5 0 {} 1 <nil>
protected_ts_records system public 1 32 8 0 {} 1 <nil>
rangelog system public 1 13 7 0 {} 1 <nil>
region_liveness system public 1 9 2 0 {} 1 <nil>
replication_constraint_stats system public 1 25 7 0 {} 1 <nil>
replication_critical_localities system public 1 26 5 0 {} 1 <nil>
replication_stats system public 1 27 7 0 {} 1 <nil>
reports_meta system public 1 28 2 0 {} 1 <nil>
role_id_seq system public 1 48 1 0 {} 1 <nil>
role_members system public 1 23 5 5 {} 1 <nil>
role_options system public 1 33 4 1 {} 1 <nil>
scheduled_jobs system public 1 37 10 1 {} 1 <nil>
settings system public 1 6 4 0 {} 1 <nil>
span_configurations system public 1 47 3 0 {} 1 <nil>
span_count system public 1 51 2 0 {} 1 <nil>
span_stats_buckets system public 1 56 5 1 {} 1 <nil>
span_stats_samples system public 1 57 2 1 {} 1 <nil>
span_stats_tenant_boundaries system public 1 58 2 0 {} 1 <nil>
span_stats_unique_keys system public 1 55 2 1 {} 1 <nil>
sql_instances system public 1 46 8 0 {} 1 <nil>
sqlliveness system public 1 39 3 0 {} 1 <nil>
statement_activity system public 1 61 17 7 {} 1 <nil>
statement_bundle_chunks system public 1 34 3 0 {} 1 <nil>
statement_diagnostics system public 1 36 7 0 {} 1 <nil>
statement_diagnostics_requests system public 1 35 11 1 {} 1 <nil>
statement_execution_insights system public 1 66 29 4 {} 1 <nil>
statement_statistics system public 1 42 19 8 {} 1 <nil>
table_metadata system public 1 67 16 10 {} 1 <nil>
table_statistics system public 1 20 12 0 {} 1 <nil>
task_payloads system public 1 59 8 0 {} 1 <nil>
tenant_id_seq system public 1 63 1 0 {} 1 <nil>
tenant_settings system public 1 50 6 0 {} 1 <nil>
tenant_tasks system public 1 60 7 0 {} 1 <nil>
tenant_usage system public 1 45 14 0 {} 1 <nil>
tenants system public 1 8 6 2 {} 1 <nil>
transaction_activity system public 1 62 14 7 {} 1 <nil>
transaction_execution_insights system public 1 65 23 2 {} 1 <nil>
transaction_statistics system public 1 43 14 7 {} 1 <nil>
ui system public 1 14 3 0 {} 1 <nil>
users system public 1 4 4 1 {} 1 <nil>
web_sessions system public 1 19 9 4 {} 1 <nil>
zones system public 1 5 2 0 {} 1 <nil>
mytable defaultdb public 100 104 3 0 {1} 1 <nil>
mytable2 defaultdb public 100 105 4 0 {1} 1 <nil>
comments system public 1 24 4 0 {1} 1 <nil>
database_role_settings system public 1 44 4 1 {1} 1 <nil>
descriptor system public 1 3 2 0 {1} 1 <nil>
descriptor_id_seq system public 1 7 1 0 {1} 1 <nil>
eventlog system public 1 12 6 0 {1} 1 <nil>
external_connections system public 1 53 7 0 {1} 1 <nil>
job_info system public 1 54 4 0 {1} 1 <nil>
jobs system public 1 15 12 4 {1} 1 <nil>
join_tokens system public 1 41 3 0 {1} 1 <nil>
lease system public 1 11 5 0 {1} 1 <nil>
locations system public 1 21 4 0 {1} 1 <nil>
migrations system public 1 40 5 0 {1} 1 <nil>
mvcc_statistics system public 1 64 6 0 {1} 1 <nil>
namespace system public 1 30 4 0 {1} 1 <nil>
privileges system public 1 52 5 2 {1} 1 <nil>
protected_ts_meta system public 1 31 5 0 {1} 1 <nil>
protected_ts_records system public 1 32 8 0 {1} 1 <nil>
rangelog system public 1 13 7 0 {1} 1 <nil>
region_liveness system public 1 9 2 0 {1} 1 <nil>
replication_constraint_stats system public 1 25 7 0 {1} 1 <nil>
replication_critical_localities system public 1 26 5 0 {1} 1 <nil>
replication_stats system public 1 27 7 0 {1} 1 <nil>
reports_meta system public 1 28 2 0 {1} 1 <nil>
role_id_seq system public 1 48 1 0 {1} 1 <nil>
role_members system public 1 23 5 5 {1} 1 <nil>
role_options system public 1 33 4 1 {1} 1 <nil>
scheduled_jobs system public 1 37 10 1 {1} 1 <nil>
settings system public 1 6 4 0 {1} 1 <nil>
span_configurations system public 1 47 3 0 {1} 1 <nil>
span_count system public 1 51 2 0 {1} 1 <nil>
span_stats_buckets system public 1 56 5 1 {1} 1 <nil>
span_stats_samples system public 1 57 2 1 {1} 1 <nil>
span_stats_tenant_boundaries system public 1 58 2 0 {1} 1 <nil>
span_stats_unique_keys system public 1 55 2 1 {1} 1 <nil>
sql_instances system public 1 46 8 0 {1} 1 <nil>
sqlliveness system public 1 39 3 0 {1} 1 <nil>
statement_activity system public 1 61 17 7 {1} 1 <nil>
statement_bundle_chunks system public 1 34 3 0 {1} 1 <nil>
statement_diagnostics system public 1 36 7 0 {1} 1 <nil>
statement_diagnostics_requests system public 1 35 11 1 {1} 1 <nil>
statement_execution_insights system public 1 66 29 4 {1} 1 <nil>
statement_statistics system public 1 42 19 8 {1} 1 <nil>
table_metadata system public 1 67 16 10 {1} 1 <nil>
table_statistics system public 1 20 12 0 {1} 1 <nil>
task_payloads system public 1 59 8 0 {1} 1 <nil>
tenant_id_seq system public 1 63 1 0 {1} 1 <nil>
tenant_settings system public 1 50 6 0 {1} 1 <nil>
tenant_tasks system public 1 60 7 0 {1} 1 <nil>
tenant_usage system public 1 45 14 0 {1} 1 <nil>
tenants system public 1 8 6 2 {1} 1 <nil>
transaction_activity system public 1 62 14 7 {1} 1 <nil>
transaction_execution_insights system public 1 65 23 2 {1} 1 <nil>
transaction_statistics system public 1 43 14 7 {1} 1 <nil>
ui system public 1 14 3 0 {1} 1 <nil>
users system public 1 4 4 1 {1} 1 <nil>
web_sessions system public 1 19 9 4 {1} 1 <nil>
zones system public 1 5 2 0 {1} 1 <nil>

query
DROP TABLE mytable
Expand Down

0 comments on commit 9159c85

Please sign in to comment.