Skip to content

Instantly share code, notes, and snippets.

@ollieh-m
Created March 17, 2022 17:01
Show Gist options
  • Save ollieh-m/c1a3709935e11066fdbd76180054d3ec to your computer and use it in GitHub Desktop.
Save ollieh-m/c1a3709935e11066fdbd76180054d3ec to your computer and use it in GitHub Desktop.
it "causes deadlock?", use_transactional_tests: false do
device = create(:device, push_notification_subscriptions: %w(cooksnap_reminder mentioned_in_comment moderation_message))
threads = []
threads << Thread.new do
puts "START THREAD 1"
DeviceCreationService.run(
device.user, {
access_token: device.access_token,
token: device.token,
platform: device.platform,
push_notification_subscriptions: ["tip_likers", "comment"]
}
)
end
threads << Thread.new do
puts "START THREAD 2"
sleep(0.07)
DeviceCreationService.run(
device.user, {
access_token: device.access_token,
token: "different token",
platform: device.platform,
push_notification_subscriptions: ["tip_likers", "comment"]
}
)
end
threads.each(&:join)
ensure
# Need to perform manual clean up since transactional tests are disabled
User.destroy_all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment