Configurable Zstd compression level does not work in PyMongo

MongoDB server 5.0.1
PyMongo 3.12.0

Zstd compression level setting is declared in MongoDB 5.0. But it doesn’t work for me in PyMongo.

Code:
coll_obj = trg_db_obj.create_collection(src_file_name[:-3], storageEngine={'wiredTiger': {'configString': 'block_compressor=zstd,zstdCompressionLevel=22'}})

Error:
pymongo.errors.OperationFailure: 22: Invalid argument. [1627214735:927020][2228:0x7fce9f9c1700], wiredtiger_config_validate: config_check_search, 65: unknown configuration key: 'zstdCompressionLevel': Invalid argument., full error: {'ok': 0.0, 'errmsg': "22: Invalid argument. [1627214735:927020][2228:0x7fce9f9c1700], wiredtiger_config_validate: config_check_search, 65: unknown configuration key: 'zstdCompressionLevel': Invalid argument.", 'code': 2, 'codeName': 'BadValue'}

If I replace zstdCompressionLevel to zstd_compression_level, the result is the same.

I believe those options are only configurable by way of MongoDB’s configuration file, not through the createCollection command.

1 Like

Okay, let that be my feature request.

1 Like

Currently facing the same problem, it would be very beneficial if the compression level could be set on a collection level.

1 Like

Hi @Robin_Muller, @Platon_workaccount,

For server feature requests, please create a new suggestion on the MongoDB Feedback site including more information on your use case.

As noted earlier in this discussion, zstdCompressionLevel is a server-level configuration setting added in MongoDB 5.0. If you are using zstd as a blockCompressor and change the zstdCompressionLevel value, all subsequent collections created will inherit this default.

Regards,
Stennie

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.