Permalink
Browse files

JAVA-1126: Fixed infinite loop in OrderedRunGenerator if write count …

…> max write batch size
  • Loading branch information...
jyemin committed Feb 28, 2014
1 parent 1550273 commit 9fb293568dffa412372870feaa73b3477e0cfd5d
@@ -570,7 +570,7 @@ public Run next() {
private int getStartIndexOfNextRun() {
WriteRequest.Type type = writeRequests.get(curIndex).getType();
for (int i = curIndex; i < writeRequests.size(); i++) {
- if (i == db.getConnector().getServerDescription(port.getAddress()).getMaxWriteBatchSize()
+ if (i == curIndex + db.getConnector().getServerDescription(port.getAddress()).getMaxWriteBatchSize()
|| writeRequests.get(i).getType() != type) {
return i;
}
@@ -266,6 +266,34 @@ class BulkWriteOperationSpecification extends FunctionalSpecification {
collection.findOne(new BasicDBObject('_id', 8)) == new BasicDBObject('_id', 8)
}
+ def 'should split ordered when the number of writes is larger than the match write batch size'() {
+ given:
+ def op = collection.initializeOrderedBulkOperation()
+ (0..2000).each {
+ op.insert(new BasicDBObject())
+ }
+
+ when:
+ op.execute()
+
+ then:
+ collection.find().count() == 2001
+ }
+
+ def 'should split unordered when the number of writes is larger than the match write batch size'() {
+ given:
+ def op = collection.initializeUnorderedBulkOperation()
+ (0..2000).each {
+ op.insert(new BasicDBObject())
+ }
+
+ when:
+ op.execute()
+
+ then:
+ collection.find().count() == 2001
+
+ }
def 'error details should have correct index on unordered write failure'() {
given:
collection.insert(getTestInserts())

0 comments on commit 9fb2935

Please sign in to comment.