ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Bug]: Strand is not yeilding at `runtime:sleep`

Open heshanpadmasiri opened this issue 1 year ago • 0 comments

Description

Assume we have two worker, say w1 and w2 and have an alternate wait (ie. wait w1|w2). Now assume we have a runtime:sleep in the first worker to execute (say this is w1). When we hit this sleep it should cause the strand of w1 to pause. This should free us the thread that was running that strand to execute w2. However this doesn't happen and instead w1 blocks the execution of the program.

Steps to Reproduce

  1. Clone https://github.com/heshanpadmasiri/worker-yeild-bug
  2. Run bal run in fallowing directories
    1. ExternalServices
    2. server
    3. client

worker w2 should run first and when it hits sleep it don't yield and handover to w1

I couldn't get a more simpler test case to work since runtime will always choose to execute worker without the sleep every time. This is the only time I managed to get the runtime to run the worker with sleep first

Affected Version(s)

verified on 2201.8.6

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

heshanpadmasiri avatar May 02 '24 06:05 heshanpadmasiri