Create index concurrency fix

This commit is contained in:
Kyle Banker 2010-11-09 13:34:28 -05:00
parent ced3bfbfe8
commit b4d5448179
3 changed files with 16 additions and 15 deletions

View File

@ -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

View File

@ -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]])

View File

@ -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