yugabyte/yugabyte-db

[DocDB] Some catalog manager methods hold the CM::mutex_ while doing IO on the sys catalog

Opened this issue · 0 comments

Jira Link: DB-11971

Description

Examples:

Result<string> CatalogManager::GetPgSchemaName(const TableInfoPtr& table_info) {
RSTATUS_DCHECK_EQ(table_info->GetTableType(), PGSQL_TABLE_TYPE, InternalError,
Format("Expected YSQL table, got: $0", table_info->GetTableType()));
const uint32_t database_oid = VERIFY_RESULT(GetPgsqlDatabaseOid(table_info->namespace_id()));
uint32_t relfilenode_oid = VERIFY_RESULT(table_info->GetPgRelfilenodeOid());
uint32_t pg_table_oid = VERIFY_RESULT(table_info->GetPgTableOid());
// If this is a rewritten table, confirm that the relfilenode oid of pg_class entry with
// OID pg_table_oid is table_oid.
if (pg_table_oid != relfilenode_oid) {
uint32_t pg_class_relfilenode_oid = VERIFY_RESULT(
sys_catalog_->ReadPgClassColumnWithOidValue(
database_oid,
pg_table_oid,
"relfilenode"));
if (pg_class_relfilenode_oid != relfilenode_oid) {
// This must be an orphaned table from a failed rewrite.
return STATUS(NotFound, kRelnamespaceNotFoundErrorStr +
std::to_string(pg_table_oid));
}
}
const uint32_t relnamespace_oid = VERIFY_RESULT(
sys_catalog_->ReadPgClassColumnWithOidValue(database_oid, pg_table_oid, "relnamespace"));

Result<std::string> GetPgSchemaName(const TableInfoPtr& table_info) REQUIRES_SHARED(mutex_);

The catalog manager mutex is a spinlock, so this is particularly wasteful.

Issue Type

kind/bug

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

  • I confirm this issue does not contain any sensitive information.