meteor / meteor/meteor

`oplogIncludeCollections` option breaks oplog tailing performance

Open
#13,244 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

idle Project:Mongo Driver
Dominant language
JavaScript
Stars
44.8k
Forks
5.2k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

The `oplogIncludeCollections` option for oplog tailing introduced in 2.16.0 seems very useful for us as most database updates are made to collections we don't subscribe to. Unfortunately, adding the option made our application stop working when the oplog contains sufficiently many entries (~30M does the trick).

This seems to be because the option changes the query to just a [top-level `$and`](https://github.com/meteor/meteor/blob/7da5b32d7882b510df8aa2002f891fc4e1ae1126/packages/mongo/oplog_tailing.js#L286). However, this means there is no top-level `ts` property on the selector, which means that [the `oplogReplay` flag is not set](https://github.com/meteor/meteor/blob/7da5b32d7882b510df8aa2002f891fc4e1ae1126/packages/mongo/mongo_driver.js#L1028).

Moving the `ts` selector outside of the `$and` fixes the problem.

Haven't tested with Meteor 3 yet, but as the code is unchanged (above links are to the latest revision), I assume the problem still exists.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/mongo/oplog_tailing.js at the linked selector construction, then trace packages/mongo/mongo_driver.js at the linked oplogReplay check. Reproduce the problem with an oplog containing roughly 30M entries and oplogIncludeCollections enabled. Done means collection filtering no longer prevents the intended oplog-tailing performance behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
backend, databases, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.