Skip to content

Commit

Permalink
ENG-4683 (#874): Fix user table UI to exclude transactions and sequen…
Browse files Browse the repository at this point in the history
…ces tables

Summary:
Currently, transactions table shows up as a "user table" in UI, which is incorrect. This should be marked as a system table instead.

Changes include:
1. Remove transactions table from the User Table section
2. Change the column names in the TServer list
{{Load (Num Tablets) --> User Tablets (Total)
Leader Count (Num Tablets) --> User Tablets (Leaders)}}
3. Add 2 new columns to the end of the TServer list
{{System Tablets (Total)
System Tablets (Leaders)}}
4. Move UUID in the Tserver list to right below the name of the TServer in the Server column.
5. If Primary Cluster UUID is NONE, then do not show that line at all.

Test Plan:
{F11973}

{F11974}

Created cluster and tested UI.
Attached screenshots

Reviewers: sid, karthik, bogdan, bharat

Reviewed By: bogdan, bharat

Subscribers: hector, ybase, bharat

Differential Revision: https://phabricator.dev.yugabyte.com/D6307
  • Loading branch information
ndeodhar committed Mar 13, 2019
1 parent bd64c96 commit 9093416
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 34 deletions.
3 changes: 3 additions & 0 deletions src/yb/common/entity_ids.h
Expand Up @@ -43,6 +43,9 @@ using FlushRequestId = std::string;

using RedisConfigKey = std::string;

static const uint32_t kPgSequencesDataTableOid = 0xFFFF;
static const uint32_t kPgSequencesDataDatabaseOid = 0xFFFF;

// Get YB namespace id for a Postgres database.
NamespaceId GetPgsqlNamespaceId(uint32_t database_oid);

Expand Down
38 changes: 38 additions & 0 deletions src/yb/master/catalog_manager.cc
Expand Up @@ -3771,6 +3771,44 @@ bool CatalogManager::IsSystemTable(const TableInfo& table) const {
return false;
}

// True if table is created by user.
// Table can be regular table or index in this case.
bool CatalogManager::IsUserCreatedTable(const TableInfo& table) const {
if (table.GetTableType() == PGSQL_TABLE_TYPE || table.GetTableType() == YQL_TABLE_TYPE) {
if (!IsSystemTable(table) && !IsSequencesSystemTable(table)) {
return true;
}
}
return false;
}

bool CatalogManager::IsUserTable(const TableInfo& table) const {
return IsUserCreatedTable(table) && table.indexed_table_id().empty();
}

bool CatalogManager::IsUserIndex(const TableInfo& table) const {
return IsUserCreatedTable(table) && !table.indexed_table_id().empty();
}

bool CatalogManager::IsSequencesSystemTable(const TableInfo& table) const {
if (table.GetTableType() == PGSQL_TABLE_TYPE) {
Result<uint32_t> database_oid = GetPgsqlDatabaseOid(table.namespace_id());
if (!database_oid.ok()) {
LOG(WARNING) << "Invalid Namespace ID " << table.namespace_id();
return false;
}
Result<uint32_t> table_oid = GetPgsqlTableOid(table.id());
if (!table_oid.ok()) {
LOG(WARNING) << "Invalid Table ID " << table.id();
return false;
}
if (*database_oid == kPgSequencesDataDatabaseOid && *table_oid == kPgSequencesDataTableOid) {
return true;
}
}
return false;
}

void CatalogManager::NotifyTabletDeleteFinished(const TabletServerId& tserver_uuid,
const TabletId& tablet_id) {
scoped_refptr<DeletedTableInfo> deleted_table;
Expand Down
13 changes: 13 additions & 0 deletions src/yb/master/catalog_manager.h
Expand Up @@ -1054,6 +1054,19 @@ class CatalogManager : public tserver::TabletPeerLookupIf {
// Is the table a system table?
bool IsSystemTable(const TableInfo& table) const;

// Is the table a user created table?
bool IsUserTable(const TableInfo& table) const;

// Is the table a user created index?
bool IsUserIndex(const TableInfo& table) const;

// Is the table a special sequences system table?
bool IsSequencesSystemTable(const TableInfo& table) const;

// Is the table created by user?
// Note that table can be regular table or index in this case.
bool IsUserCreatedTable(const TableInfo& table) const;

// Let the catalog manager know that we have received a response for a delete tablet request,
// and that we either deleted the tablet successfully, or we received a fatal error.
void NotifyTabletDeleteFinished(const TabletServerId& tserver_uuid, const TableId& table_id);
Expand Down
89 changes: 62 additions & 27 deletions src/yb/master/master-path-handlers.cc
Expand Up @@ -161,8 +161,8 @@ inline void MasterPathHandlers::TServerTable(std::stringstream* output) {
<< " <th>Server</th>\n"
<< " <th>Time since </br>heartbeat</th>\n"
<< " <th>Status & Uptime</th>\n"
<< " <th>Load (Num Tablets)</th>\n"
<< " <th>Leader Count</br>(Num Tablets)</th>\n"
<< " <th>User Tablets</br>(Total)</th>\n"
<< " <th>User Tablets</br>(Leaders)</th>\n"
<< " <th>RAM Used</th>\n"
<< " <th>SST Files Size</th>\n"
<< " <th>Uncompressed SST </br>Files Size</th>\n"
Expand All @@ -171,7 +171,8 @@ inline void MasterPathHandlers::TServerTable(std::stringstream* output) {
<< " <th>Cloud</th>\n"
<< " <th>Region</th>\n"
<< " <th>Zone</th>\n"
<< " <th>UUID</th>\n"
<< " <th>System Tablets</br>(Total)</th>\n"
<< " <th>System Tablets</br>(Leaders)</th>\n"
<< " </tr>\n";
}

Expand Down Expand Up @@ -204,6 +205,7 @@ string UptimeString(uint64_t seconds) {

void MasterPathHandlers::TServerDisplay(const std::string& current_uuid,
std::vector<std::shared_ptr<TSDescriptor>>* descs,
TabletCountMap* tablet_map,
std::stringstream* output) {
for (auto desc : *descs) {
if (desc->placement_uuid() == current_uuid) {
Expand All @@ -214,8 +216,9 @@ void MasterPathHandlers::TServerDisplay(const std::string& current_uuid,
reg.common().http_addresses(0).host(),
reg.common().http_addresses(0).port());
*output << " <tr>\n";
*output << " <td>" << RegistrationToHtml(reg.common(), host_port) << "</td>";
*output << " <td>" << time_since_hb << "</td>";
*output << " <td>" << RegistrationToHtml(reg.common(), host_port) << "</br>";
*output << " " << desc->permanent_uuid() << "</td>";
*output << "<td>" << time_since_hb << "</td>";
bool is_dead = false;
if (master_->ts_manager()->IsTSLive(desc)) {
*output << " <td style=\"color:Green\">" << kTserverAlive << ":" <<
Expand All @@ -225,20 +228,23 @@ void MasterPathHandlers::TServerDisplay(const std::string& current_uuid,
*output << " <td style=\"color:Red\">" << kTserverDead << "</td>";
}

*output << " <td>" << (is_dead ? 0 : desc->num_live_replicas()) << "</td>";
*output << " <td>" << (is_dead ? 0 : desc->leader_count()) << "</td>";
*output << " <td>" << BytesToHumanReadable
(desc->total_memory_usage()) << "</td>";
*output << " <td>" << BytesToHumanReadable
(desc->total_sst_file_size()) << "</td>";
*output << " <td>" << BytesToHumanReadable
(desc->uncompressed_sst_file_size()) << "</td>";
auto tserver = tablet_map->find(desc->permanent_uuid());
bool no_tablets = tserver == tablet_map->end() || is_dead;
*output << " <td>" << (no_tablets ? 0
: tserver->second.user_tablet_leaders + tserver->second.user_tablet_followers) << "</td>";
*output << " <td>" << (no_tablets ? 0 : tserver->second.user_tablet_leaders) << "</td>";
*output << " <td>" << BytesToHumanReadable(desc->total_memory_usage()) << "</td>";
*output << " <td>" << BytesToHumanReadable(desc->total_sst_file_size()) << "</td>";
*output << " <td>" << BytesToHumanReadable(desc->uncompressed_sst_file_size()) << "</td>";
*output << " <td>" << desc->read_ops_per_sec() << "</td>";
*output << " <td>" << desc->write_ops_per_sec() << "</td>";
*output << " <td>" << reg.common().cloud_info().placement_cloud() << "</td>";
*output << " <td>" << reg.common().cloud_info().placement_region() << "</td>";
*output << " <td>" << reg.common().cloud_info().placement_zone() << "</td>";
*output << " <td>" << desc->permanent_uuid() << "</td>";
*output << " <td>" << (no_tablets ? 0
: tserver->second.system_tablet_leaders + tserver->second.system_tablet_followers)
<< "</td>";
*output << " <td>" << (no_tablets ? 0 : tserver->second.user_tablet_leaders) << "</td>";
*output << " </tr>\n";
}
}
Expand All @@ -262,6 +268,38 @@ void MasterPathHandlers::HandleTabletServers(const Webserver::WebRequest& req,
const auto& ts_manager = master_->ts_manager();
ts_manager->GetAllDescriptors(&descs);

// Get user and system tablet leader and follower counts for each TabletServer
TabletCountMap tablet_map;

vector<scoped_refptr<TableInfo>> tables;
master_->catalog_manager()->GetAllTables(&tables, true /* include only running tables */);
for (const auto& table : tables) {
TabletInfos tablets;
table->GetAllTablets(&tablets);
bool is_user_table = master_->catalog_manager()->IsUserCreatedTable(*table);

for (const auto& tablet : tablets) {
TabletInfo::ReplicaMap replication_locations;
tablet->GetReplicaLocations(&replication_locations);

for (const auto& replica : replication_locations) {
if (is_user_table) {
if (replica.second.role == consensus::RaftPeerPB_Role_LEADER) {
tablet_map[replica.first].user_tablet_leaders++;
} else {
tablet_map[replica.first].user_tablet_followers++;
}
} else {
if (replica.second.role == consensus::RaftPeerPB_Role_LEADER) {
tablet_map[replica.first].system_tablet_leaders++;
} else {
tablet_map[replica.first].system_tablet_followers++;
}
}
}
}
}

unordered_set<string> read_replica_uuids;
for (auto desc : descs) {
if (!read_replica_uuids.count(desc->placement_uuid()) && desc->placement_uuid() != live_id) {
Expand All @@ -272,18 +310,19 @@ void MasterPathHandlers::HandleTabletServers(const Webserver::WebRequest& req,
*output << std::setprecision(output_precision_);
*output << "<h2>Tablet Servers</h2>\n";


*output << "<h3 style=\"color:" << kYBDarkBlue << "\">Primary Cluster UUID: "
<< (live_id.empty() ? kNoPlacementUUID : live_id) << "</h3>\n";
if (!live_id.empty()) {
*output << "<h3 style=\"color:" << kYBDarkBlue << "\">Primary Cluster UUID: "
<< live_id << "</h3>\n";
}

TServerTable(output);
TServerDisplay(live_id, &descs, output);
TServerDisplay(live_id, &descs, &tablet_map, output);

for (const auto& read_replica_uuid : read_replica_uuids) {
*output << "<h3 style=\"color:" << kYBDarkBlue << "\">Read Replica UUID: "
<< (read_replica_uuid.empty() ? kNoPlacementUUID : read_replica_uuid) << "</h3>\n";
TServerTable(output);
TServerDisplay(read_replica_uuid, &descs, output);
TServerDisplay(read_replica_uuid, &descs, &tablet_map, output);
}
}

Expand Down Expand Up @@ -312,14 +351,14 @@ void MasterPathHandlers::HandleCatalogManager(const Webserver::WebRequest& req,

table_cat = kUserTable;
// Determine the table category.
if (IsSystemTable(*table)) {
if (master_->catalog_manager()->IsUserIndex(*table)) {
table_cat = kIndexTable;
} else if (!master_->catalog_manager()->IsUserTable(*table)) {
// Skip system tables if we should.
if (skip_system_tables) {
continue;
}
table_cat = kSystemTable;
} else if (!table->indexed_table_id().empty()) {
table_cat = kIndexTable;
}

const TableName long_table_name = TableLongName(
Expand Down Expand Up @@ -480,10 +519,6 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req,
HtmlOutputTasks(table->GetTasks(), output);
}

bool MasterPathHandlers::IsSystemTable(const TableInfo& table) {
return master_->catalog_manager()->IsSystemTable(table) || table.IsRedisTable();
}

void MasterPathHandlers::RootHandler(const Webserver::WebRequest& req,
stringstream* output) {

Expand Down Expand Up @@ -553,7 +588,7 @@ void MasterPathHandlers::RootHandler(const Webserver::WebRequest& req,
// Get the list of user tables.
vector<scoped_refptr<TableInfo> > user_tables;
for (scoped_refptr<TableInfo> table : tables) {
if (!IsSystemTable(*table)) {
if (master_->catalog_manager()->IsUserTable(*table)) {
user_tables.push_back(table);
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/yb/master/master-path-handlers.h
Expand Up @@ -82,6 +82,16 @@ class MasterPathHandlers {
kNumTypes
};

struct TabletCounts {
uint32_t user_tablet_leaders = 0;
uint32_t user_tablet_followers = 0;
uint32_t system_tablet_leaders = 0;
uint32_t system_tablet_followers = 0;
};

// Map of tserver UUID -> TabletCounts
typedef std::unordered_map<std::string, TabletCounts> TabletCountMap;

const string table_type_[3] = {"User", "Index", "System"};

const string kNoPlacementUUID = "NONE";
Expand All @@ -90,6 +100,7 @@ class MasterPathHandlers {

void TServerDisplay(const std::string& current_uuid,
std::vector<std::shared_ptr<TSDescriptor>>* descs,
TabletCountMap* tmap,
std::stringstream* output);

void CallIfLeaderOrPrintRedirect(const Webserver::WebRequest& req, std::stringstream* output,
Expand All @@ -110,10 +121,7 @@ class MasterPathHandlers {
std::stringstream* output);
void HandleGetClusterConfig(const Webserver::WebRequest& req, std::stringstream* output);

// Checks if the table is system managed table (including redis table).
bool IsSystemTable(const TableInfo& table);

// Convert location of peers to HTML, indicating the roles
// Convert location of peers to HTML, indicating the roles
// of each tablet server in a consensus configuration.
// This method will display 'locations' in the order given.
std::string RaftConfigToHtml(const std::vector<TabletReplica>& locations,
Expand Down
3 changes: 0 additions & 3 deletions src/yb/yql/pggate/pg_session.cc
Expand Up @@ -55,9 +55,6 @@ static MonoDelta kSessionTimeout = 60s;
static constexpr const char* const kPgSequencesNamespaceName = "system_postgres";
static constexpr const char* const kPgSequencesDataTableName = "sequences_data";

// Used to build this table's uuid.
static constexpr const YBCPgOid kPgSequencesDataTableOid = 0xFFFF;
static constexpr const YBCPgOid kPgSequencesDataDatabaseOid = 0xFFFF;
static const string kPgSequencesDataNamespaceId = GetPgsqlNamespaceId(kPgSequencesDataDatabaseOid);

// Columns names and ids.
Expand Down

0 comments on commit 9093416

Please sign in to comment.