Skip to content

Conversation

@the-wunmi
Copy link

@the-wunmi the-wunmi commented Aug 10, 2025

Summary

This PR updates backup compression by replacing the deprecated qpress dependency with configurable compression options, allowing users to choose from multiple compression algorithms for MySQL and MongoDB backups.

Background

Previous MySQL backups enforced qpress compression by default, but qpress has been disabled in newer PMM versions due to deprecation. This change removes the qpress dependency and provides users with flexible compression options.

Changes Made

Compression Algorithm Options

  • Added BackupCompression enum support: QuickLZ, ZSTD, LZ4, S2, GZIP, Snappy, PGZip, Default and None
  • Breaking Change: Removed enforced qpress compression from MySQL backups
  • Users can now explicitly choose their preferred compression algorithm or disable compression entirely

MySQL Backup Updates

  • Removed mandatory --compress flag from xtrabackup commands
  • Made qpress dependency conditional (only required when QuickLZ is selected)
  • Updated MySQLBackupJob and MySQLRestoreJob to accept compression parameters
  • Improved binary detection to only check for qpress when needed

MongoDB Backup Enhancement

  • Extended existing MongoDB backup compression support
  • Added compression parameter passing to pbm commands
  • Consistent API across both database engines

API and Data Model Updates

  • Extended backup request/response APIs to include compression settings
  • Updated scheduled backup configurations to store compression preferences
  • Modified artifact metadata to track which compression was used
  • Updated database schemas and models accordingly

Impact

  • Removes Technical Debt: Eliminates dependency on deprecated qpress
  • User Control: Provides explicit compression choice instead of forced qpress
  • Performance Options: Users can select compression algorithms based on their speed/size trade-off preferences
  • Forward Compatibility: Prepares infrastructure for future compression algorithms

Migration

  • Existing backups remain compatible, legacy artifacts are updated to use quicklz and s2 for MySQL and MongoDB respectively as currently supported

  • New backups default to default compression provided by the backup tool (xtrabackup/pbm) unless explicitly specified

  • Users who need QuickLZ can still select it, but qpress binary must be available

  • API Docs updated

  • Link to related pull request: Backup: Replace deprecated qpress with configurable compression options grafana#839

Demo

  • Before:
pmm-backup-bug.mov

After:

pmm-backup-compression-demo.mov

@the-wunmi the-wunmi marked this pull request as ready for review August 10, 2025 05:34
@the-wunmi the-wunmi requested review from a team and BupycHuk as code owners August 10, 2025 05:34
@the-wunmi the-wunmi requested review from JiriCtvrtka and idoqo and removed request for a team August 10, 2025 05:34
}

switch j.compression {
case backuppb.BackupCompression_BACKUP_COMPRESSION_DEFAULT:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifies PBMs configuration options, and by default no specific compression

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks to me like it's defaulting to gzip though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its an empty case block, allowing to use PBM's default option to compress with s2, can explicitly specify that if that's preferred.

if _, err := exec.LookPath(qpressBin); err != nil {
return errors.Wrapf(err, "lookpath: %s", qpressBin)
if j.compression == backuppb.BackupCompression_BACKUP_COMPRESSION_QUICKLZ {
if _, err := exec.LookPath(qpressBin); err != nil {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensures we only check that qpress is installed if user wants to explicitly use quicklz, other compression options are installed as part of xtrabackup, so no need to explicitly check for them

}

// ListServiceCompression returns available compression methods for a service.
func (s *BackupService) ListServiceCompression(ctx context.Context, req *backupv1.ListServiceCompressionRequest) (*backupv1.ListServiceCompressionResponse, error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described, provided an input service, checks for the available compression methods for the related service type

}

switch j.compression {
case backuppb.BackupCompression_BACKUP_COMPRESSION_DEFAULT:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks to me like it's defaulting to gzip though.

Comment on lines +230 to +231
case backuppb.BackupCompression_BACKUP_COMPRESSION_S2:
pbmArgs = append(pbmArgs, "--compression=s2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure pbm supports this compression method?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 36.58537% with 182 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.48%. Comparing base (13c4fd3) to head (534a92c).
⚠️ Report is 3 commits behind head on v3.

Files with missing lines Patch % Lines
managed/services/agents/jobs.go 0.00% 49 Missing ⚠️
...naged/services/management/backup/backup_service.go 50.57% 38 Missing and 5 partials ⚠️
agent/runner/jobs/mongodb_backup_job.go 5.26% 18 Missing ⚠️
agent/runner/jobs/mysql_backup_job.go 0.00% 18 Missing ⚠️
agent/runner/jobs/mysql_restore_job.go 0.00% 16 Missing ⚠️
managed/models/scheduled_tasks_helpers.go 0.00% 11 Missing and 1 partial ⚠️
managed/models/artifact_model.go 78.78% 6 Missing and 1 partial ⚠️
...aged/services/management/backup/restore_service.go 0.00% 5 Missing ⚠️
managed/services/scheduler/task.go 28.57% 4 Missing and 1 partial ⚠️
agent/client/client.go 0.00% 4 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #4340      +/-   ##
==========================================
- Coverage   44.56%   44.48%   -0.08%     
==========================================
  Files         363      363              
  Lines       45706    45937     +231     
==========================================
+ Hits        20369    20437      +68     
- Misses      23677    23831     +154     
- Partials     1660     1669       +9     
Flag Coverage Δ
admin 17.33% <ø> (ø)
agent 53.03% <1.72%> (-0.28%) ⬇️
managed 44.51% <45.41%> (-0.02%) ⬇️
vmproxy 74.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@the-wunmi the-wunmi requested a review from idoqo August 22, 2025 07:31
@the-wunmi
Copy link
Author

@idoqo ICYMI, I've fixed the linter error that caused the workflow trigger to fail, might want to help trigger again

@JiriCtvrtka
Copy link
Contributor

@the-wunmi could you resolve conflicts please?

@the-wunmi
Copy link
Author

@the-wunmi could you resolve conflicts please?

@JiriCtvrtka resolved.

@the-wunmi
Copy link
Author

hello @JiriCtvrtka @idoqo conflict on this has been resolved, alongside failing workflows, except for a linkspector check, unrelated to my changes here

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants