Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on batch insert if InsertOpts.UniqueOpts is specified #7

Merged
merged 1 commit into from
Nov 11, 2023

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Nov 11, 2023

As I was writing docs for batch insertion today [1], I remembered that
we don't support job uniqueness on batch inserts because the mechanism
uses PG advisory locks, and holding many locks at once could easily lead
to contention and deadlocks.

We may remove this limitation in the future, but I figure that in the
meantime, it might not be the worst idea to error if they're specified
on batch insert so as not to mislead the user that what they expected to
happen happened. That's what this change does.

[1] https://riverqueue.com/docs/batch-job-insertion

@brandur brandur requested a review from bgentry November 11, 2023 01:41
if err := c.validateManyInsertOpts(param.InsertOpts); err != nil {
return 0, err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

These method bodies are getting to be fairly long for being entirely duplicated, thoughts on extracting everything except the last line of each into a shared unexported method or helper?

Copy link
Contributor Author

@brandur brandur Nov 11, 2023

Choose a reason for hiding this comment

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

WFM. Updated to include Client.insertManyParams.

@brandur brandur force-pushed the brandur-error-on-batch-unique-opts branch from 3d679e4 to dced48f Compare November 11, 2023 19:29
As I was writing docs for batch insertion today [1], I remembered that
we don't support job uniqueness on batch inserts because the mechanism
uses PG advisory locks, and holding many locks at once could easily lead
to contention and deadlocks.

We may remove this limitation in the future, but I figure that in the
meantime, it might not be the worst idea to error if they're specified
on batch insert so as not to mislead the user that what they expected to
happen happened. That's what this change does.

[1] https://riverqueue.com/docs/batch-job-insertion
@brandur brandur force-pushed the brandur-error-on-batch-unique-opts branch from dced48f to b07d2af Compare November 11, 2023 19:36
@brandur brandur merged commit 7e836f2 into master Nov 11, 2023
5 checks passed
@brandur brandur deleted the brandur-error-on-batch-unique-opts branch November 11, 2023 19:38
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