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

[DocDB] Fix system.partitions query to return correct namespace name after upgrade #17712

Closed
1 task done
karan-yb opened this issue Jun 7, 2023 · 0 comments
Closed
1 task done

Comments

@karan-yb
Copy link
Contributor

karan-yb commented Jun 7, 2023

Jira Link: DB-6814

Description

In version 2.3.0, this change introduced a new table level field and code for new tables to fill it. However there was no migration code. And later in 2.11.2, this change switched the read path to use the field added in 2.3.0. Because of no migration code, if any table which was created before 2.3.0 and we upgrade the system to any version > 2.11.2, then we will return empty namespace name to client. This breaks the driver from properly routing requests.

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@karan-yb karan-yb added area/docdb YugabyteDB core features status/awaiting-triage Issue awaiting triage labels Jun 7, 2023
@karan-yb karan-yb self-assigned this Jun 7, 2023
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Jun 7, 2023
@yugabyte-ci yugabyte-ci added priority/high High Priority and removed status/awaiting-triage Issue awaiting triage priority/medium Medium priority issue labels Jun 8, 2023
karan-yb added a commit that referenced this issue Jun 8, 2023
…pace name when its not set at table level

Summary:
Tables created before version 2.3 will have empty namespace name in master state, which in turn breaks the client partition routing since client receive empty namespace name. This change fixes the issue by resolving the namespace id to namespace name when namespace name is not set.

Thanks @jhe for your help with validating the fix.
Jira: DB-6814

Test Plan:
Jenkins
@jhe helped validate this change by creating a table in older version 2.2 and then upgrading the system.
Before fix (notice that only the newly created table has a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+-------------------------
               | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 | {'127.0.0.1': 'LEADER'}
               |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c | {'127.0.0.1': 'LEADER'}
               |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a | {'127.0.0.1': 'LEADER'}
               |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 | {'127.0.0.1': 'LEADER'}
               |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 | {'127.0.0.1': 'LEADER'}
               |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'LEADER'}
               |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 | {'127.0.0.1': 'LEADER'}
               |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac | {'127.0.0.1': 'LEADER'}
               |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 | {'127.0.0.1': 'LEADER'}
               |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 | {'127.0.0.1': 'LEADER'}
               |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b | {'127.0.0.1': 'LEADER'}
               |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb | {'127.0.0.1': 'LEADER'}
               |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 | {'127.0.0.1': 'LEADER'}
               |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 | {'127.0.0.1': 'LEADER'}
               |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac | {'127.0.0.1': 'LEADER'}
               |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 | {'127.0.0.1': 'LEADER'}
               |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 | {'127.0.0.1': 'LEADER'}
               |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'LEADER'}
```
With the fix (all tables have a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+---------------------------
   system_auth | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 |   {'127.0.0.1': 'LEADER'}
 system_schema |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c |   {'127.0.0.1': 'LEADER'}
 system_schema |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a |   {'127.0.0.1': 'LEADER'}
        system |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 |   {'127.0.0.1': 'LEADER'}
 system_schema |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 |   {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'FOLLOWER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'FOLLOWER'}
        system |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 |   {'127.0.0.1': 'LEADER'}
 system_schema |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac |   {'127.0.0.1': 'LEADER'}
   system_auth |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 |   {'127.0.0.1': 'LEADER'}
        system |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b |   {'127.0.0.1': 'LEADER'}
        system |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb |   {'127.0.0.1': 'LEADER'}
 system_schema |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 |   {'127.0.0.1': 'LEADER'}
   system_auth |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 |   {'127.0.0.1': 'LEADER'}
 system_schema |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac |   {'127.0.0.1': 'LEADER'}
 system_schema |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'FOLLOWER'}
```

Reviewers: jhe, bogdan, slingam

Reviewed By: jhe, bogdan

Subscribers: yql, ybase, jhe, bogdan

Differential Revision: https://phorge.dev.yugabyte.com/D26033
karan-yb added a commit that referenced this issue Jun 8, 2023
…urn empty namespace name when its not set at table level

Summary:
Original commit: 218253c / D26033
Tables created before version 2.3 will have empty namespace name in master state, which in turn breaks the client partition routing since client receive empty namespace name. This change fixes the issue by resolving the namespace id to namespace name when namespace name is not set.

Thanks @jhe for your help with validating the fix.
Jira: DB-6814

