Skip to content
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 parallel workers under the lead process in UI via ORDER BY #289

Conversation

kmoppel-cognite
Copy link
Contributor

Currently they're jumping around annoyingly. Relevant for vers >= 9.6

Currently they're jumping around annoyingly. Relevant for vers >= 9.6
@kmoppel-cognite
Copy link
Contributor Author

Currently something like this happens: Screenshot from 2022-05-03 14-02-26

@kmoppel-cognite
Copy link
Contributor Author

Or such:
Screenshot from 2022-05-03 14-35-03

@kmoppel-cognite
Copy link
Contributor Author

After patch:
Screenshot from 2022-05-03 14-34-25

@blogh
Copy link
Collaborator

blogh commented May 5, 2022

Hi,

It has also been bugging me for a while.
Since we sort here afterwards. I wonder if we should ditch the sort in the query and add the pid sort in the sorted function.

@dlax do you have an opinion on this ?

@dlax
Copy link
Member

dlax commented May 6, 2022

Since we sort here afterwards. I wonder if we should ditch the sort in the query and add the pid sort in the sorted function.

Indeed, it might be worth trying:

diff --git a/pgactivity/activities.py b/pgactivity/activities.py
index da0689a..bcb989c 100644
--- a/pgactivity/activities.py
+++ b/pgactivity/activities.py
@@ -198,7 +198,7 @@ def sorted(processes: List[T], *, key: SortKey, reverse: bool = False) -> List[T
     """
     return builtins.sorted(
         processes,
-        key=lambda p: getattr(p, key.name) or 0,  # TODO: avoid getattr()
+        key=lambda p: (getattr(p, key.name) or 0, p.pid),  # TODO: avoid getattr()
         reverse=reverse,
     )

@dlax
Copy link
Member

dlax commented May 6, 2022

Indeed, it might be worth trying:

Pushed this suggestion into procs-sort branch, if you can give it a try; @blogh, @kmoppel-cognite.

@kmoppel-cognite
Copy link
Contributor Author

@dlax Oh I see, sorted in code instead. But the above comment didn't work for me sadly - this did:

diff --git a/pgactivity/activities.py b/pgactivity/activities.py
index bcb989c..31636eb 100644
--- a/pgactivity/activities.py
+++ b/pgactivity/activities.py
@@ -198,7 +198,7 @@ def sorted(processes: List[T], *, key: SortKey, reverse: bool = False) -> List[T
     """
     return builtins.sorted(
         processes,
-        key=lambda p: (getattr(p, key.name) or 0, p.pid),  # TODO: avoid getattr()
+        key=lambda p: (getattr(p, key.name) or (p.duration, p.pid)),  # TODO: avoid getattr()
         reverse=reverse,
     )

@kmoppel-cognite
Copy link
Contributor Author

Closing in favour of Python code based sorting #291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants