-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,54 @@ | |||
// Check proper covered index handling when query and processGetMore yield. | |||
// SERVER-4975 | |||
|
|||
if ( 0 ) { // SERVER-4975 | |||
|
|||
t = db.jstests_coveredIndex3; | |||
t2 = db.jstests_coveredIndex3_other; | |||
t.drop(); | |||
t2.drop(); | |||
|
|||
function doTest( batchSize ) { | |||
|
|||
// Insert an array, which will make the { a:1 } index multikey and should disable covered index | |||
// matching. | |||
p1 = startParallelShell( | |||
'for( i = 0; i < 60; ++i ) { \ | |||
db.jstests_coveredIndex3.save( { a:[ 2000, 2001 ] } ); \ | |||
sleep( 300 ); \ | |||
}' | |||
); | |||
|
|||
// Frequent writes cause the find operation to yield. | |||
p2 = startParallelShell( | |||
'for( i = 0; i < 1800; ++i ) { \ | |||
db.jstests_coveredIndex3_other.save( {} ); \ | |||
sleep( 10 ); \ | |||
}' | |||
); | |||
|
|||
for( i = 0; i < 30; ++i ) { | |||
t.drop(); | |||
t.ensureIndex( { a:1 } ); | |||
|
|||
for( j = 0; j < 1000; ++j ) { | |||
t.save( { a:j } ); | |||
} | |||
|
|||
c = t.find( {}, { _id:0, a:1 } ).hint( { a:1 } ).batchSize( batchSize ); | |||
while( c.hasNext() ) { | |||
o = c.next(); | |||
// If o contains a high numeric 'a' value, it must come from an array saved in p1. | |||
assert( !( o.a > 1500 ), 'improper object returned ' + tojson( o ) ); | |||
} | |||
} | |||
|
|||
p1(); | |||
p2(); | |||
|
|||
} | |||
|
|||
doTest( 2000 ); // Test query. | |||
doTest( 500 ); // Try to test getMore - not clear if this will actually trigger the getMore issue. | |||
|
|||
} |