question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow a fiber to be "freezed" / paused + resumed

See original GitHub issue

The title says it all. I want to be able to “pause” + “resume” a fiber/effect. This should already be possible at every point we currently would be doing interruption by just telling the scheduler to not run any more effects from this fiber.

Why would I want to do that?

example 1: I have a long running calculation that now and then has to access third party systems. There are many calls that access many third party systems. I could now implement a retry with backoff logic on every of these calls. But I could also have a component that monitors the connection to these third party systems. If one of the connections goes down, I want to be able to simply pause my long running effect and resume it when the connections are back up.

example 2: same long running calculation (by long running, I mean >24h)… my end-user wants to pause the long running calculation to inspect the used resources (e.g. published data in 3rd party systems/databases, created files/folders, logfiles, etc.) … kind of like debugging with a debugger, but at a higher level.

example 3: I could have various background jobs (e.g. processing some streams, syncing files, etc.) that I can manage using a UI where I can start / pause / resume / stop the job.

example 4: debugging (as a dev): When my system is behaving strangely, it would be helpful to simply pause some fibers that are creating a lot of noise. Then I can zoom-in to the part of the system that is creating problems using thread-dumps, heap-dumps, profilers, proxies, etc. I could even create a management module to list and control fibers from the outside via REST or JMX.

I know that I can implement a similar behavior as a workaround by creating a Ref[Boolean] and check that in every step of my fiber… but I would have to do that in every new functionality I program and it would never be as clean as telling the scheduler “dont execute any more effects from that fiber”… so any “workaround” is not the point of this ticket.

In theory, freezing a fiber/effect would also be a first step to being able to migrate fibers/effects to other nodes, kind of like its possible in other languages like erlang (but that is just a thought experiment for now…)

I think this feature would be something entirely unique to ZIO on the JVM. Something that only a few people deemed possible a few years ago. Something that not even Loom will provide in the near future. And I think we should already be having almost everything that would be required to make that possible. In my simplified view of ZIO its as simple as telling the scheduler to stop processing effects from fiber x… I’m probably missing something, but would be great to read your thoughts!

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adamgfrasercommented, Nov 2, 2022

@gregor-rayman I think you want to take a look at ZIO Flow for that.

0reactions
gregor-raymancommented, Nov 2, 2022

A different but related topic: Would it be possible to suspend and persist a fiber (or something similar), stop the whole application (e.g. to deploy a new version) and then later to load the fiber’s state and to continue? (This would be usable for loooong running business processes that are waiting on external events.). I know this is more domain of BPEL… but describing business processes as for comprehentions seem so much more atractive

Read more comments on GitHub >

github_iconTop Results From Across the Web

class Fiber - RDoc Documentation
Basically they are a means of creating code blocks that can be paused and resumed, much like threads. The main difference is that...
Read more >
Whatever happened to Google Fiber? - CNET
The fiber freeze​​ In 2016, before Google Fiber could develop a significant footprint in new markets, the company abruptly announced an immediate ...
Read more >
Pause or resume data for a Flexible group plan - Google Fi Help
Owners and managers of a group plan can pause data service for any member: Open the Google Fi website or app Fi ....
Read more >
How to Change or Cancel Optimum Service | CableTV.com
How to Change or Cancel Optimum. We've done the research and here's what you'll need to update, pause, or drop your Optimum service....
Read more >
Transition to Brightspeed FAQs - CenturyLink
Note that if you placed a freeze on your CenturyLink service to prevent unauthorized transfer to another carrier, it was automatically lifted to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found