Skip to content

Commit

Permalink
修复云mongodb不能同时提交多条创建索引语句的bug (#1845)
Browse files Browse the repository at this point in the history
修复云mongodb不能创建索引的bug
  • Loading branch information
czxin788 authored Sep 25, 2022
1 parent bc86cda commit 4eec758
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sql/engines/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ def get_slave(self):
sql = """var host=""; rs.status().members.forEach(function(item) {i=1; if (item.stateStr =="SECONDARY") \
{host=item.name } }); print(host);"""
slave_msg = self.exec_cmd(sql)
# 如果是阿里云的云mongodb,会获取不到备节点真实的ip和端口,那就干脆不获取,直接用主节点来执行sql
# 如果是自建mongodb,获取到备节点的ip是192.168.1.33:27019这样的值;但如果是阿里云mongodb,获取到的备节点ip是SECONDARY、hiddenNode这样的值
# 所以,为了使代码更加通用,通过有无冒号来判断自建Mongod还是阿里云mongdb;没有冒号就判定为阿里云mongodb,直接返回false;
if ":" not in slave_msg:
return False
if slave_msg.lower().find("undefined") < 0:
sp_host = slave_msg.replace('"', "").split(":")
self.host = sp_host[0]
Expand Down

0 comments on commit 4eec758

Please sign in to comment.