PktBuf *buf;
PgSocket *waiter;
usec_t now = get_cached_time();
+ usec_t max_wait;
struct CfValue cv;
int pool_mode;
admin_error(admin, "no mem");
return true;
}
- pktbuf_write_RowDescription(buf, "ssiiiiiiiis",
+ pktbuf_write_RowDescription(buf, "ssiiiiiiiiis",
"database", "user",
"cl_active", "cl_waiting",
"sv_active", "sv_idle",
"sv_used", "sv_tested",
"sv_login", "maxwait",
- "pool_mode");
+ "maxwait_us", "pool_mode");
statlist_for_each(item, &pool_list) {
pool = container_of(item, PgPool, head);
waiter = first_socket(&pool->waiting_client_list);
+ max_wait = (waiter && waiter->query_start) ? now - waiter->query_start : 0;
pool_mode = pool_pool_mode(pool);
- pktbuf_write_DataRow(buf, "ssiiiiiiiis",
+ pktbuf_write_DataRow(buf, "ssiiiiiiiiis",
pool->db->name, pool->user->name,
statlist_count(&pool->active_client_list),
statlist_count(&pool->waiting_client_list),
statlist_count(&pool->tested_server_list),
statlist_count(&pool->new_server_list),
/* how long is the oldest client waited */
- (waiter && waiter->query_start)
- ? (int)((now - waiter->query_start) / USEC) : 0,
+ (int)(max_wait / USEC),
+ (int)(max_wait % USEC),
cf_get_lookup(&cv));
}
admin_flush(admin, buf, "SHOW");