Skip to content

Remote debugging TileDB MariaDB on Linux

Andreas Ntalakas edited this page Apr 23, 2020 · 5 revisions

Remote debugging TileDB-MariaDB on Linux

Using Ubuntu 18.04

Select a folder to work: ~/workspace

Install prerequisites

sudo apt update
sudo apt upgrade
sudo apt install gosu pwgen tzdata gcc g++ build-essential libasan0 bison chrpath cmake gdb gnutls-dev libaio-dev libboost-dev libdbd-mysql libjudy-dev libncurses5-dev libpam0g-dev libpcre3-dev libreadline-gplv2-dev   libstemmer-dev libssl-dev libnuma-dev libxml2-dev lsb-release perl psmisc zlib1g-dev libcrack2-dev cracklib-runtime libjemalloc-dev libsnappy-dev liblzma-dev libzmq3-dev uuid-dev ccache git wget libcurl4 libcurl4-openssl-dev
rm -rf /var/lib/apt/lists/*
sudo apt update

Clone required repositories

git clone https://github.com/TileDB-Inc/TileDB.git -b 2.0.0-rc4
git clone [email protected]:MariaDB/server.git -b 10.4
git clone [email protected]:TileDB-Inc/TileDB-MariaDB.git

Build TileDB Core

  • ~workspace/TileDB is the location of cloned TileDB
cd TileDB
mkdir build && cd build
cmake -DTILEDB_VERBOSE=OFF -DTILEDB_S3=ON -DTILEDB_SERIALIZATION=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install-tiledb

Build MYTILE storage engine

  • ~workspace/server is the location of cloned MariaDB
  • ~workspace/TileDB-MariaDB is the location of cloned TileDB-MariaDB
cd ~/workspace/server/storage
ln -s ~/TileDB-MariaDB mytile
cd mytile
ls -lah
cd ~/workspace/server
mkdir builddir && cd builddir
CXXFLAGS="$CXXFLAGS -Wno-noexcept-type" cmake DPLUGIN_TOKUDB=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_MROONGA=NO -DPLUGIN_SPIDER=NO -DPLUGIN_SPHINX=NO -DPLUGIN_FEDERATED=NO -DPLUGIN_FEDERATEDX=NO -DPLUGIN_CONNECT=NO -DCMAKE_BUILD_TYPE=Debug -DPLUGIN_MYTILE=YES -DCMAKE_INSTALL_PREFIX=/opt/server -SWITH_DEBUG=1 -DWITH_EMBEDDED_SERVER=OFF ..
make -j4
find . -name ha_mytile.so

output: ./storage/mytile/ha_mytile.so

Run tests

cd ~/workspace/server/builddir
./mysql-test/mysql-test-run --suite mytile

To run a single test:

./mysql-test/mysql-test-run --suite mytile <name of test, i.e data_types>
  • --debug adds tracing which defaults to /tmp/mysqld.trace

  • --gdb/--lldb or --manual-gdb/--manual-lldb, see --help for even more options

  • --manual-lldb allows user to start the test server manually

Use gdb server

Objectives:

  • Run the mysql server with gdbserver localhost:6666 //mysqld
  • Use remote gdb in CLion to connect
  • Connect from a local mysql client mysql and run queries by hand and use breakpoints in mariadb
Install mysql server
cd ~/workspace/server/builddir
sudo make install

Installs on /opt/server

Create a configuration file for mysql server

Example $HOME/.my.cnf for use of running:

cat ~/.my.cnf 
# Example mysql config file.
# You can copy this to one of:
# /etc/my.cnf to set global options,
# /mysql-data-dir/my.cnf to get server specific options or
# ~/my.cnf for user specific options.
#
# One can use all long options that the program supports.
# Run the program with --help to get a list of available options
# This will be passed to all mysql clients
[client]
socket=/tmp/mysql.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# The MySQL server
[mysqld]
port=3306
socket=/tmp/mysql.sock
pid-file=/tmp/mariadb.pid
temp-pool
plugin-load=ha_mytile
default-storage-engine=aria
gdb
#debug
######### Fix the three following paths
# Where you want to have your database
datadir=/home/ubuntu/data/debug_mariadb
# Where you have your mysql/MariaDB source + sql/share/english
language=/opt/server/share/english
plugin_dir=/opt/server/lib/plugin
plugin-maturity=experimental
Create a folder to store mysql data
mkdir -R /home/ubuntu/data/debug_mariadb
One off mysql initilization
/opt/server/scripts/mysql_install_db

Data is written in /home/ubuntu/data/debug_mariadb

Start MariaDB Server with gdb server
gdbserver 0.0.0.0:6666 /opt/server/bin/mariadbd
Start MariaDB Client
/opt/server/bin/mariadb
show engines;
set mytile_tiledb_config='vfs.s3.region=eu-central-1';
use test;
show create table `s3://eu-frankfurt-01/newsroom_2020`;
select * from `s3://eu-frankfurt-01/newsroom_2020` limit 1;
flush tables;
Use CLion to connect
  • Open ~/workspace/server folder
  • Edit configurations
    • Create new configuration: GDB Remote Debug
    • Target remote: IP:6666
    • Sysroot: /
    • Path mappings
      • Remote: /home/ubuntu/server
      • Local: /Users/andreas/workspace/tiledb/server

Using OSX

Build MYTILE storage engine

CFLAGS="$CFLAGS -Wno-error=unused-variable -Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=maybe-uninitialized -Wno-error=format-overflow -I/usr/local/include" CXXFLAGS="$CXXFLAGS -Wno-error=unused-variable -Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=maybe-uninitialized -Wno-error=format-overflow -I/usr/local/include" cmake -DPLUGIN_TOKUDB=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_MROONGA=NO -DPLUGIN_SPIDER=NO -DPLUGIN_SPHINX=NO -DPLUGIN_FEDERATED=NO -DPLUGIN_FEDERATEDX=NO -DPLUGIN_CONNECT=NO -DCMAKE_BUILD_TYPE=Debug -DPLUGIN_MYTILE=YES -DCMAKE_INSTALL_PREFIX=/opt/server -SWITH_DEBUG=1 -DWITH_EMBEDDED_SERVER=OFF -DWITH_SSL=bundled ..