File: removeb.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (39 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (3)
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
// Test removal of Records that have been reused since the remove operation began.  SERVER-5198

t = db.jstests_removeb;
t.drop();

t.ensureIndex( { a:1 } );

// Make the index multikey to trigger cursor dedup checking.
t.insert( { a:[ -1, -2 ] } );
t.remove();

// Insert some data.
for( i = 0; i < 20000; ++i ) {
    t.insert( { a:i } );
}
db.getLastError();

p = startParallelShell(
                       // Wait until the remove operation (below) begins running.
                       'while( db.jstests_removeb.count() == 20000 );' +
                       // Insert documents with increasing 'a' values.  These inserted documents may
                       // reuse Records freed by the remove operation in progress and will be
                       // visited by the remove operation if it has not completed.
                       'for( i = 20000; i < 40000; ++i ) {' +
                       '    db.jstests_removeb.insert( { a:i } );' +
                       '    db.getLastError();' +
                       '    if (i % 1000 == 0) {' +
                       '        print( i-20000 + \" of 20000 documents inserted\" );' +
                       '    }' +
                       '}'
                       );

// Remove using the a:1 index in ascending direction.
t.remove( { a:{ $gte:0 } } );
assert( !db.getLastError(), 'The remove operation failed.' );

p();

t.drop();