Commit Graph

116 Commits

Author SHA1 Message Date
gsuess
e02bf0fb30 Fixes #4522: Mongo upsert with dotted keys
Break down dotted key-value pairs into an object when simulating
the way Mongo generates an object from a selector in upsert.
2015-08-19 13:24:36 -07:00
David Glasser
7d6e759954 Don't try to interact with fences that have fired
This bug was introduced by #4694 which switched OplogObserveDriver's
listener from using beginWrite to the new onBeforeFire.  beginWrite
doesn't throw an error when called on a retired fence; onBeforeFire
does.  So don't try to interact with fired fences. (I'm not sure if
there is an importance to the distinction between retired and fired
introduced by dcd26415f, but this code should be fine.)

While we're at it, make the error in question (which shouldn't happen)
be delivered to Mongo write callbacks (or thrown), if for no other
reason than that it allows us to test this fix.

Fixes #4839.
2015-08-12 17:50:05 -07:00
David Greenspan
eb76d56ebf Remove spurious dependencies on logging package
We've been shipping the `logging` package to the client even though it
isn't used on the client by any core packages.  Now that the `logging`
package is removable from your app, let's make it actually removable
by deleting totally worthless dependencies that exist for bizarre
historical reasons.

For example, some packages, like `reload` and `mongo`, depend on
`logging` because that's where `Meteor._debug` used to be, before it
was moved to the `meteor` package and `logging` was repurposed for
something else.  The `ddp-server` package had a crazy overreaching set
of dependencies, pulling in a bunch of client-side libraries even though
it only has server-side code of its own.
2015-08-04 16:37:13 -07:00
David Greenspan
db8308672a Remove JSON package
JSON support is in all browsers we could conceivably care about; it's
ES5 and has perfect support in IE 8.  No need to ship a library as
a core package, and no need to specify dependencies on it.

We could conceivably publish a new version of the `json` package that
is empty, so that apps using packages that still say `use("json")`
also get the code size reduction, but we'll wait until someone requests
that.
2015-08-04 16:37:13 -07:00
Sashko Stubailo
02dfd2c8f0 Throw error in Mongo.Collection when selector is array, fixes #4804 2015-07-31 10:47:12 -07:00
David Glasser
43b4b30205 Release PLUGINS-PREVIEW@1
This included removing some internal version constraints. It would be
nice if package A could say "use B@2.0.0" (when both have changed), but
when they're both in the release, we need to make a release that has a
B@2.0.0-rc in it, which doesn't match that constraint. Fortunately,
constraints aren't necessary within a release anyway.
2015-07-22 23:19:11 -07:00
Oleksandr Chekhovskyi
565fa39037 Catch up to oplog at most once per write fence
Before this change, number of catch-up attempts was N*M, where N is number of
writes inside of the fence, and M is number of active observers on affected collections.
Every catch up issues yet another query to find the latest oplog entry.

It was extremely inefficient, in terms of both CPU usage and added latency.
After executing write-heavy methods, application process was occupied for many seconds
doing the same thing over and over again.

This change provides a performance improvement for all kinds of workloads.
2015-07-09 09:25:56 -07:00
Martijn Walraven
3790e0987b Add ability to login with a case insensitive username or email
Closes #550.

`loginWithPassword` now matches username or email in a case insensitive manner.
If there are multiple users with a username or email only differing in case, a
case sensitive match is required.

Although `createUser` won't let you create users with ambiguous usernames or
emails, this could happen with existing databases or if you modify the users
collection directly.

Because MongoDB does not support case insensitive indexes, we perform a case
insensitive query both before and after inserting a new user, removing the user
when we detect another matching user has been inserted in the meantime. This
leaves us with the theoretical possibility that a server crash could occur in
between the insert and the second query or remove. In that situation there
would be two accounts with a username or email only differing in case, so we
will require a case sensitive login.
2015-06-29 19:12:52 -07:00
Slava Kim
85ca501b7c Merge branch 'minimongo-separation' into devel 2015-06-12 11:33:17 -07:00
Slava Kim
b3096e9366 Extract MongoId into a separate package to reduce the dependencies on minimongo 2015-06-12 11:07:20 -07:00
David Glasser
67e13306c6 Document rawCollection/rawDatabase
Fixes #4509.
2015-06-10 14:41:42 -07:00
Slava Kim
68fa782930 Separate diff functions from minimongo 2015-04-27 15:02:44 -07:00
David Glasser
64c170d6e3 The tool only needs the ddp client
However, turns out the previous commit doesn't really work --- making
webapp a strong dependency of ddp-server means that as soon as we load
mongo we'll load webapp in the tool which is bad.  So move the mongodb
Npm module out of mongo, since that's all we need in the tool.
2015-04-14 21:48:41 -07:00
David Glasser
44d387c3ab Detect 'drop database' in oplog observe driver
Fixes #3847.
2015-04-01 15:55:48 -04:00
David Glasser
4daaa76b12 METEOR@1.0.4 2015-03-17 13:06:07 -07:00
David Glasser
873018df44 Minor version bumps to packages with new features
* accounts-base: client-side login hooks
* accounts-password: emailTemplates features
* autoupdate: reload via Node IPC messages (and SIGHUP)
* blaze: template-level subscriptions and onRendered/etc hooks
* ddp: client-side onStop callback, permessage-deflate, subscriptionId
  on subscription handles
* http: npmRequestOptions, HTTPInternals.NpmModules
* mongo: validated against 2.6, oplog-backlog,
  rawCollection/rawDatabase, MongoInternals.NpmModules
