Skip to content

fix: passes arguments to mysqld process in docker-entypoint.sh file, fixes #6668 - #6669

Closed
stijnveeke wants to merge 5 commits into
ddev:masterfrom
stijnveeke:patch-2
Closed

stijnveeke wants to merge 5 commits into
ddev:masterfrom
stijnveeke:patch-2

Conversation

@stijnveeke

@stijnveeke stijnveeke commented Oct 30, 2024 •

Copy link
Copy Markdown

The Issue

How This PR Solves The Issue

Checks for arguments if present and passes them to the mysqld execution. In case not present it will use the default execution process which ismysqld --server-id=0.

TODO

  • Test coverage for this feature
  • Documentation of how to use this feature in docker-compose.*.yaml

Manual Testing Instructions

Extend the functionality of the db container by adding to a docker compose additional execution arguments like this.
command: --server-id=1 --log-bin=mysql-bin --binlog-format=row It should now check if a server-id is present in case it is it will add the above arguments to the execution of mysqld in case this is not present it will append these arguments to the already present --server-id=0 argument.

Automated Testing Overview

No automatic tests are needed because it always defaults back to the default functionality which is:
mysqld --server-id=0

Release/Deployment Notes

Nothing has to change during deployment.

@stijnveeke
stijnveeke requested a review from a team as a code owner October 30, 2024 13:18
@stijnveeke stijnveeke changed the title Updated docker-entrypoint.sh to allow arguments passed to entrypoints… fix: passes arguments to mysqld process in docker-entypoint.sh file, fixes #6668 Oct 30, 2024
@rfay
rfay marked this pull request as draft October 30, 2024 23:22
@rfay

rfay commented Oct 30, 2024

Copy link
Copy Markdown
Member

This doesn't actually do anything until a matching image is built and pushed, and versionconstraints.go updated to use the new image. Moving to draft as a result.

@rfay
rfay requested a review from stasadev November 4, 2024 23:35
@rfay

rfay commented Nov 4, 2024

Copy link
Copy Markdown
Member

I'm inclined to not do this one, because it introduces new risks with no particular benefit to any but one known user, who has a clear workaround.

Requested @stasadev 's opinion.

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stijnveeke and others added 3 commits November 9, 2024 15:44
… to apply in mysqld.

Currently, passing an argument to the database container using commands inside the docker-compose file does not apply the arguments to the MySQL execution. This file change resolves the issue, allowing for a more flexible container configuration.
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 9, 2024
@rfay

rfay commented Nov 9, 2024

Copy link
Copy Markdown
Member

I pushed the db images and rebased. This feature needs manual testing and automated test coverage still.

@github-actions

github-actions Bot commented Nov 9, 2024 •

Copy link
Copy Markdown

@rfay

rfay commented Nov 10, 2024 •

Copy link
Copy Markdown
Member

This causes unexpected failures and unpredicted results starting in TestExtraPackages. I had to use tmate to do a make testpkg to be able to study it.

ddev logs -s db output
Starting mysqld.
+ echo
+ echo 'MySQL init process done. Ready for start up.'
+ echo
+ echo 'Starting mysqld.'
+ '[' 4 -eq 0 ']'
+ [[  -c config_file=/etc/postgresql/postgresql.conf -c hba_file=/etc/postgresql/pg_hba.conf  =~ --server-id([=[:space:]]|$) ]]
+ exec mysqld --server-id=0 -c config_file=/etc/postgresql/postgresql.conf -c hba_file=/etc/postgresql/pg_hba.conf
+ tail -f /var/log/mysqld.log
2024-11-10  1:40:50 0 [Warning] option 'server_id': unsigned value 0 adjusted to 1
2024-11-10  1:40:50 0 [Note] Starting MariaDB 10.11.9-MariaDB-ubu2204-log source revision 0e8fb977b00983d98c4c35e39bc1f36463095938 server_uid D9lFr3c5JpyQ2okxU60XOZjMCnY= as process 1
2024-11-10  1:40:50 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-11-10  1:40:50 0 [Note] InnoDB: Number of transaction pools: 1
2024-11-10  1:40:50 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-11-10  1:40:50 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2024-11-10  1:40:50 0 [Warning] mysqld: io_uring_queue_init() failed with errno 1
2024-11-10  1:40:50 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2024-11-10  1:40:50 0 [Note] InnoDB: Initializing buffer pool, total size = 1.000GiB, chunk size = 16.000MiB
2024-11-10  1:40:50 0 [Note] InnoDB: Completed initialization of buffer pool
2024-11-10  1:40:50 0 [Note] InnoDB: Buffered log writes (block size=4096 bytes)
2024-11-10  1:40:50 0 [Note] InnoDB: End of log at LSN=47008
2024-11-10  1:40:50 0 [Note] InnoDB: Resizing redo log from 12.016KiB to 48.000MiB; LSN=47008
2024-11-10  1:40:50 0 [Note] InnoDB: Buffered log writes (block size=4096 bytes)
2024-11-10  1:40:50 0 [Note] InnoDB: 128 rollback segments are active.
2024-11-10  1:40:50 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2024-11-10  1:40:50 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2024-11-10  1:40:50 0 [Note] InnoDB: log sequence number 47008; transaction id 16
2024-11-10  1:40:50 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2024-11-10  1:40:50 0 [Note] InnoDB: Cannot open '/var/lib/mysql/ib_buffer_pool' for reading: No such file or directory
2024-11-10  1:40:50 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-11-10  1:40:50 0 [Warning] 'innodb-log-files-in-group' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
2024-11-10  1:40:50 0 [ERROR] mysqld: unknown option '-c'
2024-11-10  1:40:50 0 [ERROR] mysqld: unknown option '-c'
2024-11-10  1:40:50 0 [ERROR] Aborting

You'll note that it's crazily picking up postgres config files:

+ echo 'Starting mysqld.'
+ '[' 4 -eq 0 ']'
+ [[  -c config_file=/etc/postgresql/postgresql.conf -c hba_file=/etc/postgresql/pg_hba.conf  =~ --server-id([=[:space:]]|$) ]]

The reason for this is that .ddev/.ddev-docker-compose-full.yaml has this erroneous command in the db section:

services:
    db:
        build:
            args:
                BASE_IMAGE: ddev/ddev-dbserver-mariadb-10.11:20241109_stijnveeke_mysql_args
                gid: "127"
                uid: "1001"
                username: runner
            context: /home/runner/tmp/ddevtest/TestPkgDrupal10781603732/.ddev/.dbimageBuild
            dockerfile: Dockerfile
        cap_add:
            - SYS_NICE
        command:
            - -c
            - config_file=/etc/postgresql/postgresql.conf
            - -c
            - hba_file=/etc/postgresql/pg_hba.conf

Somehow $DDEV_DB_CONTAINER_COMMAND has been left set in the environment; previously it was intended only for postgresql, but now with this change it's being picked up.

This can be recreated with

make testpkg TESTARGS="-run '(TestPostgresConfigOverride|TestExtraPackages)'"

So it's TestPostgresConfigOverride that leaves the system in an inappropriate state.

@rfay

rfay commented Nov 10, 2024 •

Copy link
Copy Markdown
Member

TestConfigDefaultContainerTimeout fails with too many arguments,

Starting mysqld.
+ exec mysqld --server-id=0 restore_snapshot TestConfigDefaultContainerTimeout120-mariadb_10.11.gz
+ tail -f /var/log/mysqld.log
2024-11-10  7:53:18 0 [Warning] option 'server_id': unsigned value 0 adjusted to 1
2024-11-10  7:53:18 0 [Note] Starting MariaDB 10.11.9-MariaDB-ubu2204-log source revision 0e8fb977b00983d98c4c35e39bc1f36463095938 server_uid 4RbDAq83deyYnw4uGUUUGWri5gc= as process 1
2024-11-10  7:53:18 0 [Warning] innodb_use_native_aio may cause hangs with this kernel 5.15.0-124-generic; see https://jira.mariadb.org/browse/MDEV-26674
2024-11-10  7:53:18 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-11-10  7:53:18 0 [Note] InnoDB: Number of transaction pools: 1
2024-11-10  7:53:18 0 [Note] InnoDB: Using ARMv8 crc32 + pmull instructions
2024-11-10  7:53:18 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2024-11-10  7:53:18 0 [Warning] mysqld: io_uring_queue_init() failed with errno 1
2024-11-10  7:53:18 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2024-11-10  7:53:18 0 [Note] InnoDB: Initializing buffer pool, total size = 1.000GiB, chunk size = 16.000MiB
2024-11-10  7:53:18 0 [Note] InnoDB: Completed initialization of buffer pool
2024-11-10  7:53:18 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
2024-11-10  7:53:18 0 [Note] InnoDB: End of log at LSN=47028
2024-11-10  7:53:18 0 [Note] InnoDB: Resizing redo log from 12.016KiB to 48.000MiB; LSN=47028
2024-11-10  7:53:18 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
2024-11-10  7:53:18 0 [Note] InnoDB: 128 rollback segments are active.
2024-11-10  7:53:18 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2024-11-10  7:53:18 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2024-11-10  7:53:18 0 [Note] InnoDB: log sequence number 47028; transaction id 14
2024-11-10  7:53:18 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2024-11-10  7:53:18 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-11-10  7:53:18 0 [Note] InnoDB: Cannot open '/var/lib/mysql/ib_buffer_pool' for reading: No such file or directory
2024-11-10  7:53:18 0 [Warning] 'innodb-log-files-in-group' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
mysqld: Too many arguments (first extra is 'restore_snapshot').
2024-11-10  7:53:18 0 [ERROR] Aborting

@rfay

rfay commented Nov 10, 2024

Copy link
Copy Markdown
Member

Mostly we use args here in an environment for doing the snapshot function, which has been robust for a long time. I don't like the environment variable technique, and it could use a makeover.

But the overall impact and destabilization of this proposed feature is not to my liking. It's more work than I'm willing to invest right now.

@rfay

rfay commented Nov 11, 2024

Copy link
Copy Markdown
Member

Closing for now. If anybody wants to chase all the fallout, we can reopen it. Refactor to do something fancier than using that DDEV_DB_CONTAINER_COMMAND environment variable would be welcome also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants