Commit Graph

59 Commits

Author SHA1 Message Date
Noah Stapp
34ca694c9f
PYTHON-3801 gRPC POC phase 1 (#1317) 2023-07-26 14:01:22 -07:00
Iris
c8133cdbe3
PYTHON-3776 add types to collection.py (#1283) 2023-07-03 16:08:27 -07:00
Iris
a750098057
PYTHON-3750 add types to server.py (#1248) 2023-06-22 14:20:33 -07:00
Shane Harvey
0092b0af79
PYTHON-2504 Run pyupgrade 3.4.0 and ruff 0.0.265 (#1196)
pyupgrade --py37-plus bson/*.py pymongo/*.py gridfs/*.py test/*.py tools/*.py test/*/*.py
ruff --fix-only --select ALL --fixable ALL --target-version py37 --line-length=100 --unfixable COM812,D400,D415,ERA001,RUF100,SIM108,D211,D212,SIM105,SIM,PT,ANN204,EM bson/*.py pymongo/*.py gridfs/*.py test/*.py test/*/*.py
2023-05-11 15:27:17 -07:00
Steven Silvester
afd7e1c2cd
PYTHON-3460 Implement OIDC SASL mechanism (#1138) 2023-05-11 14:35:30 -05:00
Steven Silvester
a0fe7c03af
PYTHON-3120 Set up flake8 linting (#868) 2022-02-17 06:44:08 -06:00
Steven Silvester
5578999a90
PYTHON-1834 Use a code formatter (#852) 2022-02-09 06:44:28 -06:00
Steven Silvester
dd6c140d43
PYTHON-3060 Add typings to pymongo package (#831) 2022-02-02 21:12:36 -06:00
David Kim
c760f900f2
Edit simple typo in docs (#828) 2021-12-20 07:32:53 -06:00
Shane Harvey
ff3a8b44dc
PYTHON-1864 PYTHON-2931 Spec complaint $readPreference (#809)
Stop sending $readPreference to standalone servers.
Stop sending $readPreference primary because it's the server default.
Remove outdated secondary_ok flag.
2021-12-13 15:47:34 -08:00
Shane Harvey
c94a3ad1df
PYTHON-2585 Remove legacy multi-auth code (#816) 2021-12-09 18:00:41 -08:00
Bernie Hackett
146179db53 PYTHON-2803 Eliminate the use of 'slave' 2021-09-13 12:47:24 -07:00
Prashant Mital
ff6ca53328
PYTHON-2572 Introduce NotPrimaryError and deprecate NotMasterError (#646) 2021-06-22 13:24:07 -07:00
Shane Harvey
4c77d7c855
PYTHON-2677 Better wait queue timeout errors for load balanced clusters (#639)
Remove checkout argument in favor of SocketInfo.pin_txn/pin_cursor()
2021-06-21 18:29:36 -07:00
Shane Harvey
c8f32a7a37 PYTHON-2673 Connection pinning behavior for load balanced clusters (#630)
Tweak spec test because pymongo unpins cursors eagerly after errors.
Tweak spec test for PoolClearedEvent ordering when MongoDB handshake fails (see DRIVERS-1785).
Only skip killCursors for some error codes.
Rely on SDAM error handling to close the connection after a state change error.
Add service_id to various events.
Retain reference to pinned sockets to prevent premptive closure by CPython's cyclic GC.
2021-06-15 14:14:56 -07:00
Prashant Mital
d26bf933ed
PYTHON-1636 Support exhaust cursors in OP_MSG (#629) 2021-05-27 17:16:50 -07:00
Shane Harvey
93ac5e0277
PYTHON-2676 Add load balancer tests in EVG (#625)
Add load balancer spec tests
Ensure LB supports retryable reads/writes
Add assertNumberConnectionsCheckedOut, createFindCursor, ignoreResultAndError
Add PoolClearedEvent.service_id and fix isClientError unified test assertion
2021-05-27 15:05:26 -07:00
Shane Harvey
5bf15c8e18
PYTHON-2672 SDAM, CMAP, and server selection changes for load balancers (#621)
Disable SRV Polling, SDAM compatibility check, logicalSessionTimeoutMinutes check.
server session pool pruning, server selection, and server monitoring.
A ServerType of LoadBalancer MUST be considered a data-bearing server.
"drivers MUST emit the following series of SDAM events" section.
Send loadBalanced:True with handshakes, validate serviceId.
Add topologyVersion fallback when serviceId is missing.
Don't mark load balancers unknown.
2021-05-18 14:12:49 -07:00
Shane Harvey
86b40c195d
PYTHON-2462 Avoid connection storms: implement pool PAUSED state (#531)
Mark server unknown and clear the pool when background connections fail.
Eagerly evict threads from the wait queue when pool is paused. Evicted
threads will raise the following error:
AutoReconnect('localhost:27017: connection pool paused')
Introduce PoolClearedEvent and ConnectionPoolListener.pool_ready.

CMAP spec test changes:
- CMAP unit tests should not use real monitors
- Assert that CMAP threads complete all scheduled operations
2021-01-06 15:15:37 -08:00
Shane Harvey
b2fba416e9
PYTHON-2342 Prefer checking error codes over error messages (#492) 2020-10-02 11:30:39 -07:00
Prashant Mital
956ce3d4b0
Incorporate review changes 2020-07-01 16:47:33 -07:00
Prashant Mital
9fc7ed1e11
PYTHON-2143 Use an allow-list to determine resumable change stream errors 2020-07-01 16:43:27 -07:00
Shane Harvey
463d759ddc PYTHON-2116 Add __repr__ to monitoring events and description classes 2020-04-20 16:13:14 -07:00
Shane Harvey
58866319f9 PYTHON-1884 Support auto encryption in cursors 2019-08-06 14:54:23 -07:00
Shane Harvey
a15266083b PYTHON-1674 Support retryable reads
Add retryReads URI option that defaults to True.
Supported read operations will be retried once after transient
network, election, and shutdown errors on MongoDB 3.6+.
Supported operations are:
listCollections, listIndexes, and listDatabases
distinct
count, estimated_document_count, count_documents
aggregate (not including $out)
find (only for the initial find command, getMore commands are not
retried).
ChangeStreams: watch (initial aggregate command).
GridFS read APIs.

Test changes:
Add retryable reads spec test runner.
Disable retryable reads in network error tests.
2019-04-25 14:28:12 -07:00
Shane Harvey
7f4c504560 PYTHON-1674 Refactor Cursor/CommandCursor.__send_message
Move exhaust getMore out of Cursor.
Move cursor command response decoding into Server so that all command
listener events can be published in the same location.
2019-04-25 14:27:41 -07:00
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