[CSHARP-2017] DeleteMany().DeletedCount overflow Created: 14/Jul/17  Updated: 27/Oct/23  Resolved: 19/Jul/17

Status: Closed
Project: C# Driver
Component/s: Operations
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Alexander Babkin Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 3.2.10, windows 10 64-bit (the same on centOS)


Issue Links:
Related
is related to SERVER-30232 delete command on mongos can return a... Backlog
Backwards Compatibility: Fully Compatible

 Description   

For example, I have collection wtih documents count a little bit more than int.MaxValue.
DeleteMany to all documents on this collection returns DeletedCount (long). This DeletedCount will be negative, because an overflow has occured.

var mongoServer = Create("mongodb://localhost:27017", 1024, 1024);
var db = mongoServer.GetDatabase("overflow");
var coll = db.GetCollection<MyInt>("overflowcoll");
var deletedCount = coll.DeleteManyAsync(filter)
                .GetAwaiter().GetResult().DeletedCount;



 Comments   
Comment by Robert Stam [ 19/Jul/17 ]

Closing driver ticket because it turns out it is a server issue.

Comment by Robert Stam [ 19/Jul/17 ]

Linked to server ticket.

Comment by Robert Stam [ 19/Jul/17 ]

Upon further investigation this turns out to be a server issue, not a driver issue (the previous comment is wrong).

While the issue exists in server version 3.2.10, it no longer exists in server version 3.4.6. I'm not sure in which version exactly of the server this was changed.

Comment by Robert Stam [ 18/Jul/17 ]

I have verified that this is a bug. While DeletedCount is a long, the driver uses an int in some lower level code which results in the overflow.

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