Test Plan:
Jenkins
@jhe helped validate this change by creating a table in older version 2.2 and then upgrading the system.
Before fix (notice that only the newly created table has a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+-------------------------
               | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 | {'127.0.0.1': 'LEADER'}
               |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c | {'127.0.0.1': 'LEADER'}
               |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a | {'127.0.0.1': 'LEADER'}
               |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 | {'127.0.0.1': 'LEADER'}
               |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 | {'127.0.0.1': 'LEADER'}
               |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'LEADER'}
               |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 | {'127.0.0.1': 'LEADER'}
               |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac | {'127.0.0.1': 'LEADER'}
               |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 | {'127.0.0.1': 'LEADER'}
               |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 | {'127.0.0.1': 'LEADER'}
               |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b | {'127.0.0.1': 'LEADER'}
               |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb | {'127.0.0.1': 'LEADER'}
               |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 | {'127.0.0.1': 'LEADER'}
               |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 | {'127.0.0.1': 'LEADER'}
               |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac | {'127.0.0.1': 'LEADER'}
               |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 | {'127.0.0.1': 'LEADER'}
               |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 | {'127.0.0.1': 'LEADER'}
               |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'LEADER'}
```
With the fix (all tables have a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+---------------------------
   system_auth | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 |   {'127.0.0.1': 'LEADER'}
 system_schema |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c |   {'127.0.0.1': 'LEADER'}
 system_schema |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a |   {'127.0.0.1': 'LEADER'}
        system |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 |   {'127.0.0.1': 'LEADER'}
 system_schema |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 |   {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'FOLLOWER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'FOLLOWER'}
        system |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 |   {'127.0.0.1': 'LEADER'}
 system_schema |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac |   {'127.0.0.1': 'LEADER'}
   system_auth |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 |   {'127.0.0.1': 'LEADER'}
        system |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b |   {'127.0.0.1': 'LEADER'}
        system |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb |   {'127.0.0.1': 'LEADER'}
 system_schema |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 |   {'127.0.0.1': 'LEADER'}
   system_auth |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 |   {'127.0.0.1': 'LEADER'}
 system_schema |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac |   {'127.0.0.1': 'LEADER'}
 system_schema |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'FOLLOWER'}
```

Reviewers: jhe, bogdan, slingam

Reviewed By: bogdan

Subscribers: bogdan, jhe, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D26075
karan-yb added a commit that referenced this issue Jun 8, 2023
…urn empty namespace name when its not set at table level

Summary:
Original commit: 218253c / D26033
Tables created before version 2.3 will have empty namespace name in master state, which in turn breaks the client partition routing since client receive empty namespace name. This change fixes the issue by resolving the namespace id to namespace name when namespace name is not set.

Thanks @jhe for your help with validating the fix.
Jira: DB-6814

Test Plan:
Jenkins
@jhe helped validate this change by creating a table in older version 2.2 and then upgrading the system.
Before fix (notice that only the newly created table has a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+-------------------------
               | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 | {'127.0.0.1': 'LEADER'}
               |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c | {'127.0.0.1': 'LEADER'}
               |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a | {'127.0.0.1': 'LEADER'}
               |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 | {'127.0.0.1': 'LEADER'}
               |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 | {'127.0.0.1': 'LEADER'}
               |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'LEADER'}
               |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 | {'127.0.0.1': 'LEADER'}
               |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac | {'127.0.0.1': 'LEADER'}
               |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 | {'127.0.0.1': 'LEADER'}
               |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 | {'127.0.0.1': 'LEADER'}
               |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b | {'127.0.0.1': 'LEADER'}
               |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb | {'127.0.0.1': 'LEADER'}
               |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 | {'127.0.0.1': 'LEADER'}
               |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 | {'127.0.0.1': 'LEADER'}
               |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac | {'127.0.0.1': 'LEADER'}
               |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 | {'127.0.0.1': 'LEADER'}
               |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 | {'127.0.0.1': 'LEADER'}
               |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'LEADER'}
```
With the fix (all tables have a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+---------------------------
   system_auth | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 |   {'127.0.0.1': 'LEADER'}
 system_schema |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c |   {'127.0.0.1': 'LEADER'}
 system_schema |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a |   {'127.0.0.1': 'LEADER'}
        system |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 |   {'127.0.0.1': 'LEADER'}
 system_schema |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 |   {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'FOLLOWER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'FOLLOWER'}
        system |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 |   {'127.0.0.1': 'LEADER'}
 system_schema |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac |   {'127.0.0.1': 'LEADER'}
   system_auth |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 |   {'127.0.0.1': 'LEADER'}
        system |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b |   {'127.0.0.1': 'LEADER'}
        system |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb |   {'127.0.0.1': 'LEADER'}
 system_schema |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 |   {'127.0.0.1': 'LEADER'}
   system_auth |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 |   {'127.0.0.1': 'LEADER'}
 system_schema |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac |   {'127.0.0.1': 'LEADER'}
 system_schema |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'FOLLOWER'}
```

Reviewers: jhe, bogdan, slingam

Reviewed By: bogdan

Subscribers: yql, ybase, jhe, bogdan

Differential Revision: https://phorge.dev.yugabyte.com/D26074
karan-yb added a commit that referenced this issue Jun 8, 2023
…urn empty namespace name when its not set at table level

Summary:
Original commit: 218253c / D26033
Tables created before version 2.3 will have empty namespace name in master state, which in turn breaks the client partition routing since client receive empty namespace name. This change fixes the issue by resolving the namespace id to namespace name when namespace name is not set.

Thanks @jhe for your help with validating the fix.
Jira: DB-6814

Test Plan:
Jenkins
@jhe helped validate this change by creating a table in older version 2.2 and then upgrading the system.
Before fix (notice that only the newly created table has a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+-------------------------
               | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 | {'127.0.0.1': 'LEADER'}
               |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c | {'127.0.0.1': 'LEADER'}
               |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a | {'127.0.0.1': 'LEADER'}
               |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 | {'127.0.0.1': 'LEADER'}
               |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 | {'127.0.0.1': 'LEADER'}
               |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'LEADER'}
               |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 | {'127.0.0.1': 'LEADER'}
               |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac | {'127.0.0.1': 'LEADER'}
               |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 | {'127.0.0.1': 'LEADER'}
               |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 | {'127.0.0.1': 'LEADER'}
               |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b | {'127.0.0.1': 'LEADER'}
               |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb | {'127.0.0.1': 'LEADER'}
               |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 | {'127.0.0.1': 'LEADER'}
               |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 | {'127.0.0.1': 'LEADER'}
               |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac | {'127.0.0.1': 'LEADER'}
               |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 | {'127.0.0.1': 'LEADER'}
               |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 | {'127.0.0.1': 'LEADER'}
               |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'LEADER'}
```
With the fix (all tables have a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+---------------------------
   system_auth | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 |   {'127.0.0.1': 'LEADER'}
 system_schema |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c |   {'127.0.0.1': 'LEADER'}
 system_schema |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a |   {'127.0.0.1': 'LEADER'}
        system |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 |   {'127.0.0.1': 'LEADER'}
 system_schema |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 |   {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'FOLLOWER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'FOLLOWER'}
        system |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 |   {'127.0.0.1': 'LEADER'}
 system_schema |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac |   {'127.0.0.1': 'LEADER'}
   system_auth |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 |   {'127.0.0.1': 'LEADER'}
        system |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b |   {'127.0.0.1': 'LEADER'}
        system |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb |   {'127.0.0.1': 'LEADER'}
 system_schema |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 |   {'127.0.0.1': 'LEADER'}
   system_auth |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 |   {'127.0.0.1': 'LEADER'}
 system_schema |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac |   {'127.0.0.1': 'LEADER'}
 system_schema |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'FOLLOWER'}
```

Reviewers: jhe, bogdan, slingam

Reviewed By: bogdan

Subscribers: bogdan, jhe, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D26073
karan-yb added a commit that referenced this issue Jun 14, 2023
…return empty namespace name when its not set at table level

Summary:
Original commit: 218253c / D26033
Tables created before version 2.3 will have empty namespace name in master state, which in turn breaks the client partition routing since client receive empty namespace name. This change fixes the issue by resolving the namespace id to namespace name when namespace name is not set.

Thanks @jhe for your help with validating the fix.
Jira: DB-6814

