Commit Graph

33 Commits

Author SHA1 Message Date
Shane Harvey
5a9b3340d9 PYTHON-1508 Fix read preference regression in mapreduce 2018-05-24 13:53:22 -07:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
Shane Harvey
2a05236f61 PYTHON-1332 Only gossip cluster time on >= 3.6.
Do not add readConcern to explain.
Test explain with collation.
2017-11-30 14:53:14 -08:00
Shane Harvey
f0b847adb8 PYTHON-1329 Refactor wire protocol message parsing.
Use _OpReply class instead of passing bytes around.
Remove unnecessary operation argument to receive message.
Move _first_batch to message.py to avoid circular import.
2017-10-09 15:11:50 -07:00
A. Jesse Jiryu Davis
0534596dc5 PYTHON-1362 - Add raw_batches option to find() 2017-08-25 15:24:16 -04:00
Luke Lovett
8fdb581c6a PYTHON-1113 - Support collation per operation.
This commit add the pymongo.collation.Collation class and associated enums.  A
collation may be sent with individual write operations when connected to MongoDB
3.4+. Unlike read and write concern, a collation may not be attached to a
database or collection instance.
2016-09-07 13:45:41 -07:00
aherlihy
d98a745700 PYTHON-1067 - Implement SDAM Monitoring 2016-06-14 15:20:19 +02:00
Luke Lovett
dde4a658b5 PYTHON-981 - Implement ReadConcern. 2015-11-18 14:12:28 -08:00
aherlihy
1a3aeea426 PYTHON-978 - Use find/getMore commands 2015-11-18 12:57:47 -08:00
Bernie Hackett
28885b25e8 PYTHON-952 - API improvements
This commit implements the following simplifications and improvements:

- The Subscriber ABC has been renamed to CommandListener
- The subscribe function has been renamed to register
- The COMMAND constant has been removed
- The get_subscribers function has been removed
- Command listeners can now be registered per MongoClient instance
  instead of just globally
2015-10-09 17:03:51 -07:00
Luke Lovett
b6182d0587 PYTHON-976 - Publish a CommandFailedEvent for arbitrary failures. 2015-10-07 11:08:05 -07:00
Bernie Hackett
fa4a6a39d3 PYTHON-952 - Query and getMore monitoring
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.
2015-08-11 12:19:28 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
Bernie Hackett
e7c5cafc07 PYTHON-865 - Fix mongos $readPreference issues. 2015-03-23 19:07:15 -07:00
A. Jesse Jiryu Davis
c000354416 PYTHON-857 - Use client._get_socket_for_writes for OP_UPDATE and OP_DELETE.
Also check max document size in legacy writes.
2015-03-16 17:35:59 -04:00
A. Jesse Jiryu Davis
f737ec0db9 PYTHON-728 - Translate socket.error to ConnectionFailure in pool.py.
SocketInfo and Pool are now responsible for catching all socket.errors and
gaierrors and translating them to ConnectionFailure. Server and MongoClient
need no longer worry about anything but ConnectionFailure. Functions in pool.py
and network.py still throw socket.errors into SocketInfo and Pool.
2015-03-11 19:57:01 -04:00
A. Jesse Jiryu Davis
9b208caed9 PYTHON-829 Call ismaster on each new connection.
Call ismaster on each new connection and store the results on the SocketInfo
instance.

The upcoming Authentication Spec says: "If credentials exist, upon opening a
socket, drivers MUST send an isMaster command immediately. This allows a driver
to determine whether the server is an Arbiter. Calling ismaster additionally
allows the driver to know if the default authentication method for each socket
is MONGODB-CR or SCRAM-SHA-1, avoiding races when the driver repopulates the
pool after a disconnect."

