Skip to content

2.27.0.0-b449

@vdamle-yb vdamle-yb tagged this 14 Aug 19:37
Summary:
Connection manager gathers a stat named `avg_wait_time_ns` which records the time taken to assign a
backend to a logical connection (for every transaction/query). To calculate the average, conn mgr
keeps track of the number of transactions executed in a pool and the total time spent allocating a
backend.

However, the same logic cannot work for control pool backends as the control backends do not execute
any queries or transactions, so the `count_tx` stat is always 0, and thus, `avg_wait_time_ns` is
never updated for this pool's stats.

This fix co-opts the `count_tx` variable to instead count the number of times a backend was
assigned/attempted to be assigned by incrementing count_tx at the end of od_router_attach. This
increment is done *only* for the control pool. Conversely, `count_tx` is only otherwise incremented
in the function `od_stat_query_end()` which is never called for routes of the control pool.

The rest of the stats calculations are unchanged.

This change was verified manually by adding a delay of 5 seconds in `od_router_attach()` and then
running a burst of connections to check that `avg_wait_time_ns` has a value just above 5e9 ns.
This was verified for auth backend and for auth passthrough (contingent on the changes made in
diff D45736.

JUnit test for this is to be added in a separate revision.
Jira: DB-17738

Test Plan: Jenkins: urgent, all tests

Reviewers: skumar, mkumar, asrinivasan, arpit.saxena, #db-approvers

Reviewed By: arpit.saxena, #db-approvers

Subscribers: svc_phabricator, yql

Differential Revision: https://phorge.dev.yugabyte.com/D45898
Assets 2
Loading