txmongo icon indicating copy to clipboard operation
txmongo copied to clipboard

TxMongo should correctly reject too large documents

Open IlyaSkriblovsky opened this issue 7 years ago • 2 comments

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:

  1. when insert() is called with too large document, it fails with OperationFailure
  2. when insert_one() is called, it fails with AutoReconnect, 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:

  1. Database.command (covers all new-style *_one/_many methods)
  2. Old-style insert(), update(), etc.
  3. Bulk ops

IlyaSkriblovsky avatar May 02 '17 09:05 IlyaSkriblovsky

Nice find and I agree that the check on the TxMongo side would reduce overhead on MongoDB itself and save us extra calls.

psi29a avatar May 02 '17 09:05 psi29a

reduce overhead on MongoDB itself and save us extra calls

and extra reconnects in case of new-style insert_one() :)

IlyaSkriblovsky avatar May 02 '17 09:05 IlyaSkriblovsky