Deprecated operation requested with latest CSharp driver

MongoDB Community Server: 5.0.18
Test Application uses .NET CSharp Driver 2.21.0

Periodically in the MongoDB logs I see a message “Deprecated operation requested. The client driver may require an upgrade in order to ensure compatibility with future server versions.”

However I am using a fairly recent version of the CSharp driver.

My theory is that the driver is detecting the max wire version of the server - 13 I believe for MongoDB 5.0 - and is issuing a command using a deprecated format for this reason. I am hoping that upgrading to a newer version of the MongoDB server (say 6.0+) would lead to the CSharp driver detecting a higher max wire version, sending a command using the new message format and therefore the deprecation warning message would be eliminated.

Wondering if anyone could confirm this is indeed what is happening? Thanks.

Hi, @David_O_Shea,

Welcome to the MongoDB Community Forums. Thank you for reaching out about the “Deprecated operation requested” warning when using the .NET/C# Driver. This warning indicates that a legacy op code such as OP_QUERY or deprecated command such as getLastError was received by the server. The following is an example:

{
    "t":{
        "$date":"2022-04-29T15:28:30.850-06:00"},
        "s":"W",
        "c":"COMMAND",
        "id":5578800,
        "ctx":"conn1384",
        "msg":"Deprecated operation requested. For more details see https://dochub.mongodb.org/core/legacy-opcode-compatibility",
        "attr":{
            "op":"getLastError",
            "clientInfo":{
                "application":{"name":"MongoDB Shell"},
                "driver":{"name":"MongoDB Internal Client","version":"5.0.7"},
                "os":{"type":"Darwin","name":"Mac OS X","architecture":"x86_64","version":"21.4.0"}
            }
        }
}

We can see that the deprecated command was getLastError and that it was sent by the legacy mongo shell version 5.0.7.

Searching through my mongod logs, I do not see any deprecated commands coming from the .NET/C# Driver. Please file a CSHARP JIRA ticket with the relevant complete log lines so that we can investigate further.

Sincerely,
James

Before opening a Jira ticket - our further investigation indicates that this deprecated operation requested warning is associated with a MongoDB driver connection attempt. The following are the logs we have captured when this occurs with SetLogLevel(1):

