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

Discovery domain does not reschedule lazily executed Tasks #723

Closed
amydevs opened this issue May 20, 2024 · 4 comments · Fixed by #716
Closed

Discovery domain does not reschedule lazily executed Tasks #723

amydevs opened this issue May 20, 2024 · 4 comments · Fixed by #716
Assignees
Labels
bug Something isn't working r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy

Comments

@amydevs
Copy link
Contributor

amydevs commented May 20, 2024

Describe the bug

The Discovery domain does not reschedule lazily executed Tasks when stopping. The trace for this is as follows:

  1. Discovery.start is called to register handlers onto TaskManager before it starts processing.
  2. TaskManager.startProcessing is called to start task processing.
  3. The Discovery.discoverVertexHandler is executed lazily.
  4. TaskManager.stopProcessing is called in order to stop task processing.
  5. Discovery.discoverVertexHandler catches an ErrorTaskStop on ctx.signal.reason.
  6. It calls Discovery.scheduleDiscoveryForVertex to reschedule the task.
  7. Discovery.scheduleDiscoveryForVertex calls TaskManager.getTasks, seeing that the task that is currently executing cleanup already exists.
  8. The new task is not rescheduled.
  9. TaskManager.startProcessing is called, the task to resume discovery is not executed.

To Reproduce

As the code to reproduce this only exists within the context of my Discovery domain pagination changes, please refer to

test('identity discovery persistence across restarts', async () => {

Expected behavior

The discovery task should be rescheduled so that discovery of vertices can be resumed after restarts.

Screenshots

Platform (please complete the following information)

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context

Found whilst working on #716

Notify maintainers

@tegefaulkes

@amydevs amydevs added the bug Something isn't working label May 20, 2024
Copy link

linear bot commented May 20, 2024

@amydevs
Copy link
Contributor Author

amydevs commented May 20, 2024

there needs to be a way to override the scheduleDiscoveryForVertex i think so that we force rescheduling, or just have a different method altogether

@tegefaulkes
Copy link
Contributor

From what I recall from coding this bit, The intention was for there to only be 1 task per vertex. This was enforced in 2 ways.

  1. When scheduling a vertex if there was a task that already exists for it then that task was modified instead of creating a new one.
  2. If there just happens to be multiple tasks for a vertex, the extra tasks are cancelled.

At the time rescheduling just wasn't implemented and this was the intended behaviour. So I'm not really sure this can be considered a bug. That said, the requirements have changed and we need the ability to have a task reschedule itself if it doesn't fully complete. To that end we can look into reducing or removing these restrictions but we need to be careful about it.

@tegefaulkes
Copy link
Contributor

I think the main issue right now is that the scheduleDiscoveryForVertex will not schedule a new task if there is an already scheduled task. But an active task is technically scheduled task. so calling scheduleDiscoveryForVertex inside the discoverVertex` handler will just skip the task since it's active.

One way to address this is to allow scheduleDiscoveryForVertex to schedule multiple discoverVertex tasks, Basically if there is any active tasks it will allow 1 new task to be scheduled. Or basically basically, just make it ignore active tasks.

@CMCDragonkai CMCDragonkai added the r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy
3 participants