-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_app.rb
42 lines (39 loc) · 968 Bytes
/
web_app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'sinatra'
require 'securerandom'
require './dutiful_worker'
require './redis_connection'
def redis
$redis_connection ||= RedisConnection.new.redis('sidekiq-hk-bug-results')
end
get '/' do
body = <<-HTML
<html>
<body>
<script type="text/javascript">
window.triggerJobs = function() {
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', '/addJob');
httpRequest.send();
}
</script>
<h2>This app illustrates a bug that causes Sidekiq jobs to be executed multiple times on Heroku</h2>
<button type="button" onclick="triggerJobs();">Click to add 20 jobs</button>
<h3>Duplicate jobs listed belows (refresh page)</h3>
</body>
</html>
HTML
keys = redis.keys '*'
keys.each do |key|
val = redis.get key
if val.to_i > 1
body << "<p>#{key} ==> #{val}</p>"
end
end
body
end
get '/addJob' do
20.times do
DutifulWorker.perform_async(SecureRandom.uuid)
end
200
end