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

MongoDB 3.6 --> Mongo::Error::OperationFailure: Unknown modifier: $pushAll #189

Open
Startouf opened this issue Sep 17, 2018 · 6 comments
Open

Comments

@Startouf
Copy link

It seems that the $pushAll operator was removed in MongoDB 3.6, making systematic crashes when trying to update an uploader

My gem/server versions

  • MongoDB server v3.6.11
  • mongoid 6.1.1
  • mongo 2.6.2
  • Rails/activesupport 5.0.5

Here is a full stack trace. At first sight it doesn not seem related to mongoid carrierwave, but the bug only occurs when I try to add an image file so I'm not sure what to think of it

Mongo::Error::OperationFailure: Unknown modifier: $pushAll (9)
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/operation/result.rb:267:in `raise_operation_failure'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/operation/result.rb:263:in `validate!'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/operation/shared/write.rb:42:in `execute'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/collection/view/writable.rb:307:in `block (2 levels) in update_one'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/retryable.rb:158:in `legacy_write_with_retry'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/retryable.rb:106:in `write_with_retry'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/collection/view/writable.rb:295:in `block in update_one'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/cluster.rb:524:in `with_session'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/client.rb:550:in `with_session'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/collection/view.rb:204:in `with_session'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongo-2.6.2/lib/mongo/collection/view/writable.rb:294:in `update_one'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/query_cache.rb:182:in `update_one_with_clear_cache'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/persistable/updatable.rb:137:in `block in update_document'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/persistable/updatable.rb:112:in `block (2 levels) in prepare_update'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:126:in `call'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
... 8 levels...
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:455:in `call'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.5/lib/active_support/callbacks.rb:90:in `run_callbacks'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/interceptable.rb:132:in `run_callbacks'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/persistable/updatable.rb:110:in `prepare_update'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/persistable/updatable.rb:132:in `update_document'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/mongoid-6.1.1/lib/mongoid/persistable/savable.rb:25:in `save'
	from (irb):38
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/railties-5.0.5/lib/rails/commands/console.rb:65:in `start'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/railties-5.0.5/lib/rails/commands/console_helper.rb:9:in `start'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/railties-5.0.5/lib/rails/commands/commands_tasks.rb:78:in `console'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/railties-5.0.5/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /websites/hermes-production/shared/bundle/ruby/2.3.0/gems/railties-5.0.5/lib/rails/commands.rb:18:in `<top (required)>'
	from bin/rails:14:in `require'
	from bin/rails:14:in `<main>'
@Startouf Startouf changed the title Mongo::Error::OperationFailure: Unknown modifier: $pushAll MongoDB 3.6 --> Mongo::Error::OperationFailure: Unknown modifier: $pushAll Sep 17, 2018
@rmm5t
Copy link
Member

rmm5t commented Sep 19, 2018

I think this is an issue with the mongoid (v6) gem itself:
https://jira.mongodb.org/browse/MONGOID-4469

Thoughts?

Edit: It looks like mongoid v7 fixes the problem. Is it possible for you to try to upgrade to that?

@Startouf
Copy link
Author

Startouf commented Oct 8, 2018

I tried but upgrading to Mongoid v7 requires that I upgrade too many other gems. Currently I'm stuck on mongoid 6.1.1 but I'll be working on the upgrade.

I also discovered another problem (which might be fixed with a mongoid upgrade) : It seems like
remove_logo! does not seem to work properly on embedded documents

model.nested_document.logo.present? # true
model.nested_document.remove_logo! # true
model.nested_document.save! # true
model.nested_document.logo.present? # false
model.reload
model.nested_document.logo.present? # true

# Note that I also tried saving directly the parent `model.save! # true` which did not work better.

It seems like the logo attributes keeps the value __old__ which causes the method .present? to return true. I did not have this bug with carrierwave < 1.x

Note that the following works :

model.nested_document.remove_attribute('logo') #=> "_old_"
model.nested_document.save!
model.nested_document.company_logo.present? #=> false

I'm not sure if I should open a ticket or wait to see if Mongoid v7 will fix that too

@niksosf
Copy link

niksosf commented Nov 6, 2018

@Startouf I had the same error and updated Mongoid to 6.4.2 and it went away. Maybe try it out since it's still on the 6.x branch?

@Startouf
Copy link
Author

Startouf commented Nov 6, 2018

@rmm5t I have migrated to Mongo v7 a couple days ago on our production app (it was quite a pain btw) and the error's gone, and it seems like @niksosf also fixed it by bumping Mongoid6, so I guess we can close ?

Or do we need to enforce some version dependency on the Gemfile to avoid this ?

@niksosf
Copy link

niksosf commented Nov 6, 2018 via email

@rmm5t
Copy link
Member

rmm5t commented Nov 6, 2018

Thanks for the updates @niksosf and @Startouf. I'm glad things were fixed by the core mongoid gem (both in the v6 and v7 branches of development).

Let me give this some thought as to whether we should modify the gemspec here or not.

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

3 participants