MongoDB:在建立索引时,从mongos到分片创建的连接过多

时间:2018-07-03 04:20:32

标签: mongodb

我们在生产ENV中为每个分片设置了具有副本集的分片集群。昨晚,我们在连接到集群并通过mongo shell通过mongos实例而不是直接连接到特定分片来发出build index命令时遇到了一个问题。

问题是:一旦开始建立索引,从mongos创建的与此分片的连接就会迅速增加,并且“过多连接”错误很快就会显示在主分片的日志文件中。 以下是主碎片的日志摘要的链接: At the very beginning for index 然后很快,连接数达到了10000: Connection limit exceeded

从三个mongos的日志中,所有连接均从mongos启动。我们已经用Google搜索并找到了相关的问题链接,例如:https://jira.mongodb.org/browse/SERVER-28822 但是没有触发条件。同时,我尝试在测试ENV中重现该问题,但不再发生。所以,请帮忙。

这是mongos的配置: mongos' configuration 这是碎片: primary shard's configuration

1 个答案:

答案 0 :(得分:0)

找到了答案。
这是因为class BuyAdapter(internal var context: Context, internal var ressource: Int, internal var buyList: ArrayList<Buy> ) : RecyclerView.Adapter<BuyAdapter.ViewHolder>() { override fun getItemCount(): Int { return buyList.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(context) .inflate(ressource, parent, false) return ViewHolder(view) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val buy: Buy = buyList[position] holder.price.text = buy.price.toString() } class ViewHolder(v: View) : RecyclerView.ViewHolder(v){ var price: TextView = v.tvPrice } 命令发出的索引创建是前台的,而不是后台的。我弄错了mongorestore采取的方式,但没有检查表模式的元文件。

相关问题