| Bug #108947 | mysql-8.0.31: build fails if building user cannot access mysqld's tempdir | ||
|---|---|---|---|
| Submitted: | 1 Nov 2022 4:40 | Modified: | 21 Nov 2022 18:02 |
| Reporter: | Hank Leininger | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
| Version: | 8.0.31 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | BuildID, CREATE_INFO_BIN | ||
[1 Nov 2022 13:17]
MySQL Verification Team
Hi Mr. Leininger, Thank you for your bug report. However, Gentoo is not among the supported Linux platforms, which you can notice yourself on our Download pages. Regarding `tmpdir`, we require that user building from the source has all privileges on that directory. We shall check whether we have to add that to our Reference Manual. Unsupported.
[1 Nov 2022 17:12]
Hank Leininger
Gentoo is not particularly relevant here, the important thing is the currently-building mysqld should not load any system-installed conf files; it should load none, or, load only the currently-building default files. You do not see how it can be a problem that during compilation, existing/production configs are loaded?
[1 Nov 2022 18:38]
Terje Røsten
Hi! Thanks for your report, indeed adding --no-defaults was forgotten when adding this code to run the newly built mysqld. The common pattern of adding --no-defaults is used several places in the test suite to avoid exactly such problems.
[21 Nov 2022 18:02]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Server 8.0.32 release, and here's the proposed changelog entry from the documentation team: Building MySQL would fail if the building user lacked access to mysqld's temporary directory. Now --no-defaults is used when creating the INFO_BIN file. Thank you for the bug report.
[22 Nov 2022 13:22]
MySQL Verification Team
Thank you, Philip.

Description: If a host has mysql configured to use a tmpdir that only the mysql user can access, and mysql is compiled as a different user, the build will fail towards the very end; in the below example on Gentoo Linux, mysql is compiled by user portage under a /var/tmp/portage/... path: [100%] Generating Docs/INFO_BIN /usr/bin/cmake -DMYSQLD_EXECUTABLE=/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build/runtime_output_directory/mysqld -DCMAKE_BUILD_TYPE=RelWithDebInfo -P /var/tmp/portage/dev-db/mysql-8.0.31/work/mysql/cmake/info_bin.cmake CMake Error at info_macros.cmake:185 (MESSAGE): mysqld --help failed: mysqld: Can't get stat of '/usr/local/mysql-data/tmp' (OS errno 13 - Permission denied) 2022-11-01T03:14:41.014206Z 0 [ERROR] [MY-010119] [Server] Aborting Call Stack (most recent call first): /var/tmp/portage/dev-db/mysql-8.0.31/work/mysql/cmake/info_bin.cmake:36 (CREATE_INFO_BIN) make[2]: *** [CMakeFiles/INFO_BIN.dir/build.make:71: CMakeFiles/INFO_BIN] Error 1 make[2]: Leaving directory '/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build' make[1]: *** [CMakeFiles/Makefile2:2735: CMakeFiles/INFO_BIN.dir/all] Error 2 make[1]: Leaving directory '/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build' make: *** [Makefile:156: all] Error 2 Here info_bin.cmake is calling CREATE_INFO_BIN defined in cmake/info_macros.cmake.in In my case, mysql's tmpdir = /usr/local/mysql-data/tmp, which is mysql-only, inaccessible to user portage: # namei -l /usr/local/mysql-data/tmp f: /usr/local/mysql-data/tmp drwxr-xr-x root root / drwxr-xr-x root root usr drwxr-xr-x root root local drwxrwx--T root mysql mysql-data drwxr-xr-x mysql mysql tmp How to repeat: 1) Create a path that is only accessible to user mysql 2) configure /etc/mysql/... to set tmpdir= to some path under #1 3) Compile mysql as a non-root, non-mysql user 4) When build is nearly complete, it aborts with the above error. Suggested fix: This was never a problem until recently; sometime between 8.0.27 and 8.0.31 this was added: $ diff -u \ mysql-8.0.27/work/mysql/cmake/info_macros.cmake.in \ mysql-8.0.31/work/mysql/cmake/info_macros.cmake.in ... + IF(HAVE_BUILD_ID_SUPPORT AND NOT WITHOUT_SERVER) + FILE(APPEND ${INFO_BIN} "\n===== BUILD ID =====\n") + EXECUTE_PROCESS(COMMAND + ${MYSQLD_EXECUTABLE} --help + OUTPUT_VARIABLE mysqld_help ... This will call the just-built mysqld binary, but it reads in configs from the real /etc/mysql/ if present, causing an error. So the fix is to avoid reading the system's in-place configs, if any. Adding --no-defaults to that mysqld invocation avoids the problem of the build user trying to follow paths only user mysql can access, but still includes the BuildID in the output that the recipe wants. So: --- a/cmake/info_macros.cmake.in 2022-09-13 12:15:16.000000000 -0400 +++ b/cmake/info_macros.cmake.in 2022-11-01 00:12:06.270464679 -0400 @@ -175,7 +175,7 @@ IF(HAVE_BUILD_ID_SUPPORT AND NOT WITHOUT_SERVER) FILE(APPEND ${INFO_BIN} "\n===== BUILD ID =====\n") EXECUTE_PROCESS(COMMAND - ${MYSQLD_EXECUTABLE} --help + ${MYSQLD_EXECUTABLE} --no-defaults --help OUTPUT_VARIABLE mysqld_help RESULT_VARIABLE mysqld_help_result ERROR_VARIABLE mysqld_help_error