[CSHARP-4730] Unable to set Network Compression via Connection String for "zstd" when using MongoUrlBuilder Created: 25/Jul/23  Updated: 28/Oct/23  Resolved: 20/Oct/23

Status: Closed
Project: C# Driver
Component/s: URI Options
Affects Version/s: None
Fix Version/s: 2.23.0

Type: Bug Priority: Major - P3
Reporter: Ruben Ramirez Assignee: James Kovacs
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2023-08-02 at 1.55.06 PM.png     PNG File image-2023-07-25-14-02-08-498.png    
Backwards Compatibility: Minor Change
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

We are unable to set Network Compression to "zstd" via the connection string. We use the MongoUrlBuilder to create the connection string. The Network Compression is lost when building the string via the MongoUrlBuidler.ToString() method. 

Please provide the version of the driver. v = 2.20

How to Reproduce

  1. Copy -paste the proceeding code into an .net application
  2. Add a breakpoint on "hasNetworkCompressorSetting"
  3. Run code

Expected: hasNetworkCompressorSetting == true

Actual: hasNetworkCompressorSetting == false

 

var mongoConnectionString = "baseMongoConnectionString?compressors=zstd";
var builder = new MongoUrlBuilder(mongoConnectionString);
var builderConnectionString = builder.ToString(); // results in
"baseMongoConnectionString?compressors=zstandard"
var settings = MongoClientSetttings.FromConnectionString(builderConnectionString);
var hasNetworkCompressorSetting = settings.Compressors.Any()

 

 

Additional Background

I believe this should be a quick fix. The problem lies in the mapper. I've attached the code that prevents the compressor from being added. It does not register 'zstandard" as "zstd". A couple of potential fixes are:

  1. Rename CompressorType.ZStandard to CompressorType.Zstd
  2. Modify ConnectionString.SaveCompressors() to add the compressor if it's already in the ServerName format


 Comments   
Comment by Githook User [ 20/Oct/23 ]

Author:

{'name': 'James Kovacs', 'email': 'jkovacs@post.harvard.edu', 'username': 'JamesKovacs'}

Message: CSHARP-4730: Always encode CompressionType.ZStandard as zstd. (#1207)
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/680cb4e1ea776a075bf1589d28b310797732cf55

Comment by PM Bot [ 25/Jul/23 ]

Hi rcramirezjr93@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.