Commit Graph

49 Commits

Author SHA1 Message Date
Shane Harvey
a886922157 PYTHON-1684 Support sharded transactions recovery token (#406)
Transient errors inside transaction unpins the session.
Add brief docs about sharded transactions and add 3.9 changelog.
Tests changes:
Add spec tests for sharded transaction recoveryToken.
Speed up txn tests by reducing SDAM waiting time after a network error.
Remove outdated test workaround for killAllSessions.
2019-02-27 13:28:06 -08:00
Shane Harvey
05565783d9 PYTHON-1759 Find/getMore command failures reset servers's SDAM state (#406) 2019-02-27 13:25:43 -08:00
Bernie Hackett
548343c29e PYTHON-1551 - Deprecate MongoClient.close_cursor 2018-06-06 11:17:02 -07:00
Shane Harvey
5a652be993 PYTHON-1508 Add read_preference to TransactionOptions
All read operations use the transaction's read preference.
Add transaction read preference spec tests.
Remove write test in test_read_preferences.
2018-05-08 11:38:28 -07:00
Shane Harvey
c6488c117d Ending a session always aborts the transaction 2018-04-16 09:57:45 -04:00
Shane Harvey
cd92850b36 Test changing transaction readPreference
Add original readPreference to getMores to simplify code check.
2018-04-16 09:57:45 -04:00
A. Jesse Jiryu Davis
9df87b6401 prototype transaction tests 2018-04-16 09:57:45 -04:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
Shane Harvey
b669cd86dc PYTHON-1332 Session may only be used by the client that started it.
Centralize $clusterTime receiving.
2017-11-17 09:27:21 -08:00
Shane Harvey
49cee292cc PYTHON-1408 Cursor iteration should complete when another thread closes the cursor.
Closing a cursor should not raise an error when killCursors fails.
2017-11-13 13:08:38 -08:00
Bernie Hackett
4eda4ffaec PYTHON-1340 - Implement causally consistent reads 2017-11-09 17:16:55 -08:00
A. Jesse Jiryu Davis
df018e88e2 PYTHON-1332 - Gossip $clusterTime 2017-10-12 09:08:38 -04: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
6fa2e4047f PYTHON-1332 - Send lsid with all commands 2017-09-29 14:52:26 -04:00
A. Jesse Jiryu Davis
c1ec855060 PYTHON-1332 - Send lsid with all commands 2017-09-29 14:52:26 -04:00
A. Jesse Jiryu Davis
2487e9b71f PYTHON-1332 - Session param for Collection methods 2017-09-11 17:46:44 -04:00
Shane Harvey
74605b73f6 PYTHON-1338 Support change stream API. 2017-09-07 17:12:45 -07:00
A. Jesse Jiryu Davis
3c49e8a0f7 PYTHON-1362 - Useless check in aggregate_raw_batches
The method had checked whether any SON manipulators were configured, and
raised an error if so. But users should understand that SON manipulators
can't affect raw batches, and checking for them raises a deprecation
warning.
2017-09-01 16:20:36 -04:00
A. Jesse Jiryu Davis
cfb30e91c0 PYTHON-1362 - Add find/aggregate_raw_batches()
Rename find_raw to find_raw_batches, and add aggregate_raw_batches.
Rename RawBSONCursor and RawBSONCommandCursor to RawBatchCursor and
RawBatchCommandCursor.
2017-08-25 15:26:16 -04:00
Shane Harvey
b00584b892 PYTHON-1353 Kill cursors synchronously in CommandCursor.close. 2017-08-15 14:58:44 -07:00
Bernie Hackett
80aa1117fd PYTHON-1071 - Use command reported namespace for getMore 2016-03-14 13:47:45 -07:00
aherlihy
b8528100e1 PYTHON-978 - Use getMore command for CommandCursor 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
5dba74c005 PYTHON-952 - killCursors monitoring 2015-08-17 16:22:19 -07:00
Bernie Hackett
07d2199477 PYTHON-952 - Fix duration measurements.
We weren't including the time to decode responses in
a number of places. This commit also fixes an issue with
handling "cursor not found" errors from mongos versions
older than 2.4.
2015-08-12 14:04:21 -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
aherlihy
66dbe93d45 PYTHON-945 - Remove validation of the OP_REPLY "startingFrom" field. 2015-06-08 16:24:13 -07:00
Bernie Hackett
58ab8df727 PYTHON-894 - More doc clarifications for alive. 2015-05-07 14:52:31 -07:00
A. Jesse Jiryu Davis
cb64f87aa6 PYTHON-894 - Set cursor.alive False after final batch.
Even with this change, "next" can raise StopIteration even though
"alive" is True. For example if batch size is 2 and there are 4
documents in the result set, then after the 4th document "alive" is True
but "next" raises StopIteration.
2015-04-17 14:56:36 -04:00
Bernie Hackett
1a8478dbd5 PYTHON-893 - Fix application of SON manipulators in CommandCursor. 2015-04-14 11:39:23 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
Bernie Hackett
b71526a2da PYTHON-836 - Always set slaveOk bit for non-mongos direct connection. 2015-03-07 11:09:16 -08:00
Bernie Hackett
3f3b6bedfc PYTHON-846 - Database.connection -> Database.client 2015-02-25 11:57:39 -08:00
Bernie Hackett
1db2b0bfa5 PYTHON-800 - Clean up internal use of CodecOptions. 2014-12-23 19:52:31 -08:00
Bernie Hackett
fe5e723285 PYTHON-806 - Always use command cursor 'ns' value for OP_GET_MORE 2014-12-18 16:12:38 -08:00
A. Jesse Jiryu Davis
2ba730722b PYTHON-526 Remove 'compile_re' option.
PyMongo now never attempts to compile BSON regular expressions as Python native
regular expressions.
2014-12-05 14:06:38 -05:00
A. Jesse Jiryu Davis
daad4446f8 Rename connection_id and conn_id to "address". 2014-11-18 17:40:34 -05: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
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
d3326de5aa close_cursors requires 'address' parameter. 2014-07-28 21:21:37 -04:00
A. Jesse Jiryu Davis
36c3ccb007 Wrap server responses in a Response or ExhaustResponse object. 2014-07-28 21:21:37 -04:00
Luke Lovett
d494105aa4 PYTHON-674 python 2/3 single-source for the pymongo module 2014-04-23 18:26:18 +00:00
A. Jesse Jiryu Davis
36c13e597e Expose some CommandCursor state. 2014-02-13 16:22:12 -05:00
Bernie Hackett
a217d30e72 Changes to make cursor testing easier. 2014-02-12 18:11:16 -08:00
Bernie Hackett
e3c809bd02 Gracefully kill cursor on capped rollover PYTHON-637
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.
2014-02-12 08:33:13 -08:00
Bernie Hackett
940d73f672 Add parallel_collection_scan helper PYTHON-633
This commit adds a helper for the new parallelCollectionScan
command introduced in MongoDB 2.5.5. The helper returns
"num_cursors" instances of CommandCursor that can be iterated
by one or more threads concurrently to scan the entire collection.

This commit also removes the remaining command cursor
hacks from cursor.Cursor.
2014-02-11 13:04:53 -08:00
Bernie Hackett
cdacc2f4b9 Fix aggregate cursor read preference issues PYTHON-636
The cursor returned by aggregate now knows what server
it was created on, allowing it to return getMore results
when the read preference is not PRIMARY.

This also introduces a simplified cursor class for use
with commands that return a cursor id and perhaps an initial
set of results. None of the methods of cursor.Cursor (other
than batch_size) make sense in this case.
2014-02-10 18:55:50 -08:00