summaryrefslogtreecommitdiff
path: root/jstests/slowNightly/dur_big_atomic_update.js
blob: 800b4b831fb87d5ff1c7a1ad5504ebdb131aa95f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// @file dur_big_atomic_update.js
//
// this tests writing 1GB in an atomic update to make sure we commit periodically

var path = "/data/db/dur_big_atomic_update";

conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--durOptions", 8);
d = conn.getDB("test");
d.foo.drop();

for (var i=0; i<1024; i++){
    d.foo.insert({_id:i});
}

big_string = 'x';
while (big_string.length < 1024*1024) {
    big_string += big_string;
}

d.foo.update({$atomic:1}, {$set: {big_string: big_string}}, false, /*multi*/true);
err = d.getLastErrorObj();

assert(err.err == null);
assert(err.n == 1024);

d.dropDatabase();

for (var i=0; i<1024; i++){
    d.foo.insert({_id:i});
}

// Do it again but in a db.eval
d.eval(
    function(host, big_string) {
        new Mongo(host).getDB("test").foo.update({}, {$set: {big_string: big_string}}, false, /*multi*/true)
    }, conn.host, big_string); // Can't pass in connection or DB objects

err = d.getLastErrorObj();

assert(err.err == null);
assert(err.n == 1024);

// free up space
d.dropDatabase();

stopMongod(30001);

print("dur big atomic update SUCCESS");