Database restore loses data when a row is larger than max_allowed_packet
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
The issue identifies the database dump and import code but names no files or tests. Start by tracing where dump rows are batched and where restore statements are executed, then inspect the open pull request for the proposed approach. Done means large rows are isolated, oversized statements are split during restore, and a lost connection stops the restore with a clear message.
Written by the indexing model from the issue text.
Description
Describe the bug
Restoring a backup with large rows fails in the database step. BackWPup's dump batches rows into multi-row INSERTs and only starts a new one after the statement is already over 50000 characters, so a statement can take several multi-megabyte rows. When such a statement exceeds the database server's max_allowed_packet, the server drops the connection and data is lost.
To Reproduce
- Use a site with a large option row, e.g. All-In-One WP Security's
aiowps_plugin_checksums(about 16 MB with ~40 plugins). - Use a database server with the default
max_allowed_packetof 16 MB (MariaDB/MySQL default). - Create a backup including the database and restore it.
Observed
Database server log:
[Warning] Aborted connection ... (Got a packet bigger than 'max_allowed_packet' bytes)
With a direct mysqli connection, the restore log then contains hundreds of MySQL server has gone away errors and ends with ... SET FOREIGN_KEY_CHECKS = 1; everything after the failing statement is missing. In the reported case one INSERT INTO wp_options was about 18 MB (a 1.4 MB and a 16.7 MB row plus 50 small rows).
Expected behavior
Large rows are written into their own statement by the backup, oversized statements are split on restore, and a lost connection stops the restore with a clear message.
System
- BackWPup 5.7.8 (same dump/import code as 4.x)
- PHP 8.3, MariaDB with default
max_allowed_packet(16 MB)
A fix is ready as a pull request.
- Dominant language
- PHP
- Stars
- 96
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wp-media/backwpup
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
S3 backup list times are shifted by the site's UTC offset (timezone offset applied twice)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
WordPress XML export: posts have no categories or tags since 5.6.6Possibly taken @rafaelmaeuer claimed this 14 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Complete restore can leave the site half-restoredPossibly taken @rafaelmaeuer claimed this 14 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
Complete restore stops after the file step: user is logged out, database is not restoredPossibly taken @rafaelmaeuer claimed this 14 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
All issues in wp-media/backwpup
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
[Sync EN] Formatting improvements to "Large Objects (LOBs)" docs (#6056)Possibly taken A pull request linked to this issue is open or already merged. Opensync-en
Difficulty 1/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Перевод устарел
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
craftcms/cms#20613 · 1 comment ·
Maintainers usually reply within 1 day