You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

K8s集群中C#应用连接MongoDB超1小时无响应问题求助

MongoDB连接超时问题排查请求

环境信息

  • Kubernetes集群内部署MongoDB服务,镜像版本:docker.io/bitnami/mongodb:7.0.2-debian-11-r7
  • 同集群部署5个副本的C#控制台应用,使用MongoDB.Driver版本:2.22.0

核心查询代码

应用通过以下方法持续查询MongoDB集合:

public BsonDocument GetParemeterDetails(string companyId, string applicationId, string id)
{
    MongoClient dbClient = new MongoClient(mongDBConnectionstr);
    var database = dbClient.GetDatabase($"derivedparameters{companyId}{applicationId}");
    var collection = database.GetCollection<BsonDocument>("Derived_Paramater_Config");
    var filter = Builders<BsonDocument>.Filter.Eq("Derived_Parameter_Id", id);
    var project = Builders<BsonDocument>.Projection.Exclude("_id");
    var funcLogDocument = collection.Find(filter).Project(project).FirstOrDefault();
    return funcLogDocument;
}

问题现象

应用持续运行约1小时后,出现无法从MongoDB服务获取响应的情况。

背景补充

该问题在升级项目多个组件(包括MongoDB服务版本、MongoDB.Driver版本)后出现,原环境版本为MongoDB 4.4.11、MongoDB.Driver 2.12.0。

已尝试的临时方案

  • 1分钟后取消线程并重试,多次重试均无响应
  • 改用FindAsync方法并等待,问题出现时间延迟至约14小时
  • 尝试降级/升级MongoDB服务版本及驱动版本,问题未解决

求助方向

恳请提供排查或解决该MongoDB连接问题的思路与建议。


内容的提问来源于stack exchange,提问作者Midhun K Jayan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 00:20:26