With a sharded setup, enable sharding on a collection:
> db.runCommand( { shardcollection : "test.testshard", key :
{ name : 1, age: 1 } } )
> use test
> db.testshard.insert(
)
-
- Actual behavior:
... one second later ...
"tried to insert object with no valid shard key for
{ name: 1.0, age: 1.0 }:
{ _id: ObjectId('4ff1ecd2118f035ab2938dad'), age: 1.0 }"
-
- Expected behavior:
The error message should respond immediately.
These delays "stack up"; e.g. for each invalid document inserted, the delayed response increases by one second. So, with a nodejs program, 6 parallel inserts (followed by getLastError) means waiting for 6 seconds to get the error response.