[SERVER-5765] query option to start tailing at the end of a capped collection Created: 04/May/12  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Comments   
Comment by David Glasser [ 17/May/13 ]

This is definitely something we would use at Meteor.

In general, it would be really nice if there was a "general" way to tail a cursor that survives when the cursor dies, without there having to be a monotonically increasing sorted field like "ts" to use for restarts.

Ideally, you would be able to do something like:

db.events.find({$startTailAt: {_id: ObjectId("1234")}).addOption(OPQUERY_TAILABLE);
and/or
db.events.find({$startTailAt: {_id: ObjectId("1234")}).addOption(OPQUERY_TAILABLE);

These would essentially do a findOne on the query given and then start tailing from there. In addition, you could do something like
db.events.find({$startTailAt: {$last: 50}}).addOption(OPQUERY_TAILABLE);
to start 50 documents from the end of the capped collection, and of course {$last: 0} would work too.

(I don't care much about the particular syntax. I just want a way to specify a query that matches a SINGLE document and starts tailing from there rather than a query that needs to match the start document AND everything after it; as well as simple ways to just do "start at the end" or "start a fixed buffer before the end". The former is good for writing a generic "keep tailable cursor going even if it dies" driver; the latter are good for use cases like "show me the last 100 log entries and then keep tailing".)

Comment by Eliot Horowitz (Inactive) [ 06/May/12 ]

Yes, something like that.
Not sure this gets you all the way to pub/sub, but closer.

Comment by Scott Hernandez (Inactive) [ 05/May/12 ]

Something like db.events.find({$tail:true}).addOption(OPQUERY_TAILABLE)?

Is this the same the requirement as something like a pub/sub api? SERVER-3385

Generated at Thu Feb 08 03:09:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.