FerretDB
FerretDB copied to clipboard
Make maximum documents size configurable
What should be done?
It appears that FerretDB inherit the 16MiB document size limits from MongoDB. It is not pretty reasonable nowadays.
I think we can have an option to tweak the default limit.
FerretDB version
v1.21.0
Backend
PostgreSQL 12.7
Steps to reproduce
mongoimport
a document larger than 16MiB to FerretDB. Then mongoimport
exits with the error Failed: an inserted document is too large
.
Let's provide a testing CLI flag for that
The error appears to come from the driver. See https://github.com/mongodb/mongo-go-driver/blob/v1/x/mongo/driver/batches.go#L17. So the request didn't reached FerretDB as the driver returned error before that. Let's see what we can do before we add testing CLI flag.
So the request didn't reached FerretDB as the driver returned error before that.
It seems that MaxDocumentSize
is a configurable value indicated by the server.
https://github.com/mongodb/mongo-go-driver/blob/345ea9574e28732ca4f9d7d3bb9c103c897a65b8/x/mongo/driver/operation.go#L713
That MaxDocumentSize
is internal representation of server and not configurable for a driver. See information about x
package https://github.com/mongodb/mongo-go-driver/tree/345ea9574e28732ca4f9d7d3bb9c103c897a65b8/x
Update: I don't find implementation within FerretDB restricting maximum document size. And drivers are out of our control unfortunately.
In fact, this is indeed configurable 🙈 The value that sets driver was the response from isMaster command's maxBsonObjectSize
field.