Closed nickw closed 11 years ago
Blast. Admittedly, I totally forgot to update the config section of the docs. I need to put this into production this week as well, so I will have a play and see if I can't sort it out.
Have you tried setting the 'retries' to zero - at least temporarily?
token :length => 3, :retry => 0
That might do the trick whilst I get a patch together.
Just out of curiosity, have you created your indexes in development and production? I've tried both your configuration setups and can't seem to replicate the issue.
My other hunch is that perhaps there's something else in your save chain that is throwing a Moped::Errors::OperationFailure
- which Mongoid::Token is (erroneously) assuming is a token collision.
Incidentely, I don't think you need to explicitly turn safe mode on anymore for Mongoid::Token, since it uses the new with
method in Mongoid 3 to enforce safe mode on save.
Setting retry: 0
fixes it for now.
I considered that the indexes might be a culprit as well, but creating them had no effect. I'll do some digging re: something else in the save chain throwing the error.
FYI, here are the other Mongoid gems I'm using:
gem "mongoid", "~> 3.0.1"
gem "bson_ext", "~> 1.6.4"
gem "mongoid_token", "~> 1.1.0"
gem "voteable_mongo", git: "git://github.com/CrowdHall/voteable_mongo.git"
gem "mongo_followable", git: "git://github.com/CrowdHall/mongo_followable.git"
gem "mongoid-searchable", git: "git://github.com/CrowdHall/mongoid-searchable.git"
gem "mongoid_timeline_fu", "~> 0.0.3"
gem "profanity_filter", "~> 0.1.1", require: "profanity_filter"
Thanks for the update, good to know there's a temporary solution at least.
I'm working on refactoring the collision hander to double-check that it is the token that's causing the issue - which should help narrow down the issue you're having. Hopefully I can have this sorted this week - if all goes according to plan.
Okay - I think this one is (finally) sorted now. There is now better support for handing the collision detection, vs. other Moped/Mongoid exceptions.
I'm kinda of two minds as to whether to remove the collision detection all together in the next major release - i'm not really sure if anyone actually has any interest in it.
The gem is working fine locally, but when deployed to Heroku I consistently get CollisionRetriesExceeded exceptions - even though the token is getting generated correctly and the data is successfully saving to MongoHQ.
I don't know if this is related, but the README mentions a config value that no longer exists in Mongoid 3.x
To take advantage of this, one must set persist_in_safe_mode = true in your Mongoid configuration.
I've tried changing my Mongoid config to:
and: