Feature Support large MySQL and MariaDb databases#64
Conversation
- Add mysql:8.4 client tools stage to Dockerfile so the real mysqldump binary (with --network-timeout) takes PATH precedence over MariaDB's mysqldump symlink, which lacks this flag - Use --network-timeout in MySQL backup command; sets net_read_timeout and net_write_timeout to 86400s for the duration of the dump - Simplify config: replace net_read_timeout/net_write_timeout/max_allowed_packet with a single max_packet_size field (optional, defaults to 512M) - Log mysqldump/mariadb-dump client version as a debug message before each backup
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughThe PR extends database configuration with ChangesDatabase configuration and tooling
Windows CI/CD automation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docker/Dockerfile`:
- Around line 157-159: The runtime image is not configured to run as a non-root
user, which is a security risk. After the COPY commands that add mysqldump and
its libraries (lines 157-158), adjust the ownership and permissions of the
copied directories and binaries so they are readable by a non-root user, then
create a dedicated non-root user account using the USER instruction and set it
as the default user for the container. Ensure the non-root user has appropriate
read and execute permissions on /usr/local/bin/mysqldump and /usr/local/lib/
directories.
In `@src/services/config.rs`:
- Line 57: The `DatabaseConfig` struct now has a required `max_packet_size`
field that breaks all existing struct literal constructions that don't provide
it (such as in src/tests/domain/mysql.rs). Either update all `DatabaseConfig {
... }` struct literal instantiations throughout the codebase to include the
`max_packet_size` field with an appropriate value, or implement a constructor
method or builder pattern for `DatabaseConfig` that provides sensible defaults
and is used consistently instead of direct struct instantiation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3b328185-e9b5-47dd-b6c1-aa3ecf88d105
📒 Files selected for processing (4)
docker/Dockerfilesrc/domain/mariadb/backup.rssrc/domain/mysql/backup.rssrc/services/config.rs
|
Hi, thanks for that PR, I will review it before the end of the week end. Let me know once good in your side for review |
|
Hi @RambokDev - good to go. |
|
Hi @pcrosthwaite, Merged, thanks for you contribution to Portabase, Regards, |
Problem
Large MySQL database backups were failing with Error 2013: Lost connection to server during query mid-dump. This occurs because MySQL's server-side net_read_timeout and net_write_timeout (defaulting to 30s and 60s respectively) kill the connection while mysqldump is still reading rows from a large table.
The root cause was compounded by the Docker image installing mariadb-client, which symlinks mysqldump → mariadb-dump. MariaDB's mysqldump has no mechanism to set these timeouts from the client side — --network-timeout and equivalent options simply don't exist in that binary.
Changes
docker/Dockerfile
Added a mysql:8.4 build stage to extract the real MySQL mysqldump binary and its shared library (libmysqlclient.so.21). The binary is placed at /usr/local/bin/mysqldump, which takes PATH precedence over /usr/bin/mysqldump (MariaDB's symlink). The mariadb-dump binary is unaffected and continues to be used for MariaDB backups.
src/domain/mysql/backup.rs
Added --network-timeout to the mysqldump command. This MySQL 8.0.1+ flag automatically sets net_read_timeout and net_write_timeout to 86400 seconds (24 hours) for the duration of the dump session. Also logs the mysqldump client version as a debug message before each backup to make it easy to verify the correct binary is being used.
src/domain/mariadb/backup.rs
Logs the mariadb-dump client version as a debug message before each backup, consistent with the MySQL change.
src/services/config.rs
Added an optional max_packet_size field to DatabaseConfig (defaults to 512M). This allows per-database tuning of --max-allowed-packet for databases with large row values. Example config:
{
"name": "my-database",
"type": "mysql",
"max_packet_size": "1G"
}
Summary by CodeRabbit
Release Notes
New Features
max_packet_sizesupport for database backups (defaults to 512M).PG_BIN_DIRoverride.Bug Fixes
Chores
mysqldumptools and matching libraries.Other