-
Notifications
You must be signed in to change notification settings - Fork 231
Fix maxwait metric #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix maxwait metric #183
Changes from 6 commits
7973dd1
39000e0
b2d957b
d9729ed
464f99b
11ce838
f91f6a3
4286d53
84b5bc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,11 @@ where | |
pool_config.pool_mode.to_string(), | ||
]; | ||
for column in &columns[3..columns.len()] { | ||
let value = pool_stats.get(column.0).unwrap_or(&0).to_string(); | ||
let value = match column.0 { | ||
"maxwait" => (pool_stats.get("maxwait_us").unwrap_or(&0) / 1_000_000).to_string(), | ||
"maxwait_us" => (pool_stats.get(column.0).unwrap_or(&0) % 1_000_000).to_string(), | ||
_other_values => pool_stats.get(column.0).unwrap_or(&0).to_string() | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved the microsecond split to admin instead of doing on stats side There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prometheus metrics would be incorrect in this case. |
||
row.push(value); | ||
} | ||
res.put(data_row(&row)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,28 @@ | |
threads.map(&:join) | ||
connections.map(&:close) | ||
end | ||
|
||
it "show correct max_wait" do | ||
threads = [] | ||
connections = Array.new(4) { PG::connect("#{pgcat_conn_str}?application_name=one_query") } | ||
connections.each do |c| | ||
threads << Thread.new { c.async_exec("SELECT pg_sleep(1.5)") } | ||
end | ||
|
||
sleep(2.5) # Allow time for stats to update | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should introduce a command to refresh stats immediately. I can see our CI getting slower and slower over time as we add features :) |
||
admin_conn = PG::connect(processes.pgcat.admin_connection_string) | ||
results = admin_conn.async_exec("SHOW POOLS")[0] | ||
|
||
expect(results["maxwait"]).to eq("1") | ||
expect(results["maxwait_us"].to_i).to be_within(100_000).of(500_000) | ||
|
||
sleep(4.5) # Allow time for stats to update | ||
results = admin_conn.async_exec("SHOW POOLS")[0] | ||
expect(results["maxwait"]).to eq("0") | ||
|
||
threads.map(&:join) | ||
connections.map(&:close) | ||
end | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also show these in Prometheus metrics (
prometheus.rs
), it would be good to update this logic there too.