graph和storaged不定时产生core文件,系统日志中有报错,希望有大佬协助解决,万分感谢

  • nebula 版本:3.8.0
  • 部署方式:分布式
  • 安装方式:RPM
  • 是否上生产环境: N
  • 硬件信息
    • 磁盘 HDD
    • CPU、内存信息 48核,256G
    • 服务器数量:3台
  • 问题的具体描述
    graph和storaged不定时产生core文件,分别分析内容为:
    我使用三台完全空闲的服务器,内存是256G,CPU48核,数据库中只有几条数据,graph和storaged产生很多core文件,以下是gdb分析core文件内容:
    graphd:
    Using host libthread_db library “/lib64/libthread_db.so.1”.
    Core was generated by `/home/nebula/nebula-graph-3.8.0.el7/bin/nebula-graphd --flagfile /home/nebula/n’.
    Program terminated with signal 11, Segmentation fault.
    #0 0x0000000002282b5d in folly::EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(folly::Function<void ()>) ()
    Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64
    (gdb) bt
    #0 0x0000000002282b5d in folly::EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(folly::Function<void ()>) ()
    #1 0x000000000178a792 in ?? ()
    #2 0x00000000018f4b4c in std::_Hashtable<std::pair<nebula::HostAddr, folly::EventBase*>, std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > >, std::__detail::_Select1st, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable() ()
    #3 0x00000000018f4bde in void folly::threadlocal_detail::ElementWrapper::set<std::unordered_map<std::pair<nebula::HostAddr, folly::EventBase*>, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > > >>(std::unordered_map<std::pair<nebula::HostAddr, folly::EventBase>, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > > >)::{lambda(void, folly::TLPDestructionMode)#2}::_FUN(void*, folly::TLPDestructionMode) ()
    #4 0x00000000021fa082 in folly::threadlocal_detail::StaticMetaBase::onThreadExit(void*) ()
    #5 0x00007f7482bf1ca2 in __nptl_deallocate_tsd () from /lib64/libpthread.so.0
    #6 0x00007f7482bf1eb3 in start_thread () from /lib64/libpthread.so.0
    #7 0x00007f748291a96d in clone () from /lib64/libc.so.6

storaged:
Using host libthread_db library “/lib64/libthread_db.so.1”.
Core was generated by `/home/nebula/nebula-graph-3.8.0.el7/bin/nebula-storaged --flagfile /home/nebula’.
Program terminated with signal 11, Segmentation fault.
#0 0x00000000026a6afd in folly::EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(folly::Function<void ()>) ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64
#0 0x00000000026a6afd in folly::EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(folly::Function<void ()>) ()
#1 0x00000000013fcef2 in ?? ()
#2 0x000000000156b2ec in std::_Hashtable<std::pair<nebula::HostAddr, folly::EventBase*>, std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > >, std::__detail::_Select1st, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable() ()
#3 0x000000000156b37e in void folly::threadlocal_detail::ElementWrapper::set<std::unordered_map<std::pair<nebula::HostAddr, folly::EventBase*>, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > > >>(std::unordered_map<std::pair<nebula::HostAddr, folly::EventBase>, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient, std::hash<std::pair<nebula::HostAddr, folly::EventBase*> >, std::equal_to<std::pair<nebula::HostAddr, folly::EventBase*> >, std::allocator<std::pair<std::pair<nebula::HostAddr, folly::EventBase*> const, std::shared_ptrnebula::meta::cpp2::MetaServiceAsyncClient > > >)::{lambda(void, folly::TLPDestructionMode)#2}::_FUN(void*, folly::TLPDestructionMode) ()
#4 0x0000000002614142 in folly::threadlocal_detail::StaticMetaBase::onThreadExit(void*) ()
#5 0x00007f44d5e64ca2 in __nptl_deallocate_tsd () from /lib64/libpthread.so.0
#6 0x00007f44d5e64eb3 in start_thread () from /lib64/libpthread.so.0
#7 0x00007f44d5b8d96d in clone () from /lib64/libc.so.6

