Create index concurrency fix
This commit is contained in:
parent
ced3bfbfe8
commit
b4d5448179
|
@ -433,17 +433,18 @@ module Mongo
|
||||||
}
|
}
|
||||||
selector.merge!(opts)
|
selector.merge!(opts)
|
||||||
|
|
||||||
insert_documents([selector], Mongo::DB::SYSTEM_INDEX_COLLECTION, false, false)
|
begin
|
||||||
response = @db.get_last_error
|
insert_documents([selector], Mongo::DB::SYSTEM_INDEX_COLLECTION, false, true)
|
||||||
|
|
||||||
if response['err']
|
rescue Mongo::OperationFailure => e
|
||||||
if response['code'] == 11000 && selector[:dropDups]
|
if selector[:dropDups] && e.message =~ /^11000/
|
||||||
# NOP. If the user is intentionally dropping dups, we can ignore duplicate key errors.
|
# NOP. If the user is intentionally dropping dups, we can ignore duplicate key errors.
|
||||||
else
|
else
|
||||||
raise Mongo::OperationFailure, "Failed to create index #{selector.inspect} with the following error: " +
|
raise Mongo::OperationFailure, "Failed to create index #{selector.inspect} with the following error: " +
|
||||||
"#{response['err']}"
|
"#{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -130,11 +130,6 @@ class TestCollection < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_safe_responses
|
|
||||||
response = @@test.insert({:a => 1}, :safe => true)
|
|
||||||
assert_equal false, response
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_maximum_insert_size
|
def test_maximum_insert_size
|
||||||
docs = []
|
docs = []
|
||||||
16.times do
|
16.times do
|
||||||
|
@ -721,6 +716,15 @@ class TestCollection < Test::Unit::TestCase
|
||||||
@collection.create_index([['b', 1], ['a', 1]])
|
@collection.create_index([['b', 1], ['a', 1]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "allow multiple calls to create_index" do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
should "allow creation of multiple indexes" do
|
||||||
|
assert @collection.create_index([['a', 1]])
|
||||||
|
assert @collection.create_index([['a', 1]])
|
||||||
|
end
|
||||||
|
|
||||||
context "with an index created" do
|
context "with an index created" do
|
||||||
setup do
|
setup do
|
||||||
@collection.create_index([['b', 1], ['a', 1]])
|
@collection.create_index([['b', 1], ['a', 1]])
|
||||||
|
|
|
@ -175,10 +175,6 @@ class DBTest < Test::Unit::TestCase
|
||||||
assert_nil @@db.previous_error
|
assert_nil @@db.previous_error
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_last_error_helper
|
|
||||||
p @@db.get_last_error
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_check_command_response
|
def test_check_command_response
|
||||||
command = {:forceerror => 1}
|
command = {:forceerror => 1}
|
||||||
assert_raise OperationFailure do
|
assert_raise OperationFailure do
|
||||||
|
|
Loading…
Reference in New Issue