MongoClient now requires 2 connections and 2 threads to each MongoDB 4.4+ server.
With one connection, the server streams (or pushes) updated heartbeat info.
With the other connection, the client periodically pings the server to
establish an accurate round-trip time (RTT). This change optimizes the
discovery of server state changes such as replica set elections.
Additional changes:
- Mark server Unknown before retrying isMaster check.
- Always reset the pool _after_ marking the server unknown.
- Configure fail point before creating the client in test SpecRunner.
- Unfreeze with replSetFreeze:0 to ensure a speedy elections in test suite.
Skip test for symbol type which pymongo converts to string.
Fix {} comparison with RawBSONDocument in command events.
Add support for $$type assertions.
Nicer message in check_events.
Support errorContains with empty string.
Move custom data files to custom/.
This commit adds support for monitoring queries and getMore
operations, including getMore operations for command cursors
(e.g. aggregate cursor getMore). It also fixes a bug in duration
calculation.
With this change the max_pool_size named parameter to
MongoClient is removed. It is replaced by the maxPoolSize
MongoDB URI option, which can be passed in a URI, or as a
keyword argument to MongoClient.
MongoClient now supports all MongoReplicaSetClient's features.
Fix bugs and add features in the new MongoClient to bring it up
to spec. MongoReplicaSetClient is now a deprecated stub that
subclasses MongoClient.
Introduce new errors, NetworkTimeout and NotMasterError, to
communicate events that MongoClient must handle specially.
This change does a few things:
- Raises a new exception for CursorNotFound, inheriting from
OperationFailure so we don't break existing code.
- Catches the exception in cursor.Cursor and command_cursor.CommandCursor,
setting __killed to True.
- If the cursor is not tailable, re-raises the exception. This makes it
easier to deal with capped collection rollover when iterating a
tailable cursor.
The idea here is to unify the handling of oversize documents when using
the bulk API in MongoDB 2.6 and previous versions. This also means that
using bulk Collection.insert against legacy servers will attempt to insert
all documents previous to the oversize document before raising.
This change adds an error_document attribute to
OperationFailure and subclasses. The error_document
attr will be the complete error document returned by
the server, when available. The error document may
include valuable information other than just the error
message, particularly when connected to mongos, which
may return one or more error subdocuments representing
errors on multiple shards.
PyMongo defines a TimeoutError exception, added in PyMongo
1.8, that is supposed to be raised if the server returns
a wtimeout error for inserts, updates, or removes. This error
has not actually been raised by the driver since MongoDB 1.8,
which changed how wtimeout is reported by the server.
This commit fixes the problem by raising a new exception,
WTimeoutError, instead of OperationFailure when the server
returns wtimeout. WTimeoutError is meant to distinguish this
particular error from other "timeout" errors handled in the
driver. It inherits from (now deprecated) TimeoutError to support
applications and libraries that already catch TimeoutError.
PYTHON-576 will add the server error document to OperationFailure
and subclasses (e.g. WTimeoutError), which can be used to check
return values like 'n', 'updatedExisting', and 'writtenTo', even
though wtimeout error occured.