pg_activity icon indicating copy to clipboard operation
pg_activity copied to clipboard

processes sort with parallel worker is broken

Open dlax opened this issue 2 years ago • 4 comments

See discussion at #291.

From postgres 13, maybe we could rely on leader_pid column of pg_stat_activity view as first sort step on SQL side?

dlax avatar Jun 09 '22 07:06 dlax

FYI - just remembered that I've seen actually cases where parent pid was higher than background worker / child pid...so this code here can deliver wrong results still https://github.com/dalibo/pg_activity/pull/291/files#diff-c7ba7b4a3a801c37989b9ac81ece8995e3154d2f67325272f24877b5e730cf65R219-R222

kmoppel-cognite avatar Jun 09 '22 14:06 kmoppel-cognite

FYI - just remembered that I've seen actually cases where parent pid was higher than background worker / child pid

I agree, I've seen it too. I think changing the sort order when paused could be a valuable thing to have in the future in which case sorting in the SQL will not help. (I'd also like to add filters when paused).

When we order by mem / cpu / read / write, the \_ thing is also meaningless because the worker process is often not listed after their parent.

It was thinking about adding the parent pid and the backend type info in the UI so that we have a parent pid to sort on in the sorted function. But it adds a lot of text and we would need a better way to filter what we display. Some of the ideas in #260 might help for that (group columns and allow to cycle between groups).

It would also be neat to group the leader process and it's childs in a single "ui block", but it's a lot more complex.

Before changing the output, the switch to "rich" must be finished or cancelled. I'll try to help there next.

blogh avatar Jun 09 '22 14:06 blogh

@kmoppel-cognite what do you think about sorting/filtering in paused/interactive mode ?

blogh avatar Jun 09 '22 15:06 blogh

@kmoppel-cognite what do you think about sorting/filtering in paused/interactive mode ?

@blogh For me personally I've never had the need for such extra features, I've just used "pause" to freeze the UI to be able to copy some SQL or kill some PIDs. And there's also the new --filter syntax, so I'd personally KISS and try to reduce UI logic / code as much as possible.

kmoppel-cognite avatar Jun 10 '22 09:06 kmoppel-cognite