1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
Commit graph

595 commits

Author SHA1 Message Date
Mike Perham
5315e09c56 Ensure TID changes after fork, fixes 2017-12-08 13:24:21 -08:00
Darryl Pogue
280c7f7782 Symbolize all config.yml keys when loading
This ensures that keys in the Yaml file can be specified as either
symbols or strings, but will always be treated as symbols after loading.

It tries to use ActiveSupport's `deep_symbolize_keys!` method if
ActiveSupport is loaded, otherwise falling back to an inline version.

Closes .
2017-12-02 13:37:32 -08:00
Rachael Ludwick
4a7da4302d Log at error level on redis exceptions and then warn for exception
Backout previous change to the exception handler signature and instead
just log at error level the main part of the redis exception then just
use the original exception handler as-is (at warn level) for the
backtrace. This is a compromise in compatibility insofar as the
backtrace is now at a lower log level, but alerting specifically on
these error strings likely uses the main error strings explicitly logged
before the very verbose backtrace.
2017-11-30 10:11:16 -08:00
Rachael Ludwick
aead218b84 Make error handler change fully backwards compatible
The change that Fixes  actually broke any existing
exception handlers due to differences in expected parameter count. This
fixes it explicitly which normally seems like it won't matter but there
are random monitoring gems that install their own sidekiq exception
handlers that I don't want to break.
2017-11-30 10:11:16 -08:00
Rachael Ludwick
58d5ff1e6d Use exception handler for logging for fetch exception
Extends the `ExceptionHandler` to support multiple log levels and
additional context text in order to use it when the `Processor`
encounters an exception when fetching new work. The added options ensure
that the new behavior is fairly close to the old behavior (same log
level, same fetch error message).

Fixes 
2017-11-22 17:37:29 -08:00
Fernando Seror
63ee43353b JobSet#each goes through elements in descending score order
The current implementation of the #each method uses Redis.zrange to
paginate the iteration and use multiple lightweight calls. It performs
this pagination in descending score order, but each page is returned
from Redis in ascending order. The result is that the final iteration
through the whole set is not sorted properly. Here's an example with a
page of size 3:

Redis set: 1, 2, 3, 4, 5, 6, 7, 8, 9
JobSet.to_a: 7, 8, 9, 4, 5, 6, 1, 2, 3

This fixes it with barely no performance cost (each page is reverted in
Ruby) and all the items are perfectly sorted in descending score order.
2017-11-01 16:12:51 -07:00
Jeremy Daer
6332b9f8a3 redis-rb 4.0 support
* Loosen Redis version dep to `>= 3.3.5, < 5`
* Bump redis-namespace for looser Redis version dep. Pending
  https://github.com/resque/redis-namespace/pull/136 gem release.

Use `redis.connection` where we can and fall back to `redis._client`
where we need (to inspect timeout and scheme).

References 
2017-09-28 21:54:06 -07:00
Mike Perham
39532f8674 Refactor Worker.set impl so it can be memoized, fixes 2017-09-12 10:49:05 -07:00
Magnus von Koeller
de701c4863 When a middleware mutates arguments, retry with original args
Currently when a server middleware mutates arguments and then the job
fails, it will get re-queued with the mutated arguments, not the
original arguments.

This is unexpected and (IMO) faulty behavior as that same middleware
will now see the already-mutated arguments when the job gets executed
again.

This changes the behavior to use the pristine, unmutated jobs hash when
requeueing the failed job. It also includes a failing test case for the
old code.
2017-08-11 16:33:55 -07:00
Yuriy Naidyon
bd93f8430b Unified Job kill via Sidekiq::DeadSet#kill 2017-08-11 12:33:12 -07:00
James McCarthy
635e0628d2 Ensure Sidekiq.enable_delay! does not break Psych. 2017-07-29 08:49:54 +02:00
Mike Perham
66d6ee3535 timing is everything 2017-06-21 13:21:11 -07:00
Mike Perham
33846c849a Allow users to disable ID generation since some redis providers disable the CLIENT command, fixes 2017-06-21 04:54:18 -07:00
Mike Perham
980438c61d Add default Redis client identifier, 2017-06-16 08:40:43 -07:00
Mike Perham
b38bb6f676 polish 2017-06-07 10:26:44 -07:00
Alfonso Uceda Pompa
c02862bd97 Custom job_logger_class 2017-06-07 10:20:31 -07:00
Mike Perham
8f0a83ff52 Remove percy, the Web UI doesn’t change enough to justify the complex dependency 2017-06-06 14:54:20 -07:00
PikachuEXE
7fe2515138 Fix overriding class_attribute core extension from ActiveSupport with Sidekiq one 2017-06-06 08:10:08 -07:00
Mike Perham
1b3f70a1e5 Move class_attribute impl into Sidekiq::Worker 2017-05-15 14:57:03 -07:00
Rafael Fidelis
0d314b145c Update footer UTC time in pooling dashboard refresh () 2017-05-04 07:20:05 -07:00
Johan Lundström
3b96430046 Improve parsing of HTTP_ACCEPT_LANGUAGE (continue Nate's work) ()
* Add test case for sv locale

* Use Rack::Utils to parse locale header

* Take "q" value into account

* Make '*' match the default locale.

* Add test for available_locales

* Correct test case sv -> en

* Add missing test cases for Safari requests

* Add missing require needed to run a single test file

* Reimplement WebHelpers#locale to handle regions in header

Implementation inspired by:

https://github.com/iain/http_accept_language/blob/master/lib/http_accept_language/parser.rb

Also see:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4

* Add docs and references

* Add failing test cases for pt-br, pt-pt, pt (examples taken from Chrome & Safari)

* Add more test cases for Mac + Chrome + UK English + US English

* Make test cases for 'pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4' and 'pt-pt' pass

* Make special case 'ru,en' work (equal qvalues)
2017-05-01 10:47:51 -07:00
Mike Perham
c446782932 fix malformed test data 2017-04-24 19:09:00 -07:00
Mike Perham
aed8d4577e oops 2017-03-24 12:06:27 -07:00
Mike Perham
701584e24e Verify graceful handling of ill-formed job payloads, fixes
Sidekiq will better handle jobs with malformed payloads.  Any job which raises a JSON::ParserError will immediately move to the Dead set.  Update the API to degrade gracefully when trying to render bad JSON in the queue, scheduled or dead.  These payloads are most often from other languages where the JSON is being pieced together manually and pushed to Redis.
2017-03-24 11:59:48 -07:00
Mike Perham
773dd89c18 Merge branch 'master' into 5-0 2017-03-24 11:19:44 -07:00
Mike Perham
91ab536ac3 Remove namespace usage within test suite 2017-03-24 11:01:45 -07:00
Marc Boquet
d1510f9155 Validate 'at' argument for Sidekiq::Client.push ()
* Validate 'at' argument for Sidekiq::Client.push

* item['at'] shouldn't actually be nil
2017-03-23 11:05:20 -07:00
Mike Perham
d916feaa7a merge master 2017-03-22 11:22:45 -07:00
Mike Perham
5de44ac880 Add more testing around 2017-03-16 11:52:58 -07:00
Mike Perham
3b5862492a Remove job duplication edge case with Sidekiq Pro, fixes
In , we saw how an IO exception in the logger could cause a job to fail and be deleted before it reached the RetryJobs block, causing job loss.  To fix this, we disabled job acknowledgement until job execution starts but this has the bad side effect of duplicating jobs if the user is running a reliable scheme and the error happens after the RetryJobs middleware but before execution starts.

Instead we flip the middleware ordering; logging now happens within the retry block.  We would lose context-specific logging within retry so we move the context log setup out of the middleware into the Processor.  With these changes, we can properly retry and acknowledge even if there are errors within the initial server middleware and executor calls.

This code path has been reimplemented in Sidekiq 5.0 so this change only applies to 4.x.
2017-03-15 10:03:47 -07:00
Mike Perham
812e0f17ad Remove duplicate retry handling to due extra raise, fixes 2017-02-15 11:13:10 -08:00
Mike Perham
0c88414d94 merge master 2017-02-15 10:26:24 -08:00
Mike Perham
cfc3f314e4 escape page and poll parameters for safety 2017-02-15 09:29:17 -08:00
Stepan Tubanov
c1fcb29b3d show error class on retry page () 2017-02-09 21:43:23 -08:00
Mike Perham
0c193abcae Safer latency calculation for incomplete jobs, fixes 2017-02-02 12:25:29 -08:00
Mike Perham
9a71a121c8 Merge branch 'master' into 5-0 2017-01-31 11:37:14 -08:00
Tim Haines
90e9b27800 Integrate Percy.io for visual regression tests ()
* Integrate Percy.io for visual regression tests

* Configure Travis so Percy runs on latest ruby only.

* Wrap Percy::Capybara in a helper method

* Lock capybara and related testing gems to major versions

* Adjust Percy.io integration so PERCY_ENV=0 prevents Percy from being required
2017-01-18 14:19:48 -08:00
Mike Perham
701e06224c Rework job processing in light of Rails 5's Reloader ()
* Rework job processing in light of Rails 5's Reloader, see 

* Ignore built gems

* Documentation, testing

* Add fallback for 'retry' value server-side, fixes 

* Fix job hash reporting in stats

* cleanup

* Add job for AJ testing

* Push jobs with invalid JSON immediately to Dead set, fixes 

* Break retry logic into global and local parts, fixes 

* fix heisentest
2017-01-17 14:58:08 -08:00
Mike Perham
cc59d07e48 Disable delay extensions by default, fixes ()
* Disable delay extensions by default, fixes 

* Size check for YAML payload

* so racy

* Allow larger, explicit size in message

* Polish
2017-01-04 10:30:42 -08:00
Mike Perham
2363cef312 Remove more USR1 references 2017-01-03 15:41:48 -08:00
Mike Perham
6a8e1e0702 Switch default quiet signal to TSTP as it is available on JRuby, fixes () 2017-01-03 15:24:48 -08:00
Mike Perham
b8f7082642 Fix minitest warnings ()
* Fix minitest deprecations, fixes 

* fix jruby

* test against jruby release

* ugh

* bump to 5.0.1

* fix test
2017-01-02 12:06:02 -08:00
Fernando Seror Garcia
7a63036b21 Add the enqueued_at attribute when fake Testing ()
Trying to emulate the real behavior, the job obtains an enqueued_at
attribute when it's placed in a queue.

Since using perform_in or perform_at does not put the job in the queue
when run, the attribute is not set for those methods.
2016-11-25 21:19:16 -08:00
Mike Perham
2367bc19c1 Rewrite heartbeat so we can dynamically update tags/labels, 2016-11-25 13:39:22 -08:00
Mike Perham
257b96094f Minimize Ruby warnings in test suite 2016-11-23 14:50:11 -08:00
Edward Anderson
2f9258e4fe Put source encoding comment as line for (j)ruby 1.9 compatibility ()
In jruby 1.7.22 (1.9.3p551 compatibility mode), UTF-8 encoding is not properly
detected, because the encoding comment is not on the first line as required in ruby
1.9.

The frozen_string_literal magic comment did not come into existence until ruby 2.3,
and ruby 1.9 does not look past the first line for magic comments.

This results encoding-related syntax errors. Examples:

    SyntaxError: /home/nilbus/ws/rental_express/ROOT/rails/vendor/bundle/jruby/1.9/gems/sidekiq-4.2.6/lib/sidekiq.rb:52: Invalid char `\235' ('') in expression
      def self.❨╯°□°❩╯︵┻━┻
                ^

    SyntaxError: /home/nilbus/ws/rental_express/ROOT/rails/vendor/bundle/jruby/1.9/gems/sidekiq-4.2.6/lib/sidekiq/api.rb:269: Invalid char `\237' ('Ÿ') in expression
        alias_method :💣, :clear
                       ^

This patch should restore compatibility with ruby 1.9 and greater.
2016-11-22 20:39:00 -08:00
Eugene Kenny
d4b012bd8c Pass job hash to handle_exception again ()
When I moved the reloader inside the block so that any errors it raised
would be handled properly, the `job` local variable was pushed into a
nested scope, which meant it wasn't accessible from the rescue block any
more. This changed the meaning of `job` in that rescue block from the
local variable to the `attr_reader` with the same name.

We don't need to reload the application before parsing the job payload,
so we can move this work outside the reloader block so that the job hash
is accessible in the rescue block again.
2016-11-06 13:11:07 -08:00
Eugene Kenny
5e07c8d6dc Handle errors raised by the reloader ()
The reloader might raise an error instead of yielding control. If this
happens, the job will silently fail to run, without being reenqueued and
without logging any indication of what happened.

This change doesn't prevent the job from being lost, but at least if the
error handlers are called it will be possible to diagnose the problem.
2016-10-28 20:41:06 -07:00
inkstak
f53c59f58f Allow to disable sessions ()
* Allow to disable sessions

* Set sessions to false or to an hash

* Tests sessions settings

* Remove unnecessary code

* Add instance setters to Sidekiq::Web
2016-10-14 09:51:13 -07:00
Samwise Wang
6b14010199 Fix the error in worker#perform_in about interval type ()
Situation:
We are using Sidekiq Pro with ActiveSupport.
When I passed a object which is ActiveSupport::TimeWithZone to perform_at,
`TypeError: can't convert ActiveSupport::TimeWithZone into an exact
number` has occurred.

Problem:
Time can't plus a ActiveSupport::TimeWithZone object.

Solution:
We can transform any Time object to float, and use it to compare and
calculate.
2016-09-30 02:31:08 -07:00