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

fix(que): Fix bulk_enqueue when enqueuing more than 5 jobs #1074

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

laurglia
Copy link
Contributor

Previously, with Que bulk_enqueue a new span was created for every job in the batch.

For each such span, a tag was added to all jobs in the batch. This meant that if you enqueued 3 jobs, then 3 spans were created and each job had 3 tags pointing to 3 different spans.

This behavior became problematic when you tried to insert more than 5 jobs, as Que supports up to 5 tags per job. More specifically, a runtime error was raised by Que.

This commit fixes that bug by creating only a single span when using bulk_enqueue.

Copy link

linux-foundation-easycla bot commented Jul 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: laurglia / name: Laur (db79b63)


unless job_attrs.empty?
span.name = "#{job_attrs.first[:job_class]} publish"
span.add_attributes(QueJob.job_attributes(job_attrs.first))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it add messaging.message_id to the attributes? It shouldn't in case of a bulk enqueue. The other properties seem correct because they should be the same according to the bulk enqueue limitations.

Copy link
Contributor Author

@laurglia laurglia Jul 17, 2024

Choose a reason for hiding this comment

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

The job attributes do not contain ID in the case of bulk enqueue, so no ID is added to attributes.

This is so because IDs only exist after a job is inserted into database but for bulk enqueue we set the attributes before they are inserted into database.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will see if I can also add a test to assert that message ID is not added

Copy link
Contributor Author

@laurglia laurglia Jul 17, 2024

Choose a reason for hiding this comment

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

Added a test case to check lack of message ID attribute and presence of other attributes

@@ -363,10 +416,10 @@ def self.run(first, second); end

_(finished_spans.size).must_equal(2)

span1 = finished_spans.first
span1 = finished_spans.last
Copy link
Contributor

Choose a reason for hiding this comment

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

did something change with ordering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, forgot to mention this in commit message. It affects the "synchronous" mode test where previously the "produce" span finished first and only then "consume" finished. Now they finish in opposite order.

I do not know what is the desired behavior, not sure if it's even important here what order they are in.

But observe that now the behavior is identical to the normal enqueue for synchronous jobs. Here is same test for regular enqueue and observe that now the two tests are identical.

Copy link
Contributor

@indrekj indrekj left a comment

Choose a reason for hiding this comment

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

(not an actual reviewer but) looks good to me

@kaylareopelle
Copy link
Contributor

Hi @laurglia! Thanks for your contribution. Would you mind signing the CLA?

@laurglia
Copy link
Contributor Author

Hi @laurglia! Thanks for your contribution. Would you mind signing the CLA?

I am working on it. As I'm making this under employment with a company, I will need to first get the company sign the CLA.

@sm-deployer sm-deployer deleted the fixbulkenqueue branch July 18, 2024 07:36
@indrekj indrekj restored the fixbulkenqueue branch July 18, 2024 08:25
Copy link
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label Aug 18, 2024
@kaylareopelle
Copy link
Contributor

kaylareopelle commented Aug 19, 2024

Hi @laurglia! Any luck with the CLA? Is there anything we can do to help?

@github-actions github-actions bot removed the stale Marks an issue/PR stale label Aug 20, 2024
@laurglia
Copy link
Contributor Author

laurglia commented Sep 4, 2024

Hi @laurglia! Any luck with the CLA? Is there anything we can do to help?

The CLA has been signed.

Previously, with Que `bulk_enqueue` a new span was created for every job
in the batch.

For each such span, a tag was added to _all_ jobs in the batch. This
meant that if you enqueued 3 jobs, then 3 spans were created and each
job had 3 tags pointing to 3 different spans.

This behavior became problematic when you tried to insert more than 5
jobs, as Que supports up to 5 tags per job. More specifically, a runtime
error was raised by Que.

This commit fixes that bug by creating only a single span when using
bulk_enqueue.
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Thank you, @laurglia! (and thank you @indrekj for your review too! 🙂)

@kaylareopelle kaylareopelle merged commit dd0084b into open-telemetry:main Oct 1, 2024
57 checks passed
@github-actions github-actions bot mentioned this pull request Oct 1, 2024
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