* reactive-dict/session: Session.set({k1: v1, k2: v2})
* templating: attributes on <body>
* webapp: WebAppInternals.NpmModules
2015-03-05 22:30:22 -08:00
David Glasser
f65035e11a oplog: re-fetch on confusing modifiers
For example, 5ddf203 stops us from understanding $sets and $unsets with
empty field parts, but pre-2.6 MongoDB could generate them.  (And even
post-2.6 may be able to generate $unsets with bad field names, but it's
not important for us to match that behavior since with Minimongo you
shouldn't be able to put them in in the first place.)
2015-03-05 19:56:42 -08:00
David Glasser
3674c12fc7 Fix server side of #3571 2015-03-05 18:41:38 -08:00
David Glasser
456d06bde3 Failing test for #3571
This fails on both server and client.

This is also related to #2254.
2015-03-05 18:41:37 -08:00
David Glasser
82bbcd112c run a test on the client too 2015-03-05 18:41:37 -08:00
David Glasser
ef9671e705 Document direct access features in READMEs 2015-03-05 17:12:37 -08:00
David Glasser
63a0076305 mongo: provide direct access to node driver db
Specifically, Mongo.Collection objects on the server now have
rawCollection and rawDatabase methods.

You can use MongoInternals.NpmModules.mongodb.version to tell what
version of the mongodb npm module is the backend for HTTP.call.  This
version may change incompatibly from version to version of Meteor; use
at your own risk.  (For example, we expect to upgrade from the 1.4.x
series to the 2.x series in the not-too-distant future.)

Fixes #3640.
2015-03-05 17:12:37 -08:00
David Glasser
cfc1699b0c Add direct access to mongodb module from mongo
Addresses #3640.
2015-03-05 17:12:36 -08:00
David Glasser
6ef63ce43d Fix update when rules have different transforms
Previously, the document would be transformed based on the first deny or
allow rule's transform, instead of using the matching transform rule.
This bug only applied to update, not insert or remove.

Technically one could do something fancy to avoid calling transform
unnecessarily if there are many validators with the same transform, but
if you're stressing that much about performance you might as well just
write a method instead of using allow/deny.

Fixes #3108.
2015-03-04 19:47:06 -08:00
David Glasser
7c443e46de slight refactor to a test 2015-03-04 19:38:45 -08:00
David Glasser
0c0cbe12be Update to Mongo driver 1.4.32
This contains a PR we just submitted to help with error handling
for #2534.
2015-02-27 12:00:25 -08:00
David Glasser
3e59a1bf8c Better errors on observeChanges and sub errors 2015-02-26 11:48:47 -08:00
David Glasser
874b3ff74d Fix #2534 for oplog too
In order to test this, we applied the following diff to
minimongo/selector.js:

--- a/packages/minimongo/selector.js
+++ b/packages/minimongo/selector.js
@@ -591,6 +591,8 @@ ELEMENT_OPERATORS = {
   },
   $in: {
     compileElementSelector: function (operand) {
+      if (operand === null)
+        operand = [];
       if (!isArray(operand))
         throw Error("$in needs an array");

This means that minimongo now allows `$in: null`, and thus
OplogObserveDriver can be used for the query in the new 'bad query'
test, but mongod still returns an error that is processed by the passing
test.  (The client side of the test fails with this temporary change,
because minimongo no longer throws!)

It's hard to see how to test this better, because minimongo should throw
on any queries that mongod throws on.
2015-02-26 11:48:47 -08:00
David Glasser
2f2ba3979c Make observeChanges throw on bad query
Fixes #2534.

In the past, a bad query would be retried forever, causing the
observeChanges to hang.

(In the common case of a DDP subscription, this would also cause the
current DDP connection to completely stop reading messages, and would
make methods that do writes to the same collection (on ANY DDP
connection) never get their 'updated' messages.  See
https://github.com/meteor/meteor/issues/2534#issuecomment-73355050
These two secondary problems may still need to be fixed but at least
the root cause should be addressed.)

This only fixes PollingObserveDriver, not OplogObserveDriver, but this
issue typically only affects PollingObserveDriver because we don't
choose to use OplogObserveDriver when minimongo can't understand a
query.
2015-02-26 11:48:47 -08:00
David Glasser
cfc4015f61 Failing test for #2534.
Test fails on server (passes on client).
2015-02-26 11:48:47 -08:00
Slava Kim
62ac82c835 Bump 2015-02-24 21:16:41 -08:00
David Glasser
f426f09abb Allow asking for full update result from Mongo 2015-02-19 10:42:08 -08:00
David Glasser
7e533c6fb0 Set up skip handle earlier 2015-02-10 12:16:02 -08:00
David Glasser
b34027ec25 Use callback-hook 2015-02-10 12:16:02 -08:00
David Glasser
50d5276ad0 Fix last entry issue in a simpler way
This way we don't have to worry about NEVER getting to the "processing
an entry" phase if the firehose never stops.
2015-02-10 12:16:02 -08:00
David Glasser
9040c1461b Add a test for oplog-backlog 2015-02-10 12:16:01 -08:00
David Glasser
cf363d8530 Make sure to not clear queue completely
Expand on some comments
2015-02-10 12:16:01 -08:00
David Glasser
56f21fc82e Use double-ended-queue for various server queues
See benchmarks at https://github.com/petkaantonov/deque
2015-02-10 12:16:01 -08:00
David Glasser
a4626f1c8e If oplog tailing gets too far behind, just poll
The number of entries that is "too far" to be behind is configurable
with $METEOR_OPLOG_TOO_FAR_BEHIND and defaults to 2000.

Fixes #2668.
2015-02-10 12:16:01 -08:00
David Glasser
7ae5678db2 Move oplog tailing to an explicit background queue
This will allow us to drop the queue if it gets too far behind.
2015-02-10 12:16:01 -08:00
Sashko Stubailo
f29c954458 Bump a bunch of version numbers for new preview 2015-02-09 13:23:24 -08:00
David Glasser
8e8ee3eca4 Unregister ObserveMultiplexer before stop
It's maybe possible that stop() yields, and in general is more complex.
Since the ObserveMultiplexer is already at the point where it will not
be able to start running again, we should remove it from the registry
first.
2015-02-07 00:02:42 -08:00
David Glasser
9166de39fe Release write fences on PollingObserveDriver.stop
OplogObserveDriver.stop() already does this.
2015-02-07 00:01:20 -08:00
David Glasser
25d9ab8250 Improve error message in PollingObserveDriver
Now when we get an error from Mongo, the cursor description is included.

Other than by the test-only _resumePolling, _pollMongo is only called at
the top level of an async-queued task, so the previously thrown error
never did anything other than print the exception (from within
_SynchronousQueue) anyway.

Fixes #1633.

(See also #2534.)
2015-02-06 19:21:30 -08:00
David Glasser
eaf11fa55e Update Node Mongo driver from 1.4.1 to 1.4.30
and BSON from 0.2.7 to 0.2.18

This is past the minimum version required to use the upcoming MongoDB
3.0.

Fixes #3654.
2015-02-06 18:05:16 -08:00
David Glasser
2e4d3f2833 Don't use system.replset to check for replset
It requires an unnecessary level of permissions in Mongo 2.6.  Instead,
use the isMaster command plus parsing the URL.

Fixes #2121.
2015-02-05 22:40:45 -08:00
David Glasser
5936c0b3de Add a link to a comment about upsert 2015-02-05 22:40:44 -08:00
David Glasser
a83008ebb4 Make our upserts match 2.6 semantics
Mongo 2.4 had the following behavior: if

  c.update({_id: 'x'}, {y: 1}, {upsert: 1})

resulted in an insert, it would get a random _id instead of 'x'.  (This
only happened when the update was a "replacement" rather than a
"modifier".) We dutifully implemented this behavior in various parts of
Meteor and added tests to prove that it occured.

However, this was actually a bug which got fixed in Mongo 2.6:
https://jira.mongodb.org/browse/SERVER-5289

Since this was regarded by Mongo as a bug (not a backwards-incompatible
change deemed worthy of mention in the Mongo 2.6 release notes), we
should just make Meteor always behave the Mongo 2.6 way, no matter what
version we're on (at least in the aspects where Meteor has its own code
to control this).  In other parts of Meteor where the queries are just
getting processed by Mongo, the behavior of this special case will match
Mongo's behavior.  If you care strongly about consistent behavior in
this strange edge case, upgrade to Mongo 2.6!

Specifically:

 - The minimongo implementation of modifiers loses its special-case code
   which drops _id from the modified document during an upsert replace.
 - Mongo.Collection.update should only generate a random _id as an
   insertedId if the selector doesn't mention one.
 - The case of a selector mentioning _id and a *replacement* modifier
   not mentioning _id should still count as "known ID" in the
   lower-level MongoConnection.update, which means that there's no
   reason to use simulated upsert and that we should include it as
   insertedId in the return object.
 - Various tests of the previous behavior should be changed.

(Note that if this commit is cherry-picked onto 1.0.3.1 (ie, run against
2.4), it would fail, because some of the tested cases end up going to
unsimulated Mongo upsert and assume the 2.6 behavior. That's OK, as
described above.)

Fixes #2278.
2015-02-05 22:40:44 -08:00
David Glasser
ceb07b254e upsert: Detect "can't change _id" in Mongo 2.6
This fixes the "upsert error parse" test and changes the behavior of
other failing upsert tests to be failing with "Upsert failed after 3
tries" errors instead of failing with a "can't change _id"-style error.

First step of addressing #2278.
2015-02-05 22:40:44 -08:00
David Glasser
d9cfa85b48 Fix test depending on Mongo document key order
In Mongo 2.6, _id always comes first:
http://docs.mongodb.org/manual/release-notes/2.6/#insert-and-update-improvements
2015-02-05 22:40:44 -08:00