Skip to content

Commit

Permalink
[DB-11813] Rename ysql_conn_mgr_idle_or_pending_clients metric name
Browse files Browse the repository at this point in the history
Summary:
We were using the stat name **idle_or_pending_clients** which is not accurate. This stat name is misleading and hence we are moving to a different name for this stat. The new name is **waiting_clients**.

The PR makes the name change and also the changes needed for where the stat is being used.

The definition of the stat is as below

```
Number of logical connections which are either idle (i.e. no ongoing transaction) or waiting for the worker thread to be processed (i.e. waiting for od_router_attach to be called).
```
The above definition has not changed and is same as the old one.

Test Plan:
  - Hit the 13000/connections endpoint and verified that the stats are shown in accordance with the new name as **waiting_logical_connections**

  - Hit the 13000/prometheus-metrics endpoint and verified that the metrics are published in accordance the new name as **ysql_conn_mgr_waiting_clients**

Jenkins: all tests, enable connection manager

Reviewers: mkumar, rbarigidad, skumar, asrinivasan, nkumar, djiang

Reviewed By: rbarigidad, djiang

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D35992
  • Loading branch information
vpatibandla-yb committed Jun 26, 2024
1 parent dee7691 commit 411a32e
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class TestStatsAndMetrics extends BaseYsqlConnMgr {
"user_name",
"active_logical_connections",
"queued_logical_connections",
"idle_or_pending_logical_connections",
"waiting_logical_connections",
"active_physical_connections",
"idle_physical_connections",
"avg_wait_time_ns",
Expand Down Expand Up @@ -117,7 +117,7 @@ private void testNumLogicalConnections(String db_name,
int num_logical_conn =
pool.get("active_logical_connections").getAsInt() +
pool.get("queued_logical_connections").getAsInt() +
pool.get("idle_or_pending_logical_connections").getAsInt();
pool.get("waiting_logical_connections").getAsInt();
assertEquals("Did not get the expected number of logical connections for pool with user "
+ user_name + " and database " + db_name, exp_val, num_logical_conn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/odyssey/sources/cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int od_cron_stat_cb(od_route_t *route, od_stat_t *current,
route->client_pool.count_active;
instance->yb_stats[index].queued_clients =
route->client_pool.count_queue;
instance->yb_stats[index].idle_or_pending_clients =
instance->yb_stats[index].waiting_clients =
route->client_pool.count_pending;
instance->yb_stats[index].active_servers =
route->server_pool.count_active;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ YbGetNumYsqlConnMgrConnections(const char *db_name, const char *user_name,
* can get changed while reading the shared memory segment.
*/
*num_logical_conn += shmp[itr].active_clients +
shmp[itr].idle_or_pending_clients +
shmp[itr].waiting_clients +
shmp[itr].queued_clients;
*num_physical_conn += shmp[itr].active_servers + shmp[itr].idle_servers;
}
Expand Down
2 changes: 1 addition & 1 deletion src/yb/tserver/metrics_snapshotter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ Status MetricsSnapshotter::Thread::DoYsqlConnMgrMetricsSnapshot(const client::Ta
if (strcmp(stat.database_name, "control_connection") != 0) {
total_logical_connections += stat.active_clients +
stat.queued_clients +
stat.idle_or_pending_clients;
stat.waiting_clients;
total_physical_connections += stat.active_servers + stat.idle_servers;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/yb/yql/pggate/webserver/pgsql_webserver_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void emitYsqlConnectionManagerMetrics(PrometheusWriter *pwriter) {
for (ConnectionStats stats : stats_list) {
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_active_clients", stats.active_clients});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_queued_clients", stats.queued_clients});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_idle_or_pending_clients",
stats.idle_or_pending_clients});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_waiting_clients",
stats.waiting_clients});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_active_servers", stats.active_servers});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_idle_servers", stats.idle_servers});
ysql_conn_mgr_metrics.push_back({"ysql_conn_mgr_query_rate", stats.query_rate});
Expand Down Expand Up @@ -478,8 +478,8 @@ static void PgLogicalRpczHandler(const Webserver::WebRequest &req, Webserver::We

// Number of logical connections which are either idle (i.e. no ongoing transaction) or waiting
// for the worker thread to be processed (i.e. waiting for od_router_attach to be called).
writer.String("idle_or_pending_logical_connections");
writer.Int64(stat.idle_or_pending_clients);
writer.String("waiting_logical_connections");
writer.Int64(stat.waiting_clients);

// Number of physical connections which currently attached to a logical connection.
writer.String("active_physical_connections");
Expand Down
2 changes: 1 addition & 1 deletion src/yb/yql/ysql_conn_mgr_wrapper/ysql_conn_mgr_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
struct ConnectionStats {
uint64_t active_clients;
uint64_t queued_clients;
uint64_t idle_or_pending_clients;
uint64_t waiting_clients;
uint64_t active_servers;
uint64_t idle_servers;
uint64_t query_rate;
Expand Down
4 changes: 2 additions & 2 deletions yugabyted-ui/apiserver/cmd/server/.docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,7 @@ components:
queued_logical_connections:
format: int64
type: integer
idle_or_pending_logical_connections:
waiting_logical_connections:
format: int64
type: integer
active_physical_connections:
Expand All @@ -2637,7 +2637,7 @@ components:
- active_logical_connections
- active_physical_connections
- avg_wait_time_ns
- idle_or_pending_logical_connections
- waiting_logical_connections
- idle_physical_connections
- qps
- queued_logical_connections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1722,8 +1722,7 @@ func (c *Container) GetClusterConnections(ctx echo.Context) error {
UserName: connectionPool.UserName,
ActiveLogicalConnections: connectionPool.ActiveLogicalConnections,
QueuedLogicalConnections: connectionPool.QueuedLogicalConnections,
IdleOrPendingLogicalConnections:
connectionPool.IdleOrPendingLogicalConnections,
WaitingLogicalConnections: connectionPool.WaitingLogicalConnections,
ActivePhysicalConnections: connectionPool.ActivePhysicalConnections,
IdlePhysicalConnections: connectionPool.IdlePhysicalConnections,
AvgWaitTimeNs: connectionPool.AvgWaitTimeNs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ConnectionPool struct {
UserName string `json:"user_name"`
ActiveLogicalConnections int64 `json:"active_logical_connections"`
QueuedLogicalConnections int64 `json:"queued_logical_connections"`
IdleOrPendingLogicalConnections int64 `json:"idle_or_pending_logical_connections"`
WaitingLogicalConnections int64 `json:"waiting_logical_connections"`
ActivePhysicalConnections int64 `json:"active_physical_connections"`
IdlePhysicalConnections int64 `json:"idle_physical_connections"`
AvgWaitTimeNs int64 `json:"avg_wait_time_ns"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ConnectionStatsItem struct {

QueuedLogicalConnections int64 `json:"queued_logical_connections"`

IdleOrPendingLogicalConnections int64 `json:"idle_or_pending_logical_connections"`
WaitingLogicalConnections int64 `json:"waiting_logical_connections"`

ActivePhysicalConnections int64 `json:"active_physical_connections"`

Expand Down
4 changes: 2 additions & 2 deletions yugabyted-ui/apiserver/conf/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ components:
queued_logical_connections:
type: integer
format: int64
idle_or_pending_logical_connections:
waiting_logical_connections:
type: integer
format: int64
active_physical_connections:
Expand All @@ -1591,7 +1591,7 @@ components:
required:
- active_logical_connections
- queued_logical_connections
- idle_or_pending_logical_connections
- waiting_logical_connections
- active_physical_connections
- idle_physical_connections
- avg_wait_time_ns
Expand Down
4 changes: 2 additions & 2 deletions yugabyted-ui/apiserver/conf/openapi/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ ConnectionStatsItem:
queued_logical_connections:
type: integer
format: int64
idle_or_pending_logical_connections:
waiting_logical_connections:
type: integer
format: int64
active_physical_connections:
Expand All @@ -1197,7 +1197,7 @@ ConnectionStatsItem:
required:
- active_logical_connections
- queued_logical_connections
- idle_or_pending_logical_connections
- waiting_logical_connections
- active_physical_connections
- idle_physical_connections
- avg_wait_time_ns
Expand Down
2 changes: 1 addition & 1 deletion yugabyted-ui/ui/src/api/src/models/ConnectionStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface ConnectionStats {
* @type {number}
* @memberof ConnectionStats
*/
idle_or_pending_logical_connections: number;
waiting_logical_connections: number;
/**
*
* @type {number}
Expand Down
2 changes: 1 addition & 1 deletion yugabyted-ui/ui/src/api/src/models/ConnectionStatsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ConnectionStatsItem {
* @type {number}
* @memberof ConnectionStatsItem
*/
idle_or_pending_logical_connections: number;
waiting_logical_connections: number;
/**
*
* @type {number}
Expand Down

0 comments on commit 411a32e

Please sign in to comment.