In theory we could choose not to call ismaster if there are no credentials, but
it's simpler always to call ismaster, and paves the way for future breaking
changes to the wire protocol besides the current breaking change to
authentication.
2015-01-26 16:54:14 -05:00
A. Jesse Jiryu Davis
ca1bc57ebb Dead code. 2014-12-03 16:32:41 -05:00
A. Jesse Jiryu Davis
0b9b109e3c Make Pool.get_socket a context manager.
SocketInfo itself is no longer a context manager.
Simplifies exhaust cursors and exception handling,
and avoids a confusing weakref.
2014-12-03 16:32:41 -05:00
A. Jesse Jiryu Davis
e7b0596442 PYTHON-785 Remove start_request().
Remove MongoClient's methods start_request(), in_request(), and end_request().
The purpose of requests was to provide read-your-writes consistency when using
w=0 write concern. Starting a request pins a socket to a thread so any
operations on that thread end up in the same queue on the server side.

Justification for removing: mongos 2.6+ doesn't support socket pinning by
default, and mongos 2.8+ doesn't support it at all (SERVER-12273), so whatever
weak consistency guarantees a request was supposed to provide are not provided
with sharding.

It's unnecessary with MongoDB 2.6+ since write commands always block and send a
response.

It's a confusing feature that should rarely be used, if ever, yet people
incorrectly use it all the time. It makes our connection pool unmaintainable to
any but the most expert developers.
2014-11-24 22:48:44 -05:00
A. Jesse Jiryu Davis
8a5980d738 More consistent use of 'reset' and 'close'. 2014-11-03 14:40:06 -05:00
A. Jesse Jiryu Davis
38848d47f3 MongoClient.close() stops monitors.
Subsequent operations restart them.
2014-11-03 14:40:06 -05:00
A. Jesse Jiryu Davis
ee11436675 PYTHON-764 SCRAM-SHA-1 automatic upgrade / downgrade. 2014-10-23 16:30:55 -04:00
A. Jesse Jiryu Davis
98afef5871 Replace "Cluster" term with "Topology".
The Server Discovery And Monitoring Spec has replaced the term "cluster"
with "topology", since "cluster" in MongoDB terminology should be reserved
for sharded clusters. "Topology" describes a single server, replica set, or a
set of mongoses.

The previous commit replaced "cluster" with "topology" in file names. Here
I replace the term in class and variable names.
2014-09-17 22:32:43 -04:00
A. Jesse Jiryu Davis
735a1247ca PYTHON-525 Deprecate MongoReplicaSetClient.
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.
2014-09-16 15:33:19 -04:00
A. Jesse Jiryu Davis
a801c38d4a PYTHON-525 Restart monitor threads after fork.
A reimplementation of PYTHON-549 for PyMongo 3's new MongoClient.
2014-09-09 16:14:59 -04:00
A. Jesse Jiryu Davis
41c1a9afa6 PYTHON-525 Reimplement auth for new MongoClient.
The new MongoClient, based on Cluster and Server,
includes functionality that had been split between the
old MongoClient and MongoReplicaSetClient. A
previous commit introduced the new MongoClient
but broke authentication.
2014-09-03 17:39:52 -04:00
A. Jesse Jiryu Davis
2f9d24ade6 PYTHON-525 Reimplement MongoClient to use Cluster.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.

Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
2014-08-28 16:57:57 -04:00
A. Jesse Jiryu Davis
590c68d287 PYTHON-525 Move SERVER_TYPE to its own file. 2014-08-28 16:49:33 -04:00
A. Jesse Jiryu Davis
36c3ccb007 Wrap server responses in a Response or ExhaustResponse object. 2014-07-28 21:21:37 -04:00
A. Jesse Jiryu Davis
f10f7f91a5 PYTHON-722 Use SocketInfo in a with-statement.
SocketInfo is now responsible for sending and receiving messages,
for closing itself on error, and for returning itself to the pool
when its with-statement is exited.

Pool.discard_socket is removed. Returning a closed socket to the
pool has the same effect as discard_socket had.

Remove client._exhaust_next.
2014-07-14 16:11:35 -04:00
A. Jesse Jiryu Davis
698ddd88c5 Add docstrings in Cluster and related classes. 2014-07-03 14:17:46 -04:00
A. Jesse Jiryu Davis
d79ab6eb5e PYTHON-525 Implement Cluster, Server, and Monitor.
This is prelude to a unified MongoClient class to replace the current
MongoClient and MongoReplicaSetClient. Conforms to the Cluster Monitoring Spec.
2014-07-01 22:53:24 -04:00