How to find out what updates users collection?

Hi,

I found that the user collection is updated every 10 seconds on a production server (with all negative performance issues caused by it). On a localhost nothing similar happens.

How can I found out what’s updating this collection? I use standard packages for Google and FB accounts. Maybe something related to this?

It also seems that no data in the collection is actually changed, or for sure not all 10 user records as shown below.

Screenshot from Kadira debug:

Strange, any changes in access rights for tokens or so which would force users to relogin ?
Other than that just some kind of user-status package come to my mind.
Maybe if you link to page, or if you paste output of console.log(Object.keys(Package));

I also thinking about something from that services pushing updates… but don’t know how to debug it… Is there any hook possible to track updates’ down?

I’ve also commented Accounts.onLogin() hook to save last login time. But it didin’t help.

Packages:
[“es5-shim”, “underscore”, “meteor”, “meteor-base”, “mobile-experience”, “base64”, “ejson”, “check”, “babel-compiler”, “ecmascript”, “babel-runtime”, “ecmascript-runtime”, “promise”, “random”, “id-map”, “ordered-dict”, “tracker”, “mongo-id”, “diff-sequence”, “geojson-utils”, “minimongo”, “retry”, “ddp-common”, “reload”, “ddp-client”, “ddp”, “ddp-server”, “mongo”, “blaze-html-templates”, “reactive-dict”, “session”, “jquery”, “standard-minifiers”, “rate-limit”, “ddp-rate-limiter”, “localstorage”, “callback-hook”, “deps”, “htmljs”, “observe-sequence”, “reactive-var”, “blaze”, “accounts-base”, “service-configuration”, “spacebars”, “templating”, “url”, “oauth”, “accounts-oauth”, “npm-bcrypt”, “sha”, “srp”, “accounts-password”, “less”, “accounts-ui-unstyled”, “accounts-ui”, “oauth2”, “google”, “accounts-google”, “tomi:upload-server”, “tomi:upload-jquery”, “rajit:bootstrap3-datepicker”, “gfk:notifications”, “gfk:server-messages”, “rgnevashev:bootstrap-slider”, “meteorhacks:kadira”, “kadira:debug”, “ui”, “raix:handlebar-helpers”, “dispatch:spinner”, “cosmos:browserify”, “kadira:flow-router”, “kadira:blaze-layout”, “coffeescript”, “zimme:active-route”, “arillo:flow-router-helpers”, “natestrauser:font-awesome”, “facebook”, “accounts-facebook”, “webapp”, “livedata”, “hot-code-push”, “launch-screen”, “autoupdate”]

I see you have two queries which are updating each 10 sec. One is changing 1 document, another 10 docs. Can you see what’s the difference?

Do you see same users collection updates even there are no active clients (open browser tabs with it)?

How do you deploy? Mup, mupx, your own scripts?

If you use the collection hooks package, you could write a quick before update hook that logs the modifier to give you a better idea of what might be causing it.

1 Like

Hi,
regarding separate 10 and 1 update I believe it could be 2 different Meteor.publish() on same users connection. 1st - “my user with full data”, and 2nd “all 10 users with limited info”

“Do you see same users collection updates even there are no active clients (open browser tabs with it)?”. At least 1 user - me, is active. How can I track it if my browser is not opened the page itself?

Deploying with Mup to digitalocean

I’ve added hooks with the package you’ve mentioned. and started logging any changes to users collection. The log shows actually there are no inserts/updates/upserts happening to the collection on server.

So probably that means the server and client exchanges collection data without any need. Why can this happen?

I also see some mentioning of poll and diff strategy which updates clients in 10 seconds (like in my case). Could it be related?

Ok. I did more digging but no success yet.

I see in websocket the data is coming every 10 seconds (here only one user, as I used non-admin user for testing )

a["{\"msg\":\"changed\",\"collection\":\"users\",\"id\":\"WZ2dpbAzoAgPnrEmw\",\"fields\":{\"emails\":[{\"address\":\"aaa@gmail.com\",\"verified\":false}]}}"]
a["{\"msg\":\"changed\",\"collection\":\"users\",\"id\":\"WZ2dpbAzoAgPnrEmw\",\"fields\":{\"emails\":[{\"address\":\"aaa@gmail.com\",\"verified\":false}]}}"]
a["{\"msg\":\"changed\",\"collection\":\"users\",\"id\":\"WZ2dpbAzoAgPnrEmw\",\"fields\":{\"emails\":[{\"address\":\"aaa@gmail.com\",\"verified\":false}]}}"]
a["{\"msg\":\"changed\",\"collection\":\"users\",\"id\":\"WZ2dpbAzoAgPnrEmw\",\"fields\":{\"emails\":[{\"address\":\"aaa@gmail.com\",\"verified\":false}]}}"]

As I understand nothing is changing, but for some reason data is sent to client.
I didn’t find anything what changes “verified” or “email” in my code. and have removed ALL accounts-* packages

these packages are left:

arillo:flow-router-helpers   0.5.0  Template helpers for flow-router
blaze-html-templates         1.0.1  Compile HTML templates into reactive UI with Meteor Blaze
dispatch:spinner             0.0.5  Spinner component for displaying loading with blaze.
ecmascript                   0.1.6* Compiler plugin that supports ES2015+ in all .js files
es5-shim                     4.1.14  Shims and polyfills to improve ECMAScript 5 support
gfk:notifications            1.1.4  Notifications - Add reactive notifications to any meteor template
gfk:server-messages          1.1.0  Add server to client mediator
jquery                       1.11.4  Manipulate the DOM using CSS selectors
kadira:blaze-layout          2.3.0  Layout Manager for Blaze (works well with FlowRouter)
kadira:debug                 3.0.1  Full Stack Debugging Solution for Meteor
kadira:flow-router           2.10.0* Carefully Designed Client Side Router for Meteor
matb33:collection-hooks      0.8.1  Extends Mongo.Collection with before/after hooks for insert/update/remove/find/findOne
meteor-base                  1.0.1  Packages that every Meteor app needs
meteorhacks:kadira           2.27.3  Performance Monitoring for Meteor
mobile-experience            1.0.1  Packages for a great mobile user experience
mongo                        1.1.3  Adaptor for using MongoDB and Minimongo over DDP
natestrauser:font-awesome    4.4.0  Latest version Font-Awesome loaded via CDN
rajit:bootstrap3-datepicker  1.5.0  Meteor packaging of eternicode/bootstrap-datepicker for Bootstrap 3
reactive-var                 1.0.6  Reactive variable
rgnevashev:bootstrap-slider  6.0.6* a slider element for bootstrap 2/3
service-configuration        1.0.5  Manage the configuration for third-party services
session                      1.1.1  Session variable
standard-minifiers           1.0.2  Standard minifiers used with Meteor apps by default.
tomi:upload-jquery           2.2.1  Client template for uploads using "jquery-file-upload" from blueimp
tomi:upload-server           1.3.3  Upload server for Meteor. Allows to save and serve files from arbitrary directory
tracker                      1.0.9  Dependency tracker to allow reactive callbacks

Any ideas?

Seems I found what caused the problem, unfortunately do not know what was the exact problem.

The cause was a prototyped Array class extension:

// attach the .equals method to Array's prototype to call it on any array
Array.prototype.equals = function (array) { ... }

I’ve rewritten this to function and problem disappeared. As I understand something in Meteor internals didn’t like this method to appear, but I’m not sure, if I have time to dig deeper :slightly_smiling: This problem ate my week anyway.

Thanks for support.

1 Like

Good to know. Thanks for sharing.