Comments (5)
Any comment on this @mizzao? I would really like to make mizzao:partitioner
compatible with meteor-collection-hooks
0.9+ because I am also suffering from #203 and in my case the entire user document can be 100s of kBs.
from meteor-collection-hooks.
I've been trying to merge PR #206 into my own fork of 0.8.4 to fix #203.
I've discovered that changing this one line in meteor-collection-hooks/update.js
:
if (aspects.before || aspects.after) {
to this:
if (!_.isEmpty(aspects.before) || !_.isEmpty(aspects.after)) {
breaks mizzao:partitoner
- an update
which is only supposed to update users in one partition actually updates ALL users. Looks like this PR might have unintended side-effects...
from meteor-collection-hooks.
In the meantime, I have added a line to collection-hooks
.js in v0.8.4:
CollectionHooks.getDocs = function getDocs (collection, selector, options) {
const findOptions = { transform: null, reactive: false,
{fields: {_id: 1}}, // I added this line
}
This works because mizzao:partitioner
doesn't actually need the documents in its before hooks, all it does is modify the selector. And nothing else in my app uses collection-hooks
so this is safe for me.
I uploaded this to production about 12 hours ago. The result are as follows, showing method response time of my most common method over 24 hours:
You can see that this has halved my overall method response time, and will have drastically reduced the bandwidth from the database. There are still unnecessary fetches going on, but this is much better.
from meteor-collection-hooks.
Sorry @wildhart, I've been too busy with other stuff to look at this at the moment.
Based on your knowledge of this, where should the fix be? In collection-hooks
or mizzao:partitioner
?
from meteor-collection-hooks.
I'm really not sure to be honest. I suspect that partitioner
was using a 'feature' of collection-hooks
which meant that update
operations were also using the find
hooks and so didn't need their own hooks. For some reason I don't understand yet, adding the _.isEmpty(aspects...)
breaks that 'feature' so that the update
isn't limited to the current user's group.
So I don't know whether the 'feature' in collection-hooks
was broken by PR #206 (and may break other people's code outside of partitioner
), in which case collection-hooks
needs to be fixed; or whether partitioner
was making an unsafe assumption about the internal workings of collection-hooks
, and that assumption is no-longer valid, in which case partitioner
would need to be fixed.
I also have other priorities at the moment so I don't have much time to investigate further - I've implemented a temporary hack (as above) which mitigates the problem of fetching an entire document whenever it's updated so for the moment I'm happy. I may have more time to help identify the root cause in the new year...
from meteor-collection-hooks.
Related Issues (20)
- How i can extend ALL collections? HOT 6
- After fetch hook? HOT 3
- An after.update hook's modifier doesn't get a before.update's updated modifier
- Add GitHub actions for CI HOT 2
- Using direct still causes fetchPrevious behaviour on update method
- hook "remove" does not remove hook or removes wrong hook HOT 1
- bulk update didnt trigger after update hooks HOT 3
- attach hooks to raw collections HOT 3
- Meteor 2.6: after.insert callback does not contain correct document _id HOT 2
- problem after insert doc._id object HOT 4
- Support to Meteor 2.8 and Mongo async methods HOT 5
- After update hook does not use direct find HOT 2
- Async hooks run in parallel to the collection operation HOT 3
- Meteor 3.0 migration considerations HOT 1
- Ability to add call-level parameters to hooks HOT 1
- Core dump at Meteor 3.0 alpha 15: node: ../src/coroutine.cc:134: void* find_thread_id_key(void*): Assertion `thread_id_key != 0x7777' failed. HOT 2
- Calling Meteor.userAsync inside pub throws an error in meteor 3 beta HOT 3
- before hooks and async callbacks are not compliant with Meteor 3 promises HOT 4
- Throw in before.* should also cancel the operation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-collection-hooks.