-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[YSQL] upgrade issue from 2.0.5.7 to 2.2.2.1 - FATAL: Query error: Bad schema: Cannot have both cotable ID and pgtable ID #5658
Comments
In debug mode, you hit an earlier check: void set_cotable_id(const Uuid& cotable_id) {
if (!cotable_id.IsNil()) {
DCHECK_EQ(pgtable_id_, 0);
}
cotable_id_ = cotable_id;
}
It seems that the For those who don't know, system tables use cotable id because all system tables from all databases go in the system catalog tablet on master, and using pgtable id would not be able to distinguish between system tables across databases. |
Found it. The issue is with git log -S is_ysql_catalog_table --oneline
Commit b68b84b introduced
Commit f4d4ea7 changes diff --git a/src/yb/tablet/tablet_metadata.cc b/src/yb/tablet/tablet_metadata.cc
index 36d130fa7..e19e2efa8 100644
--- a/src/yb/tablet/tablet_metadata.cc
+++ b/src/yb/tablet/tablet_metadata.cc
@@ -40,6 +40,7 @@
#include <boost/optional.hpp>
#include "yb/rocksdb/db.h"
#include "yb/rocksdb/options.h"
+#include "yb/common/entity_ids.h"
#include "yb/common/wire_protocol.h"
#include "yb/consensus/opid_util.h"
#include "yb/docdb/docdb_rocksdb_util.h"
@@ -171,11 +172,16 @@ Status KvStoreInfo::LoadTablesFromPB(
auto table_info = std::make_unique<TableInfo>();
RETURN_NOT_OK(table_info->LoadFromPB(table_pb));
if (table_info->table_id != primary_table_id) {
- Uuid cotable_id;
- CHECK_OK(cotable_id.FromHexString(table_info->table_id));
- // TODO(#79): when adding for multiple KV-stores per Raft group support - check if we need
- // to set cotable ID.
- table_info->schema.set_cotable_id(cotable_id);
+ if (table_pb.schema().table_properties().is_ysql_catalog_table()) {
+ Uuid cotable_id;
+ CHECK_OK(cotable_id.FromHexString(table_info->table_id));
+ // TODO(#79): when adding for multiple KV-stores per Raft group support - check if we need
+ // to set cotable ID.
+ table_info->schema.set_cotable_id(cotable_id);
+ } else {
+ auto pgtable_id = VERIFY_RESULT(GetPgsqlTableOid(table_info->table_id));
+ table_info->schema.set_pgtable_id(pgtable_id);
+ }
}
tables[table_info->table_id] = std::move(table_info);
} The PBs won't have To solve this,
|
Repro:
Upgrading to debug build can make it fail earlier as mentioned in #5658 (comment). That can be avoided by applying patch in #11229 (comment), but there's still another issue (described in that same comment). |
Current fix-in-the-works for #7378 does not alter this behaviour. |
Closing as 2.0.5 is very old version, and rolling upgrade from 2.0.9 onwards should work. |
Jira Link: DB-4847
When upgrading a universe running 2.0.5.7 and having YSQL enabled with YSQL tables/indexes present, got an error when connecting to the db using ysqlsh
[yugabyte@ip-10-241-0-146 bin]$ ./ysqlsh -h 10.241.0.146
ysqlsh: FATAL: Query error: Bad schema: Cannot have both cotable ID and pgtable ID
The text was updated successfully, but these errors were encountered: