Skip to content

Commit 2b8064d

Browse files
committed
[yugabyte#8390] Fix NPE Handling for indexed_table_id
Summary: This simple diff handles nullptr cases for indexed_table_id, which stops an observed crash-on-load issue that occurs when running with a bad index schema and 'master_ignore_deleted_on_load'. Test Plan: Manual Testing 1. set_flag TEST_simulate_crash_after_table_marked_deleting 1 2. cqlsh "CREATE TABLE; CREATE INDEX; DROP TABLE" 3. yb-ctl stop & yb-ctl start. (2x) Reviewers: mbautin, rao, bogdan Reviewed By: bogdan Subscribers: ybase Differential Revision: https://phabricator.dev.yugabyte.com/D11660
1 parent 4b0cb73 commit 2b8064d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/yb/master/catalog_manager.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,11 @@ Status CatalogManager::BackfillIndex(
38093809
indexed_table = GetTableInfo(indexed_table_id);
38103810
}
38113811

3812+
if (indexed_table == nullptr) {
3813+
return STATUS(InvalidArgument, "Empty indexed table",
3814+
index_table_identifier.ShortDebugString());
3815+
}
3816+
38123817
// TODO(jason): when ready to use INDEX_PERM_DO_BACKFILL for resuming backfill across master
38133818
// leader changes, replace the following (issue #6218).
38143819

@@ -3980,7 +3985,8 @@ Status CatalogManager::DeleteTable(
39803985
indexed_table_id = PROTO_GET_INDEXED_TABLE_ID(l->pb);
39813986
}
39823987
scoped_refptr<TableInfo> indexed_table = GetTableInfo(indexed_table_id);
3983-
const bool is_pg_table = indexed_table->GetTableType() == PGSQL_TABLE_TYPE;
3988+
const bool is_pg_table = indexed_table != nullptr &&
3989+
indexed_table->GetTableType() == PGSQL_TABLE_TYPE;
39843990
bool is_transactional;
39853991
{
39863992
Schema index_schema;

src/yb/master/yql_indexes_vtable.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ Result<std::shared_ptr<QLRowBlock>> YQLIndexesVTable::RetrieveData(
5454
}
5555

5656
scoped_refptr<TableInfo> indexed_table = catalog_manager->GetTableInfo(indexed_table_id);
57+
// Skip if the index is invalid (bad schema).
58+
if (indexed_table == nullptr) {
59+
continue;
60+
}
5761
Schema indexed_schema;
5862
RETURN_NOT_OK(indexed_table->GetSchema(&indexed_schema));
5963

0 commit comments

Comments
 (0)