Skip to content

Attempt to reduce flakiness of test/integration/instrumentation_test.rb #615

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

p-schlickmann
Copy link
Contributor

Hey @rosa

This is another attempt to reduce the flakiness of test/integration/instrumentation_test.rb

I ran this locally and had no flakiness in the 100 attempts:

for i in {1..100}; do bin/rails test test/integration/instrumentation_test.rb || break; done

Previous attempts so far: f433a99
Issue: #602

scheduler.stop
end

assert events.size >= 1
event = events.last
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the async nature of Solid Queue it seems like we can't use .last reliably

@p-schlickmann
Copy link
Contributor Author

p-schlickmann commented Aug 1, 2025

I've been thinking about this fix, it does address the flakiness in this specific test file, but I’m concerned it might be masking a deeper issue.

When running the original spec, I occasionally see three SolidQueue::Job created within the same second, which feels unexpected. Here's the output of SolidQueue::Job.all when the test fails:

[#<SolidQueue::Job:0x000000012aba26d0
  id: 6817,
  queue_name: "background",
  class_name: "AddToBufferJob",
  arguments:
   {"job_class" => "AddToBufferJob",
    "job_id" => "bdcaf734-90cb-4e1a-89f8-5e60e4f13b58",
    "provider_job_id" => nil,
    "queue_name" => "background",
    "priority" => nil,
    "arguments" => [42],
    "executions" => 0,
    "exception_executions" => {},
    "locale" => "en",
    "timezone" => "UTC",
    "enqueued_at" => "2025-08-01T02:41:38.996189000Z",
    "scheduled_at" => "2025-08-01T02:41:38.996162000Z"},
  priority: 0,
  active_job_id: "bdcaf734-90cb-4e1a-89f8-5e60e4f13b58",
  scheduled_at: Fri, 01 Aug 2025 02:41:38.996162000 UTC +00:00,
  finished_at: nil,
  concurrency_key: nil,
  created_at: Fri, 01 Aug 2025 02:41:38.996331000 UTC +00:00,
  updated_at: Fri, 01 Aug 2025 02:41:38.996331000 UTC +00:00>,
 #<SolidQueue::Job:0x000000012aba2590
  id: 6818,
  queue_name: "background",
  class_name: "AddToBufferJob",
  arguments:
   {"job_class" => "AddToBufferJob",
    "job_id" => "30b58d8c-30ba-4f7d-8297-0fe30c24fcb8",
    "provider_job_id" => nil,
    "queue_name" => "background",
    "priority" => nil,
    "arguments" => [42],
    "executions" => 0,
    "exception_executions" => {},
    "locale" => "en",
    "timezone" => "UTC",
    "enqueued_at" => "2025-08-01T02:41:38.998431000Z",
    "scheduled_at" => "2025-08-01T02:41:38.998423000Z"},
  priority: 0,
  active_job_id: "30b58d8c-30ba-4f7d-8297-0fe30c24fcb8",
  scheduled_at: Fri, 01 Aug 2025 02:41:38.998423000 UTC +00:00,
  finished_at: nil,
  concurrency_key: nil,
  created_at: Fri, 01 Aug 2025 02:41:38.998515000 UTC +00:00,
  updated_at: Fri, 01 Aug 2025 02:41:38.998515000 UTC +00:00>,
 #<SolidQueue::Job:0x000000012aba2450
  id: 6819,
  queue_name: "background",
  class_name: "AddToBufferJob",
  arguments:
   {"job_class" => "AddToBufferJob",
    "job_id" => "515478a5-0fa9-4d98-9d63-42cd74d0f2a1",
    "provider_job_id" => nil,
    "queue_name" => "background",
    "priority" => nil,
    "arguments" => [42],
    "executions" => 0,
    "exception_executions" => {},
    "locale" => "en",
    "timezone" => "UTC",
    "enqueued_at" => "2025-08-01T02:41:38.999447000Z",
    "scheduled_at" => "2025-08-01T02:41:38.999440000Z"},
  priority: 0,
  active_job_id: "515478a5-0fa9-4d98-9d63-42cd74d0f2a1",
  scheduled_at: Fri, 01 Aug 2025 02:41:38.999440000 UTC +00:00,
  finished_at: nil,
  concurrency_key: nil,
  created_at: Fri, 01 Aug 2025 02:41:38.999520000 UTC +00:00,
  updated_at: Fri, 01 Aug 2025 02:41:38.999520000 UTC +00:00>]

Something unusual is definitely happening here. I’ll need a bit more time to dig into this and understand what’s really going on.

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.

1 participant