Skip to content

Commit 290c660

Browse files
authored
Merge branch 'main' into mandatory-context-to-dboscontext
2 parents a0b35de + 050cfef commit 290c660

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

dbos/system_database.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,17 +1782,6 @@ func (s *sysDB) recv(ctx context.Context, input recvInput) (any, error) {
17821782
s.logger.Warn("Recv() context cancelled", "payload", payload, "cause", context.Cause(ctx))
17831783
return nil, ctx.Err()
17841784
}
1785-
} else {
1786-
// Do a "zero" sleep to record the sleep step in the workflow history
1787-
// This is to handle cases were consecutive Recv calls for the same key are made
1788-
// The key would exist and without this, the step IDs would be: 0 recv, 1 sleep, 2 recv, 4 recv, etc
1789-
_, err := s.sleep(ctx, sleepInput{
1790-
duration: 0,
1791-
stepID: &sleepStepID,
1792-
})
1793-
if err != nil {
1794-
return nil, fmt.Errorf("failed to sleep before recv timeout: %w", err)
1795-
}
17961785
}
17971786

17981787
// Find the oldest message and delete it atomically

dbos/workflows_test.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,12 @@ func TestSendRecv(t *testing.T) {
15351535
// Verify step counting for receive workflow (receiveWorkflow calls Recv 3 times)
15361536
receiveSteps, err := GetWorkflowSteps(dbosCtx, receiveHandle.GetWorkflowID())
15371537
require.NoError(t, err, "failed to get workflow steps for receive workflow")
1538-
require.Len(t, receiveSteps, 6, "expected 4 steps in receive workflow (3 Recv calls + 1 sleep call during the first recv), got %d", len(receiveSteps))
1539-
for i, step := range receiveSteps {
1540-
require.Equal(t, i, step.StepID, "expected step %d to have correct StepID", i)
1541-
if i%2 == 1 {
1542-
require.Equal(t, "DBOS.sleep", step.StepName, "expected step %d to have StepName 'DBOS.sleep'", i)
1543-
} else {
1544-
require.Equal(t, "DBOS.recv", step.StepName, "expected step %d to have StepName 'DBOS.recv'", i)
1545-
}
1546-
}
1538+
require.Len(t, receiveSteps, 4, "expected 4 steps in receive workflow (3 Recv calls + 1 sleep call during the first recv), got %d", len(receiveSteps))
1539+
// Steps 0, 2 and 4 are recv
1540+
require.Equal(t, "DBOS.recv", receiveSteps[0].StepName, "expected step 0 to have StepName 'DBOS.recv'")
1541+
require.Equal(t, "DBOS.sleep", receiveSteps[1].StepName, "expected step 1 to have StepName 'DBOS.sleep'")
1542+
require.Equal(t, "DBOS.recv", receiveSteps[2].StepName, "expected step 2 to have StepName 'DBOS.recv'")
1543+
require.Equal(t, "DBOS.recv", receiveSteps[3].StepName, "expected step 3 to have StepName 'DBOS.recv'")
15471544
})
15481545

15491546
t.Run("SendRecvCustomStruct", func(t *testing.T) {
@@ -1654,15 +1651,13 @@ func TestSendRecv(t *testing.T) {
16541651
// Verify step counting for receive workflow (calls Recv 3 times, each with sleep)
16551652
receiveSteps, err := GetWorkflowSteps(dbosCtx, receiveHandle.GetWorkflowID())
16561653
require.NoError(t, err, "failed to get workflow steps for receive workflow")
1657-
require.Len(t, receiveSteps, 6, "expected 4 steps in receive workflow (3 Recv calls + 1 sleep calls), got %d", len(receiveSteps))
1658-
for i, step := range receiveSteps {
1659-
require.Equal(t, i, step.StepID, "expected step %d to have correct StepID", i)
1660-
if i%2 == 1 {
1661-
require.Equal(t, "DBOS.sleep", step.StepName, "expected recv step %d to have StepName 'DBOS.sleep'", i)
1662-
} else {
1663-
require.Equal(t, "DBOS.recv", step.StepName, "expected recv step %d to have StepName 'DBOS.recv'", i)
1664-
}
1665-
}
1654+
require.Len(t, receiveSteps, 4, "expected 4 steps in receive workflow (3 Recv calls + 1 sleep calls), got %d", len(receiveSteps))
1655+
// Steps 0, 2 and 4 are recv
1656+
require.Equal(t, "DBOS.recv", receiveSteps[0].StepName, "expected step 0 to have StepName 'DBOS.recv'")
1657+
require.Equal(t, "DBOS.sleep", receiveSteps[1].StepName, "expected step 1 to have StepName 'DBOS.sleep'")
1658+
require.Equal(t, "DBOS.recv", receiveSteps[2].StepName, "expected step 2 to have StepName 'DBOS.recv'")
1659+
require.Equal(t, "DBOS.recv", receiveSteps[3].StepName, "expected step 3 to have StepName 'DBOS.recv'")
1660+
16661661
})
16671662
t.Run("SendRecvIdempotency", func(t *testing.T) {
16681663
// Start the receive workflow and wait for it to be ready

0 commit comments

Comments
 (0)