Skip to content

Comments

chore: remove left over oplog code#38313

Merged
kodiakhq[bot] merged 4 commits intodevelopfrom
remove-oplog-stuff
Feb 9, 2026
Merged

chore: remove left over oplog code#38313
kodiakhq[bot] merged 4 commits intodevelopfrom
remove-oplog-stuff

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Jan 23, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor
    • Migrated internal reactivity from oplog-based mechanisms to a token-driven approach for session and user-change handling.
    • Removed oplog-related monitoring metrics and the automatic observer recovery mechanism.
    • Streamlined processing of login service configuration and user session updates for more consistent behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 23, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

⚠️ No Changeset found

Latest commit: 64d8ef9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Removes oplog-based observer recovery and metrics, disables oplog unconditionally, and introduces a token-driven reactivity system that monkey-patches observeChanges to manage per-user token callbacks and session invalidation.

Changes

Cohort / File(s) Summary
Oplog observer fix removed
apps/meteor/app/lib/server/lib/index.ts, apps/meteor/app/lib/server/lib/meteorFixes.js
Deleted internal import and removed the periodic observer recovery module that scanned MongoInternals._observeMultiplexers and forced stuck QUERYING observers back to STEADY.
Metrics removed
apps/meteor/app/metrics/server/lib/collectMetrics.ts, apps/meteor/app/metrics/server/lib/metrics.ts
Removed MongoInternals usage and oplog-related metrics: oplogEnabled, oplogQueue, and oplog counter; code paths gathering oplog queue/enablement removed.
Oplog config toggled off
apps/meteor/packages/rocketchat-mongo-config/server/index.js
Removed environment-based conditional and now always disables oplog tailing by assigning Package['disable-oplog'] = {} unconditionally.
New token-based reactivity
apps/meteor/server/services/meteor/userReactivity.ts
Adds monkey-patch of Connection._observeChanges, global serviceConfigCallbacks, per-user token callback maps, processOnChange(diff, id) export, and stop/unregister semantics for token-driven observeChanges handling.
Service integration
apps/meteor/server/services/meteor/service.ts
Removed oplog-based reactivity overrides and local oplog guards; integrated processOnChange and serviceConfigCallbacks paths for watch.users and watch.loginServiceConfiguration.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client Observer
    participant Connection as Connection._observeChanges
    participant UserReactivity as userReactivity
    participant Mongo as Mongo Users Collection
    participant Service as Meteor Service

    Client->>Connection: start observeChanges(users, fields:{tokens})
    Connection->>UserReactivity: delegate observe hook
    UserReactivity->>Mongo: initial fetch matching records
    Mongo-->>UserReactivity: return records
    UserReactivity->>UserReactivity: store per-user hashed-token callbacks
    UserReactivity-->>Client: emit added/ready events

    Service->>UserReactivity: processOnChange(diff, userId)
    UserReactivity->>UserReactivity: detect removed tokens for userId
    UserReactivity-->>Client: emit removed callbacks (session invalidation)
    Client->>Service: client handles invalidation
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested Labels

stat: ready to merge, stat: QA assured

Suggested Reviewers

  • ggazzo
  • rodrigok

Poem

🐰 I nibbled old oplog dust away,
Tokens now hop where observers play,
Callbacks per user, tidy and neat,
Sessions drop softly—no frantic repeat,
A rabbit cheers for reactivity's day! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: remove left over oplog code' accurately describes the main change: removing oplog-related code and dependencies across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-oplog-stuff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 78.57143% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.39%. Comparing base (eb366e7) to head (64d8ef9).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38313      +/-   ##
===========================================
- Coverage    70.39%   70.39%   -0.01%     
===========================================
  Files         3161     3162       +1     
  Lines       110654   110650       -4     
  Branches     19892    19920      +28     
===========================================
- Hits         77895    77889       -6     
- Misses       30731    30735       +4     
+ Partials      2028     2026       -2     
Flag Coverage Δ
e2e 60.34% <ø> (-0.03%) ⬇️
e2e-api 47.84% <78.57%> (+0.07%) ⬆️
unit 71.39% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "02/09 13:07 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38313
  • Baseline: develop
  • Timestamp: 2026-02-09 13:07:26 UTC
  • Historical data points: 30

Updated: Mon, 09 Feb 2026 13:07:27 GMT

@sampaiodiego sampaiodiego changed the title chore: remove left over oplog code chore remove left over oplog code Jan 26, 2026
@sampaiodiego sampaiodiego changed the title chore remove left over oplog code chore: remove left over oplog code Jan 26, 2026
@sampaiodiego sampaiodiego marked this pull request as ready for review January 29, 2026 17:03
@sampaiodiego sampaiodiego requested a review from a team as a code owner January 29, 2026 17:03
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/server/services/meteor/userReactivity.ts`:
- Around line 17-72: The override
MongoInternals.Connection.prototype._observeChanges must be synchronous and
return a handle immediately (not an async function); change the async function
to a normal function that starts the initial DB query asynchronously,
immediately returns an object with stop(), isReady (initially false) and
isReadyPromise (a Promise resolved when the initial query completes), and when
the async query finishes set isReady=true and resolve isReadyPromise and invoke
callbacks.added as currently implemented; also forward additional query options
(e.g., sort, limit, skip, hint, etc.) from the options param when calling
mongo.rawCollection(...).find(...) so you don't only pass projection/fields;
keep the userCallbacks and serviceConfigCallbacks logic but ensure stop() can
cancel/cleanup even if called before the initial query resolves.
🧹 Nitpick comments (3)
apps/meteor/packages/rocketchat-mongo-config/server/index.js (1)

7-8: Drop the inline comment to match repo guidance.
The assignment is self-explanatory; keep the rationale out of the implementation.

🧹 Suggested change
-// we always want Meteor to disable oplog tailing
 Package['disable-oplog'] = {};
As per coding guidelines, Avoid code comments in the implementation.
apps/meteor/server/services/meteor/userReactivity.ts (2)

11-16: Remove inline comments and the commented-out debug line.
These are implementation notes; keep code comment-free per repo guidance.

🧹 Suggested change
-// Stores the callbacks for the disconnection reactivity bellow
 const userCallbacks = new Map();

-// Overrides the native observe changes to prevent database polling and stores the callbacks
-// for the users' tokens to re-implement the reactivity based on our database listeners
 const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
@@
-	// console.error('Connection.Collection.prototype._observeChanges', collectionName, selector, options);
@@
-// Re-implement meteor's reactivity that uses observe to disconnect sessions when the token
-// associated was removed
 export const processOnChange = (diff: Record<string, any>, id: string): void => {
As per coding guidelines, Avoid code comments in the implementation.

Also applies to: 33-33, 74-76


83-90: Clean up empty per-user callback sets.
After removals, empty sets remain in userCallbacks; deleting them avoids unnecessary retention.

🧹 Suggested change
 	if (cbs) {
 		[...cbs]
 			.filter(({ hashedToken }) => tokens === undefined || !tokens.includes(hashedToken))
 			.forEach((item) => {
 				item.callbacks.removed(id);
 				cbs.delete(item);
 			});
+		if (cbs.size === 0) {
+			userCallbacks.delete(id);
+		}
 	}

Co-authored-by: Kevin Aleman <kaleman960@gmail.com>
@ggazzo ggazzo added this to the 8.2.0 milestone Feb 2, 2026
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Feb 2, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 2, 2026
@kodiakhq kodiakhq bot merged commit 13433b1 into develop Feb 9, 2026
44 checks passed
@kodiakhq kodiakhq bot deleted the remove-oplog-stuff branch February 9, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants