mongod server under the hood

In the previous post I built mongodb from source. We have an image file from Fedora in elf format with debug information embedded in file.

I already have the code, so use your favorite editor to browse the code. In my case I use VisualStudio code:

I will load the mongod executable with gdb:

Provide initial arguments to mongod with gdb:

set args –dbpath=/home/albertop/mongodb

set breakpoint at main:

then run the beast:

Step the source code. the main() function is embedded in db.cpp file. This file has the entry point for mongod service.

One interesting point is that the thread to serve client request is launched here, the main logic for this thread is contained in transport_layer_asio.cpp file.

Set a breakpoint in start method from this file: