Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arulajmani opened this issue Dec 7, 2022 · 1 comment · Fixed by #93644
Closed
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-multitenant Issues owned by the multi-tenant virtual team

Comments

@arulajmani
Copy link
Collaborator

arulajmani commented Dec 7, 2022

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

@arulajmani arulajmani added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-multitenant Issues owned by the multi-tenant virtual team labels Dec 7, 2022
@knz
Copy link
Contributor

knz commented Dec 7, 2022

IMHO we should duplicate the rows in the vtable, one row for each table/index covered, with possibly the range-id duplicated across rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-multitenant Issues owned by the multi-tenant virtual team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants