Skip to content

Commit 50c119f

Browse files
committed
CSHARP-2123: Round up to the next highest integral maxTimeMS instead of truncating.
1 parent ef9872a commit 50c119f

File tree

64 files changed

+646
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+646
-219
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TestResults
1212
project.lock.json
1313
.vscode
1414

15-
#JetBrains Rider artifcats
15+
# JetBrains Rider artifacts
1616
.idea
1717

1818
# CodeReview

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Please see our [guidelines](CONTRIBUTING.md) for contributing to the driver.
104104
* Jacob Jewell [email protected]
105105
* Danny Kendrick https://github.com/dkendrick
106106
* Brian Knight [email protected]
107+
* Andrey Kondratyev https://github.com/byTimo
107108
* Anatoly Koperin https://github.com/ExM
108109
* Nik Kolev [email protected]
109110
* Oleg Kosmakov https://github.com/kosmakoff

src/MongoDB.Driver.Core/Core/Operations/AggregateExplainOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public BsonValue Hint
124124
public TimeSpan? MaxTime
125125
{
126126
get { return _maxTime; }
127-
set { _maxTime = value; }
127+
set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
128128
}
129129

130130
/// <summary>
@@ -160,7 +160,7 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
160160
{ "explain", true },
161161
{ "pipeline", new BsonArray(_pipeline) },
162162
{ "allowDiskUse", () => _allowDiskUse.Value, _allowDiskUse.HasValue },
163-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
163+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
164164
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
165165
{ "hint", () => _hint, _hint != null },
166166
{ "comment", () => _comment, _comment != null }

src/MongoDB.Driver.Core/Core/Operations/AggregateOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public TimeSpan? MaxAwaitTime
157157
public TimeSpan? MaxTime
158158
{
159159
get { return _maxTime; }
160-
set { _maxTime = value; }
160+
set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
161161
}
162162

163163
/// <summary>
@@ -277,7 +277,7 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
277277
{ "aggregate", _collectionNamespace.CollectionName },
278278
{ "pipeline", new BsonArray(_pipeline) },
279279
{ "allowDiskUse", () => _allowDiskUse.Value, _allowDiskUse.HasValue },
280-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
280+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
281281
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
282282
{ "hint", () => _hint, _hint != null },
283283
{ "comment", () => _comment, _comment != null }

src/MongoDB.Driver.Core/Core/Operations/AggregateToCollectionOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public BsonValue Hint
140140
public TimeSpan? MaxTime
141141
{
142142
get { return _maxTime; }
143-
set { _maxTime = value; }
143+
set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
144144
}
145145

146146
/// <summary>
@@ -220,7 +220,7 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
220220
{ "pipeline", new BsonArray(_pipeline) },
221221
{ "allowDiskUse", () => _allowDiskUse.Value, _allowDiskUse.HasValue },
222222
{ "bypassDocumentValidation", () => _bypassDocumentValidation.Value, _bypassDocumentValidation.HasValue && Feature.BypassDocumentValidation.IsSupported(serverVersion) },
223-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
223+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
224224
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
225225
{ "writeConcern", () => _writeConcern.ToBsonDocument(), Feature.CommandsThatWriteAcceptWriteConcern.ShouldSendWriteConcern(serverVersion, _writeConcern) },
226226
{ "cursor", new BsonDocument(), serverVersion >= new SemanticVersion(3, 5, 0) },

src/MongoDB.Driver.Core/Core/Operations/AsyncCursor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private BsonDocument CreateGetMoreCommand()
157157
{ "getMore", _cursorId },
158158
{ "collection", _collectionNamespace.CollectionName },
159159
{ "batchSize", () => _batchSize.Value, _batchSize > 0 },
160-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue }
160+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue }
161161
};
162162

163163
return command;

src/MongoDB.Driver.Core/Core/Operations/CountOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
172172
{ "limit", () => _limit.Value, _limit.HasValue },
173173
{ "skip", () => _skip.Value, _skip.HasValue },
174174
{ "hint", _hint, _hint != null },
175-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
175+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
176176
{ "collation", () => _collation.ToBsonDocument(), _collation != null }
177177
};
178178

src/MongoDB.Driver.Core/Core/Operations/DistinctOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
191191
{ "distinct", _collectionNamespace.CollectionName },
192192
{ "key", _fieldName },
193193
{ "query", _filter, _filter != null },
194-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
194+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
195195
{ "collation", () => _collation.ToBsonDocument(), _collation != null }
196196
};
197197

src/MongoDB.Driver.Core/Core/Operations/EvalOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ internal BsonDocument CreateCommand()
152152
{ "$eval", _function },
153153
{ "args", () => new BsonArray(_args), _args != null },
154154
{ "nolock", () => _noLock.Value, _noLock.HasValue },
155-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue }
155+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue }
156156
};
157157
}
158158

src/MongoDB.Driver.Core/Core/Operations/FindCommandOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public int? MaxScan
255255
public TimeSpan? MaxTime
256256
{
257257
get { return _maxTime; }
258-
set { _maxTime = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); }
258+
set { _maxTime = Ensure.IsNullOrInfiniteOrGreaterThanOrEqualToZero(value, nameof(value)); }
259259
}
260260

261261
/// <summary>
@@ -434,7 +434,7 @@ internal BsonDocument CreateCommand(ConnectionDescription connectionDescription,
434434
{ "singleBatch", () => _limit < 0 || _singleBatch.Value, _limit < 0 || _singleBatch.HasValue },
435435
{ "comment", _comment, _comment != null },
436436
{ "maxScan", () => _maxScan.Value, _maxScan.HasValue },
437-
{ "maxTimeMS", () => (int)_maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
437+
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue },
438438
{ "max", _max, _max != null },
439439
{ "min", _min, _min != null },
440440
{ "returnKey", () => _returnKey.Value, _returnKey.HasValue },

0 commit comments

Comments
 (0)