Skip to content

Commit e2f1558

Browse files
Fix bug with polling join event
1 parent a5283a5 commit e2f1558

3 files changed

Lines changed: 81 additions & 4 deletions

File tree

pkg/platforms/postgres/postgres.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,10 +1802,19 @@ func joins(
18021802
UPDATE isolates
18031803
SET lock = $1
18041804
WHERE id IN (
1805-
SELECT id FROM isolates
1806-
WHERE status = 'awaiting'
1807-
AND lock = -1
1808-
AND events @> '[{"type":"JoinEvent"}]'
1805+
SELECT parent.id FROM isolates parent
1806+
WHERE parent.status = 'awaiting'
1807+
AND parent.lock = -1
1808+
AND parent.events @> '[{"type":"JoinEvent"}]'
1809+
AND EXISTS (
1810+
SELECT 1
1811+
FROM jsonb_array_elements(parent.events)
1812+
WITH ORDINALITY AS e(elem, idx)
1813+
JOIN isolates child
1814+
ON child.name = e.elem->>'id'
1815+
AND child.status = 'done'
1816+
WHERE e.elem->>'type' = 'JoinEvent'
1817+
)
18091818
FOR UPDATE SKIP LOCKED
18101819
LIMIT $2
18111820
)

pkg/runtimes/dupher/worker_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,41 @@ func CallerFlowSpec() {
632632
},
633633
},
634634
},
635+
{
636+
name: "flow_function_call_no_return",
637+
flowName: "VoidCallerFlow",
638+
source: map[string]string{
639+
"voidchild.ds.go": `package main
640+
641+
import (
642+
"github.com/RainingComputers/deepslate/prelude"
643+
"time"
644+
)
645+
646+
func VoidChildSpec(a int, b int) {
647+
result := a + b
648+
prelude.Sleep(1 * time.Second)
649+
_ = result
650+
}
651+
`,
652+
"voidcaller.ds.go": `package main
653+
654+
func VoidCallerFlowSpec() {
655+
VoidChildSpec(3, 5)
656+
var done int = 1
657+
_ = done
658+
}
659+
`,
660+
},
661+
steps: []workerTestStep{
662+
{
663+
sleep: 3 * time.Second,
664+
wantVars: map[string]any{
665+
"done": 1,
666+
},
667+
},
668+
},
669+
},
635670
}
636671

637672
httpAddr, controlAddr, shutdown, err := spawnBinary(tests)

pkg/runtimes/dython/deepslate/tests/test_worker.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,39 @@ async def caller_flow():
580580
],
581581
want_traces=[],
582582
),
583+
WorkerTestCase(
584+
name="flow_function_call_no_return",
585+
flow_name="caller_flow",
586+
source={
587+
"noop.py": """\
588+
from deepslate import flow, sleep
589+
590+
591+
@flow
592+
async def noop(a: int, b: int) -> None:
593+
result: int = a + b
594+
sleep(1.0)
595+
""",
596+
"caller_flow.py": """\
597+
from deepslate import flow
598+
from .noop import noop
599+
600+
601+
@flow
602+
async def caller_flow():
603+
finished: int = 0
604+
noop(3, 5)
605+
finished = 1
606+
""",
607+
},
608+
steps=[
609+
WorkerTestStep(
610+
sleep=3.0,
611+
want_vars={"finished": 1},
612+
),
613+
],
614+
want_traces=[],
615+
),
583616
],
584617
ids=lambda t: t.name,
585618
)

0 commit comments

Comments
 (0)