Pre-requisites: Postal MariaDB 12.3+ Database Configuration #3639
c41ms0n
started this conversation in
Development discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Postal MariaDB 12.3+ Configuration
Purpose
This configuration is focused on Postal's transient mail-queue workload:
Hardware-specific tuning is intentionally excluded from the base configuration.
Docker Run
docker run -d \ --name postal-mariadb \ -p 127.0.0.1:3306:3306 \ --restart always \ -v /opt/postal/storage/mysql:/var/lib/mysql:rw \ -e MARIADB_DATABASE=postal \ -e MARIADB_ROOT_PASSWORD=postal \ docker.io/library/mariadb \ mariadbd \ --innodb-data-file-path=ibdata1:12M:autoextend:autoshrink \ --innodb-temp-data-file-path=ibtmp1:12M:autoextend:autoshrink \ --innodb-undo-log-truncate=ON \ --innodb-max-undo-log-size=1G \ --innodb-immediate-scrub-data-uncompressed=ON \ --innodb-flush-log-at-trx-commit=2 \ --innodb-buffer-pool-dump-at-shutdown=ON \ --innodb-buffer-pool-load-at-startup=ON \ --thread-handling=pool-of-threads \ --skip-log-binThread Handling
Enable MariaDB's thread pool instead of creating a dedicated server thread for every connection.
This is part of the base Postal configuration.
thread_pool_sizeis intentionally not specified. MariaDB determines the default thread-pool size from the available CPU resources, so the configuration automatically adapts to different server sizes.thread_cache_sizeis intentionally not specified because it is not used when the thread pool is enabled.Buffer Pool Persistence
Persist the current buffer-pool state during a clean shutdown and restore it during startup.
This allows MariaDB to restore frequently used pages after a restart instead of rebuilding the working set entirely from disk.
innodb-buffer-pool-dump-pctis intentionally not specified. The amount of buffer-pool state to persist should remain a deployment-specific tuning decision.Storage Reclamation
InnoDB System Tablespace
Allow the InnoDB system tablespace to grow when required and automatically shrink when reclaimable space is available.
This prevents
ibdata1from permanently retaining historical growth.Temporary Tablespace
Allow the InnoDB temporary tablespace to grow when required and automatically shrink after temporary data is released.
The temporary tablespace can also be explicitly truncated without restarting MariaDB:
Undo Tablespaces
Enable automatic truncation of undo tablespaces when they exceed the configured threshold.
The threshold limits long-term undo growth in a workload with continuous INSERT/UPDATE/DELETE activity.
The threshold can be adjusted for a particular deployment if monitoring shows that a different value is more appropriate.
Per-Table Space Reclamation
Modern MariaDB uses
innodb_file_per_table=ONby default.No explicit
innodb_file_per_tableoption is required in the configuration.Using individual tablespaces allows:
.ibdfilesData Scrubbing
Enable immediate scrubbing for applicable uncompressed InnoDB data when pages are freed.
This is the current MariaDB immediate-scrub mechanism.
It is not equivalent to the historical Percona background scrubber for compressed InnoDB pages.
Transaction Durability
Use a throughput-oriented durability mode suitable for a transient mail-queue workload.
Committed redo is flushed approximately once per second instead of forcing an fsync for every transaction commit.
Use:
when maximum crash durability is required.
Binary Logging
Disable binary logging when the Postal database is not used for replication or point-in-time recovery.
This avoids maintaining another persistent copy of transactional changes.
Postal Redo Log Requirement
Postal requires redo capacity of at least approximately 10 times the maximum configured message size.
Examples:
innodb_log_file_sizeshould therefore be configured according to the actual Postal maximum message size.Do not hard-code a single redo-log size in the generic configuration.
Packet Size
max_allowed_packetshould be larger than the configured Postal maximum message size.This is deployment-specific and is intentionally not included in the base Docker command.
Purge Threads
innodb_purge_threadsis intentionally not hard-coded.MariaDB defaults should be used initially, then adjusted based on observed:
Postal's retention workload can produce substantial purge activity, but the optimal number of purge threads depends on the actual deployment.
Buffer Pool Size
innodb_buffer_pool_sizeis intentionally not hard-coded.It should be sized according to:
Table Reclamation
Do not run
OPTIMIZE TABLEafter every DELETE.Use it selectively for long-lived Postal tables that have accumulated substantial
DATA_FREE.Check table fragmentation:
Rebuild only tables that require space reclamation:
For Postal raw-message data, dropping the complete expired raw-message table is preferred to deleting millions of individual rows.
Storage Reclamation Model
Deployment-Specific Parameters
The following parameters should be configured separately for each deployment:
innodb_log_file_size— based on the Postal maximum message sizemax_allowed_packet— based on the Postal maximum message sizeinnodb_buffer_pool_size— based on available RAM and workloadinnodb_purge_threads— based on purge workload and CPU resourcesThe base configuration deliberately avoids hard-coded CPU, RAM, storage, and message-size assumptions.
All reactions