On MongoDb 2.2.0 with PHP, I’m running this simple command:
$collection->ensureIndex(array(
'feed_nid' => 1,
'guid' => 1,
), array(
'unique' => TRUE,
'dropDups' => TRUE,
));
It is supposed to create a new unique index, and drop duplicates. But MongoDb is stuck in a loop that goes on like this:
Thu Oct 11 00:31:09 [conn4] ERROR: can't commitNow from commitIfNeeded, as we are in local db lock
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\util\stacktrace.cpp(161) mongo::printStackTrace+0x3e
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\dur.cpp(279) mongo::dur::DurableImpl::_aCommitIsNeeded+0x42a
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\index_update.cpp(401) mongo::BackgroundIndexBuildJob::addExistingToIndex+0x4c3
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\index_update.cpp(440) mongo::BackgroundIndexBuildJob::go+0xe0
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\index_update.cpp(501) mongo::buildAnIndex+0x321
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\pdfile.cpp(1356) mongo::insert_makeIndex+0x288
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\pdfile.cpp(1529) mongo::DataFileMgr::insert+0xbac
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\pdfile.cpp(1217) mongo::DataFileMgr::insertWithObjMod+0x48
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\instance.cpp(761) mongo::checkAndInsert+0xb7
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\instance.cpp(821) mongo::receivedInsert+0x790
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\instance.cpp(434) mongo::assembleResponse+0x5ff
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\db\db.cpp(192) mongo::MyMessageHandler::process+0xf5
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(86) mongo::pms::threadRun+0x59a
Thu Oct 11 00:31:10 [conn4] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(180) boost::`anonymous namespace'::thread_start_function+0x21
Thu Oct 11 00:31:10 [conn4] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17
Thu Oct 11 00:31:10 [conn4] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f
Thu Oct 11 00:31:10 [conn4] kernel32.dll
This stack is repeated thousands of times, without ever breaking that “local db lock”
This is on a test server with no traffic at all. Tried restarting MongoDb several times, to no avail.
Any help…?
-Additional info-
Running on WAMP with Apache 2.4.2, PHP 5.4.3 on Windows 7 64 bit. It’s the 64 bit MongoDb version from downloads.mongodb.org/win32/mongodb-win32-x86_64-2.2.0.zip
The problem also exists for MongoDb 2.0.7…
And when I use a tool like RockMongo to create the index (unique with dropDups), a different error shows:
E11000 duplicate key error index: local.fields_current.flatrow.$feed_nid_1_guid_1_unq dup key: { : 314, : "299435" }
Using ‘background: true’ seems to do the job!