Closed gitawego closed 6 years ago
Facing this in 2.0.2 also.
Yes I am facing this issue in version 2.0.2. But it works fine in 1.x version.
Same here. I switched to 1.x and everything works fine.
That's odd right? Because I doubt it would have been released with failing tests, yet the tests fail spectacularly (Mongo 3.4).
Actually, everything works great once I initialized my replica set, as I should have.
For any newbies out there (such as myself) make sure you keep the /local
database as you're reading from the local.opslog.<rsId>
capped collection. I thought for some reason that I needed to connect to the database with the collection I wanted to tail, and also tried capping that collection, but no such need.
Encountered this error and was able to solve by adding &authSource=admin
to the end of my connection string. My user is located in my admin database, but this package needs to connect to the /local
database to work correctly. Hope this helps someone else.
This is still failing as of v2.0.2 and MongoDB 3.4.1 (no replicas, basic mongod) --- Anyone have any alternative ideas to try out?
const oplog = MongoOplog('mongodb://127.0.0.1:27017/test');
oplog.tail(); // ERROR!
MongoError: No more documents in tailed cursor
at Function.MongoError.create (node_modules/mongodb-core/lib/error.js:31:11)
at nextFunction (node_modules/mongodb-core/lib/cursor.js:644:50)
at node_modules/mongodb-core/lib/cursor.js:593:7
at queryCallback (node_modules/mongodb-core/lib/cursor.js:232:18)
at node_modules/mongodb-core/lib/connection/pool.js:461:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Ok, so, after reading the source, mongo-oplog
wants to connect to the local
database because that's where the replicaSet keeps its oplog.rs
collection. IMO, because of the poor error description, we're led to believe we've reached the end-of-collection when in fact, we've totally tried to do one of two things:
To the first, it would be a nice-to-have if the package scripts could detect whether the instance of mongod is a replica and report a fashionable error to users.
To the second, it would be nice-to-have the package detect whether the database is 'local' and if not, suggest that it must be if you'd like to track the oplog.
Once I created a replica set and connected to the 'local' db on the primary node (the only node, truthfully) mongo-oplog works like a charm.
I documented how to spin up a replica set for oplogging here: http://stackoverflow.com/questions/29540909/finding-each-new-document-in-mongodb-oplog-collection-using-nodejs-does-not-work/43195977#43195977
@toszter I read your answer here
I am not seeing how it's different than the directions in the README for this project, beyond the usage of the --fork
option (I don't currently know what the --fork option does).
I had this same issue, I guess it wasn't clear to me that I needed to connect to the local DB, not the DB I was watching.
Also, I needed to initialize the DB for usage as a replica master. I wrote this in Node, and took me a while to figure out how to do it - I figure this may be helpful for someone:
async _setupDb(){
var db = await require("db").connect();
// Here we setup replication
try {
var status = await db.admin().command({replSetGetStatus: {}});
}catch(e){
log.info("Configuring Replicaset");
await db.admin().command({replSetInitiate: {}});
log.info("Waiting to become Primary…");
await new Promise(resolve => setTimeout(resolve, 3000));
}
}
Hi guys, I improved the readme file with better instructions on how to configure replica set. Hope this helps in future! https://github.com/cayasso/mongo-oplog/commit/fd9703c8be4fea5d7e0b968b35365c0908312c5e
Ran into this issue again. A No oplog.rs collection in this database
error early on would help a lot :smiley:
For any newbies out there (such as myself) make sure you keep the
/local
database as you're reading from thelocal.opslog.<rsId>
capped collection. I thought for some reason that I needed to connect to the database with the collection I wanted to tail, and also tried capping that collection, but no such need.
thank you, you are a legend!!!
&authSource=admin
this solve my issue
the 2.x version gives always this error:
No more documents in tailed cursor
,no such problem at all for v1.x