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

Removing ActiveJob::DeserializationError as a default ignored exception #1071

Closed
calvinhughes opened this issue Oct 18, 2020 · 5 comments · Fixed by #1180
Closed

Removing ActiveJob::DeserializationError as a default ignored exception #1071

calvinhughes opened this issue Oct 18, 2020 · 5 comments · Fixed by #1180

Comments

@calvinhughes
Copy link
Contributor

calvinhughes commented Oct 18, 2020

Summary

Recently in an ActiveJob worker we faced an issue where an exception was raised during deserialization of the arguments due to some database connection issues. This raised an ActiveJob::DeserializationError exception, which was caused by the following:

ActiveJob::DeserializationError Error while trying to deserialize arguments: PG::ConnectionBad: PQsocket() can't get socket descriptor

Because the ActiveJob::DeserializationError is ignored by default then this was not sent to Sentry.

The exception was added due to #701 and #642 where it was assumed that this is only raised when a record cannot be found but like the case above this is not the case. It's easy enough to fix in a particular app as it can just be removed from the default ignored exceptions but I feel like it could trip up new users of the gem using ActiveJob.

It would be great if we could somehow report these legitimate errors, and still ignore the NotFound type errors due to the intentioned lined out in the issues above.


We have the inspect_exception_causes_for_exclusion config option for the SDK. I understand that was added to not change the behaviour for existing users, but are there any plans for making that the default in the future?

If there are, I suppose we could just remove ActiveJob::DeserializationError when that happens as the NotFound style deserialization errors would be caught via ActiveRecord::RecordNotFound through the ExceptionCauseChain middleware.

Or if it remains solely to avoid the SentryJob example breaking when it isn't able to find a record, an alternative could be to remove it and update the async example to discard the job upon encountering a deserialization error via discard_on.

Wondered what your thoughts were, especially as the gem is currently undergoing a revamp. Happy to help with a PR too!

@st0012 st0012 modified the milestones: 4.0.0, 4.1.0 Oct 23, 2020
@st0012 st0012 self-assigned this Oct 23, 2020
@agrobbin
Copy link
Contributor

@calvinhughes you took the words right out of my mouth! We actually just ran into a very similar issue with Sentry ignoring ActiveJob::DeserializationError. In our case it was wrapping ActiveRecord::ConnectionTimeoutError:

ActiveJob::DeserializationError: Error while trying to deserialize arguments: could not obtain a connection from the pool within 5.000 seconds (waited 5.295 seconds); all pooled connections were in use

We don't discard jobs from Active Job when DeserializationError is raised, instead we discard on the more specific ActiveRecord::RecordNotFound exception, which is the only case we could think of where we don't want to retry the job or track it in Sentry:

# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
  # Automatically retry jobs that encountered a deadlock
  # retry_on ActiveRecord::Deadlocked

  # Most jobs are safe to ignore if the underlying records are no longer available
  discard_on ActiveRecord::RecordNotFound
end

@st0012
Copy link
Collaborator

st0012 commented Nov 1, 2020

@calvinhughes @agrobbin thanks for both of your opinions! since ActiveJob::DeserializationError is essentially a wrapper exception, excluding it to avoid infinite loop seems a bit too rough to me. however, because it's been in the codebase for 3 years and the 3.x version has entered maintenance mode, I want to avoid removing it directly from the old sdk, which feels risky to me.

so here's what I'm going to do:

wdyt?

@agrobbin
Copy link
Contributor

agrobbin commented Nov 1, 2020

That seems like a great plan to me @st0012!

@calvinhughes
Copy link
Contributor Author

@st0012 Sounds great!

@st0012 st0012 modified the milestones: 4.1.0, 4.2.0 Dec 15, 2020
st0012 added a commit that referenced this issue Jan 3, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 3, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
@st0012
Copy link
Collaborator

st0012 commented Jan 3, 2021

sorry for the long waiting. I've added #1180 to address this issue (in the new SDK) 🙂

st0012 added a commit that referenced this issue Jan 3, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 3, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 3, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 3, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 3, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 3, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 11, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 11, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 11, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 11, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 15, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 15, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 15, 2021
With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.
st0012 added a commit that referenced this issue Jan 15, 2021
Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.
st0012 added a commit that referenced this issue Jan 15, 2021
…lizationError (#1180)

* Turn on inspect_exception_causes_for_exclusion by default

With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.

* Remove ActiveJob::DeserializationError from ignored list

Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.

* Update async document

* Update changelog
st0012 added a commit that referenced this issue Jan 17, 2021
…lizationError (#1180)

* Turn on inspect_exception_causes_for_exclusion by default

With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.

* Remove ActiveJob::DeserializationError from ignored list

Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.

* Update async document

* Update changelog
@st0012 st0012 closed this as completed Feb 3, 2021
st0012 added a commit that referenced this issue Feb 3, 2021
* Add ThreadsInterface (#1178)

* Add ThreadsInterface

* Update changelog

* Inspect exception cause by default & don't exclude ActiveJob::DeserializationError  (#1180)

* Turn on inspect_exception_causes_for_exclusion by default

With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.

* Remove ActiveJob::DeserializationError from ignored list

Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.

* Update async document

* Update changelog

* Make sentry-rails a Rails engine and provide default job class for async (#1181)

* Make sentry-rails a Rails engine too

* Add Sentry::SendEventJob

Instead of letting users defining their SentryJob class, we should
provide a default job class for them.

* Update document and example for the new job class

* Update changelog

* Add configuration option for trusted proxies (#1126)

* Add configuration option for trusted proxies

* Add `trusted_proxies` configuration option to sentry-ruby
* Add existing ActionDispatch `trusted_proxies` values

* Address some PR feedback

* Isolate trusted proxy test configuration
* Add comments to explain why we reverse the forwarded_for ip list
* Call `uniq` on the trusted proxy list
* Rename `filter_local_addresses(ips) to filter_trusted_proxy_addresses(ips)

* Remove duplicated hash entry

* Update some tests after PR feedback

* retrigger checks

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Only define SendEventJob when ActiveJob is defined

* Allow users to configure ActiveJob adapters to ignore (#1256)

* Allow users to configure ActiveJob adapters to ignore

* Update changelog

* Add sidekiq adapter to sentry-rails' ignored adapters list (#1257)

* Add sidekiq adapter to sentry-rails' ignored adapters list

* Update changelog

* Tag queue name and jid on sidekiq events (#1258)

* Add queue name and jid to event tags

* Update changelog

* Tag job_id and provider_job_id on ActiveJob events (#1259)

* Refactor/test ActiveJob's context data

* Tag job_id and provider_job_id on ActiveJob events

* Update changelog

* Add ability to have many post initialization callbacks (#1261)

* Add ability to have many post initialization callbacks

* Revert version bumping, fix codestyle and rewrite rspec test

* Remove dependenciy bumping from sentry-sidekiq

* Add entries to CHANGELOG

* Support config.before_breadcrumb (#1253)

* Support config.before_breadcrumb

Example:

```
config.before_breadcrumb = lambda do |breadcrumb, hint|
  breadcrumb.message = "foo"
  breadcrumb
end
```

* Update changelog

* Update sentry-ruby's changelog

* Update sentry-rails' changelog

* Update sentry-sidekiq's changelog

* Rename ignored_active_job_adapters to skippable_job_adapters (#1264)

* Update sentry-ruby's changelog

Co-authored-by: Jon-Erik Schneiderhan <45184220+jeschneiderhan@users.noreply.github.com>
Co-authored-by: Valentine Kiselev <mrexox@outlook.com>
st0012 added a commit that referenced this issue Feb 3, 2021
…lizationError (#1180)

* Turn on inspect_exception_causes_for_exclusion by default

With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.

* Remove ActiveJob::DeserializationError from ignored list

Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.

* Update async document

* Update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants