diff --git a/Dockerfile b/Dockerfile index 6e787b1..3b063d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,61 @@ -FROM fedora:25 as builder +FROM ubuntu:24.04 AS builder -# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#sort-multi-line-arguments -RUN dnf install -y \ - autoconf \ - automake \ - boost-devel \ - cmake \ - dnf-plugins-core \ - file \ - gcc \ - gcc-c++ \ - git-core \ - hostname \ - libtool \ - mariadb-devel-3:10.1.26-2.fc25.x86_64 \ - mariadb-server-3:10.1.26-2.fc25.x86_64 \ - rpm-build +SHELL [ "/bin/bash", "-c" ] -RUN dnf builddep -y \ - mariadb +ARG NANOMSG_VERSION=1.2.1 +ARG LZ4_VERSION=1.10.0 -RUN useradd builder -u 1000 -m -G users,wheel && \ - mkdir /home/builder/rpm && \ - chown -R builder /home/builder +COPY <= 5.1]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -205,9 +212,7 @@ else exit(1); #endif } - ], - [ AC_MSG_RESULT([ok]) ], - [ AC_MSG_ERROR([MySQL 5.1+ is required])]) + ]])],[ AC_MSG_RESULT([ok]) ],[ AC_MSG_ERROR([MySQL 5.1+ is required])],[]) CFLAGS="$CFLAGS_old" CXXFLAGS="$CXXFLAGS_old" @@ -324,4 +329,5 @@ AC_SUBST(INSTALL_STRIP_FLAG) AC_SUBST(EXPERIMENT_DIR) -AC_OUTPUT([Makefile src/Makefile include/Makefile mysql_engine/Makefile experiments/Makefile]) +AC_CONFIG_FILES([Makefile src/Makefile include/Makefile mysql_engine/Makefile experiments/Makefile]) +AC_OUTPUT diff --git a/docker-compose.yml b/docker-compose.yml index 4a2cdc4..d867165 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,8 @@ -version: '3.2' services: - fedora-25: - image: badoo/pinba2:fedora-25 - container_name: pinba2-fedora-25 + pinba2: + image: pinba2 + container_name: pinba2 build: context: . dockerfile: Dockerfile diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0fdfa98..19db455 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -5,19 +5,13 @@ if [ $1 = "mysqld" ]; then - # fedora mysqld is in special location - ln -snf /usr/libexec/mysqld /usr/local/bin - - # disable gss auth as it's not installed in this container - rm -rf /etc/my.cnf.d/auth_gssapi.cnf - - # create default databases - # too expensive to perform on container startup really - mysql_install_db --rpm - chmod -R 777 /var/lib/mysql + # create dir where mysql.sock will be located + rundir=$(dirname `mysql_config --socket`) + mkdir -p $rundir + chmod 777 $rundir # start mysql server in background for init process - "$@" --skip-networking -umysql & + "$@" --skip-networking -umysql --plugin-maturity=unknown & pid="$!" # legen.... wait for it @@ -65,4 +59,7 @@ if [ $1 = "mysqld" ]; then fi fi -exec "$@" -umysql +exec "$@" -umysql \ + --port=3306 \ + --socket=`mysql_config --socket` \ + --plugin-maturity=unknown diff --git a/docker/build-dependencies.sh b/docker/build-dependencies.sh new file mode 100755 index 0000000..36faef8 --- /dev/null +++ b/docker/build-dependencies.sh @@ -0,0 +1,40 @@ +#!/bin/bash -xe + +# mariadb +# the annoying part - why we're building mariadb from source at all, +# is that we need internal headers that are not present in regular apt packages +# so the idea here is to avoid building the whole of mariadb, but only the parts we need +# we only need to run initial generation stage with cmake . and build a few libs quickly +# the final tricky part is to build with the same compiler flags as the server itself +# for now - there is no problem, unless mariadb is built with debug, in which case pinba should be configured with --enable-debug +cd /_src/mariadb +cmake . +make -C libservices +# boost tries to include this file globally and includes this one; but mariadb needs this to install +# mv+rm is a workaround for docker build-ing on macos case-insensitive fs +# VERSION and version are the same file and mv actually leads to both files existing at the same time +# so rm it to avoid the issue with boost described above +mv VERSION VERSION.backup +rm -f VERSION +# make mysqld_error.h available in non-esoteric location +ln -snf /_src/mariadb/libmariadb/include/mysqld_error.h include/mysqld_error.h + + +# build nanomsg and install (this one is a lil tricky to build statically) +cd /_src/nanomsg +cmake \ + -DNN_STATIC_LIB=ON \ + -DNN_ENABLE_DOC=OFF \ + -DNN_MAX_SOCKETS=4096 \ + -DCMAKE_C_FLAGS="-fPIC -DPIC" \ + -DCMAKE_INSTALL_PREFIX=/_install/nanomsg \ + -DCMAKE_INSTALL_LIBDIR=lib \ + . + +make -j4 +make install + +# build lz4 with PIC static lib +cd /_src/lz4 +make CFLAGS="-fPIC -DPIC" +make install PREFIX=/_install/lz4 diff --git a/docker/build-from-source.sh b/docker/build-from-source.sh deleted file mode 100755 index 719440c..0000000 --- a/docker/build-from-source.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -xe - -# build nanomsg and install (this one is a lil tricky to build statically) -cd /_src/nanomsg -cmake \ - -DNN_STATIC_LIB=ON \ - -DNN_ENABLE_DOC=OFF \ - -DNN_MAX_SOCKETS=4096 \ - -DCMAKE_C_FLAGS="-fPIC -DPIC" \ - -DCMAKE_INSTALL_PREFIX=/_install/nanomsg \ - -DCMAKE_INSTALL_LIBDIR=lib \ - . - -make -j4 -make install - -# build lz4 with PIC static lib -cd /_src/lz4 -make CFLAGS="-fPIC -DPIC" -make install PREFIX=/_install/lz4 - -# pinba -cd /_src/pinba2 -./buildconf.sh -./configure --prefix=/_install/pinba2 \ - --with-mysql=/home/builder/rpm/mariadb-10.1.26 \ - --with-boost=/usr \ - --with-meow=/_src/meow \ - --with-nanomsg=/_install/nanomsg \ - --with-lz4=/_install/lz4 \ - --enable-libmysqlservices -make -j4 - -# FIXME: this needs to be easier -# for install, just copy stuff to mysql plugin dir -cp /_src/pinba2/mysql_engine/.libs/libpinba_engine2.so `mysql_config --plugindir` diff --git a/docker/build-pinba.sh b/docker/build-pinba.sh new file mode 100755 index 0000000..cd77350 --- /dev/null +++ b/docker/build-pinba.sh @@ -0,0 +1,14 @@ +#!/bin/bash -xe + +# Run this after build-dependencies.sh +# pinba +cd /_src/pinba2 +./buildconf.sh +./configure --prefix=/_install/pinba2 \ + --with-boost=/usr \ + --with-mysql=/_src/mariadb \ + --with-meow=/_src/meow \ + --with-nanomsg=/_install/nanomsg \ + --with-lz4=/_install/lz4 \ + --enable-libmysqlservices +make -j4 diff --git a/docs/index.md b/docs/index.md index a07bfd4..4b269ed 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ Building **examples** -See [Dockerfile](../Dockerfile) and [build-from-source.sh](../docker/build-from-source.sh).
+See [Dockerfile](../Dockerfile), [build-dependencies.sh](../docker/build-dependencies.sh) and [build-pinba.sh](../docker/build-pinba.sh).
Also there is a rough guide for centos7 in [#17](https://github.com/badoo/pinba2/issues/17) - should be workable for multiple distros really. **requirements** diff --git a/mysql_engine/handler.cpp b/mysql_engine/handler.cpp index 3ecd7da..6914611 100644 --- a/mysql_engine/handler.cpp +++ b/mysql_engine/handler.cpp @@ -14,10 +14,12 @@ #ifdef PINBA_USE_MYSQL_SOURCE #include // #include // -#include // +#include // +#include // #else #include #include +#include #include #endif // PINBA_USE_MYSQL_SOURCE @@ -150,9 +152,9 @@ struct pinba_view___stats_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) @@ -404,9 +406,9 @@ struct pinba_view___active_reports_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) @@ -765,9 +767,9 @@ struct pinba_view___report_snapshot_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) diff --git a/mysql_engine/handler.h b/mysql_engine/handler.h index 11c613e..73080c7 100644 --- a/mysql_engine/handler.h +++ b/mysql_engine/handler.h @@ -5,8 +5,10 @@ #include "mysql_engine/view_conf.h" #ifdef PINBA_USE_MYSQL_SOURCE +#include #include #else +#include #include #endif // PINBA_USE_MYSQL_SOURCE diff --git a/mysql_engine/plugin.cpp b/mysql_engine/plugin.cpp index 0010d1a..5b652e5 100644 --- a/mysql_engine/plugin.cpp +++ b/mysql_engine/plugin.cpp @@ -314,7 +314,7 @@ static int pinba_engine_init(void *p) } auto *h = static_cast(p); - h->state = SHOW_OPTION_YES; + // h->state = SHOW_OPTION_YES; // mariadb has removed this it seems (checked on 10.11.8) h->flags = HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION | HTON_TEMPORARY_NOT_SUPPORTED; h->create = [](handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) -> handler* { return new (mem_root) pinba_handler_t(hton, table); diff --git a/mysql_engine/plugin.h b/mysql_engine/plugin.h index 624be1f..cf15811 100644 --- a/mysql_engine/plugin.h +++ b/mysql_engine/plugin.h @@ -4,9 +4,13 @@ #include "mysql_engine/pinba_mysql.h" #ifdef PINBA_USE_MYSQL_SOURCE +# include +# include # include # include #else +# include +# include # include # include #endif // PINBA_USE_MYSQL_SOURCE