70 mongodb network_error ai_generated partial

MongoServerError:ShardNotFound:分片没有可用的配置服务器主节点

MongoServerError: ShardNotFound: no config server primary available for shard

ID: mongodb/sharded-cluster-no-config-primary

其他格式: JSON · Markdown 中文 · English
70%修复率
88%置信度
1证据数
2024-01-20首次发现

版本兼容性

版本状态引入弃用备注
mongodb 7.0 active
mongodb 6.0 active
mongodb 5.0 active
mongodb 4.4 active

根因分析

配置服务器副本集由于网络分区、选举失败或节点崩溃而没有主节点。

English

The config server replica set has no primary node due to network partition, election failure, or node crash.

generic

官方文档

https://www.mongodb.com/docs/manual/reference/error-codes/#mongodb-error-70

解决方案

  1. 检查配置服务器副本集状态:在配置服务器上运行rs.status(),必要时强制重新选举:在当前主节点上运行rs.stepDown()或使用rs.reconfig()添加新成员。
  2. 如果写操作不关键,临时将读操作路由到从节点:db.getMongo().setReadPref('secondaryPreferred')

无效尝试

常见但无效的做法:

  1. 90% 失败

    The mongos is not the issue; the config server replica set needs repair.

  2. 95% 失败

    Connection pool size does not affect config server primary availability.