mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Allow parallel zstd compression when taking a base backup.
libzstd allows transparent parallel compression just by setting an option when creating the compression context, so permit that for both client and server-side backup compression. To use this, use something like pg_basebackup --compress WHERE-zstd:workers=N where WHERE is "client" or "server" and N is an integer. When compression is performed on the server side, this will spawn threads inside the PostgreSQL backend. While there is almost no PostgreSQL server code which is thread-safe, the threads here are used internally by libzstd and touch only data structures controlled by libzstd. Patch by me, based in part on earlier work by Dipesh Pandit and Jeevan Ladhe. Reviewed by Justin Pryzby. Discussion: http://postgr.es/m/CA+Tgmobj6u-nWF-j=FemygUhobhryLxf9h-wJN7W-2rSsseHNA@mail.gmail.com
This commit is contained in:
@ -177,6 +177,11 @@ parse_bc_specification(bc_algorithm algorithm, char *specification,
|
||||
result->level = expect_integer_value(keyword, value, result);
|
||||
result->options |= BACKUP_COMPRESSION_OPTION_LEVEL;
|
||||
}
|
||||
else if (strcmp(keyword, "workers") == 0)
|
||||
{
|
||||
result->workers = expect_integer_value(keyword, value, result);
|
||||
result->options |= BACKUP_COMPRESSION_OPTION_WORKERS;
|
||||
}
|
||||
else
|
||||
result->parse_error =
|
||||
psprintf(_("unknown compression option \"%s\""), keyword);
|
||||
@ -266,5 +271,16 @@ validate_bc_specification(bc_specification *spec)
|
||||
min_level, max_level);
|
||||
}
|
||||
|
||||
/*
|
||||
* Of the compression algorithms that we currently support, only zstd
|
||||
* allows parallel workers.
|
||||
*/
|
||||
if ((spec->options & BACKUP_COMPRESSION_OPTION_WORKERS) != 0 &&
|
||||
(spec->algorithm != BACKUP_COMPRESSION_ZSTD))
|
||||
{
|
||||
return psprintf(_("compression algorithm \"%s\" does not accept a worker count"),
|
||||
get_bc_algorithm_name(spec->algorithm));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user