系统日志中也有报错:
dmesg |grep nebula
[761397.518518] graph-netio3[33493]: segfault at 7fc687a02310 ip 0000000002282b5d sp 00007fc6887f5410 error 4 in nebula-graphd[f4b000+1913000]
[766000.751482] graph-netio2[42458]: segfault at 7fbc4f402310 ip 0000000002282b5d sp 00007fbc501f5410 error 4 in nebula-graphd[f4b000+1913000]
[766053.127185] graph-netio1[4170]: segfault at 7f260e602310 ip 0000000002282b5d sp 00007f260f3f5410 error 4 in nebula-graphd[f4b000+1913000]
[776420.065589] graph-netio7[8275]: segfault at 7ff4ea002310 ip 0000000002282b5d sp 00007ff4eadf5410 error 4 in nebula-graphd[f4b000+1913000]
[777792.449798] IOThreadPool1[46250]: segfault at 7f9c3ec05090 ip 00000000026a6afd sp 00007f9c3f9f5390 error 4 in nebula-storaged[1002000+1c8f000]
[779193.289671] graph-netio3[27141]: segfault at 7f9463e02310 ip 0000000002282b5d sp 00007f9464bf5410 error 4 in nebula-graphd[f4b000+1913000]
[779910.045721] graph-netio4[24777]: segfault at 7f932a202310 ip 0000000002282b5d sp 00007f932aff5410 error 4 in nebula-graphd[f4b000+1913000]
[779978.574505] graph-netio8[27523]: segfault at 7f66ad202310 ip 0000000002282b5d sp 00007f66adff5410 error 4 in nebula-graphd[f4b000+1913000]
[785030.694424] graph-netio2[46409]: segfault at 7fe3acc02310 ip 0000000002282b5d sp 00007fe3ad9f5410 error 4 in nebula-graphd[f4b000+1913000]
[850662.697566] graph-netio1[45942]: segfault at 7fb5de602310 ip 0000000002282b5d sp 00007fb5df3f5410 error 4 in nebula-graphd[f4b000+1913000]
[850665.186527] IOThreadPool332[30184]: segfault at 7fd7d5f5d090 ip 00000000026a6afd sp 00007fd6e7a46390 error 4 in nebula-storaged[1002000+1c8f000]
[862849.480717] graph-netio4[33843]: segfault at 7f582de02310 ip 0000000002282b5d sp 00007f582ebf5410 error 4 in nebula-graphd[f4b000+1913000]
[933167.660636] graph-netio2[36429]: segfault at 7f3d1a202310 ip 0000000002282b5d sp 00007f3d1aff5410 error 4 in nebula-graphd[f4b000+1913000]
[933276.125462] graph-netio1[1591]: segfault at 7f2772802310 ip 0000000002282b5d sp 00007f27735f5410 error 4 in nebula-graphd[f4b000+1913000]
[933538.312948] graph-netio1[6091]: segfault at 7ff3d1c02310 ip 0000000002282b5d sp 00007ff3d29f5410 error 4 in nebula-graphd[f4b000+1913000]

从你的 gdb 堆栈跟踪 (bt) 输出中,问题出现在以下位置:

  1. 主要问题:
    问题似乎是 folly::EventBase::runImmediatelyOrRunInEventBaseThreadAndWait 的调用中出现了段错误。这通常表明程序试图访问已经被释放或未初始化的内存。

  2. 更具体的原因:
    堆栈中的以下部分值得注意:

    • std::_Hashtable 析构函数异常:
      std::_Hashtable<...>::~_Hashtable()
      
      说明某个 std::unordered_map 容器中的元素或关联资源在析构时遇到了问题。
    • 涉及到 folly::threadlocal_detailElementWrapper::set:
      folly::threadlocal_detail::ElementWrapper::set
      
      这里的 threadlocal 机制正在管理线程局部变量,这些变量的析构过程中可能出现了问题。
  3. 线程局部变量销毁问题:
    问题可能出在 folly 库的线程局部存储管理部分。StaticMetaBase::onThreadExit 表明线程退出时尝试清理线程局部存储 (TLS) 的对象,但可能由于对象已被提前释放、未正确初始化,或者因为多线程竞争条件导致的问题,触发了段错误。


可能原因

  1. 未初始化或已释放的对象:

    • 某些 EventBase 或其相关对象在使用时已经被销毁或尚未正确初始化。
  2. 资源管理错误:

    • folly::threadlocal_detailElementWrapper 在清理资源时未能正确处理相关的 std::unordered_map,例如 MetaServiceAsyncClient 对象的生命周期未正确管理。
  3. 多线程问题:

    • 如果 folly::EventBase 被多个线程共享,可能发生竞争条件或资源并发访问问题。
  4. 不匹配的依赖版本:

    • folly 或其相关库的版本可能与 nebula-graphd 不兼容,导致运行时行为异常。

解决方法

  1. 检查代码:

    • 确保所有 folly::EventBase 和相关的 MetaServiceAsyncClient 对象在所有线程中初始化正确,并且生命周期一致。
    • 避免在 unordered_map 中存储原始指针,使用智能指针 (std::shared_ptrstd::unique_ptr) 以便更好地管理资源。
  2. 调试内存问题:

    • 使用 ValgrindAddressSanitizer 检查是否有内存越界、未初始化内存访问等问题:
      valgrind --tool=memcheck ./nebula-graphd --flagfile /home/nebula/n
      
  3. 多线程调试:

    • 如果问题与多线程相关,使用线程调试工具 (如 Helgrind) 检查竞争条件:
      valgrind --tool=helgrind ./nebula-graphd --flagfile /home/nebula/n
      
  4. 依赖库检查:

    • 确保 folly 和相关依赖库版本与 nebula-graphd 的需求匹配。你可以使用以下命令检查动态链接库版本:
      ldd /home/nebula/nebula-graph-3.8.0.el7/bin/nebula-graphd
      
  5. 启用调试符号:

    • 安装调试符号以获得更详细的回溯信息:
      sudo debuginfo-install glibc-2.17-317.el7.x86_64
      
  6. 独立复现问题:

    • 如果可能,单独编写一个小型程序,复现 folly::EventBaseMetaServiceAsyncClient 的交互行为,验证问题是否与 folly 的用法有关。

进一步行动

如果上述方法无法解决问题,你可以:

  1. Nebula Graph 开发团队提交问题报告,附上完整的堆栈跟踪和运行环境信息。
  2. 提供更详细的上下文,包括相关代码段或配置文件内容,以便进一步分析问题根源。

这些步骤应能帮助你定位和解决段错误问题。
Power by ChatGPT

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。