-
Notifications
You must be signed in to change notification settings - Fork 27
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
Use deltas in GScan #543
Use deltas in GScan #543
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah, it gets messy. Conceptually it's easy:
But in practice GraphQL isn't that abstract, need to spend some time on this one soonish to see if it's achievable easily. It's filters that really mess it up, e.g. filtering by task state but I guess that could be handled in a simple dumb manner just merging what we can:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
GScan doesn't seem to respond to the addition or removal of stopped workflows. I think it might not be responding to the full range of flow change events. Perhaps we need to add more info to the deltas? Steps to reproduce:
The Something strange is happening in the dashboard too which might be related. The number of stopped workflows keeps flickering between two I think one matches the number visible in GScan (correct when the page loaded) and the other matches the current number of flows. |
Oh, never thought about renaming workflows. The UIS probably doesn't send a message telling the UIS to remove that workflow, or if does, I think the UI doesn't handle that 😥 The old code, that is not deltas-based, would handle that as it always re-rendered the whole list, so I think we can't push that to a follow-up. Will have to think about this one and confirm whether there's a solution in the UI. Otherwise will create and link an issue in UIS. Thanks for the testing @oliver-sanders ! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Made it to the end 😓.
Looks great, the queries and subs are nicely centralised and the mixins should make view development easier 👍.
Still need to dive into the subscription merging (unexpected bonus 🎉). To help me review this could you comment about what the subscription merging is supposed to merge and what it isn't (i.e. what subscriptions we should expect to have for different views).
Still need to do some hands on testing with:
- Lookup / tree structures.
- Subscription merging.
- Delta processing.
I have only found a couple of small snags so far which are to do with the life cycle of subscriptions.
Here's the diff I used for testing (you may need to correct me if my method is wrong):
diff --git a/src/services/workflow.service.js b/src/services/workflow.service.js
index 455f60e8..ccdf521c 100644
--- a/src/services/workflow.service.js
+++ b/src/services/workflow.service.js
@@ -203,6 +203,8 @@ class WorkflowService {
} catch (e) {
subscription.handleViewState(ViewState.ERROR, e)
}
+
+ console.warn('# START', this.subscriptions)
}
/**
@@ -271,6 +273,7 @@ class WorkflowService {
store.dispatch(actionName).then(() => {})
})
delete this.subscriptions[subscription.query.name]
+ console.warn('# STOP', this.subscriptions)
}
// --- Merging GraphQL queries...
Note: This logs the subscriptions AFTER a subscription has been started or stopped.
And here are my results:
Experiment 1: Move from the Dashboard to workflow page.
The "root" subscription is cancelled and re-started causing GScan to flicker.
Experiment 2: Open new tree views
(Note: to replicate this I had to start on the Dashboard page)
The "root" subscription is canceled and re-started.
Having some spare time this week after the work on this PR, and don't want to add more PR's that will cause this PR to have to be rebased or its merge delayed. So decided to cover a part of the new code that I thought wasn't too important to add tests initially (but doesn't hurt to have more tests right :) Last commit only includes a handful new unit tests, no changes to the code. |
@oliver-sanders I think your diff is correct. And the results of your test look correct to me. Initially, I re-used the GScan query for Dashboard & WorkflowTables. Which resulted in less subscriptions being stopped and started again, but then I thought it would be best to keep things as they are for now, and focus on getting the GScan component and the subscriptions in place first, leaving a few teaks like this one for later. Probably to be addressed when we work on the new issues for query merging after this PR. |
I think the first example requires some extra logic to handle nicely (suggestion below), the second example (opening a new tree view) looks like a bug on this branch causing the Perhaps the solution to the first issue is to make the "unregister subscription" logic schedule a callback rather than cancelling the sub straight away. The callback can then check whether any new view has subscribed to the sub in the mean time. This way the GScan subscription wouldn't get cancelled. This leads onto the idea of keeping workflow subs active for a configured period so that users can switch back and forth between workflows with minimum waiting. Related to #392. |
I thought the root subscription had been cancelled because the Dashboard query had been removed, resulting in a call to I will take a look tomorrow, but you are correct, it's supposed to stop |
@oliver-sanders found the bug that was causing the GScan The issue was that I was never setting Fixed, and found another bug where I was not saving the result of union's of collections. Fix is really small, but I will probably need a bit more of time to write tests for these 2 issues I just found, to prevent them from happening again 👍 Thanks!!! |
…f merging action names
Done! If tests pass in CI, it should not stop/start the root subscription when going from Dashboard to the Tree view or Workflow with Tree view 👍 |
Brilliant that fixes both of my scenarios 💯 . |
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.
Great 🍾, really nice code, should give us a pattern to grow into.
Thanks @oliver-sanders ! |
I'm having a good play with this, probably can't improve on @oliver-sanders ' thorough review. Looks great so far, massive effort to close so many issues, thanks @kinow 💐 |
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.
Very nice 👍
These changes close a lot of issues, listed below. Do not worry about assigning to me, setting milestone, etc. After the final review, and when this issue is closed, then I will go through each issue linked below, will assign and set the milestone 👍
SubscriptionQuery
class, that gets filled from the VueRouter + VuexStore info via thegraphql.js
mixin 👍subscriptionView
mixin) we guarantee that we don't start subscriptions that are immediately going to be stopped.workflows.workflows
. The workflow data is stored inworkflows.lookup
(workflow subscription lookup withid
as key, and GraphQL data as value), and Tree view data is stored inworkflows.workflow
. The Tree view is re-using the data inworkflows.lookup
when it createsworkflows.workflow
, avoiding data duplication.setAlert(null)
when the user dismisses the alert. Note: if the user does not dismiss the alert, once a new alert appears, it will replace the existing alert 👍queries.js
file in this branch, at what's exported… there should be only subscription queries with deltas) the issue does not happen anymore.Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.Notes from discussions on Element and comments here:
stateTotals
to retrieve the states in the workflow, with their count tooJobStatus
enum!)