Drupal 7: indexes not rebuilt when importing via mariadb-init volume
Opened this issue · 2 comments
Isssue
When using mariadb-init
bind mount for database import Drupal 7 does not build indexes when visit the site first time. I check indexes after the first visit via:
show index from system;
Column cardinality is still 0
. Reproducible with Vanilla Drupal 7.61 (-4.9.2
) and MariaDB 10.2.18, 10.3.10 (-3.3.9
)
However when import performed via drush sqlc < file.sql
or mysql db < file.sql
after the full init/start of mariadb, indexes built correctly after the first visit.
Couldn't reproduce this issue with Drupal 8.
Workaround
Do not use import via mariadb-init
bind mount, instead import manually post-start. You can rename your dump file in mariadb-init
bind mount from dump.sql
or dump.sql.gz
to something like dump.txt
so MariaDB would ignore it during init. Then access mariadb container after it has started via docker-compose exec mariadb sh
and run:
mysql -udrupal -drupal drupal < /docker-entrypoint-initdb.d/dump.txt
@csandanov another way is to run a mysql optimize to rebuild the indices mysqlcheck -o -udrupal -p drupal
Isssue
When using
mariadb-init
bind mount for database import Drupal 7 does not build indexes when visit the site first time. I check indexes after the first visit via:show index from system;
Column cardinality is still
0
. Reproducible with Vanilla Drupal 7.61 (-4.9.2
) and MariaDB 10.2.18, 10.3.10 (-3.3.9
)However when import performed via
drush sqlc < file.sql
ormysql db < file.sql
after the full init/start of mariadb, indexes built correctly after the first visit.Couldn't reproduce this issue with Drupal 8.
Workaround
Do not use import via
mariadb-init
bind mount, instead import manually post-start. You can rename your dump file inmariadb-init
bind mount fromdump.sql
ordump.sql.gz
to something likedump.txt
so MariaDB would ignore it during init. Then access mariadb container after it has started viadocker-compose exec mariadb sh
and run:mysql -udrupal -drupal drupal < /docker-entrypoint-initdb.d/dump.txt
This is not a valid mysql command, it has to be
mysql -u drupal -pdrupal drupal < /docker-entrypoint-initdb.d/dump.txt