Mongo:“不允许复制”

时间:2018-10-05 10:33:55

标签: java mongodb groovy spring-data-mongodb

我有一个很小的常规脚本,可以对Mongo DB ver的副本集运行.mongo文件。 3.6:

ScriptOperations scriptOps = new MongoTemplate( mongoClient, 'mydb' ).scriptOps()

[ 'inx.mongo', 'roles.mongo' ].each{
  try{
    ExecutableMongoScript s = new ExecutableMongoScript( new File( it ).text )
    def res = scriptOps.execute s
    log.info "processed $it >> $res"
  }catch( Throwable t ){
    log.error "$it --> $t"
  }
}

运行脚本时,我得到了日志:

  

10:22:23.017 [main]信息迁移器-处理过的inx.mongo >> [retval:[createdCollectionAutomatically:false,numIndexesBefore:4,numIndexesAfter:4,note:所有索引已经存在,确定:1.0,operationTime:Timestamp {value = 6608816253102456876,seconds = 1538734942,inc = 44},$ clusterTime:[clusterTime:Timestamp {value = 6608816253102456876,seconds = 1538734942,inc = 44},签名:[hash:org.bson.types.Binary@c98f581, keyId:0]]],确定:1.0,operationTime:Timestamp {value = 6608816253102456876,秒= 1538734942,inc = 44},$ clusterTime:[clusterTime:Timestamp {value = 6608816253102456876,秒= 1538734942,inc = 44},签名:[hash:org.bson.types.Binary @ c98f581,keyId:0]]]

     

10:22:23.087 [main]错误迁移器-Roles.mongo-> com.mongodb.MongoCommandException:命令失败,错误139:'错误:持有锁时不允许等待复制:   _getErrorWithCode@src/mongo/shell/utils.js:25:13   DB.prototype.updateRole@src/mongo/shell/db.js:1713:19   @:1:1   在服务器mozaiq_mongo2_1:27002上。完整的响应为{“ operationTime”:{“ $ timestamp”:{“ t”:1538734942,“ i”:44}},“ ok”:0.0,“ errmsg”:“错误:在保留期间不允许等待复制锁:\ n_getErrorWithCode@src/mongo/shell/utils.js:25:13 \ nDB.prototype.updateRole@src/mongo/shell/db.js:1713:19 \ n @:1:1 \ n“, “ code”:139,“ codeName”:“ JSInterpreterFailure”,“ $ clusterTime”:{“ clusterTime”:{“ $ timestamp”:{“ t”:1538734942,“ i”:44}},“签名”:{ “ hash”:{“ $ binary”:“ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA =”,“ $ type”:“ 00”},“ keyId”:{“ $ numberLong”:“ 0”}}}}

因此,第一个文件inx.mongo似乎处理得很好,但是第二个文件roles.mongo抛出了Error: Waiting for replication not allowed while holding a lock

如何解决此问题?

0 个答案:

没有答案