File: drop2.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 (48 lines) | stat: -rw-r--r-- 1,294 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
40
41
42
43
44
45
46
47
48
t = db.jstests_drop2;
t.drop();

function debug( x ) {
    printjson( x );
}

t.save( {} );
db.getLastError();

function op( drop ) {
    p = db.currentOp().inprog;
    debug( p );
    for ( var i in p ) {
        var o = p[ i ];
        if ( drop ) {
            if (  o.query && o.query.drop && o.query.drop == "jstests_drop2" ) {
                return o.opid;
            }
        } else {
            if (  o.query && o.query.query && o.query.query.$where && o.ns == "test.jstests_drop2" ) {
                return o.opid;
            }
        }
    }
    return null;
}

s1 = startParallelShell( "print(\"Count thread started\");"
                         + "db.jstests_drop2.count( { $where: function() {"
                         + "while( 1 ) { sleep( 1 ); } } } );"
                         + "print(\"Count thread terminating\");" );
countOp = null;
assert.soon( function() { countOp = op( false ); return countOp; } );

s2 = startParallelShell( "print(\"Drop thread started\");"
                         + "db.jstests_drop2.drop();"
                         + "print(\"Drop thread terminating\")" );
dropOp = null;
assert.soon( function() { dropOp = op( true ); return dropOp; } );

db.killOp( dropOp );
db.killOp( countOp );

s1();
s2();

t.drop(); // in SERVER-1818, this fails