Skip to content

Conversation

@maxdml
Copy link
Collaborator

@maxdml maxdml commented Aug 13, 2025

No description provided.

@maxdml maxdml marked this pull request as ready for review August 14, 2025 00:18
@maxdml maxdml requested a review from Copilot August 14, 2025 00:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds deduplication and priority features to workflow queues. The implementation introduces a mechanism to prevent duplicate workflows from being enqueued based on a deduplication ID and allows workflows to be prioritized for execution order.

  • Adds WithDeduplicationID and WithPriority workflow options for configuring queue behavior
  • Implements deduplication logic that throws QueueDeduplicated error when duplicate workflows are detected
  • Extends queue system to support priority-based execution ordering

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dbos/workflow.go Adds deduplication and priority parameters to workflow options and enqueue functionality
dbos/system_database.go Implements deduplication constraint handling with proper error detection
dbos/errors.go Defines new QueueDeduplicated error type for deduplication violations
dbos/queues_test.go Comprehensive test coverage for deduplication and priority queue features
dbos/client_test.go Client-side tests for deduplication and priority functionality
dbos/workflows_test.go Minor test improvements and timeout adjustments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@kraftp kraftp left a comment

Choose a reason for hiding this comment

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

This looks good! Only thing I'd check is that it should be easy to check if an error is the deduplicated error so it can be handled specially.

@maxdml
Copy link
Collaborator Author

maxdml commented Aug 14, 2025

This looks good! Only thing I'd check is that it should be easy to check if an error is the deduplicated error so it can be handled specially.

Here's how you'd do the check (https://github.com/dbos-inc/dbos-transact-go/pull/55/files#diff-305ba99507d11e31f033fa05624d0ed3fc5bcda80bfa2e1fc70603c974cdfcdbR306)

_, err = RunAsWorkflow(dbosCtx, testWorkflow, "def", WithQueue(dedupQueue.Name), WithWorkflowID(wfid2), WithDeduplicationID(dedupID))
require.Error(t, err, "expected error when enqueueing workflow with same deduplication ID")

// Check that it's the correct error type and message
dbosErr, ok := err.(*DBOSError)
require.True(t, ok, "expected error to be of type *DBOSError, got %T", err)
assert.Equal(t, QueueDeduplicated, dbosErr.Code, "expected error code to be QueueDeduplicated")

@maxdml maxdml merged commit 584e8b2 into main Aug 14, 2025
1 check passed
@maxdml maxdml deleted the q-dedup-and-prio branch August 14, 2025 20:29
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.

3 participants