Aleksei Sviridkin 4f9ff665da fix(mariadb): derive my.cnf sizing from the instance's own resources
The shipped my.cnf hardcoded the tuning of a large bare-metal host: a 60G
buffer pool, a 4096M redo log, a 1024M MyISAM key cache, 4096 connections
and 24 pool threads. The chart defaults to t1.nano, which is 250m of CPU
and 128Mi of memory with a 10Gi volume, so by default a 128Mi container
was asked to map 60G of buffer pool and preallocate a redo log worth 40%
of its data volume.

That is not merely wasteful. With the Linux default heuristic overcommit
the 60G mapping is refused outright on a node without the memory to back
it, and mariadbd exits with "Cannot map innodb_buffer_pool_size_max"; where
the mapping is permitted, the eagerly allocated key cache alone exceeds a
small instance's limit and the pod is OOM killed during startup. A nano
instance only survives on a node large enough for the mapping to be granted
and with a working set small enough never to touch it.

Every value that is a memory allocation or a thread count now derives from
the memory and CPU limits resolved by the same cozy-lib helper that fills
the MariaDB CR's resource stanza, so an explicit resources block and a
preset both flow through. Settings that encode durability or storage
behaviour rather than size -- the flush method, flush_log_at_trx_commit,
io_capacity, fast_shutdown -- are left alone, because the chart cannot
infer them from the pod.

The buffer pool takes half of the memory limit. The usual advice to give
InnoDB 70-80% of RAM assumes a dedicated host where the rest is page cache
and overshooting merely swaps; under a cgroup limit the same budget must
also cover per-connection buffers, temp tables, the key cache and mysqld's
own heap, and overshooting is a kill rather than a slowdown. Sizes above
128 MiB are rounded down to a whole number of 128 MiB chunks. On the 10.6
line InnoDB allocates the pool in 128 MiB chunks and rounds a request up,
which would hand the pod more pool than its limit allows; the newer lines
either autosize the chunk or ignore it outright, so there the rounding only
costs a little pool on a limit that is at least 256 MiB and not a multiple
of it -- the rounding applies to half the limit, and below one whole chunk
it does not fire at all -- and buys one effective size across every version
the chart ships.

Most caps are the previously shipped value, so an instance large enough to
reach one is sized as it is today, and most floors are the server's own
default, so a small instance is not configured more restrictively than an
untuned MariaDB. Three clamps deliberately break that symmetry. The buffer
pool has no cap: pinning it to the old 60G would keep the largest instances
sized for a host they do not run on, so an instance with 128Gi or more of
memory is the one case where a value goes up rather than down, to half of a
limit it already has. The MyISAM key cache goes the other way, capped at
128M against the 1024M shipped and floored at 8M against a 128M default,
because it is allocated eagerly at startup and MariaDB's own system tables
are Aria rather than MyISAM, so on a small instance it is close to dead
weight charged against the limit. The IO threads are the third, floored at
2 against a default of 4, because they should follow the CPU limit rather
than the host. The one user-visible narrowing is
max_connections on small instances, which falls from 4096 to the stock
default of 151 -- a limit those instances could not have served anyway, and
one that now rises automatically as the instance is sized up.

Changing the redo log size is safe on every version this chart ships.
InnoDB replays the existing log during crash recovery and only then rewrites
it at the new size. This was verified on all four shipped versions --
10.6.24, 10.11.15, 11.4.9 and 11.8.5 -- after both a clean shutdown and a
SIGKILL mid-write, with the data intact afterwards. The size is also
bounded by a twentieth of the data volume, so first boot no longer
preallocates a large part of it -- below roughly 2Gi of volume the 96M
floor wins instead and the server's own default is what lands.

The ConfigMap is not labelled k8s.mariadb.com/watch, so the operator does
not roll an instance when it changes. That is left as it was. An instance
crashlooping on the old config picks the new one up as soon as the kubelet
restarts it, which is the case this fixes, while a healthy instance keeps
its current sizing until it next restarts for some other reason. Rolling
every tenant database on a chart upgrade would be the larger risk.

innodb_buffer_pool_instances and innodb_thread_concurrency are dropped
rather than scaled. Both were removed from the server in 10.6, below the
oldest version this chart ships, and each start logged "was removed. It
does nothing now and exists only for compatibility with old my.cnf files".

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-07-19 01:36:26 +03:00
2025-10-08 09:43:34 +05:00
2025-04-01 18:48:14 +02:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

Open Source Apache-2.0 License Support Active GitHub Release GitHub Commit OpenSSF Best Practices OpenSSF Scorecard

Cozystack

Cozystack is a free platform and framework for building clouds.

Cozystack is a CNCF Sandbox Level Project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You can express your intention to on the fix on your own. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join our Telegram group and come to our weekly community meetings. Add them to your Google Calendar or iCal for convenience.

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 48%
Shell 37%
TypeScript 6.9%
Go Template 5.3%
Makefile 1.4%
Other 1.2%