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

集成JaegerTracing后Ceph RGW无法上传对象问题求助

问题分析与解决方案

我来帮你排查下这个问题,你遇到的上传失败是因为Jaeger追踪代码的实现方式存在几个关键问题,直接干扰了Ceph RGW的正常流程:

核心问题点

  1. Tracer重复创建与销毁
    你在queue_aio_write这个高频调用的AIO写队列函数里,每次请求都重新加载配置文件、创建Tracer、初始化全局Tracer,最后还调用Close()。这不仅会带来严重的性能开销,更关键的是,Jaeger Tracer的初始化和关闭是全局一次性操作,反复执行会导致内部资源冲突,甚至阻塞后续的网络请求处理。

  2. 不必要的同步IO操作
    函数里的ofstream写本地文件操作是同步IO,在Ceph的AIO高性能路径里做这种操作会严重拖慢整个存储流程,甚至可能引发线程阻塞,间接导致RGW的请求处理超时或失败。

  3. Jaeger连接配置错误
    错误提示里的localhost:8000连接被拒绝,说明你的Jaeger配置文件(tracerConfig.yaml)里,Reporter的HTTP endpoint指向了这个端口,但实际上没有Jaeger Collector在该端口运行。或者你误配置成了HTTP模式,而实际上应该使用默认的UDP模式连接Jaeger Agent(默认端口6831)。

修复步骤

1. 全局初始化Jaeger Tracer

把Tracer的初始化逻辑移到程序启动阶段(比如RGW的初始化入口),而不是每个AIO请求里重复执行:

// 程序启动时执行一次
void init_jaeger_tracer() {
    auto yaml = YAML::LoadFile("tracerConfig.yaml");
    auto config = jaegertracing::Config::parse(yaml);
    auto tracer = jaegertracing::Tracer::make(
        "Ceph-RGW-Writing", config, jaegertracing::logging::consoleLogger()
    );
    opentracing::Tracer::InitGlobal(
        static_pointer_cast<opentracing::Tracer>(tracer)
    );
}

// 程序退出时执行一次
void shutdown_jaeger_tracer() {
    opentracing::Tracer::Global()->Close();
}

2. 修正Jaeger配置文件

检查tracerConfig.yaml,如果使用Jaeger Agent(推荐方式),配置应该类似:

reporter:
  logSpans: true
  agentHost: localhost
  agentPort: 6831
sampler:
  type: const
  param: 1

如果使用Collector的HTTP模式,确保Collector在对应端口运行,配置示例:

reporter:
  logSpans: true
  collectorEndpoint: http://localhost:14268/api/traces
sampler:
  type: const
  param: 1

3. 简化queue_aio_write里的追踪逻辑

只保留Span的创建和结束逻辑,移除所有不必要的IO操作:

void librados::IoCtxImpl::queue_aio_write(AioCompletionImpl *c) {
    // 获取全局Tracer创建Span,用Scope自动管理生命周期
    auto scope = opentracing::Tracer::Global()->StartActiveSpan("queue_aio_write");
    
    get();
    std::scoped_lock l{aio_write_list_lock};
    ceph_assert(c->io == this);
    c->aio_write_seq = ++aio_write_seq;
    ldout(client->cct, 20) << "queue_aio_write " << this << " completion " << c << " write_seq " << aio_write_seq << dendl;
    aio_write_list.push_back(&c->aio_write_list_item);
    
    // Scope会在销毁时自动结束Span,无需手动调用Finish()
}

4. 确保Jaeger服务正常运行

如果使用Agent,启动Jaeger Agent:

jaeger-agent --reporter.grpc.host-port=localhost:14250

如果使用Collector,确保Jaeger Collector和Query服务已启动:

jaeger-collector --grpc-server.host-port=localhost:14250

按照这些步骤调整后,应该就能解决上传失败的问题,同时正常启用Jaeger追踪。

内容的提问来源于stack exchange,提问作者Abhinav Singh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 00:42:32