diff --git a/src/yb/client/client.cc b/src/yb/client/client.cc index cd5a2b190731..0e2f4f8ea9c0 100644 --- a/src/yb/client/client.cc +++ b/src/yb/client/client.cc @@ -2599,6 +2599,7 @@ Result> YBClient::ListTables( for (int i = 0; i < resp.tables_size(); i++) { const ListTablesResponsePB_TableInfo& table_info = resp.tables(i); + VLOG_WITH_FUNC(4) << "Table: " << AsString(table_info); DCHECK(table_info.has_namespace_()); DCHECK(table_info.namespace_().has_name()); DCHECK(table_info.namespace_().has_id()); diff --git a/src/yb/master/catalog_manager.cc b/src/yb/master/catalog_manager.cc index cd9e3d00b77f..8e7e16b45432 100644 --- a/src/yb/master/catalog_manager.cc +++ b/src/yb/master/catalog_manager.cc @@ -5561,15 +5561,15 @@ Status CatalogManager::RemoveTableIdsFromTabletInfo( } Result> CatalogManager::FindTable( - const TableIdentifierPB& table_identifier) const { + const TableIdentifierPB& table_identifier, bool include_deleted) const { SharedLock lock(mutex_); - return FindTableUnlocked(table_identifier); + return FindTableUnlocked(table_identifier, include_deleted); } Result> CatalogManager::FindTableUnlocked( - const TableIdentifierPB& table_identifier) const { + const TableIdentifierPB& table_identifier, bool include_deleted) const { if (table_identifier.has_table_id()) { - return FindTableByIdUnlocked(table_identifier.table_id()); + return FindTableByIdUnlocked(table_identifier.table_id(), include_deleted); } if (table_identifier.has_table_name()) { @@ -5583,7 +5583,7 @@ Result> CatalogManager::FindTableUnlocked( } auto it = table_names_map_.find({namespace_info->id(), table_identifier.table_name()}); - if (it == table_names_map_.end()) { + if (it == table_names_map_.end() || (!include_deleted && it->second->is_deleted())) { return STATUS_EC_FORMAT( NotFound, MasterError(MasterErrorPB::OBJECT_NOT_FOUND), "Table $0.$1 not found", namespace_info->name(), table_identifier.table_name()); @@ -5602,9 +5602,9 @@ Result> CatalogManager::FindTableById( } Result> CatalogManager::FindTableByIdUnlocked( - const TableId& table_id) const { + const TableId& table_id, bool include_deleted) const { auto table = tables_->FindTableOrNull(table_id); - if (table == nullptr) { + if (table == nullptr || (!include_deleted && table->is_deleted())) { return STATUS_EC_FORMAT( NotFound, MasterError(MasterErrorPB::OBJECT_NOT_FOUND), "Table with identifier $0 not found", table_id); @@ -7658,7 +7658,7 @@ Status CatalogManager::GetTableSchemaInternal(const GetTableSchemaRequestPB* req // Lookup the table and verify if it exists. TRACE("Looking up table"); - auto table = VERIFY_RESULT(FindTable(req->table())); + auto table = VERIFY_RESULT(FindTable(req->table(), !req->check_exists_only())); if (req->check_exists_only()) { return Status::OK(); } diff --git a/src/yb/master/catalog_manager.h b/src/yb/master/catalog_manager.h index 72242c591c53..e317df3ac6dc 100644 --- a/src/yb/master/catalog_manager.h +++ b/src/yb/master/catalog_manager.h @@ -1049,16 +1049,18 @@ class CatalogManager : public CatalogManagerIf, public SnapshotCoordinatorContex const NamespaceId& id) const REQUIRES_SHARED(mutex_); Result> FindTableUnlocked( - const TableIdentifierPB& table_identifier) const REQUIRES_SHARED(mutex_); + const TableIdentifierPB& table_identifier, bool include_deleted = true) const + REQUIRES_SHARED(mutex_); Result> FindTable( - const TableIdentifierPB& table_identifier) const override EXCLUDES(mutex_); + const TableIdentifierPB& table_identifier, bool include_deleted = true) const override + EXCLUDES(mutex_); Result> FindTableById( const TableId& table_id) const override EXCLUDES(mutex_); Result> FindTableByIdUnlocked( - const TableId& table_id) const REQUIRES_SHARED(mutex_); + const TableId& table_id, bool include_deleted = true) const REQUIRES_SHARED(mutex_); Result GetColocatedTableId( const TablegroupId& tablegroup_id, ColocationId colocation_id) const EXCLUDES(mutex_); diff --git a/src/yb/master/catalog_manager_if.h b/src/yb/master/catalog_manager_if.h index 0c128c3b45a2..c1d10223660b 100644 --- a/src/yb/master/catalog_manager_if.h +++ b/src/yb/master/catalog_manager_if.h @@ -262,7 +262,7 @@ class CatalogManagerIf : public tserver::TabletPeerLookupIf { const GetCDCDBStreamInfoRequestPB* req, GetCDCDBStreamInfoResponsePB* resp) = 0; virtual Result> FindTable( - const TableIdentifierPB& table_identifier) const = 0; + const TableIdentifierPB& table_identifier, bool include_deleted = true) const = 0; virtual Status IsInitDbDone( const IsInitDbDoneRequestPB* req, IsInitDbDoneResponsePB* resp) = 0;