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

Merged
merged 18 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 11 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
6 changes: 6 additions & 0 deletions mariadb/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ 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: `parameters.innodb_buffer_pool_size` (optional)

Some users have experienced [errors][migration-issues] during Home Assistant schema updates on large databases.
Increasing this value from the default 128M can help if there is RAM available.

## 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 +106,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
6 changes: 5 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 All @@ -23,6 +23,8 @@ options:
rights:
- database: homeassistant
username: homeassistant
parameters:
- innodb_buffer_pool_size: 128M
ports:
3306/tcp: null
schema:
Expand All @@ -38,6 +40,8 @@ schema:
CREATE VIEW|DELETE|DELETE HISTORY|DROP|EVENT|GRANT OPTION|INDEX|\
INSERT|LOCK TABLES|SELECT|SHOW VIEW|TRIGGER|UPDATE)?"
username: str
parameters:
- innodb_buffer_pool_size: str
services:
- mysql:provide
startup: system
Expand Down
16 changes: 14 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,19 @@
# Start MariaDB service
# ==============================================================================

# Initialize an empty string to hold the concatenated parameters
param_string=""
danielszilagyi marked this conversation as resolved.
Show resolved Hide resolved

# Fetch the full array of parameters
item=$(bashio::config "parameters")

while read -r param; do
param_string+="--$param "
done < <(jq --raw-output 'to_entries[] | "\(.key)=\(.value)"' <<< "$item")

param_string=$(echo -n "$param_string" | sed 's/[[:space:]]*$//'|tr -d '\n')

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