Files
supabase/apps/studio/components/interfaces/Observability/DatabaseConnections/DatabaseConnections.constants.ts
Joshen Lim cbb076ddf1 Blocked by card to only highlight if any query is blocked longer than 10 sec (#48292)
## Context

As per PR title - we're currently showing a "danger" state for the
blocked by metric card as long as there's at least query that's blocked.
This may come off as too noisy in a real database scenario hence opting
to fine tune this behaviour a little

## Changes involved
We'll now only show the "danger" state for the blocked by metric card if
any of the blocked queries are blocked for longer than 10 seconds

<img width="356" height="256" alt="image"
src="https://github.com/user-attachments/assets/e7db5d7e-749a-4c4e-b519-9433a639b0a0"
/>

Otherwise will just be a default card

<img width="359" height="266" alt="image"
src="https://github.com/user-attachments/assets/f9aad85f-8d74-4f55-a3c5-a859d46bd8c1"
/>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added clearer blocked-query monitoring, including the longest-blocked
process and duration.
  - Added interactive selection for the longest-blocked process.

- **Bug Fixes**
- Improved activity-duration tracking across active and
idle-in-transaction states.
- Blocked-query warnings now reflect duration thresholds rather than
query count alone.
  - Prevented negative duration values in blocked-query metrics.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-27 13:02:55 +08:00

21 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// [Joshen] These are opinionated thresholds for when things might need attention
// For queries in "active" state - show warning variant if running longer than 30 seconds
// - Typically Not a problem unless its running longer than expected
// For queries in "idle in transaction" state - show warning variant if running longer than 30 seconds
// - Shorter threshold as it indicates a lock
export const WARN_DURATION_ACTIVE_QUERY = 30 // seconds
export const WARN_DURATION_IDLE_TXN = 10 // seconds
export const WARN_DURATION_BLOCKED = 10 // seconds
export const WARN_TOP_BLOCKER = 3 // If the query is blocking more than 3 queries
export const QUERY_STATE_TOOLTIP = {
['active']: 'Currently executing a query.',
['idle']: 'Connected, but not currently running a query.',
['disabled']: 'Activity tracking is disabled for this session.',
['idle in transaction']: 'Has an open transaction but isnt currently running a query.',
['idle in transaction (aborted)']:
'The last statement in this transaction failed and hasnt been rolled back yet.',
['fastpath function call']:
'Executing a function call via Postgress low-level fastpath protocol.',
}