Skip to content

multitenant: rethink UX/schema of crdb_internal.range{,_no_leases} under multi-tenancy #93198

@arulajmani

Description

@arulajmani

Describe the problem

With #92131, secondary tenants are able to access crdb_internal.ranges{,_no_leases}. Here's how some sample output looks:

select * from crdb_internal.ranges_no_leases;

  range_id | start_key |    start_pretty     | end_key  |     end_pretty      | table_id | database_name | schema_name | table_name | index_name | replicas |    replica_localities    | voting_replicas | non_voting_replicas | learner_replicas |   split_enforced_until
-----------+-----------+---------------------+----------+---------------------+----------+---------------+-------------+------------+------------+----------+--------------------------+-----------------+---------------------+------------------+----------------------------
        55 | \xfe8a    | /Tenant/2           | \xfe8af2 | /Tenant/2/Table/106 |        0 |               |             |            |            | {1}      | {"region=us-east1,az=b"} | {1}             | {}                  | {}               | 2022-12-07 17:23:50.37541
        56 | \xfe8af2  | /Tenant/2/Table/106 | \xffff   | /Max                |      106 | movr          | public      | users      |            | {1}      | {"region=us-east1,az=b"} | {1}             | {}                  | {}               | NULL
(2 rows)

The schema here assumes that every range will belong to at-most 1 table. However, this isn't true for secondary tenants, as we no longer split on table boundaries for them. As such, this schema doesn't make much sense and could use a rethink.


Completing the example above, the output above seems to indicate that the users table is on range 56. This isn't true however, as the output of SHOW TABLES is here:

 SHOW TABLES;

  schema_name |         table_name         | type  | owner | estimated_row_count | locality
--------------+----------------------------+-------+-------+---------------------+-----------
  public      | promo_codes                | table | demo  |                1000 | NULL
  public      | rides                      | table | demo  |                 500 | NULL
  public      | user_promo_codes           | table | demo  |                   5 | NULL
  public      | users                      | table | demo  |                  50 | NULL
  public      | vehicle_location_histories | table | demo  |                1000 | NULL
  public      | vehicles                   | table | demo  |                  15 | NULL

All these tables are on r56.

cc @knz @ecwall

Jira issue: CRDB-22216

Epic CRDB-22701

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-multitenantIssues owned by the multi-tenant virtual team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions