[MDEV-26319] Mismatch in MARIADB_UNIX_ADDR default value for MariaDB Server and Connector C Created: 2021-08-07  Updated: 2023-03-18  Resolved: 2021-08-19

Status: Closed
Project: MariaDB Server
Component/s: Configuration, libmariadb
Affects Version/s: 10.6.4
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Otto Kekäläinen Assignee: Daniel Black
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

While working on MariaDB 10.6.4 compilation I noticed this warning:

$ eatmydata ninja package
[27/50] Building C object client/CMakeFiles/mariadb-upgrade.dir/mysql_upgrade.c.o
...
In file included from ../client/mysql_upgrade.c:19:
In file included from ../client/client_priv.h:27:
include/mysql_version.h:23:9: warning: 'MARIADB_UNIX_ADDR' macro redefined [-Wmacro-redefined]
#define MARIADB_UNIX_ADDR               "/var/lib/mysql/mysql.sock"
        ^
../libmariadb/include/mariadb_version.h:17:9: note: previous definition is here
#define MARIADB_UNIX_ADDR               "/tmp/mysql.sock"
...

It is understanable that the variable is defined twice, but it is not good that we have two different default values of MARIADB_UNIX_ADDR.

The client sets it to /tmp/mysql.sock in https://github.com/mariadb-corporation/mariadb-connector-c/blob/1f320a663cf08191e3be03be11bd61c7560b0cb7/CMakeLists.txt#L181

The server sets MARIADB_UNIX_ADDR to MYSQL_UNIX_ADDR which in turn is set to INSTALL_UNIX_ADDRDIR which ends up being /var/lib/mysql in the build.

I suggest the default path would be the same in both projects.



 Comments   
Comment by Daniel Black [ 2021-08-09 ]

It is configured to propagate:

cmake/install_layout.cmake:SET(INSTALL_UNIX_ADDRDIR_DEB            "/run/mysqld/mysqld.sock")
cmake/install_layout.cmake:  SET(MYSQL_UNIX_ADDR ${INSTALL_UNIX_ADDRDIR})
cmake/mariadb_connector_c.cmake:SET(MARIADB_UNIX_ADDR ${MYSQL_UNIX_ADDR})

Where does /var/lib/mysql/mysql.sock come from if /run/mysqld/mysqld.sock is the Debian default? Are you building with `-DDEB=1`?

Comment by Otto Kekäläinen [ 2021-08-11 ]

This is not a Debian build. This is vanilla build of upstream with `cmake -DRPM=`. I did not manage to track down exactly where `/var/lib/mysql/mysql.sock` comes from other than what is already above. I came across this while working with improving https://github.com/MariaDB/server/blob/10.6/.gitlab-ci.yml

Comment by Daniel Black [ 2021-08-11 ]

The -DRPM is definitely getting the CI_JOB_NAME value? If its blank that could explain the observed results as it will fallback to a "STANDALONE" layout if both DEB and RPM are blank/undefined.

Because on RPM distros the INSTALL_UNIX_ADDRDIR_RPM is the install_layout.cmake too which is where the path comes from.

~/repos/build-mariadb-server-10.6-centos 
$ cmake  -DRPM=centos7 ../mariadb-server-10.6
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dan/repos/build-mariadb-server-10.6-centos
 
~/repos/build-mariadb-server-10.6-centos 
$ grep -r UNIX_ADDR *
CMakeCache.txt://UNIX_ADDR installation directory
CMakeCache.txt:INSTALL_UNIX_ADDRDIR:STRING=/var/lib/mysql/mysql.sock
CMakeCache.txt://ADVANCED property for variable: INSTALL_UNIX_ADDRDIR
CMakeCache.txt:INSTALL_UNIX_ADDRDIR-ADVANCED:INTERNAL=1
include/mysql_version.h:#define MARIADB_UNIX_ADDR               "/var/lib/mysql/mysql.sock"
include/mysql_version.h:#define MYSQL_UNIX_ADDR                 MARIADB_UNIX_ADDR
libmariadb/include/mariadb_version.h:#define MARIADB_UNIX_ADDR               "/var/lib/mysql/mysql.sock"
libmariadb/include/mariadb_version.h:#ifndef MYSQL_UNIX_ADDR
libmariadb/include/mariadb_version.h:#define MYSQL_UNIX_ADDR MARIADB_UNIX_ADDR
 
$  grep LAYOUT CMake*
CMakeCache.txt:INSTALL_LAYOUT:STRING=RPM
CMakeCache.txt:OLD_INSTALL_LAYOUT:INTERNAL=RPM
 
~/repos/build-mariadb-server-10.6-centos 
$ cmake --build . --target mariadb-upgrade
[211/211] Linking CXX executable client/mariadb-upgrade
 
~/repos/build-mariadb-server-10.6-centos 
$ cmake --build . --target mariadb
[5/5] Linking CXX executable client/mariadb
 
~/repos/build-mariadb-server-10.6-centos 
$ cmake --build . --target mariadb-check
[2/2] Linking CXX executable client/mariadb-check
 
$  strace -fe trace=connect client/mariadb-upgrade
strace: Process 555703 attached
strace: Process 555704 attached
[pid 555704] +++ exited with 0 +++
[pid 555703] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555704, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
[pid 555703] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555703, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 555705 attached
strace: Process 555706 attached
[pid 555706] +++ exited with 0 +++
[pid 555705] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555706, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
[pid 555705] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555705, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 555707 attached
strace: Process 555708 attached
[pid 555708] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 555708] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 555708] connect(3, {sa_family=AF_UNIX, sun_path="/var/lib/sss/pipes/nss"}, 110) = 0
[pid 555708] connect(4, {sa_family=AF_UNIX, sun_path="/var/lib/mysql/mysql.sock"}, 110) = -1 ECONNREFUSED (Connection refused)
[pid 555708] +++ exited with 1 +++
[pid 555707] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555708, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
[pid 555707] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555707, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
strace: Process 555709 attached
strace: Process 555710 attached
[pid 555710] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 555710] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
[pid 555710] connect(3, {sa_family=AF_UNIX, sun_path="/var/lib/sss/pipes/nss"}, 110) = 0
[pid 555710] connect(4, {sa_family=AF_UNIX, sun_path="/var/lib/mysql/mysql.sock"}, 110) = -1 ECONNREFUSED (Connection refused)
[pid 555710] +++ exited with 1 +++
[pid 555709] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555710, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
[pid 555709] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=555709, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (111)
FATAL ERROR: Upgrade failed
+++ exited with 1 +++

Comment by Sergei Golubchik [ 2021-08-14 ]

otto, could you show the complete command line that you used for invoking cmake?

Comment by Otto Kekäläinen [ 2021-08-16 ]

Looking at latest https://gitlab.com/ottok/mariadb/-/pipelines/351707761 and e.g. https://storage.googleapis.com/gitlab-gprd-artifacts/ef/be/efbe5970cae20178291094d61fe81817e0d99f85c40a27182aab9db8e4ab370a/2021_08_11/1496181632/1610210407/job.log?response-content-type=text%2Fplain%3B%20charset%3Dutf-8&response-content-disposition=inline&GoogleAccessId=gitlab-object-storage-prd@gitlab-production.iam.gserviceaccount.com&Signature=UqsJYBoFMcNkKI3EkoZZGk4aRPLZnJGOkDylwMQzM96fFGwcpDYUVUS6sBOy%0AyQt3FdH2XG7lKKDokexz2ihJ3X4cEXbVZLtmIMEg7k0L8NwWaAbZWJcm%2FtIe%0Aupa7f5eof9Ww%2BiRX%2B16JtB5lavzS3I%2FVrBC3fBtNinRMwIPkiWjT0kkzSrYD%0AGE1Uv3OWgFU3r96y7pOzoTPCnitM3B8kfi%2F%2BQVx8nXdsleXeWux1WfcBJyCS%0AqH5srIC%2BTpvTfjJ4pGYmOnNoA1ikJS3fdQTcN6QRW9OrCTJn03kCcNJ3UG67%0A5Ya4OTedfX7dr2hKs9yi%2FNNZnnuR1EAbVWojN%2Bnn0A%3D%3D&Expires=1629092253

..the exact build line is unfortunately printed out only in the non-evaluated form:

$ cmake -DRPM=$CI_JOB_NAME $CMAKE_FLAGS .. 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log

I need to do a test run that echoes it out to verify what the -DRPM value actually ends up being.

Comment by Daniel Black [ 2021-08-16 ]

"-- Installation layout: DEFAULT" in the output suggests its likely to be blank. Could just set -DRPM=

{some-fixed-value}

. It really only affects the names of the generated RPMs.

Comment by Daniel Black [ 2021-08-19 ]

Verified looking at RPM based builds on buildbot like http://buildbot.askmonty.org/buildbot/builders/kvm-rpm-centos73-ppc64/builds/18101/steps/compile/logs/stdio

-- Installation layout: RPM

exists when the -DRPM="actual value". So Otto, you must have it blank.

Comment by Otto Kekäläinen [ 2021-08-29 ]

danblack The value of `-DRPM` is not empty. Seems that it is just not being picked up.

I added to CPackRPM.cmake a debug line to print out the value:

MESSAGE("CPackRPM:Debug: Building with RPM configuration: ${RPM}")

In the example log of a Gitlab test build one can see that `-DRPM=centos8` was for sure passed to `cmake'.

The debug code does however not see any:

CPack: Create package
CPackRPM:Debug: Building with RPM configuration: 
CPackRPM:Debug: Testing rpm --recommends: 1
CPackRPM:Debug: rpmbuild version is <4.11.3>

The lines output by libmariadb/CMakeLists.txt also say DEFAULT and not RPM:

Installation layout: DEFAULT

Comment by Daniel Black [ 2021-08-29 ]

please edit the example log url. I'm getting "ExpiredToken". Found - https://gitlab.com/ottok/mariadb/-/jobs/1528209679 for cento7 showing Installation layout: DEFAULT but not for centos8.

Same with https://gitlab.com/ottok/mariadb/-/jobs/1543385136

Could this be tied to the cmake version?

$ cmake --trace-source=cmake/install_layout.cmake --trace-expand

Comment by Otto Kekäläinen [ 2021-08-29 ]

Indeed, the INSTALL_LAYOUT is DEFAULT if RPM=centos7.

On all other values for RPM (centos8, fedora, generic) seem to work and INSTALL_LAYOUT is RPM.

New debug code:

--- a/cmake/cpack_rpm.cmake
+++ b/cmake/cpack_rpm.cmake
@@ -1,5 +1,7 @@
 IF(RPM)
 +MESSAGE("CPackRPM building with RPM configuration: ${RPM}")

RPM=centos7 https://gitlab.com/ottok/mariadb/-/jobs/1544023335

-- MariaDB Connector/c configuration:
-- Static PLUGINS pvio_socket;mysql_native_password;mysql_old_password
-- Dynamic PLUGINS dialog;client_ed25519;caching_sha2_password;sha256_password;auth_gssapi_client;mysql_clear_password
-- CPack generation: TGZ
-- SSL support: OPENSSL Libs: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so
-- Zlib support: ON
-- Installation layout: DEFAULT
-- Include files will be installed in include/mysql
-- Libraries will be installed in lib64
-- Binaries will be installed in bin
-- Documentation included from 
-- Required: dl;m;pthread
-- MariaDB Connector/C 3.2.4
CPackRPM building with RPM configuration: centos7

RPM=centos8 https://gitlab.com/ottok/mariadb/-/jobs/1544023333

-- MariaDB Connector/c configuration:
-- Static PLUGINS mysql_native_password;mysql_old_password;pvio_socket
-- Dynamic PLUGINS dialog;client_ed25519;caching_sha2_password;sha256_password;auth_gssapi_client;mysql_clear_password
-- CPack generation: TGZ
-- SSL support: OPENSSL Libs: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so
-- Zlib support: ON
-- Installation layout: RPM
-- Include files will be installed in include/mysql
-- Libraries will be installed in lib64
-- Binaries will be installed in bin
-- Documentation included from 
-- Required: dl;m;pthread
-- MariaDB Connector/C 3.2.4
CPackRPM building with RPM configuration: centos8

Comment by Otto Kekäläinen [ 2021-08-29 ]

I confirm this was a CMake version issue.

Centos 7 has cmake version 2.8.12.2. After installing cmake3 version 3.17.5 from EPEL the exact same build evaluated INSTALL_LAYOUT correctly:

-- MariaDB Connector/c configuration:
-- Static PLUGINS mysql_native_password;mysql_old_password;pvio_socket
-- Dynamic PLUGINS dialog;client_ed25519;caching_sha2_password;sha256_password;auth_gssapi_client;mysql_clear_password
-- CPack generation: TGZ
-- SSL support: OPENSSL Libs: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so
-- Zlib support: ON
-- Installation layout: RPM
-- Include files will be installed in include/mysql
-- Libraries will be installed in lib64
-- Binaries will be installed in bin
-- Documentation included from 
-- Required: dl;m;pthread
-- MariaDB Connector/C 3.2.4
-- CPackRPM building with RPM configuration: centos7

I ran the trace cmake -DRPM=centos7 --trace-source=cmake/install_layout.cmake --trace-expand on both CMake 2 and CMake 3 and compared, but in traces both evaluated INSTALL_LAYOUT "DEFAULT".

IF(NOT INSTALL_LAYOUT)
  SET(INSTALL_LAYOUT "DEFAULT")
ENDIF()

After adding a bunch of MESSAGE here and there to debug I arrived that the root cause is the STRQUAL comparison, and the fix is:

diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake
index a9b103345cd..ebe07f8c5a0 100644
--- a/cmake/mariadb_connector_c.cmake
+++ b/cmake/mariadb_connector_c.cmake
@@ -22,9 +22,9 @@ ENDIF()
 SET(CONC_WITH_CURL OFF)
 SET(CONC_WITH_MYSQLCOMPAT ON)
 
-IF (INSTALL_LAYOUT STREQUAL "RPM")
+IF (${INSTALL_LAYOUT} STREQUAL "RPM")
   SET(CONC_INSTALL_LAYOUT "RPM")
-ELSEIF (INSTALL_LAYOUT STREQUAL "DEB")
+ELSEIF (${INSTALL_LAYOUT} STREQUAL "DEB")
   SET(CONC_INSTALL_LAYOUT "DEB")
 ELSE()
   SET(CONC_INSTALL_LAYOUT "DEFAULT")

Should I make a PR of this?

Comment by Otto Kekäläinen [ 2021-08-30 ]

Did now https://github.com/MariaDB/server/pull/1897 as CentOS 7 will be around for a while more..

Comment by Otto Kekäläinen [ 2023-03-18 ]

Since CMake 2.x use is getting very rare I will just close https://github.com/MariaDB/server/pull/1897, in particular since nobody else reported running into this issue in https://jira.mariadb.org/browse/MDEV-26319.

Generated at Thu Feb 08 09:44:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.