blob: 1e81bee56ea54d991c3148159b7a0818bef308b8 (
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
49
50
51
52
|
// this test makes sure that old journal files are removed
// tunables
STRING_SIZE = 1024*1024;
NUM_TO_INSERT = 2.5*1024;
PATH = "/data/db/dur_remove_old_journals";
SYNC_DELAY = 5; // must be a number
conn = startMongodEmpty("--port", 30001, "--dbpath", PATH, "--dur", "--smallfiles", "--syncdelay", ''+SYNC_DELAY);
db = conn.getDB("test");
longString = 'x';
while (longString.length < STRING_SIZE)
longString += longString;
numInserted = 0;
while (numInserted < NUM_TO_INSERT){
db.foo.insert({_id: numInserted++, s:longString});
if (numInserted % 100 == 0){
print("numInserted: " + numInserted);
db.adminCommand({fsync:1});
db.foo.remove();
db.adminCommand({fsync:1});
}
}
sleepSecs = SYNC_DELAY + 15 // long enough for data file flushing and journal keep time
print("\nWaiting " + sleepSecs + " seconds...\n");
sleep(sleepSecs*1000);
files = listFiles(PATH + "/journal")
printjson(files);
var nfiles = 0;
files.forEach(function (file) {
assert.eq('string', typeof (file.name)); // sanity checking
if (/prealloc/.test(file.name)) {
;
}
else {
nfiles++;
}
})
assert.eq(2, nfiles); // latest journal file and lsn
stopMongod(30001);
print("*** success ***");
|