Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/gp/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func GetStatus(blockSessID *int, waiting *bool, reason *string) string {
return "blocked"
}
if reason != nil {
if waiting != nil && *waiting && *reason == "resgroup" {
if waiting != nil && *waiting && (*reason == "resgroup" || *reason == "resqueue") {
return "waiting"
}
if waiting != nil && *waiting && *reason == "replication" {
Expand Down
24 changes: 24 additions & 0 deletions internal/gp/sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,27 @@ func TestSessionDescriptionsUseCoordinatorHost(t *testing.T) {
assert.Equal(t, host, query.Hostname)
}
}

func TestGetStatusFromWaitingReason(t *testing.T) {
blocker := 7
for _, tc := range []struct {
name string
blocker *int
waiting bool
reason string
want string
}{
{name: "blocked by session", blocker: &blocker, want: "blocked"},
{name: "lock wait", waiting: true, reason: "lock", want: "blocked"},
{name: "resource group wait", waiting: true, reason: "resgroup", want: "waiting"},
{name: "resource queue wait", waiting: true, reason: "resqueue", want: "waiting"},
{name: "replication wait", waiting: true, reason: "replication", want: "waiting"},
{name: "idle client", reason: "", want: ""},
{name: "reason without waiting", reason: "lock", want: ""},
} {
t.Run(tc.name, func(t *testing.T) {
waiting, reason := tc.waiting, tc.reason
assert.Equal(t, tc.want, GetStatus(tc.blocker, &waiting, &reason))
})
}
}
18 changes: 16 additions & 2 deletions internal/gp/stat_activity/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,27 @@ from
xact_start AS XactStart,
query_start AS QueryStart,
state_change AS StateChange,
false as waiting,
-- Only lock, resource management and synchronous
-- replication waits count. Idle clients (Client) and
-- background processes (Activity) always report a wait
-- event and must not show up as waiting.
(wait_event_type IN ('Lock', 'ResourceGroup', 'ResourceQueue', 'Replication')
OR (wait_event_type = 'IPC' AND wait_event = 'SyncRep')) AS waiting,
state,
backend_type AS BackendType,
backend_xid AS BackendXid,
backend_xmin AS backendXmin,
query,
'' as WaitingReason,
-- Same vocabulary as waiting_reason on GP6.
CASE
WHEN wait_event_type = 'ResourceQueue'
OR (wait_event_type = 'Lock' AND wait_event = 'resource queue') THEN 'resqueue'
WHEN wait_event_type = 'Lock' THEN 'lock'
WHEN wait_event_type = 'ResourceGroup' THEN 'resgroup'
WHEN wait_event_type = 'Replication'
OR (wait_event_type = 'IPC' AND wait_event = 'SyncRep') THEN 'replication'
ELSE ''
END AS WaitingReason,
rsgid,
rsgname,
0 as rsgqueueduration,
Expand Down