Create index concurrency fix
This commit is contained in:
parent
ced3bfbfe8
commit
b4d5448179
@ -433,17 +433,18 @@ module Mongo
|
||||
}
|
||||
selector.merge!(opts)
|
||||
|
||||
insert_documents([selector], Mongo::DB::SYSTEM_INDEX_COLLECTION, false, false)
|
||||
response = @db.get_last_error
|
||||
begin
|
||||
insert_documents([selector], Mongo::DB::SYSTEM_INDEX_COLLECTION, false, true)
|
||||
|
||||
if response['err']
|
||||
if response['code'] == 11000 && selector[:dropDups]
|
||||
rescue Mongo::OperationFailure => e
|
||||
if selector[:dropDups] && e.message =~ /^11000/
|
||||
# NOP. If the user is intentionally dropping dups, we can ignore duplicate key errors.
|
||||
else
|
||||
raise Mongo::OperationFailure, "Failed to create index #{selector.inspect} with the following error: " +
|
||||
"#{response['err']}"
|
||||
"#{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
name
|
||||
end
|
||||
|
||||
@ -630,7 +631,7 @@ module Mongo
|
||||
# Rename this collection.
|
||||
#
|
||||
# Note: If operating in auth mode, the client must be authorized as an admin to
|
||||
# perform this operation.
|
||||
# perform this operation.
|
||||
#
|
||||
# @param [String] new_name the new name for this collection
|
||||
#
|
||||
|
@ -130,11 +130,6 @@ class TestCollection < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_safe_responses
|
||||
response = @@test.insert({:a => 1}, :safe => true)
|
||||
assert_equal false, response
|
||||
end
|
||||
|
||||
def test_maximum_insert_size
|
||||
docs = []
|
||||
16.times do
|
||||
@ -721,6 +716,15 @@ class TestCollection < Test::Unit::TestCase
|
||||
@collection.create_index([['b', 1], ['a', 1]])
|
||||
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
|
||||
setup do
|
||||
@collection.create_index([['b', 1], ['a', 1]])
|
||||
|
@ -175,10 +175,6 @@ class DBTest < Test::Unit::TestCase
|
||||
assert_nil @@db.previous_error
|
||||
end
|
||||
|
||||
def test_get_last_error_helper
|
||||
p @@db.get_last_error
|
||||
end
|
||||
|
||||
def test_check_command_response
|
||||
command = {:forceerror => 1}
|
||||
assert_raise OperationFailure do
|
||||
|
Loading…
Reference in New Issue
Block a user