0

在带有 PHP 的 MongoDb 2.2.0 上,我正在运行这个简单的命令:

  $collection->ensureIndex(array(
    'feed_nid' => 1,
    'guid' => 1,
  ), array(
    'unique' => TRUE,
    'dropDups' => TRUE,
  ));

它应该创建一个新的唯一索引,并删除重复项。但是 MongoDb 陷入了这样的循环:

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  

这个堆栈重复了数千次,却从未破坏过“本地数据库锁”。这是在一个完全没有流量的测试服务器上。尝试重启 MongoDb 几次,无济于事。

有什么帮助...?

-附加信息-

在 Windows 7 64 位上使用 Apache 2.4.2、PHP 5.4.3 在 WAMP 上运行。它是来自 downloads.mongodb.org/win32/mongodb-win32-x86_64-2.2.0.zip 的 64 位 MongoDb 版本

MongoDb 2.0.7 也存在这个问题......

当我使用 RockMongo 之类的工具创建索引(dropDups 独有)时,会显示不同的错误:

E11000 duplicate key error index: local.fields_current.flatrow.$feed_nid_1_guid_1_unq dup key: { : 314, : "299435" }
4

1 回答 1

0

使用“背景:真实”似乎可以完成这项工作!

  $collection->ensureIndex(array(
    'feed_nid' => 1,
    'guid' => 1,
  ), array(
    'unique' => TRUE,
    'dropDups' => TRUE,
    'background' => TRUE,
  ));
于 2012-10-10T23:19:15.740 回答