Test Plan:
Jenkins
@jhe helped validate this change by creating a table in older version 2.2 and then upgrading the system.
Before fix (notice that only the newly created table has a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+-------------------------
               | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 | {'127.0.0.1': 'LEADER'}
               |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c | {'127.0.0.1': 'LEADER'}
               |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a | {'127.0.0.1': 'LEADER'}
               |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 | {'127.0.0.1': 'LEADER'}
               |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 | {'127.0.0.1': 'LEADER'}
               |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'LEADER'}
               |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 | {'127.0.0.1': 'LEADER'}
               |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac | {'127.0.0.1': 'LEADER'}
               |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 | {'127.0.0.1': 'LEADER'}
               |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 | {'127.0.0.1': 'LEADER'}
               |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b | {'127.0.0.1': 'LEADER'}
               |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb | {'127.0.0.1': 'LEADER'}
               |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 | {'127.0.0.1': 'LEADER'}
               |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 | {'127.0.0.1': 'LEADER'}
               |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac | {'127.0.0.1': 'LEADER'}
               |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 | {'127.0.0.1': 'LEADER'}
               |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 | {'127.0.0.1': 'LEADER'}
               |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'LEADER'}
```
With the fix (all tables have a keyspace_name):
```
ycqlsh> select * from system.partitions;

 keyspace_name | table_name                      | start_key | end_key | id                                   | replica_addresses
---------------+---------------------------------+-----------+---------+--------------------------------------+---------------------------
   system_auth | resource_role_permissions_index |        0x |      0x | 536e2bf0-825f-7283-9746-471b31c671c7 |   {'127.0.0.1': 'LEADER'}
 system_schema |                         columns |        0x |      0x | 4418bfc9-dc72-72b4-894c-0112777c724c |   {'127.0.0.1': 'LEADER'}
 system_schema |                      aggregates |        0x |      0x | 7c150dd2-a045-c495-8c4c-d2c966b6b11a |   {'127.0.0.1': 'LEADER'}
        system |                  size_estimates |        0x |      0x | 18e36d79-fb60-9c93-534d-8a21a1f10e98 |   {'127.0.0.1': 'LEADER'}
 system_schema |                       keyspaces |        0x |      0x | f99f0aa3-1cc8-ad85-c544-b88dbe4c7d36 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           types |        0x |      0x | 1f94be70-fb7d-e6a4-6a47-187b194841b9 |   {'127.0.0.1': 'LEADER'}
           jhe |                      test_after |        0x |  0x8000 | 27fabca6-ae97-55bc-5c41-3899f4891790 | {'127.0.0.1': 'FOLLOWER'}
           jhe |                      test_after |    0x8000 |      0x | 8644a3cd-4c6f-bba7-fd47-f7761c24c5bb | {'127.0.0.1': 'FOLLOWER'}
        system |                      partitions |        0x |      0x | c3abda51-6757-ffb1-d14e-466c4d912cd9 |   {'127.0.0.1': 'LEADER'}
 system_schema |                        triggers |        0x |      0x | e656d4d5-ce96-3b89-d94c-f4e913cc1fac |   {'127.0.0.1': 'LEADER'}
   system_auth |                role_permissions |        0x |      0x | 8bd3a5af-71ea-f6a2-0f42-a4027e760c30 |   {'127.0.0.1': 'LEADER'}
 system_schema |                           views |        0x |      0x | 5d3c58c3-2ecc-4eb7-374f-88d4fa49efe0 |   {'127.0.0.1': 'LEADER'}
        system |                           peers |        0x |      0x | 178e5231-95bb-739d-aa46-f5497f2adb3b |   {'127.0.0.1': 'LEADER'}
        system |                           local |        0x |      0x | 3fc04471-ae7a-2a9c-8a4f-e173b41aabeb |   {'127.0.0.1': 'LEADER'}
 system_schema |                       functions |        0x |      0x | c8b1b8ec-69f7-13a9-d741-a8617a7aed38 |   {'127.0.0.1': 'LEADER'}
   system_auth |                           roles |        0x |      0x | d65d943f-65d4-93be-3d41-2669a0d323d2 |   {'127.0.0.1': 'LEADER'}
 system_schema |                          tables |        0x |      0x | a2447e71-a6b9-bea4-f147-036c487133ac |   {'127.0.0.1': 'LEADER'}
 system_schema |                         indexes |        0x |      0x | 91891ec0-8bb3-d281-2e4c-6f7062879838 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |        0x |  0x7fff | 491d7947-4fd1-6685-da40-7da00ad14d93 |   {'127.0.0.1': 'LEADER'}
           jhe |                            test |    0x7fff |      0x | 16d0567a-90cb-99a0-f645-89db0e90f473 | {'127.0.0.1': 'FOLLOWER'}
```

Reviewers: jhe, bogdan, slingam

Reviewed By: bogdan

Subscribers: bogdan, jhe, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D26161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants