summaryrefslogtreecommitdiff
path: root/jstests/mmap_v1
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2018-03-20 17:56:02 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2018-03-20 17:57:31 -0400
commit2682dbfb28324406f6eded1f22f6e342a392ff13 (patch)
tree1a12a708dd45c159ce3a803090a7397e40fc68b7 /jstests/mmap_v1
parent152e55c697613b0d99c619e9569fd6e57c303d2f (diff)
downloadmongo-2682dbfb28324406f6eded1f22f6e342a392ff13.tar.gz
Revert "SERVER-30005: remove $isolated/$atomic option"
This reverts commit cd950b113ee0d00e88036b2fe6306866c7ba27f9.
Diffstat (limited to 'jstests/mmap_v1')
-rw-r--r--jstests/mmap_v1/dur_big_atomic_update.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/jstests/mmap_v1/dur_big_atomic_update.js b/jstests/mmap_v1/dur_big_atomic_update.js
new file mode 100644
index 00000000000..567349ed72b
--- /dev/null
+++ b/jstests/mmap_v1/dur_big_atomic_update.js
@@ -0,0 +1,50 @@
+// @file dur_big_atomic_update.js
+//
+// this tests writing 1GB in an atomic update to make sure we commit periodically
+
+var conn = MongoRunner.runMongod({journal: "", journalOptions: 8});
+d = conn.getDB("test");
+d.foo.drop();
+
+var bulk = d.foo.initializeUnorderedBulkOp();
+for (var i = 0; i < 1024; i++) {
+ bulk.insert({_id: i});
+}
+assert.writeOK(bulk.execute());
+
+var server_bits = db.serverStatus().mem.bits;
+var big_string_size = (server_bits == 32 ? 64 * 1024 : 1024 * 1024);
+
+var big_string = 'xxxxxxxxxxxxxxxx';
+while (big_string.length < big_string_size) {
+ big_string += big_string;
+}
+
+var res = assert.writeOK(
+ d.foo.update({$atomic: 1}, {$set: {big_string: big_string}}, false, true /* multi */));
+assert.eq(1024, res.nModified);
+
+d.dropDatabase();
+
+bulk = d.foo.initializeUnorderedBulkOp();
+for (var i = 0; i < 1024; i++) {
+ bulk.insert({_id: i});
+}
+assert.writeOK(bulk.execute());
+
+// Do it again but in a db.eval
+var err = d.eval(function(big_string) {
+ var db = new Mongo().getDB("test");
+ db.foo.update({}, {$set: {big_string: big_string}}, false, /*multi*/ true);
+ return db.getLastErrorObj();
+}, big_string); // Can't pass in connection or DB objects
+
+assert.eq(err.err, null, tojson(err));
+assert.eq(err.n, 1024, tojson(err));
+
+// free up space
+d.dropDatabase();
+
+MongoRunner.stopMongod(conn);
+
+print("dur big atomic update SUCCESS");