Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate slow query log in MySQL test setup #5186

Merged
merged 4 commits into from
Dec 11, 2019

Conversation

florimondmanca
Copy link
Contributor

What does this PR do?

Activate and configure slow query logs for the MySQL Docker Compose setup (for both MySQL and MariaDB flavors).

Motivation

This makes it much easier to test slow query logs locally. I essentially got tired of having to do the setup manually. :-)

Additional Notes

/

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@@ -28,4 +28,4 @@ setenv =
8.0: MYSQL_VERSION=8.0
maria: COMPOSE_FILE=mariadb.yaml
maria: MYSQL_FLAVOR=mariadb
maria: MYSQL_VERSION=10.1.30-r1
maria: MYSQL_VERSION=10.1.43
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewers: I had to upgrade the image version because of a bug in the RC1 we were using - it wasn't able to read the my_custom.conf config file properly due to a permission error.

@@ -7,6 +7,9 @@ services:
- MYSQL_ALLOW_EMPTY_PASSWORD=1
ports:
- "${MYSQL_PORT}:3306"
volumes:
# This is a supported conf location that isn't used by the image.
- ${MYSQL_CONF_PATH}:/etc/my.cnf
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewers: list of supported config files are documented here (table 4.2).

@@ -13,6 +13,8 @@ services:
- MARIADB_DATABASE=my_database
ports:
- "${MYSQL_PORT}:3306"
volumes:
- ${MYSQL_CONF_PATH}:/bitnami/mariadb/conf/my_custom.cnf:ro
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewers: the path to this config file is officially documented here.

Copy link
Member

@AlexandreYang AlexandreYang left a comment

Choose a reason for hiding this comment

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

💯

Just a comment about documentation.

mysql/tests/compose/mysql.conf Show resolved Hide resolved
mysql/tests/conftest.py Outdated Show resolved Hide resolved
Copy link
Member

@mgarabed mgarabed left a comment

Choose a reason for hiding this comment

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

While this will configure MySQL env to export and generate slow log reports, how does the agent get configured? There are some additional config files that need to be updated on the agent container. Maybe there needs to be another PR to handle broader log support via a ddev env start option or flag?

@florimondmanca
Copy link
Contributor Author

Thanks for the reviews! I pushed fixes in the latest commits.

@mgarabed

how does the agent get configured?

Log collection by the agent is not automatically configured, indeed — the logs section of the conf.yaml file should contain an entry for the slow log. For MySQL this is already documented: both the conf.yaml.example file as well as the README.md document this, e.g.:

logs:
  # ...
  - type: file
    path: /var/log/mysql/mysql-slow.log
    source: mysql
    sourcecategory: database
    service: myapplication

For development, I believe we don't need the Agent to collect logs, though. I went away with grabbing the output from the slow logs (e.g. in this case, using a tail command on the log file within the MySQL leader container), and using them as unit test cases for the log parser. Or is there something I'm missing?

AlexandreYang
AlexandreYang previously approved these changes Dec 11, 2019
Copy link
Member

@AlexandreYang AlexandreYang left a comment

Choose a reason for hiding this comment

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

Looks good to me overall.

Just a nit below.

mysql/tests/conftest.py Show resolved Hide resolved
@florimondmanca florimondmanca merged commit 1750eb7 into master Dec 11, 2019
@florimondmanca florimondmanca deleted the florimondmanca/mysql-slow-logs branch December 11, 2019 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants