[go: up one dir, main page]

Skip to content

Unique host path in database volume map for each app

SHORT DESCRIPTION (required)

The path on the host for the DATABASE_VOLUME_MAP must be unique for each php app.

DETAILED STEPS TO REPRODUCE (required)

We need to run on the same host 2 php apps trying to use different databases.

This will make mysql fail to start for the second app when we run the command server up http.

First App

env file
# START - Created by Php Docker Stack
# Edits will not be overridden...
DB_HOST=database
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=beanstalkd
REDIS_HOST=cache
HTTP_PORT_MAP=80:80
# END - Created by Php Docker Stack
starting the php docker stack
server up http
checking the docker container state

All containers are up and running as expected or have the expected exit status 0.

$ server ps
            Name                           Command              State           Ports        
---------------------------------------------------------------------------------------------
16117prestashopdev_code_1       /true                           Exit 0                       
16117prestashopdev_database_1   docker-entrypoint.sh mysqld     Up       3306/tcp            
16117prestashopdev_http_1       nginx -g daemon off;            Up       0.0.0.0:8000->80/tcp
16117prestashopdev_php_1        docker-php-entrypoint php-fpm   Up       9000/tcp  

Second App

the .env file
# START - Created by Php Docker Stack
# Edits will not be overridden...
DB_HOST=database
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=beanstalkd
REDIS_HOST=cache
HTTP_PORT_MAP=8000:80
# END - Created by Php Docker Stack

# The database container will create the below database and user instead of the default ones
DB_DATABASE=prestashop_16117
DB_USERNAME=prestashop_16117
starting the php docker stack
server up http
checking the docker container state

Here we can see that the database container exited with code 1, thus is not up and running as expected.

$ server ps
            Name                           Command              State           Ports        
---------------------------------------------------------------------------------------------
16117prestashopdev_code_1       /true                           Exit 0                       
16117prestashopdev_database_1   docker-entrypoint.sh mysqld     Exit 1                       
16117prestashopdev_http_1       nginx -g daemon off;            Up       0.0.0.0:8000->80/tcp
16117prestashopdev_php_1        docker-php-entrypoint php-fpm   Up       9000/tcp 
checking the logs for the error in database container

Here we can see that the issue is that InnoDB is not able to lock the file .ibdata1 because another mysql process already have locked, the one started by the first App. See last 2 lines on the below excerpt of the logs.

$ server logs database
Attaching to 16117prestashopdev_database_1
database_1        | 2017-11-05T22:21:25.006383Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
database_1        | 2017-11-05T22:21:25.006432Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
database_1        | 2017-11-05T22:21:25.007987Z 0 [Note] mysqld (mysqld 5.7.19-17) starting as process 1 ...
database_1        | 2017-11-05T22:21:25.012006Z 0 [Note] InnoDB: PUNCH HOLE support available
database_1        | 2017-11-05T22:21:25.012052Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
database_1        | 2017-11-05T22:21:25.012057Z 0 [Note] InnoDB: Uses event mutexes
database_1        | 2017-11-05T22:21:25.012061Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
database_1        | 2017-11-05T22:21:25.012064Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
database_1        | 2017-11-05T22:21:25.012068Z 0 [Note] InnoDB: Using Linux native AIO
database_1        | 2017-11-05T22:21:25.012306Z 0 [Note] InnoDB: Number of pools: 1
database_1        | 2017-11-05T22:21:25.012420Z 0 [Note] InnoDB: Using CPU crc32 instructions
database_1        | 2017-11-05T22:21:25.013903Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
database_1        | 2017-11-05T22:21:25.018603Z 0 [Note] InnoDB: Completed initialization of buffer pool
database_1        | 2017-11-05T22:21:25.021228Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
database_1        | 2017-11-05T22:21:25.031372Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
database_1        | 2017-11-05T22:21:25.031408Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
database_1        | 2017-11-05T22:21:25.031421Z 0 [Note] InnoDB: Retrying to lock the first data file
database_1        | 2017-11-05T22:21:26.031571Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
...

EXPECTED BEHAVIOUR (required)

Start first and second apps and have the mysql up and running for both apps with different databases.

RELATED TO (optional)

Healthy check on docker-compose.yml for databse service is not working as expected, once have not aborted the execution of server up http sequence, thus another issue needs to be opened to address it.

DEPENDS ON (optional)

N/A

LINKS (optional)

N/A