-
Notifications
You must be signed in to change notification settings - Fork 5
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
Claim Discovery Task Atomization to Apply Task Deadline Individually Across Each Claim Request #716
Conversation
This is really well explained, good work! |
Nice! I want to point out that we do have some notion of "time destructuring". https://github.com/MatrixAI/MatrixAI-Graph/issues/42 https://github.com/MatrixAI/MatrixAI-Graph/issues/43 - this is the right one. |
Regarding your ideas on parallelising the request process. Just beware of a couple of things:
|
d4c82b9
to
033a7e2
Compare
hmm alright, i think i'll just stick with the step-through timing then |
Parallelism DraftHowever, this is still kind of slow. We would ideally want the pages to be processed in parallel. GH search will provide the amount of total Gists returned from a specific query: We can simply take this number and apply it to This will dramatically cut down on the amount of time required to get the ClaimIds. Note, when there are no gist results, a different message is shown instead, so we should expect that the element to find amount of matching gists may not exist. |
db6d2a7
to
7a2c868
Compare
I can abunch of warnings about dangling tasks being put in to the queue each time i
I'm not exactly sure what these tasks are, given that the task manager is shutting down gracefully and that the discovery background task has already long-completed before i shut down the agent. This problem only happens sometimes, so not what sure it could be... I was consistently getting it, but after my latest commits, i am not |
719d047
to
a73e196
Compare
I think in general tasks need to be checked for any weird errors. The latest staging version still comes up with things like this:
|
THIS IS NOT A PROBLEM, DISREGARD THIS! THE ROOT CAUSE HAS BEEN IDENTIFIED IN THE PROCEEDING COMMENTfor discovery resumption there needs to be changes in the code path. I have implemented the ProviderPaginationToken in order to support resumption of identity vertex discovery if the TaskManager is shutdown. However, I have come to realize that the discovery of a Node Vetex and all connected Vertices are all performed in a single Task. Therefore, passing a single The solutions are either:
|
fb75acd
to
2f7e77b
Compare
The main problem right now, is that I've found discovering a Node vertex will make a Polykey agent request and iterate through the pages of claims on an identity in order to just obtain the There are 3 options for this I have discussed with @tegefaulkes about:
Edit: It has been deemed that solution 2 is the probably the way to go. |
2decf7e
to
dbf2363
Compare
@tegefaulkes roger wanted to let you know that the PR can be handed off to you. The last part is just fixing #723 and then it should be ready to merge |
Alright, I've fixed the main problem that was left. The main solution was to add a flag to Besides that I had to apply some small fixes here and there. This should be ready for review now. |
0d0f537
to
6657dda
Compare
…ovider` API supports getting ClaimIds and Claims in single request
…laims stored in the local `SigChain`
…staltGraph` ctx is aborted before all Claims have been processed
97dad8b
to
b442e54
Compare
fix: registering `checkRediscoveryHandler` fix: discovery ignores active tasks when scheduling a new task fix: fixed problem with `verifyIdentityClaims` handling abortion [ci skip]
b442e54
to
4d98422
Compare
everything seems good, merging now |
Description
The goal of this PR is to refactor the
Discovery
domain so thatdiscoverVertexHandler
does not timeout upon making multiple GET requests for claims on the identity provider.This will fix the issue listed as currently, what is failing the discovery of multiple claims is purely the fact that
Discovery.verifyIdentityClaims
is not an atomic operation. The method will only return once all ClaimIds and their associated Claims have been retrieved from the identity provider.In the case of GitHub, where
n = number of claims
, the requests made for the discovery of a given identity will beceiling(n / 10) + n
. The reason for theceiling(n / 10)
requests is that GitHub will only show 10 Gists per page, meaning that we have to paginate to get all ClaimIds.Given that the amount of requests, and therefore amount of time taken scales linearly, that is why
discoverVertexHandler
times out when processing more than 1 Claim.Task Aggregation
Upon realizing debugging many, many, many tasks might be a pain, I've realized the most painless solution.
Instead of scheduling a task for each request made, we can simply refresh the ctx to emulate this behaviour. Refreshing a ctx will not reset the timer if the timer has already hit the deadline, so it makes it very easy to emulate this behaviour. Furthermore, since the task is rescheduled when lazily cancelled by the task manager stopping, we can just paramaritise our progress before the task manager shuts down.
From here on out, please keep this in mind when I talk about creating new tasks, as I am now doing this instead.
Claim Pagination
Given that the time taken to paginate across a gist search to find all ClaimIds is
ceiling(n / 10)
, we could run into a timeout on this task. This would happen with the current implementation:In order to apply our timeout deadline to each request individually, we can instead have the task that processes the first page schedule a task to process the second page once it is done:
In order to do this we need a way to paginate through each page of Claims that is:
The way we can do this is by returning a generic
Opaque
String
that represents thePaginationToken
to to be handed to the next task to execute their query. This type will have no meaning other than being what should be provided to the next function to get the next page.Claim Requests
Each task to process a page can represent a pipeline to get all of the contents of the claims on that particular page. The directed graph in the order of which tasks are scheduled can be represented as so:
This way, we can streamline the meaning of
Discovery.discoverVertexTimeoutTime
to be the timeout time of each request in the Discovery task pipelines. By binding the timeout time with a specific expectation, we can expect less unexpected errors such as that found in the issue.Identities
Provider
Abstract Class InterfaceBecause we now have to account for pagination + getting claim ids to schedule tasks for requesting each claim, we need to have a
getClaimIds
async generator method onProvider
interface.We will also need to add paginated versions of the
getClaims
andgetClaimIds
methods that will also return a paginationToken. The reason for this, is so that the task to process each request triggered by the method call to a paginatedget...
method, as well as resume if the task were stopped. This will be a bit messy as we cannot follow our existing pagination conventions, considering that there different providers will use different pagination methods. GitHub will use page index, but Twitter will use tokens and timestamps.Issues Fixed
Discovery
domain does not reschedule lazily executedTask
s #723Tasks
Identities.Provider
abstract class to include paginated API optionsDiscovery.verifyIdentityClaims
so that we can schedule a task for requesting and processing each claim separately.Discovery
handlergetClaimPages
directly in the case where data can be aggregated more efficientlyFinal checklist