def get_last_oplog_timestamp(conn,db_name):
start_time = time.time()
oplog=conn.local.oplog.rs;
if not db_name:
curr = oplog.find().sort(
'$natural', pymongo.DESCENDING
).limit(1)
else:
#{'ns': {'$in': oplog_ns_set}}
reg="^"+db_name+"\."
curr = oplog.find(
{'ns': re.compile(reg)}
).sort('$natural', pymongo.DESCENDING).limit(1)
if curr.count(with_limit_and_skip=True) == 0:
return None
print_cost_time("get_last_oplog_timestamp ", start_time)
return curr[0]['ts']
评论列表
文章目录