diff --git a/pages/database-management/debugging.mdx b/pages/database-management/debugging.mdx index 0e45245ac..4bd1b9498 100644 --- a/pages/database-management/debugging.mdx +++ b/pages/database-management/debugging.mdx @@ -67,7 +67,8 @@ container, necessary for running debugging tools. Memgraph supports the following debug capabilities: 1. [Using GDB](#using-gdb): Attaching Memgraph with `GDB` and inspecting threads 2. [Generating a core dump](#generating-core-dump-via-docker) after Memgraph crashed -3. [Using `perf`](#profiling-with-perf) to identify performance bottlenecks +3. [Running Memgraph in GDB inside Docker](#running-memgraph-in-gdb-inside-docker): Directly running Memgraph or MAGE in GDB inside a Docker container. +4. [Using `perf`](#profiling-with-perf) to identify performance bottlenecks ### Using GDB @@ -234,6 +235,42 @@ services: - QUICK_CONNECT_MG_PORT=7687 ``` +### Running Memgraph in GDB inside Docker + + +To run Memgraph or MAGE in GDB inside a Docker container, you can use the following +commands to override the entry point and create a bind mount for core dumps: + +```bash +# create a directory with sufficient permissions to save the core on the host +mkdir -p cores +chmod 777 cores + +# run memgraph via the debug script by overriding the entry point, and creating a bind mount for the core dump +docker run --rm \ + --name memgraph \ + -v "$(pwd)/cores:/tmp/cores" \ + --entrypoint /usr/lib/memgraph/run_with_gdb.sh \ + -p 7687:7687 \ + memgraph/memgraph:3.7-relwithdebinfo +``` + +Optionally, the core dump path can be overridden by setting the `CORE_PATH` variable: + +```bash +docker run --rm \ + --name memgraph \ + -v "$(pwd)/cores:/some/other/dir/cores" \ + -e CORE_PATH=/some/other/dir/cores/core.dump \ + --entrypoint /usr/lib/memgraph/run_with_gdb.sh \ + -p 7687:7687 \ + memgraph/memgraph:3.7-relwithdebinfo +``` + +In the case where Memgraph crashes, a core dump will be created in the directory +specified by the `CORE_PATH` variable (`tmp/cores/core` by default) and the full +backtrace will be printed to the terminal. + ### Using `heaptrack` with Docker