Skip to content

Commit 7e7b57a

Browse files
author
rstam
committed
CSHARP-715: InsertBatch fails when large batch has to be split into smaller sub batches.
1 parent 072aad4 commit 7e7b57a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

MongoDB.Driver/Communication/Messages/MongoInsertMessage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ internal byte[] RemoveLastDocument(BsonBuffer buffer)
6060
var lastDocumentLength = buffer.Position - _lastDocumentStartPosition;
6161
buffer.Position = _lastDocumentStartPosition;
6262
var lastDocument = buffer.ReadBytes(lastDocumentLength);
63+
buffer.Position = _lastDocumentStartPosition;
6364
buffer.Length = _lastDocumentStartPosition;
6465
BackpatchMessageLength(buffer);
6566
return lastDocument;
@@ -68,6 +69,7 @@ internal byte[] RemoveLastDocument(BsonBuffer buffer)
6869
internal void ResetBatch(BsonBuffer buffer, byte[] lastDocument)
6970
{
7071
buffer.Position = _firstDocumentStartPosition;
72+
buffer.Length = _firstDocumentStartPosition;
7173
buffer.WriteBytes(lastDocument);
7274
BackpatchMessageLength(buffer);
7375
}

0 commit comments

Comments
 (0)