Mongodb 7.0 RC0 Cycle in dependency graph: LoadICUData

Hi, I’m maintaining some MongoDB ports for FreeBSD.

I accomplished to compile 7.0-RC0. But on first run it crashes.

# mongod --dbpath /var/tmp/mongotest/
{"t":{"$date":"2023-05-02T09:15:47.365Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"thread1","msg":"Error during global initialization","attr":{"error":{"code":5,"codeName":"GraphContainsCycle","errmsg":"Cycle in dependency graph: LoadICUData -> LoadIcuPrep -> default -> BeginExpressionRegistration -> addToExpressionParserMap_stdDevSamp -> LoadICUData"}}}

This is all. No files are created in the dbpath. Any thoughts or advice on this? It happens on amd64 as well as on aarch64.

Thank you for your work on the port.

I am trying to repro this locally but it will take time (small VM). That error usually comes incorrect usage of MONGO_INITIALIZER_GENERAL (and related functions) which want to define a DAG for a list of functions to call at startup. It does a topological sort so it is incompatible with a graph with cycles.

  1. What build command were you using? Below is the command I am using (I am building debug to aid troubleshooting) on FreeBSD 13.1-STABLE.
buildscripts/ --cxx-std=20 --disable-warnings-as-errors --dbg=on --opt=off AR=llvm-ar VERBOSE=on --use-sasl-client --ssl CC="clang" CPPPATH="/usr/local/include" CXX="clang++" LIBPATH="/usr/local/lib" VARIANT_DIR=jem --libc++ --ninja --allocator=system

I had to add define into SConstruct for _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS to fix an issue in ASIO with the recent upgrade to C++ 20 in the MongoDB source code.

  1. Are there any local patches that you may have applied?


  • Mark

Hi, thanks for your quick reply.

The command I’m using is:

/wrkdirs/usr/ports/databases/mongodb70/work/mongo-r7.0.0-rc0/buildscripts/	-C /wrkdirs/usr/ports/databases/mongodb70/work/mongo-r7.0.0-rc0 --cxx-std=20  --disable-warnings-as-errors  --libc++  --runtime-hardening=on  --use-system-icu  --use-system-libunwind  --use-system-pcre2  --use-system-snappy  --use-system-stemmer  --use-system-yaml  --use-system-zlib  --use-system-zstd  -j2  AR=llvm-ar  MONGO_VERSION=7.0.0-rc0  VERBOSE=on --use-sasl-client --ssl CC="cc"  CCFLAGS="-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing "  CPPPATH="/usr/local/include"  CXX="c++"  CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing  "  LIBPATH="/usr/local/lib"  LINKFLAGS="  -fstack-protector-strong "  PKGCONFIGDIR=""  PREFIX="/usr/local"  destdir=/wrkdirs/usr/ports/databases/mongodb70/work/stage DESTDIR=/wrkdirs/usr/ports/databases/mongodb70/work/stage

And added “# define ASIO_HAS_STD_INVOKE_RESULT” to src/third_party/asio-master/asio/include/asio/detail/config.hpp to make asio compile.

In the meantime I found that mongod runs fine if I don’t use --use-system-* for various libraries. Currently trying to find which use-system was the cause. It runs at least if I disable all of them.

Succeeded in running mongod without errors by removing --use-system-icu from the build parameters.
The port is submitted:
Now testing some of you parameters like --ninja and --allocator=system.

What would be the benefits of using those settings?

I filed two issues: (Fix mongodb compilation with libc++) and (Fix --use-system-icu) for the issues you identified. The fix for --use-system-icu is in the ticket.

In terms of the two options, --ninja is a useful for developers as it compiles faster then scons. For packaging, It is simpler to just use scons. The --allocator=system tells MongoDB to use system allocator instead of the vendored GPerfTools/tcmalloc. Since FreeBSD uses jemalloc, which is comparable in performance too tcmalloc, you save a tiny bit of binary size by just using it.

  • Mark

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.