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

Identity map not cleared #23

Closed
doxavore opened this issue Jan 19, 2012 · 7 comments
Closed

Identity map not cleared #23

doxavore opened this issue Jan 19, 2012 · 7 comments

Comments

@doxavore
Copy link

The Mongoid::IdentityMap should probably be cleared between job runs, as it is for ActiveRecord in:
https://github.com/collectiveidea/delayed_job/blob/5c7628d40c9e2e26ab2076453ab6488df3464730/lib/delayed/backend/base.rb#L92

@gurgeous
Copy link

This is a very serious issue. It causes nearly all non-trivial uses of DJ+Mongoid to fail in mysterious ways. I hacked this together as a workaround:

#
# clear Mongoid::IdentityMap before each job
#

module Delayed
  module Plugins
    class ClearIdentityMap < Plugin
      callbacks do |lifecycle|
        lifecycle.before(:invoke_job) do |worker, &block|
          Mongoid::IdentityMap.clear
        end
      end
    end
  end
end

Delayed::Worker.plugins << Delayed::Plugins::ClearIdentityMap

@doxavore
Copy link
Author

That's much cleaner than what I've been using... but I feel this should be fixed in this project. Any thoughts from @collectiveidea ? 👍

@iamnader
Copy link
Collaborator

iamnader commented Oct 5, 2012

hey guys, any thoughts on this?

@jbescoyez
Copy link

I ran into serious trouble because of this issue 👍

@ulitiy
Copy link

ulitiy commented Nov 3, 2012

+1

@sferik
Copy link
Collaborator

sferik commented Nov 3, 2012

Can someone please put together a pull request with tests that fail on master?

@srleo
Copy link
Contributor

srleo commented Apr 23, 2013

I put the code from @gurgeous into a pull request. #38

iamnader added a commit that referenced this issue May 9, 2013
Fixes issue #23 identity map not cleared
@iamnader iamnader closed this as completed May 9, 2013
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

No branches or pull requests

7 participants