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

Add support for mariadb server config parameter #3763

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mariadb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.7.2

- Add option to configure MariaDB server parameters (see also [home-assistant/addons#3754](https://github.com/home-assistant/addons/issues/3754))

## 2.7.1

**Note:** Restart the add-on before upgrade if the current version is lower
Expand Down
8 changes: 8 additions & 0 deletions mariadb/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ If omitted, grants `ALL PRIVILEGES` to the user. Restricting privileges of the u
that Home Assistant uses is not recommended but if you want to allow other applications
to view recorder data should create a user limited to read-only access on the database.

### Option: `mariadb_server_args` (optional)

Some users have experienced [errors][migration-issues] during Home Assistant schema updates on large databases.
Defining the recommended parameters can help if there is RAM available.

Example: `--innodb_buffer_pool_size=512M`

## Home Assistant Configuration

MariaDB will be used by the `recorder` and `history` components within Home Assistant. For more information about setting this up, see the [recorder integration][mariadb-ha-recorder] documentation for Home Assistant.
Expand Down Expand Up @@ -101,6 +108,7 @@ In case you've found a bug, please [open an issue on our GitHub][issue].
[username]: https://mariadb.com/kb/en/create-user/#user-name-component
[hostname]: https://mariadb.com/kb/en/create-user/#host-name-component
[grant]: https://mariadb.com/kb/en/grant/
[migration-issues]: https://github.com/home-assistant/core/issues/125339
[mariadb-ha-recorder]: https://www.home-assistant.io/integrations/recorder/
[discord]: https://discord.gg/c5DvZ4e
[forum]: https://community.home-assistant.io
Expand Down
4 changes: 3 additions & 1 deletion mariadb/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 2.7.1
version: 2.7.2
slug: mariadb
name: MariaDB
description: A SQL database server
Expand Down Expand Up @@ -38,6 +38,8 @@ schema:
CREATE VIEW|DELETE|DELETE HISTORY|DROP|EVENT|GRANT OPTION|INDEX|\
INSERT|LOCK TABLES|SELECT|SHOW VIEW|TRIGGER|UPDATE)?"
username: str
mariadb_server_args:
- str?
services:
- mysql:provide
startup: system
Expand Down
15 changes: 13 additions & 2 deletions mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
# Start MariaDB service
# ==============================================================================

if bashio::config.has_value "mariadb_server_args"; then
readarray -t extra_args <<< "$(bashio::config 'mariadb_server_args')"
bashio::log.info "Starting MariaDB with command line parameters: ${extra_args[*]}"
else
bashio::log.info "Starting MariaDB"
fi

# Start mariadb
bashio::log.info "Starting MariaDB"
mkdir -p /run/mysqld
exec mysqld --datadir="${MARIADB_DATA}" --user=root < /dev/null

if [ -z "${extra_args+x}" ] || [ ${#extra_args[@]} -eq 0 ]; then
exec mysqld --datadir="${MARIADB_DATA}" --user=root < /dev/null
else
exec mysqld --datadir="${MARIADB_DATA}" --user=root "${extra_args[@]}" < /dev/null
fi