txmongo
txmongo copied to clipboard
TxMongo should correctly reject too large documents
PyMongo raises DocumentTooLarge
in all situations when document that is larger than max_bson_size
is sent to DB.
TxMongo fails with two different invalid errors:
- when
insert()
is called with too large document, it fails withOperationFailure
- when
insert_one()
is called, it fails withAutoReconnect
, probably because MongoDB closes the connection when TxMongo tries to send too large document with new-style command-based API.
Size checking should be done on TxMongo's size at least in following places:
- Database.command (covers all new-style *_one/_many methods)
- Old-style insert(), update(), etc.
- Bulk ops
Nice find and I agree that the check on the TxMongo side would reduce overhead on MongoDB itself and save us extra calls.
reduce overhead on MongoDB itself and save us extra calls
and extra reconnects in case of new-style insert_one()
:)