gpt4 book ai didi

python - 为什么我每天早上在 CI 上都会收到 python 异常 "OperationFailure: local.oplog.rs missing. did you drop it? if so restart server"?

转载 作者:可可西里 更新时间:2023-11-01 10:44:19 27 4
gpt4 key购买 nike

最近,我们将 CI 上的 mongodb 设置为 ReplicaSet。我们有两个节点 localhost:27017、localhost:27018 和 localhost:27019 上的仲裁器(journal = false)。

MongoDB version 是 2.4.3 和 pymongo==2.5.2 在 linux Ubuntu 11.10 上运行

我们配置了集群:

cfg = {                                                                                
_id : 'my-data-cluster',
members : [
{ _id : 0, host : '127.0.0.1:27017' },
{ _id : 1, host : '127.0.0.1:27018' },
{ _id : 2, host : '127.0.0.1:27019', arbiterOnly: true}
]
};
rs.initiate(cfg);

并使用 python 调用:

MongoReplicaSetClient(hosts_or_uri=hosts, replicaSet='my-data-cluster')

好吧,那么单元测试是绿色的,验收测试是绿色的。但是每天早上(单元测试在午夜左右启动)所有的 mongo 测试都被破坏了:

Traceback (most recent call last):
commons/test/test_user_dao.py line 12 in setUp
self.user_dao = UserDao(self.connection.get(UNIT_TEST))
commons/src/user_dao.py line 9 in __init__
self.__create_indexes()
commons/src/user_dao.py line 14 in __create_indexes
self.collection.ensure_index('login', pymongo.ASCENDING, unique=True, background=True)
DEV/lib/python2.7/site-packages/pymongo/collection.py line 916 in ensure_index
return self.create_index(key_or_list, cache_for, **kwargs)
DEV/lib/python2.7/site-packages/pymongo/collection.py line 823 in create_index
**self._get_wc_override())
DEV/lib/python2.7/site-packages/pymongo/collection.py line 357 in insert
continue_on_error, self.__uuid_subtype), safe)
lib/src/mongo_connection.py line 19 in wrapper
return func(*args, **kwargs)
lib/src/mongo_connection.py line 82 in _send_message
return super(ReconnectingMongoReplicaSetClient, self)._send_message(msg, with_last_error, _connection_to_use)
DEV/lib/python2.7/site-packages/pymongo/mongo_replica_set_client.py line 1360 in _send_message
rv = self.__check_response_to_last_error(response)
DEV/lib/python2.7/site-packages/pymongo/mongo_replica_set_client.py line 1271 in __check_response_to_last_error
raise OperationFailure(error["err"], error["code"])
OperationFailure: local.oplog.rs missing. did you drop it? if so restart server

我检查了服务器日志,我看到的唯一可疑行如下所示:

09:13:53.788 [rsBackgroundSync] replSet db exception in producer: 1000 replSet source for syncing doesn't seem to be await capable -- is it an older version of mongodb?

当我重新启动三个 Mongo 实例时,测试恢复为绿色。

最佳答案

我们发现我们每晚都在清理 mongo 数据库:

db.adminCommand("listDatabases").databases.forEach( function (d) {
if (d.name != "admin" && d.name != "config")
db.getSiblingDB(d.name).dropDatabase();
})

但是我们放弃了 db.local 这不是一个好主意:它保存了副本集配置!

关于python - 为什么我每天早上在 CI 上都会收到 python 异常 "OperationFailure: local.oplog.rs missing. did you drop it? if so restart server"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17038934/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com