{"t":{"$date":"2023-10-25T08:47:03.465+00:00"},"s":"W",  "c":"NETWORK",  "id":23234,   "ctx":"conn13587","msg":"No SSL certificate provided by peer"}
{"t":{"$date":"2023-10-25T08:47:03.719+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn13587","msg":"client metadata","attr":{"remote":"x.x.x.x:36848","client":"conn13587","doc":{"application":{"name":"MyTestApp"},"driver":{"name":"mongo-csharp-driver","version":"2.21.0.0"},"os":{"type":"Linux","name":"Linux 5.10.192-183.736.amzn2.x86_64 #1 SMP Wed Sep 6 21:15:41 UTC 2023","architecture":"x86_64","version":"5.10.192-183.736.amzn2.x86_64"},"platform":".NET 7.0.4"}}}
{"t":{"$date":"2023-10-25T08:47:03.719+00:00"},"s":"D1", "c":"ACCESS",   "id":20226,   "ctx":"conn13587","msg":"Returning user from cache","attr":{"user":{"user":"mytestapp_user","db":"admin"}}}
{"t":{"$date":"2023-10-25T08:47:03.719+00:00"},"s":"D1", "c":"ACCESS",   "id":20226,   "ctx":"conn13587","msg":"Returning user from cache","attr":{"user":{"user":"mytestapp_user","db":"admin"}}}
{"t":{"$date":"2023-10-25T08:47:03.719+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn13587","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","appName":"MyTestApp","command":{"isMaster":1,"helloOk":true,"client":{"application":{"name":"MyTestApp"},"driver":{"name":"mongo-csharp-driver","version":"2.21.0.0"},"os":{"type":"Linux","name":"Linux 5.10.192-183.736.amzn2.x86_64 #1 SMP Wed Sep 6 21:15:41 UTC 2023","architecture":"x86_64","version":"5.10.192-183.736.amzn2.x86_64"},"platform":".NET 7.0.4"},"compression":[],"saslSupportedMechs":"admin.mytestappdb","speculativeAuthenticate":{"saslStart":1,"mechanism":"SCRAM-SHA-256","payload":{"$binary":{"base64":"biwsbj1jY3NqcG1vcmdhbmZ4c19xYSxyPUFqXVJQPUA8YUdlJ2IpWjMvO2FE","subType":"0"}},"options":{"skipEmptyExchange":true},"db":"admin"},"$readPreference":{"mode":"secondaryPreferred"},"$db":"admin"},"numYields":0,"reslen":1159,"locks":{},"authorization":{"startedUserCacheAcquisitionAttempts":2,"completedUserCacheAcquisitionAttempts":2,"userCacheWaitTimeMicros":1},"remote":"x.x.x.x:36848","protocol":"op_query","durationMillis":0}}
{"t":{"$date":"2023-10-25T08:47:03.911+00:00"},"s":"W",  "c":"COMMAND",  "id":5578800, "ctx":"conn13587","msg":"Deprecated operation requested. The client driver may require an upgrade in order to ensure compatibility with future server versions. For more details see https://dochub.mongodb.org/core/legacy-opcode-compatibility","attr":{"op":"query","clientInfo":{"application":{"name":"MyTestApp"},"driver":{"name":"mongo-csharp-driver","version":"2.21.0.0"},"os":{"type":"Linux","name":"Linux 5.10.192-183.736.amzn2.x86_64 #1 SMP Wed Sep 6 21:15:41 UTC 2023","architecture":"x86_64","version":"5.10.192-183.736.amzn2.x86_64"},"platform":".NET 7.0.4"}}}
{"t":{"$date":"2023-10-25T08:47:03.911+00:00"},"s":"D1", "c":"ACCESS",   "id":20226,   "ctx":"conn13587","msg":"Returning user from cache","attr":{"user":{"user":"mytestapp_user","db":"admin"}}}
{"t":{"$date":"2023-10-25T08:47:03.911+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn13587","msg":"Authentication succeeded","attr":{"mechanism":"SCRAM-SHA-256","speculative":true,"principalName":"mytestapp_user","authenticationDatabase":"admin","remote":"x.x.x.x:36848","extraInfo":{}}}
{"t":{"$date":"2023-10-25T08:47:03.912+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn13587","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","appName":"MyTestApp","command":{"saslContinue":1,"conversationId":1,"payload":"xxx","$readPreference":{"mode":"secondaryPreferred"},"$db":"admin"},"numYields":0,"reslen":265,"locks":{},"authorization":{"startedUserCacheAcquisitionAttempts":1,"completedUserCacheAcquisitionAttempts":1,"userCacheWaitTimeMicros":3},"readConcern":{"level":"local","provenance":"implicitDefault"},"remote":"x.x.x.x:36848","protocol":"op_query","durationMillis":0}}
{"t":{"$date":"2023-10-25T08:47:03.913+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn13587","msg":"Slow query","attr":{"type":"command","ns":"mytestappdb.message_store","appName":"MyTestApp","command":{"find":"message_store","filter":{"NotificationId":"f61a34c1-c5a7-4b25-8f4b-b0a60090c2bb"},"limit":1,"$db":"mytestappdb","lsid":{"id":{"$uuid":"b78aeed8-3a39-4df6-a2a2-401cb33ce1ff"}},"$clusterTime":{"clusterTime":{"$timestamp":{"t":1698223623,"i":17}},"signature":{"hash":{"$binary":{"base64":"gGCqNiRGGh1rsEooZOmnE5UIXuM=","subType":"0"}},"keyId":7236338067701760005}}},"planSummary":"IXSCAN { NotificationId: 1 }","keysExamined":0,"docsExamined":0,"cursorExhausted":true,"numYields":0,"nreturned":0,"queryHash":"FF227F32","planCacheKey":"00A59619","reslen":242,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":1}},"Global":{"acquireCount":{"r":1}},"Mutex":{"acquireCount":{"r":1}}},"readConcern":{"level":"local","provenance":"implicitDefault"},"storage":{"data":{"bytesRead":3737,"timeReadingMicros":11}},"remote":"x.x.x.x:36848","protocol":"op_msg","durationMillis":0}}