Giter VIP home page Giter VIP logo

Comments (11)

holden avatar holden commented on June 29, 2024

It just noticed that it is recording the version number and modifier in the current record, just no associated tracker.

from mongoid-history.

dblock avatar dblock commented on June 29, 2024

Did it stop working with the mongoid upgrade? I would get the code for mongoid-history, update the mongoid reference and try to run all tests first, see if anything fails.

from mongoid-history.

holden avatar holden commented on June 29, 2024

I'm not sure if it was the mongoid update or not, it doesn't seem likely, I didn't notice it wasn't recording new versions for several days. So it could be anything. All of my tests pass and it works 100% on my development machine.

I cloned mongoid-history and upped the gem file for mongoid from 3.0.4 to 3.0.13. 85 examples, 0 failures.

I downloaded the mongo db from the server, to be sure everything was the same, the same result. It just stopped working in production. No idea why or how to resolve it.

from mongoid-history.

dblock avatar dblock commented on June 29, 2024

Try running your app with RAILS_ENV=production locally or something like that for a repro. Then, look at how the versioning is implemented, maybe it will give you a clue.

from mongoid-history.

holden avatar holden commented on June 29, 2024

Running it in production on my local machine also works fine. It must be something specific with either heroku or mongohq, but I can't imagine what that could be, how it could have occurred or how to debug it further. ;-(

from mongoid-history.

dblock avatar dblock commented on June 29, 2024

Open a heroku console and get a small repro.

Enable logging with

Moped.logger = Logger.new(STDOUT)
Moped.logger.level = Logger::DEBUG

Redo the repro, capture database queries.

from mongoid-history.

holden avatar holden commented on June 29, 2024

Here's what I see when I do that.

Create it...

c=Article.create!(:title => "This is a title", :excerpt => "This is a brief desc.", :content => "here's some content", :user_id => User.first.id)
  MOPED: 10.254.66.79:27082 QUERY        database=app3383995 collection=users selector={"$query"=>{}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (1.4637ms)
  MOPED: 10.254.66.79:27082 QUERY        database=app3383995 collection=articles selector={"_slugs"=>{"$all"=>[/^this\-is\-a\-title(?:-(\d+))?$/]}, "_id"=>{"$ne"=>"50ad38d2ebda22048b000006"}} flags=[:slave_ok] limit=0 skip=0 fields=nil (1.4756ms)

MOPED: 10.254.66.79:27082 INSERT       database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad38d2ebda22048b000007", "association_chain"=>[{"name"=>"Article", "id"=>"50ad38d2ebda22048b000006"}], "scope"=>"article", "original"=>{}, "modified"=>{"state"=>"draft", "_slugs"=>["this-is-a-title-1"], "city_ids"=>[], "title"=>"This is a title", "excerpt"=>"This is a brief desc.", "content"=>"here's some content", "user_id"=>"4f69a0dfb0ac200001000001"}, "version"=>1, "action"=>"create", "updated_at"=>2012-11-21 20:25:54 UTC, "created_at"=>2012-11-21 20:25:54 UTC}] flags=[] (0.1450ms)
  MOPED: 10.254.66.79:27082 INSERT       database=app3383995 collection=articles documents=[{"state"=>"draft", "_id"=>"50ad38d2ebda22048b000006", "_slugs"=>["this-is-a-title-1"], "city_ids"=>[], "title"=>"This is a title", "excerpt"=>"This is a brief desc.", "content"=>"here's some content", "user_id"=>"4f69a0dfb0ac200001000001", "updated_at"=>2012-11-21 20:25:54 UTC, "created_at"=>2012-11-21 20:25:54 UTC, "version"=>1}] flags=[] (0.0994ms)
=> #<Article _id: 50ad38d2ebda22048b000006, _type: nil, _slugs: ["this-is-a-title-1"], created_at: 2012-11-21 20:25:54 UTC, updated_at: 2012-11-21 20:25:54 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "here's some content", published_at: nil, tags_array: nil, categories_array: nil, version: 1, modifier_id: nil, state: "draft">

First update:

#<Article _id: 50ad354aebda22048b000001, _type: nil, _slugs: ["this-is-a-title"], created_at: 2012-11-21 20:10:51 UTC, updated_at: 2012-11-21 20:10:51 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "here's some content", published_at: nil, tags_array: nil, categories_array: nil, version: 1, modifier_id: nil, state: "draft">
irb(main):006:0> c.update_attributes(:content => "This should fire the version")

MOPED: 10.254.66.79:27082 INSERT       database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad3591ebda22048b000003", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"here's some content"}, "modified"=>{"content"=>"This should fire the version"}, "version"=>2, "action"=>"update", "updated_at"=>2012-11-21 20:12:01 UTC, "created_at"=>2012-11-21 20:12:01 UTC}] flags=[] (0.2418ms)
MOPED: 10.254.66.79:27082 UPDATE       database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the version", "updated_at"=>2012-11-21 20:12:01 UTC, "version"=>2}} flags=[] (0.0978ms)

Second update:

MOPED: 10.254.66.79:27082 INSERT       database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad35e2ebda22048b000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the version"}, "modified"=>{"content"=>"This should fire the another version"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 20:13:22 UTC, "created_at"=>2012-11-21 20:13:22 UTC}] flags=[] (0.1411ms)
MOPED: 10.254.66.79:27082 UPDATE       database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the another version", "updated_at"=>2012-11-21 20:13:22 UTC, "version"=>3}} flags=[] (0.0970ms)

#<Article _id: 50ad354aebda22048b000001, _type: nil, _slugs: ["this-is-a-title"], created_at: 2012-11-21 20:10:51 UTC, updated_at: 2012-11-21 20:13:22 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "This should fire the another version", published_at: nil, tags_array: nil, categories_array: nil, version: 3, modifier_id: nil, state: "draft">
irb(main):009:0> c.history_tracks
=> #<Mongoid::Criteria
   selector: {"scope"=>"article", "association_chain"=>{"$elemMatch"=>{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}}},
   options:  {},
   class:    HistoryTracker,
   embedded: false>

irb(main):010:0> c.history_tracks.size
  MOPED: 10.254.66.79:27082 COMMAND      database=app3383995 command={:count=>"history_trackers", :query=>{"scope"=>"article", "association_chain"=>{"$elemMatch"=>{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}}}} (8.2543ms)
=> 0
irb(main):011:0> 

from mongoid-history.

dblock avatar dblock commented on June 29, 2024

Do the same in your local environment that works. What's the difference?

from mongoid-history.

holden avatar holden commented on June 29, 2024

They're almost identical adding to the weirdness.

MOPED: 10.254.66.79:27082 INSERT       database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad35e2ebda22048b000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the version"}, "modified"=>{"content"=>"This should fire the another version"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 20:13:22 UTC, "created_at"=>2012-11-21 20:13:22 UTC}] flags=[] (0.1411ms)
MOPED: 10.254.66.79:27082 UPDATE       database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the another version", "updated_at"=>2012-11-21 20:13:22 UTC, "version"=>3}} flags=[] (0.0970ms)

MOPED: 127.0.0.1:27017 INSERT       database=recordapp collection=history_trackers documents=[{"_id"=>"50ad5f55cd1ea59a5e000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad5e06cd1ea59a5e000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the another version"}, "modified"=>{"content"=>"This should fire the another version sdfsdfsdfsd"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 23:10:13 UTC, "created_at"=>2012-11-21 23:10:13 UTC}] flags=[] (0.2029ms)
MOPED: 127.0.0.1:27017 UPDATE       database=recordapp collection=articles selector={"_id"=>"50ad5e06cd1ea59a5e000001"} update={"$set"=>{"content"=>"This should fire the another version sdfsdfsdfsd", "updated_at"=>2012-11-21 23:10:13 UTC, "version"=>3}} flags=[] (0.1280ms)

from mongoid-history.

holden avatar holden commented on June 29, 2024

Mystery solved. Or at least identified. By process of elimination, I realized that the mongoid_fulltext search was the cause. I removed it, and now it works.

It makes a large number of calls each time a document is created or updated, I thought to take it out staring at the list of updates it makes. Somehow it interfered with the history tracking but only on the server. No idea why.

Thanks for the tips!

from mongoid-history.

dblock avatar dblock commented on June 29, 2024

I am going to close this, since it seems to be some combination of issue with another gem, but it would be great if you found time to track the root cause.

from mongoid-history.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.