Skip to content

Commit e25f978

Browse files
committed
corrected issue with not setting MaxBatchCount in all cases. Also added MongoDefaults.MaxBatchCount.
1 parent ab14dab commit e25f978

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

MongoDB.Driver/CommandResults/IsMasterResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public int MinWireVersion
169169
/// </value>
170170
public int MaxWriteBatchSize
171171
{
172-
get { return Response.GetValue("maxWriteBatchSize", 1000).ToInt32(); }
172+
get { return Response.GetValue("maxWriteBatchSize", MongoDefaults.MaxBatchCount).ToInt32(); }
173173
}
174174

175175
/// <summary>

MongoDB.Driver/Communication/MongoServerInstance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ internal MongoServerInstance(MongoServerSettings settings, MongoServerAddress ad
7474
_state = MongoServerState.Disconnected;
7575
_serverInfo = new ServerInformation
7676
{
77+
MaxBatchCount = MongoDefaults.MaxBatchCount,
7778
MaxDocumentSize = MongoDefaults.MaxDocumentSize,
7879
MaxMessageLength = MongoDefaults.MaxMessageLength,
7980
InstanceType = MongoServerInstanceType.Unknown
@@ -684,6 +685,7 @@ private void LookupServerInformation(MongoConnection connection)
684685
IsPassive = isMasterResult.IsPassive,
685686
IsPrimary = isMasterResult.IsPrimary,
686687
IsSecondary = isMasterResult.IsSecondary,
688+
MaxBatchCount = isMasterResult.MaxWriteBatchSize,
687689
MaxDocumentSize = isMasterResult.MaxBsonObjectSize,
688690
MaxMessageLength = isMasterResult.MaxMessageLength,
689691
ReplicaSetInformation = replicaSetInformation

MongoDB.Driver/MongoDefaults.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static class MongoDefaults
3030
private static TimeSpan __connectTimeout = TimeSpan.FromSeconds(30);
3131
private static TimeSpan __maxConnectionIdleTime = TimeSpan.FromMinutes(10);
3232
private static TimeSpan __maxConnectionLifeTime = TimeSpan.FromMinutes(30);
33+
private static int __maxBatchCount = 1000;
3334
private static int __maxConnectionPoolSize = 100;
3435
private static int __maxMessageLength = 16000000; // 16MB (not 16 MiB!)
3536
private static int __minConnectionPoolSize = 0;
@@ -102,6 +103,15 @@ public static GuidRepresentation GuidRepresentation
102103
set { BsonDefaults.GuidRepresentation = value; }
103104
}
104105

106+
/// <summary>
107+
/// Gets or sets the maximum batch count.
108+
/// </summary>
109+
public static int MaxBatchCount
110+
{
111+
get { return __maxBatchCount; }
112+
set { __maxBatchCount = value; }
113+
}
114+
105115
/// <summary>
106116
/// Gets or sets the max connection idle time.
107117
/// </summary>

0 commit comments

Comments
 (0)