Skip to content

Conversation

@shirzady1934
Copy link
Contributor

This PR addresses issue #148 by refactoring the system database to merge the functionality of recordChildGetResult into
recordOperationResult.

The recordOperationResult function has been updated to handle the parent-child relationship by accepting a childWorkflowID. The recordChildGetResult function has been removed, and its call sites have been updated to use the new recordOperationResult.

During the development process, a few other issue were identified and resolved a bug in the dynamic SQL query construction in the refactored recordOperationResult function was fixed.

Additionally, this PR addresses a race condition in the CLI integration tests that was causing flaky test runs. The tests were failing because they were checking for queued workflows before the parent workflow had finished enqueueing them. A polling mechanism has been added to wait until the expected number of workflows are present in the queue before proceeding with the assertions.

Copy link
Collaborator

@maxdml maxdml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shirzady1934 for the PR.

Comment on lines +254 to +255
isGetResult: true,
stepName: "DBOS.getResult",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to use the stepName to determine whether this is a get result step (no need for isGetResult). (We also don't need the on conflict cause.)

Comment on lines +1264 to +1267
conflictClause := ""
if input.isGetResult {
conflictClause = "ON CONFLICT DO NOTHING"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want that -- this was a bug in record child result and we should absolutely let conflicts return errors (which are caught later in this function)

Comment on lines +380 to +395
require.Eventually(t, func() bool {
args := append([]string{"workflow", "list", "--queue", "example-queue"}, baseArgs...)
cmd := exec.Command(cliPath, args...)
cmd.Env = append(os.Environ(), "DBOS_SYSTEM_DATABASE_URL="+getDatabaseURL(dbRole))

output, err := cmd.CombinedOutput()
if err != nil {
return false
}
var workflows []dbos.WorkflowStatus
err = json.Unmarshal(output, &workflows)
if err != nil {
return false
}
return len(workflows) >= 10
}, 5*time.Second, 500*time.Millisecond, "Should find at least 10 workflows in the queue")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants