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

Error in oplog callback Error: Buffer inexplicably empty #2274

Closed
giavjeko opened this Issue Jul 3, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@giavjeko

giavjeko commented Jul 3, 2014

I'm getting the following error:

Error in oplog callback Error: Buffer inexplicably empty
     at _.extend._removePublished (packages/mongo-livedata/oplog_observe_driver.js:240)
     at _.extend._removeMatching (packages/mongo-livedata/oplog_observe_driver.js:330)
     at _.extend._handleOplogEntrySteadyOrFetching (packages/mongo-livedata/oplog_observe_driver.js:499)
     at packages/mongo-livedata/oplog_observe_driver.js:118
     at packages/mongo-livedata/oplog_observe_driver.js:16
     at Object.Meteor._noYieldsAllowed (packages/meteor/fiber_helpers.js:15)
     at packages/mongo-livedata/oplog_observe_driver.js:106
     at packages/mongo-livedata/oplog_tailing.js:79
     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:89)
     at packages/meteor/dynamics_nodejs.js:102

Reproducible example is available in this repository. It happens on both master and devel branches.

cc @mitar

@giavjeko

This comment has been minimized.

giavjeko commented Jul 3, 2014

In order to reproduce the error, a client must be subscribed to TestCollection. After starting server, it will wait for 10 seconds so that you have time to open it in browser.

So the steps to reproduce the error are:

  1. Run server
  2. Open the page in browser
  3. 10 seconds after the server has started an error will occur.
@Slava

This comment has been minimized.

Member

Slava commented Jul 3, 2014

It is not crashing if you wrap the code inside the for loop into a function:

function fillCollection(count) {
  for(var i = 0; i < count; i++) {
    (function (i) {
      TestCollection.insert({
        data: "Dummy data #" + i,
        sortField: i,
        toDelete: true
      })
    })(i)
  }
}

The oplog tailing code gets confused as the passed sortField field gets modified? I think it is related to the for-loop scoping: http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example

@giavjeko

This comment has been minimized.

giavjeko commented Jul 3, 2014

Are you sure it is not crashing? I get the same error even if I insert dummy data without loop (multiple static queries).

@Slava

This comment has been minimized.

Member

Slava commented Jul 3, 2014

@giavjeko https://github.com/Slava/meteor-issue-2274 - here is my fork that doesn't crash for me.

I think it is still a bug, we probably don't deep-clone the input document somewhere.

@giavjeko

This comment has been minimized.

giavjeko commented Jul 3, 2014

Your fork crashes for me as well. It won't crash if there is no client, or if client connects after those 10 seconds I mentioned.

I'm not sure if it is of any help to you, but this error occurs only when a published document gets removed from collection, and if it is published with a query containing sort and limit. Also, it works just fine if I remove published element specifically by _id. It crashes if I use flags like I did in the example.

@glasser glasser closed this in 8e005ca Jul 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment