public inbox for [email protected]help / color / mirror / Atom feed
[PATCH 04/12] wal_compression_method: default to zlib.. 112+ messages / 7 participants [nested] [flat]
* [PATCH 04/12] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8db3727502..3ece007922 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 47d30d6cda..15649bd2a7 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1288,7 +1288,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4767,7 +4767,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --45Z9DzgjV8m4Oswq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/12] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8db3727502..3ece007922 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 47d30d6cda..15649bd2a7 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1288,7 +1288,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4767,7 +4767,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --45Z9DzgjV8m4Oswq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH v9 4/9] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index f7909aa1d7..3254c42243 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -98,7 +98,7 @@ char *XLogArchiveCommand = NULL; bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; -int wal_compression = WAL_COMPRESSION_NONE; +int wal_compression = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index ce1149bed5..14a2203225 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4822,7 +4822,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression, - WAL_COMPRESSION_NONE, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --neYutvxvOLaeuPCA Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH v7 4/9] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 18dd4ff1eb..a43e04fc0b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 99932582ba..a448267ee9 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1311,7 +1311,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4832,7 +4832,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --JYK4vJDZwFMowpUq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v7-0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH v8 4/9] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 18d8743715..bbac9ac882 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -98,7 +98,7 @@ char *XLogArchiveCommand = NULL; bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; -int wal_compression = WAL_COMPRESSION_NONE; +int wal_compression = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8860deda2a..f1d73c8b61 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4822,7 +4822,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression, - WAL_COMPRESSION_NONE, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --P+33d92oIH25kiaB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6eb46ea8a7..f5d4450654 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --jozmn01XJZjDjM3N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 4/8] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --f0KYrhQ4vYSV2aJu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* [PATCH 04/10] wal_compression_method: default to zlib.. @ 2021-03-11 23:36 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Justin Pryzby @ 2021-03-11 23:36 UTC (permalink / raw) this is meant to exercise the CIs, and not meant to be merged --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/misc/guc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0183589b4d..8bae73b4ec 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_PGLZ; +int wal_compression_method = WAL_COMPRESSION_ZLIB; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8084027465..c37a8313d3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1269,7 +1269,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &wal_compression, - false, + true, NULL, NULL, NULL }, @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_PGLZ, wal_compression_options, + WAL_COMPRESSION_ZLIB, wal_compression_options, NULL, NULL, NULL }, -- 2.17.0 --0qVF/w3MHQqLSynd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-re-add-wal_compression_method-lz4.patch" ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Support run-time partition pruning for hash join @ 2024-01-27 03:29 vignesh C <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: vignesh C @ 2024-01-27 03:29 UTC (permalink / raw) To: Richard Guo <[email protected]>; +Cc: Alexander Lakhin <[email protected]>; David Rowley <[email protected]>; Andy Fan <[email protected]>; pgsql-hackers On Tue, 7 Nov 2023 at 13:25, Richard Guo <[email protected]> wrote: > > > On Mon, Nov 6, 2023 at 11:00 PM Alexander Lakhin <[email protected]> wrote: >> >> Please look at a warning and an assertion failure triggered by the >> following script: >> set parallel_setup_cost = 0; >> set parallel_tuple_cost = 0; >> set min_parallel_table_scan_size = '1kB'; >> >> create table t1 (i int) partition by range (i); >> create table t1_1 partition of t1 for values from (1) to (2); >> create table t1_2 partition of t1 for values from (2) to (3); >> insert into t1 values (1), (2); >> >> create table t2(i int); >> insert into t2 values (1), (2); >> analyze t1, t2; >> >> select * from t1 right join t2 on t1.i = t2.i; >> >> 2023-11-06 14:11:37.398 UTC|law|regression|6548f419.392cf5|WARNING: Join partition pruning $0 has not been performed yet. >> TRAP: failed Assert("node->as_prune_state"), File: "nodeAppend.c", Line: 846, PID: 3747061 > > > Thanks for the report! I failed to take care of the parallel-hashjoin > case, and I have to admit that it's not clear to me yet how we should do > join partition pruning in that case. > > For now I think it's better to just avoid performing join partition > pruning for parallel hashjoin, so that the patch doesn't become too > complex for review. We can always extend it in the future. > > I have done that in v5. Thanks for testing! CFBot shows that the patch does not apply anymore as in [1]: === Applying patches on top of PostgreSQL commit ID 924d046dcf55887c98a1628675a30f4b0eebe556 === === applying patch ./v5-0001-Support-run-time-partition-pruning-for-hash-join.patch ... patching file src/include/nodes/plannodes.h ... patching file src/include/optimizer/cost.h Hunk #1 FAILED at 211. 1 out of 1 hunk FAILED -- saving rejects to file src/include/optimizer/cost.h.rej Please post an updated version for the same. [1] - http://cfbot.cputube.org/patch_46_4512.log Regards, Vignesh ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Support run-time partition pruning for hash join @ 2024-01-30 02:33 Richard Guo <[email protected]> parent: vignesh C <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Richard Guo @ 2024-01-30 02:33 UTC (permalink / raw) To: vignesh C <[email protected]>; +Cc: Alexander Lakhin <[email protected]>; David Rowley <[email protected]>; Andy Fan <[email protected]>; pgsql-hackers On Sat, Jan 27, 2024 at 11:29 AM vignesh C <[email protected]> wrote: > CFBot shows that the patch does not apply anymore as in [1]: > > Please post an updated version for the same. Attached is an updated patch. Nothing else has changed. Thanks Richard Attachments: [application/octet-stream] v6-0001-Support-run-time-partition-pruning-for-hash-join.patch (59.3K, ../../CAMbWs49Pg9TvDrWBHzBDNPe7XP1jTpHukG-nwpNEo-mmr9h4zA@mail.gmail.com/3-v6-0001-Support-run-time-partition-pruning-for-hash-join.patch) download | inline diff: From 05d18d47135ba086fe416c02abdaa44b69612c03 Mon Sep 17 00:00:00 2001 From: Richard Guo <[email protected]> Date: Mon, 14 Aug 2023 14:55:26 +0800 Subject: [PATCH v6] Support run-time partition pruning for hash join If we have a hash join with an Append node on the outer side, something like Hash Join Hash Cond: (pt.a = t.a) -> Append -> Seq Scan on pt_p1 pt_1 -> Seq Scan on pt_p2 pt_2 -> Seq Scan on pt_p3 pt_3 -> Hash -> Seq Scan on t We can actually prune those subnodes of the Append that cannot possibly contain any matching tuples from the other side of the join. To do that, when building the Hash table, for each row from the inner side we can compute the minimum set of subnodes that can possibly match the join condition. When we have built the Hash table and start to execute the Append node, we should have known which subnodes are survived and thus can skip other subnodes. This patch implements this idea. --- src/backend/commands/explain.c | 61 ++++ src/backend/executor/execPartition.c | 127 +++++++- src/backend/executor/nodeAppend.c | 32 +- src/backend/executor/nodeHash.c | 75 +++++ src/backend/executor/nodeHashjoin.c | 10 + src/backend/executor/nodeMergeAppend.c | 22 +- src/backend/optimizer/path/costsize.c | 106 +++++++ src/backend/optimizer/plan/createplan.c | 49 ++- src/backend/optimizer/plan/setrefs.c | 61 ++++ src/backend/partitioning/partprune.c | 298 ++++++++++++++++-- src/include/executor/execPartition.h | 17 +- src/include/nodes/execnodes.h | 3 + src/include/nodes/pathnodes.h | 3 + src/include/nodes/plannodes.h | 36 +++ src/include/optimizer/cost.h | 4 + src/include/partitioning/partprune.h | 12 +- src/test/regress/expected/partition_prune.out | 86 +++++ src/test/regress/sql/partition_prune.sql | 39 +++ 18 files changed, 992 insertions(+), 49 deletions(-) diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 83d00a4663..04450b9c37 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -18,6 +18,7 @@ #include "commands/createas.h" #include "commands/defrem.h" #include "commands/prepare.h" +#include "executor/execPartition.h" #include "executor/nodeHash.h" #include "foreign/fdwapi.h" #include "jit/jit.h" @@ -118,6 +119,9 @@ static void show_instrumentation_count(const char *qlabel, int which, PlanState *planstate, ExplainState *es); static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es); static void show_eval_params(Bitmapset *bms_params, ExplainState *es); +static void show_join_pruning_result_info(Bitmapset *join_prune_paramids, + ExplainState *es); +static void show_joinpartprune_info(HashState *hashstate, ExplainState *es); static const char *explain_get_index_name(Oid indexId); static bool peek_buffer_usage(ExplainState *es, const BufferUsage *usage); static void show_buffer_usage(ExplainState *es, const BufferUsage *usage); @@ -2104,9 +2108,17 @@ ExplainNode(PlanState *planstate, List *ancestors, show_incremental_sort_info(castNode(IncrementalSortState, planstate), es); break; + case T_Append: + if (es->verbose) + show_join_pruning_result_info(((Append *) plan)->join_prune_paramids, + es); + break; case T_MergeAppend: show_merge_append_keys(castNode(MergeAppendState, planstate), ancestors, es); + if (es->verbose) + show_join_pruning_result_info(((MergeAppend *) plan)->join_prune_paramids, + es); break; case T_Result: show_upper_qual((List *) ((Result *) plan)->resconstantqual, @@ -2122,6 +2134,8 @@ ExplainNode(PlanState *planstate, List *ancestors, break; case T_Hash: show_hash_info(castNode(HashState, planstate), es); + if (es->verbose) + show_joinpartprune_info(castNode(HashState, planstate), es); break; case T_Memoize: show_memoize_info(castNode(MemoizeState, planstate), ancestors, @@ -3562,6 +3576,53 @@ show_eval_params(Bitmapset *bms_params, ExplainState *es) ExplainPropertyList("Params Evaluated", params, es); } +/* + * Show join partition pruning results at Append/MergeAppend nodes. + */ +static void +show_join_pruning_result_info(Bitmapset *join_prune_paramids, ExplainState *es) +{ + int paramid = -1; + List *params = NIL; + + if (bms_is_empty(join_prune_paramids)) + return; + + while ((paramid = bms_next_member(join_prune_paramids, paramid)) >= 0) + { + char param[32]; + + snprintf(param, sizeof(param), "$%d", paramid); + params = lappend(params, pstrdup(param)); + } + + ExplainPropertyList("Join Partition Pruning", params, es); +} + +/* + * Show join partition pruning infos at Hash nodes. + */ +static void +show_joinpartprune_info(HashState *hashstate, ExplainState *es) +{ + List *params = NIL; + ListCell *lc; + + if (!hashstate->joinpartprune_state_list) + return; + + foreach(lc, hashstate->joinpartprune_state_list) + { + JoinPartitionPruneState *jpstate = (JoinPartitionPruneState *) lfirst(lc); + char param[32]; + + snprintf(param, sizeof(param), "$%d", jpstate->paramid); + params = lappend(params, pstrdup(param)); + } + + ExplainPropertyList("Partition Prune", params, es); +} + /* * Fetch the name of an index in an EXPLAIN * diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index b22040ae8e..95c791633c 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -199,6 +199,8 @@ static void find_matching_subplans_recurse(PartitionPruningData *prunedata, PartitionedRelPruningData *pprune, bool initial_prune, Bitmapset **validsubplans); +static bool get_join_prune_matching_subplans(PlanState *planstate, + Bitmapset **partset); /* @@ -1806,7 +1808,7 @@ ExecInitPartitionPruning(PlanState *planstate, * Perform an initial partition prune pass, if required. */ if (prunestate->do_initial_prune) - *initially_valid_subplans = ExecFindMatchingSubPlans(prunestate, true); + *initially_valid_subplans = ExecFindMatchingSubPlans(prunestate, true, NULL); else { /* No pruning, so we'll need to initialize all subplans */ @@ -1836,6 +1838,37 @@ ExecInitPartitionPruning(PlanState *planstate, return prunestate; } +/* + * ExecInitJoinpartpruneList + * Initialize data structures needed for join partition pruning + */ +List * +ExecInitJoinpartpruneList(PlanState *planstate, + List *joinpartprune_info_list) +{ + ListCell *lc; + List *result = NIL; + + foreach(lc, joinpartprune_info_list) + { + JoinPartitionPruneInfo *jpinfo = (JoinPartitionPruneInfo *) lfirst(lc); + JoinPartitionPruneState *jpstate = palloc(sizeof(JoinPartitionPruneState)); + + jpstate->part_prune_state = + CreatePartitionPruneState(planstate, jpinfo->part_prune_info); + Assert(jpstate->part_prune_state->do_exec_prune); + + jpstate->paramid = jpinfo->paramid; + jpstate->nplans = jpinfo->nplans; + jpstate->finished = false; + jpstate->part_prune_result = NULL; + + result = lappend(result, jpstate); + } + + return result; +} + /* * CreatePartitionPruneState * Build the data structure required for calling ExecFindMatchingSubPlans @@ -2273,7 +2306,9 @@ PartitionPruneFixSubPlanMap(PartitionPruneState *prunestate, /* * ExecFindMatchingSubPlans * Determine which subplans match the pruning steps detailed in - * 'prunestate' for the current comparison expression values. + * 'prunestate' if any for the current comparison expression values, and + * meanwhile match the join partition pruning results if any stored in + * Append/MergeAppend node's join_prune_paramids. * * Pass initial_prune if PARAM_EXEC Params cannot yet be evaluated. This * differentiates the initial executor-time pruning step from later @@ -2281,11 +2316,30 @@ PartitionPruneFixSubPlanMap(PartitionPruneState *prunestate, */ Bitmapset * ExecFindMatchingSubPlans(PartitionPruneState *prunestate, - bool initial_prune) + bool initial_prune, + PlanState *planstate) { Bitmapset *result = NULL; MemoryContext oldcontext; int i; + Bitmapset *join_prune_partset = NULL; + bool do_join_prune; + + /* Retrieve the join partition pruning results if any */ + do_join_prune = + get_join_prune_matching_subplans(planstate, &join_prune_partset); + + /* + * Either we're here on partition prune done according to the pruning steps + * detailed in 'prunestate', or we have done join partition prune. + */ + Assert(do_join_prune || prunestate != NULL); + + /* + * If there is no 'prunestate', then rely entirely on join pruning. + */ + if (prunestate == NULL) + return join_prune_partset; /* * Either we're here on the initial prune done during pruning @@ -2326,6 +2380,10 @@ ExecFindMatchingSubPlans(PartitionPruneState *prunestate, /* Add in any subplans that partition pruning didn't account for */ result = bms_add_members(result, prunestate->other_subplans); + /* Intersect join partition pruning results */ + if (do_join_prune) + result = bms_intersect(result, join_prune_partset); + MemoryContextSwitchTo(oldcontext); /* Copy result out of the temp context before we reset it */ @@ -2396,3 +2454,66 @@ find_matching_subplans_recurse(PartitionPruningData *prunedata, } } } + +/* + * get_join_prune_matching_subplans + * Retrieve the join partition pruning results if any stored in + * Append/MergeAppend node's join_prune_paramids. Return true if we can + * do join partition pruning, otherwise return false. + * + * Adds valid (non-prunable) subplan IDs to *partset + */ +static bool +get_join_prune_matching_subplans(PlanState *planstate, Bitmapset **partset) +{ + Bitmapset *join_prune_paramids; + int nplans; + int paramid; + + if (planstate == NULL) + return false; + + if (IsA(planstate, AppendState)) + { + join_prune_paramids = + ((Append *) planstate->plan)->join_prune_paramids; + nplans = ((AppendState *) planstate)->as_nplans; + } + else if (IsA(planstate, MergeAppendState)) + { + join_prune_paramids = + ((MergeAppend *) planstate->plan)->join_prune_paramids; + nplans = ((MergeAppendState *) planstate)->ms_nplans; + } + else + { + elog(ERROR, "unrecognized node type: %d", (int) nodeTag(planstate)); + return false; + } + + if (bms_is_empty(join_prune_paramids)) + return false; + + Assert(nplans > 0); + *partset = bms_add_range(NULL, 0, nplans - 1); + + paramid = -1; + while ((paramid = bms_next_member(join_prune_paramids, paramid)) >= 0) + { + ParamExecData *param; + JoinPartitionPruneState *jpstate; + + param = &(planstate->state->es_param_exec_vals[paramid]); + Assert(param->execPlan == NULL); + Assert(!param->isnull); + jpstate = (JoinPartitionPruneState *) DatumGetPointer(param->value); + + if (jpstate != NULL) + *partset = bms_intersect(*partset, jpstate->part_prune_result); + else /* the Hash node for this pruning has not been executed */ + elog(WARNING, "Join partition pruning $%d has not been performed yet.", + paramid); + } + + return true; +} diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index c7059e7528..b68a1e2eb2 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -151,11 +151,13 @@ ExecInitAppend(Append *node, EState *estate, int eflags) nplans = bms_num_members(validsubplans); /* - * When no run-time pruning is required and there's at least one - * subplan, we can fill as_valid_subplans immediately, preventing - * later calls to ExecFindMatchingSubPlans. + * When no run-time pruning or join pruning is required and there's at + * least one subplan, we can fill as_valid_subplans immediately, + * preventing later calls to ExecFindMatchingSubPlans. */ - if (!prunestate->do_exec_prune && nplans > 0) + if (!prunestate->do_exec_prune && + bms_is_empty(node->join_prune_paramids) && + nplans > 0) { appendstate->as_valid_subplans = bms_add_range(NULL, 0, nplans - 1); appendstate->as_valid_subplans_identified = true; @@ -170,10 +172,18 @@ ExecInitAppend(Append *node, EState *estate, int eflags) * subplans as valid; they must also all be initialized. */ Assert(nplans > 0); - appendstate->as_valid_subplans = validsubplans = - bms_add_range(NULL, 0, nplans - 1); - appendstate->as_valid_subplans_identified = true; + validsubplans = bms_add_range(NULL, 0, nplans - 1); appendstate->as_prune_state = NULL; + + /* + * When join pruning is not enabled we can fill as_valid_subplans + * immediately, preventing later calls to ExecFindMatchingSubPlans. + */ + if (bms_is_empty(node->join_prune_paramids)) + { + appendstate->as_valid_subplans = validsubplans; + appendstate->as_valid_subplans_identified = true; + } } /* @@ -580,7 +590,7 @@ choose_next_subplan_locally(AppendState *node) else if (!node->as_valid_subplans_identified) { node->as_valid_subplans = - ExecFindMatchingSubPlans(node->as_prune_state, false); + ExecFindMatchingSubPlans(node->as_prune_state, false, &node->ps); node->as_valid_subplans_identified = true; } @@ -647,7 +657,7 @@ choose_next_subplan_for_leader(AppendState *node) if (!node->as_valid_subplans_identified) { node->as_valid_subplans = - ExecFindMatchingSubPlans(node->as_prune_state, false); + ExecFindMatchingSubPlans(node->as_prune_state, false, &node->ps); node->as_valid_subplans_identified = true; /* @@ -723,7 +733,7 @@ choose_next_subplan_for_worker(AppendState *node) else if (!node->as_valid_subplans_identified) { node->as_valid_subplans = - ExecFindMatchingSubPlans(node->as_prune_state, false); + ExecFindMatchingSubPlans(node->as_prune_state, false, &node->ps); node->as_valid_subplans_identified = true; mark_invalid_subplans_as_finished(node); @@ -876,7 +886,7 @@ ExecAppendAsyncBegin(AppendState *node) if (!node->as_valid_subplans_identified) { node->as_valid_subplans = - ExecFindMatchingSubPlans(node->as_prune_state, false); + ExecFindMatchingSubPlans(node->as_prune_state, false, &node->ps); node->as_valid_subplans_identified = true; classify_matching_subplans(node); diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index f90e16ede8..00138a61a2 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -31,6 +31,7 @@ #include "catalog/pg_statistic.h" #include "commands/tablespace.h" #include "executor/execdebug.h" +#include "executor/execPartition.h" #include "executor/hashjoin.h" #include "executor/nodeHash.h" #include "executor/nodeHashjoin.h" @@ -48,6 +49,8 @@ static void ExecHashIncreaseNumBatches(HashJoinTable hashtable); static void ExecHashIncreaseNumBuckets(HashJoinTable hashtable); static void ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable); static void ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable); +static void ExecJoinPartitionPrune(HashState *node); +static void ExecStoreJoinPartitionPruneResult(HashState *node); static void ExecHashBuildSkewHash(HashJoinTable hashtable, Hash *node, int mcvsToUse); static void ExecHashSkewTableInsert(HashJoinTable hashtable, @@ -189,8 +192,14 @@ MultiExecPrivateHash(HashState *node) } hashtable->totalTuples += 1; } + + /* Perform join partition pruning */ + ExecJoinPartitionPrune(node); } + /* Store the surviving partitions for Append/MergeAppend nodes */ + ExecStoreJoinPartitionPruneResult(node); + /* resize the hash table if needed (NTUP_PER_BUCKET exceeded) */ if (hashtable->nbuckets != hashtable->nbuckets_optimal) ExecHashIncreaseNumBuckets(hashtable); @@ -401,6 +410,12 @@ ExecInitHash(Hash *node, EState *estate, int eflags) hashstate->hashkeys = ExecInitExprList(node->hashkeys, (PlanState *) hashstate); + /* + * initialize join partition pruning infos + */ + hashstate->joinpartprune_state_list = + ExecInitJoinpartpruneList(&hashstate->ps, node->joinpartprune_info_list); + return hashstate; } @@ -1610,6 +1625,56 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable) } } +/* + * ExecJoinPartitionPrune + * Perform join partition pruning at this join for each + * JoinPartitionPruneState. + */ +static void +ExecJoinPartitionPrune(HashState *node) +{ + ListCell *lc; + + foreach(lc, node->joinpartprune_state_list) + { + JoinPartitionPruneState *jpstate = (JoinPartitionPruneState *) lfirst(lc); + Bitmapset *matching_subPlans; + + if (jpstate->finished) + continue; + + matching_subPlans = + ExecFindMatchingSubPlans(jpstate->part_prune_state, false, NULL); + jpstate->part_prune_result = + bms_add_members(jpstate->part_prune_result, matching_subPlans); + + if (bms_num_members(jpstate->part_prune_result) == jpstate->nplans) + jpstate->finished = true; + } +} + +/* + * ExecStoreJoinPartitionPruneResult + * For each JoinPartitionPruneState, store the set of surviving partitions + * to make it available for the Append/MergeAppend node. + */ +static void +ExecStoreJoinPartitionPruneResult(HashState *node) +{ + ListCell *lc; + + foreach(lc, node->joinpartprune_state_list) + { + JoinPartitionPruneState *jpstate = (JoinPartitionPruneState *) lfirst(lc); + ParamExecData *param; + + param = &(node->ps.state->es_param_exec_vals[jpstate->paramid]); + Assert(param->execPlan == NULL); + Assert(!param->isnull); + param->value = PointerGetDatum(jpstate); + } +} + /* * ExecHashTableInsert * insert a tuple into the hash table depending on the hash value @@ -2354,6 +2419,16 @@ void ExecReScanHash(HashState *node) { PlanState *outerPlan = outerPlanState(node); + ListCell *lc; + + /* reset the state in JoinPartitionPruneStates */ + foreach(lc, node->joinpartprune_state_list) + { + JoinPartitionPruneState *jpstate = (JoinPartitionPruneState *) lfirst(lc); + + jpstate->finished = false; + jpstate->part_prune_result = NULL; + } /* * if chgParam of subnode is not null then plan will be re-scanned by diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 1cbec4647c..4f84799929 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -311,6 +311,16 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel) */ node->hj_FirstOuterTupleSlot = NULL; } + else if (hashNode->joinpartprune_state_list != NIL) + { + /* + * Give the hash node a chance to run join partition + * pruning if there is any JoinPartitionPruneState that can + * be evaluated at it. So do not apply the empty-outer + * optimization in this case. + */ + node->hj_FirstOuterTupleSlot = NULL; + } else if (HJ_FILL_OUTER(node) || (outerNode->plan->startup_cost < hashNode->ps.plan->total_cost && !node->hj_OuterNotEmpty)) diff --git a/src/backend/executor/nodeMergeAppend.c b/src/backend/executor/nodeMergeAppend.c index 0817868452..ec0ac29654 100644 --- a/src/backend/executor/nodeMergeAppend.c +++ b/src/backend/executor/nodeMergeAppend.c @@ -99,11 +99,13 @@ ExecInitMergeAppend(MergeAppend *node, EState *estate, int eflags) nplans = bms_num_members(validsubplans); /* - * When no run-time pruning is required and there's at least one - * subplan, we can fill ms_valid_subplans immediately, preventing - * later calls to ExecFindMatchingSubPlans. + * When no run-time pruning or join pruning is required and there's at + * least one subplan, we can fill ms_valid_subplans immediately, + * preventing later calls to ExecFindMatchingSubPlans. */ - if (!prunestate->do_exec_prune && nplans > 0) + if (!prunestate->do_exec_prune && + bms_is_empty(node->join_prune_paramids) && + nplans > 0) mergestate->ms_valid_subplans = bms_add_range(NULL, 0, nplans - 1); } else @@ -115,9 +117,15 @@ ExecInitMergeAppend(MergeAppend *node, EState *estate, int eflags) * subplans as valid; they must also all be initialized. */ Assert(nplans > 0); - mergestate->ms_valid_subplans = validsubplans = - bms_add_range(NULL, 0, nplans - 1); + validsubplans = bms_add_range(NULL, 0, nplans - 1); mergestate->ms_prune_state = NULL; + + /* + * When join pruning is not enabled we can fill ms_valid_subplans + * immediately, preventing later calls to ExecFindMatchingSubPlans. + */ + if (bms_is_empty(node->join_prune_paramids)) + mergestate->ms_valid_subplans = validsubplans; } mergeplanstates = (PlanState **) palloc(nplans * sizeof(PlanState *)); @@ -218,7 +226,7 @@ ExecMergeAppend(PlanState *pstate) */ if (node->ms_valid_subplans == NULL) node->ms_valid_subplans = - ExecFindMatchingSubPlans(node->ms_prune_state, false); + ExecFindMatchingSubPlans(node->ms_prune_state, false, &node->ps); /* * First time through: pull the first tuple from each valid subplan, diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 8b76e98529..ea3d5e57c1 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -173,6 +173,10 @@ static void get_restriction_qual_cost(PlannerInfo *root, RelOptInfo *baserel, static bool has_indexed_join_quals(NestPath *path); static double approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals); +static double get_joinrel_matching_outer_size(PlannerInfo *root, + RelOptInfo *outer_rel, + Relids inner_relids, + List *restrictlist); static double calc_joinrel_size_estimate(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, @@ -5409,6 +5413,61 @@ get_parameterized_joinrel_size(PlannerInfo *root, RelOptInfo *rel, return nrows; } +/* + * get_joinrel_matching_outer_size + * Make a size estimate for the outer side that matches the inner side. + */ +static double +get_joinrel_matching_outer_size(PlannerInfo *root, + RelOptInfo *outer_rel, + Relids inner_relids, + List *restrictlist) +{ + double nrows; + Selectivity fkselec; + Selectivity jselec; + SpecialJoinInfo *sjinfo; + SpecialJoinInfo sjinfo_data; + + sjinfo = &sjinfo_data; + sjinfo->type = T_SpecialJoinInfo; + sjinfo->min_lefthand = outer_rel->relids; + sjinfo->min_righthand = inner_relids; + sjinfo->syn_lefthand = outer_rel->relids; + sjinfo->syn_righthand = inner_relids; + sjinfo->jointype = JOIN_SEMI; + sjinfo->ojrelid = 0; + sjinfo->commute_above_l = NULL; + sjinfo->commute_above_r = NULL; + sjinfo->commute_below_l = NULL; + sjinfo->commute_below_r = NULL; + /* we don't bother trying to make the remaining fields valid */ + sjinfo->lhs_strict = false; + sjinfo->semi_can_btree = false; + sjinfo->semi_can_hash = false; + sjinfo->semi_operators = NIL; + sjinfo->semi_rhs_exprs = NIL; + + fkselec = get_foreign_key_join_selectivity(root, + outer_rel->relids, + inner_relids, + sjinfo, + &restrictlist); + jselec = clauselist_selectivity(root, + restrictlist, + 0, + sjinfo->jointype, + sjinfo); + + nrows = outer_rel->rows * fkselec * jselec; + nrows = clamp_row_est(nrows); + + /* For safety, make sure result is not more than the base estimate */ + if (nrows > outer_rel->rows) + nrows = outer_rel->rows; + return nrows; +} + /* * calc_joinrel_size_estimate * Workhorse for set_joinrel_size_estimates and @@ -6530,3 +6589,50 @@ compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, return pages_fetched; } + +/* + * compute_partprune_cost + * Compute the overhead of join partition pruning. + */ +double +compute_partprune_cost(PlannerInfo *root, RelOptInfo *appendrel, + Cost append_total_cost, int append_nplans, + Relids inner_relids, double inner_rows, + List *prunequal) +{ + Cost prune_cost; + Cost saved_cost; + double matching_outer_rows; + double unmatched_nplans; + + switch (appendrel->part_scheme->strategy) + { + + case PARTITION_STRATEGY_LIST: + case PARTITION_STRATEGY_RANGE: + prune_cost = cpu_operator_cost * LOG2(append_nplans) * inner_rows; + break; + case PARTITION_STRATEGY_HASH: + prune_cost = cpu_operator_cost * append_nplans * inner_rows; + break; + default: + elog(ERROR, "unexpected partition strategy: %d", + (int) appendrel->part_scheme->strategy); + break; + } + + matching_outer_rows = + get_joinrel_matching_outer_size(root, + appendrel, + inner_relids, + prunequal); + + /* + * We assume that each outer joined row occupies one new partition. This + * is really the worst case. + */ + unmatched_nplans = append_nplans - Min(matching_outer_rows, append_nplans); + saved_cost = (unmatched_nplans / append_nplans) * append_total_cost; + + return prune_cost - saved_cost; +} diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 610f4a56d6..55cd3bb616 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -242,7 +242,8 @@ static Hash *make_hash(Plan *lefttree, List *hashkeys, Oid skewTable, AttrNumber skewColumn, - bool skewInherit); + bool skewInherit, + List *joinpartprune_info_list); static MergeJoin *make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, @@ -342,6 +343,7 @@ create_plan(PlannerInfo *root, Path *best_path) /* Initialize this module's workspace in PlannerInfo */ root->curOuterRels = NULL; root->curOuterParams = NIL; + root->join_partition_prune_candidates = NIL; /* Recursively process the path tree, demanding the correct tlist result */ plan = create_plan_recurse(root, best_path, CP_EXACT_TLIST); @@ -369,6 +371,8 @@ create_plan(PlannerInfo *root, Path *best_path) if (root->curOuterParams != NIL) elog(ERROR, "failed to assign all NestLoopParams to plan nodes"); + Assert(root->join_partition_prune_candidates == NIL); + /* * Reset plan_params to ensure param IDs used for nestloop params are not * re-used later @@ -1223,6 +1227,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) int nasyncplans = 0; RelOptInfo *rel = best_path->path.parent; PartitionPruneInfo *partpruneinfo = NULL; + Bitmapset *join_prune_paramids = NULL; int nodenumsortkeys = 0; AttrNumber *nodeSortColIdx = NULL; Oid *nodeSortOperators = NULL; @@ -1377,6 +1382,8 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) * If any quals exist, they may be useful to perform further partition * pruning during execution. Gather information needed by the executor to * do partition pruning. + * + * Also gather information needed by the executor to do join pruning. */ if (enable_partition_pruning) { @@ -1399,13 +1406,20 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) partpruneinfo = make_partition_pruneinfo(root, rel, best_path->subpaths, - prunequal); + prunequal, + NULL); + + join_prune_paramids = + make_join_partition_pruneinfos(root, rel, + (Path *) best_path, + best_path->subpaths); } plan->appendplans = subplans; plan->nasyncplans = nasyncplans; plan->first_partial_plan = best_path->first_partial_path; plan->part_prune_info = partpruneinfo; + plan->join_prune_paramids = join_prune_paramids; copy_generic_path_info(&plan->plan, (Path *) best_path); @@ -1445,6 +1459,7 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, ListCell *subpaths; RelOptInfo *rel = best_path->path.parent; PartitionPruneInfo *partpruneinfo = NULL; + Bitmapset *join_prune_paramids = NULL; /* * We don't have the actual creation of the MergeAppend node split out @@ -1541,6 +1556,8 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, * If any quals exist, they may be useful to perform further partition * pruning during execution. Gather information needed by the executor to * do partition pruning. + * + * Also gather information needed by the executor to do join pruning. */ if (enable_partition_pruning) { @@ -1554,11 +1571,18 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, if (prunequal != NIL) partpruneinfo = make_partition_pruneinfo(root, rel, best_path->subpaths, - prunequal); + prunequal, + NULL); + + join_prune_paramids = + make_join_partition_pruneinfos(root, rel, + (Path *) best_path, + best_path->subpaths); } node->mergeplans = subplans; node->part_prune_info = partpruneinfo; + node->join_prune_paramids = join_prune_paramids; /* * If prepare_sort_from_pathkeys added sort columns, but we were told to @@ -4743,6 +4767,13 @@ create_hashjoin_plan(PlannerInfo *root, AttrNumber skewColumn = InvalidAttrNumber; bool skewInherit = false; ListCell *lc; + List *joinpartprune_info_list; + + /* + * Collect information required to build JoinPartitionPruneInfos at this + * join. + */ + prepare_join_partition_prune_candidate(root, &best_path->jpath); /* * HashJoin can project, so we don't have to demand exact tlists from the @@ -4754,6 +4785,11 @@ create_hashjoin_plan(PlannerInfo *root, outer_plan = create_plan_recurse(root, best_path->jpath.outerjoinpath, (best_path->num_batches > 1) ? CP_SMALL_TLIST : 0); + /* + * Retrieve all the JoinPartitionPruneInfos for this join. + */ + joinpartprune_info_list = get_join_partition_prune_candidate(root); + inner_plan = create_plan_recurse(root, best_path->jpath.innerjoinpath, CP_SMALL_TLIST); @@ -4859,7 +4895,8 @@ create_hashjoin_plan(PlannerInfo *root, inner_hashkeys, skewTable, skewColumn, - skewInherit); + skewInherit, + joinpartprune_info_list); /* * Set Hash node's startup & total costs equal to total cost of input @@ -5986,7 +6023,8 @@ make_hash(Plan *lefttree, List *hashkeys, Oid skewTable, AttrNumber skewColumn, - bool skewInherit) + bool skewInherit, + List *joinpartprune_info_list) { Hash *node = makeNode(Hash); Plan *plan = &node->plan; @@ -6000,6 +6038,7 @@ make_hash(Plan *lefttree, node->skewTable = skewTable; node->skewColumn = skewColumn; node->skewInherit = skewInherit; + node->joinpartprune_info_list = joinpartprune_info_list; return node; } diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 22a1fa29f3..c83d3bc0ad 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -156,6 +156,11 @@ static Plan *set_mergeappend_references(PlannerInfo *root, MergeAppend *mplan, int rtoffset); static void set_hash_references(PlannerInfo *root, Plan *plan, int rtoffset); +static void set_joinpartitionprune_references(PlannerInfo *root, + List *joinpartprune_info_list, + indexed_tlist *outer_itlist, + int rtoffset, + double num_exec); static Relids offset_relid_set(Relids relids, int rtoffset); static Node *fix_scan_expr(PlannerInfo *root, Node *node, int rtoffset, double num_exec); @@ -1897,6 +1902,62 @@ set_hash_references(PlannerInfo *root, Plan *plan, int rtoffset) /* Hash nodes don't have their own quals */ Assert(plan->qual == NIL); + + set_joinpartitionprune_references(root, + hplan->joinpartprune_info_list, + outer_itlist, + rtoffset, + NUM_EXEC_TLIST(plan)); +} + +/* + * set_joinpartitionprune_references + * Do set_plan_references processing on JoinPartitionPruneInfos + */ +static void +set_joinpartitionprune_references(PlannerInfo *root, + List *joinpartprune_info_list, + indexed_tlist *outer_itlist, + int rtoffset, + double num_exec) +{ + ListCell *l; + + foreach(l, joinpartprune_info_list) + { + JoinPartitionPruneInfo *jpinfo = (JoinPartitionPruneInfo *) lfirst(l); + ListCell *l1; + + foreach(l1, jpinfo->part_prune_info->prune_infos) + { + List *prune_infos = lfirst(l1); + ListCell *l2; + + foreach(l2, prune_infos) + { + PartitionedRelPruneInfo *pinfo = lfirst(l2); + + pinfo->rtindex += rtoffset; + + pinfo->initial_pruning_steps = (List *) + fix_upper_expr(root, + (Node *) pinfo->initial_pruning_steps, + outer_itlist, + OUTER_VAR, + rtoffset, + NRM_EQUAL, + num_exec); + pinfo->exec_pruning_steps = (List *) + fix_upper_expr(root, + (Node *) pinfo->exec_pruning_steps, + outer_itlist, + OUTER_VAR, + rtoffset, + NRM_EQUAL, + num_exec); + } + } + } } /* diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index 6b635e8ad1..17725aa972 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -48,7 +48,9 @@ #include "optimizer/appendinfo.h" #include "optimizer/cost.h" #include "optimizer/optimizer.h" +#include "optimizer/paramassign.h" #include "optimizer/pathnode.h" +#include "optimizer/restrictinfo.h" #include "parser/parsetree.h" #include "partitioning/partbounds.h" #include "partitioning/partprune.h" @@ -103,15 +105,16 @@ typedef enum PartClauseTarget * * gen_partprune_steps() initializes and returns an instance of this struct. * - * Note that has_mutable_op, has_mutable_arg, and has_exec_param are set if - * we found any potentially-useful-for-pruning clause having those properties, - * whether or not we actually used the clause in the steps list. This - * definition allows us to skip the PARTTARGET_EXEC pass in some cases. + * Note that has_mutable_op, has_mutable_arg, has_exec_param and has_vars are + * set if we found any potentially-useful-for-pruning clause having those + * properties, whether or not we actually used the clause in the steps list. + * This definition allows us to skip the PARTTARGET_EXEC pass in some cases. */ typedef struct GeneratePruningStepsContext { /* Copies of input arguments for gen_partprune_steps: */ RelOptInfo *rel; /* the partitioned relation */ + Bitmapset *available_rels; /* rels whose Vars may be used for pruning */ PartClauseTarget target; /* use-case we're generating steps for */ /* Result data: */ List *steps; /* list of PartitionPruneSteps */ @@ -119,6 +122,7 @@ typedef struct GeneratePruningStepsContext bool has_mutable_arg; /* clauses include any mutable comparison * values, *other than* exec params */ bool has_exec_param; /* clauses include any PARAM_EXEC params */ + bool has_vars; /* clauses include any Vars from 'available_rels' */ bool contradictory; /* clauses were proven self-contradictory */ /* Working state: */ int next_step_id; @@ -144,8 +148,10 @@ static List *make_partitionedrel_pruneinfo(PlannerInfo *root, List *prunequal, Bitmapset *partrelids, int *relid_subplan_map, + Bitmapset *available_rels, Bitmapset **matchedsubplans); static void gen_partprune_steps(RelOptInfo *rel, List *clauses, + Bitmapset *available_rels, PartClauseTarget target, GeneratePruningStepsContext *context); static List *gen_partprune_steps_internal(GeneratePruningStepsContext *context, @@ -204,6 +210,10 @@ static PartClauseMatchStatus match_boolean_partition_clause(Oid partopfamily, static void partkey_datum_from_expr(PartitionPruneContext *context, Expr *expr, int stateidx, Datum *value, bool *isnull); +static bool contain_forbidden_var_clause(Node *node, + GeneratePruningStepsContext *context); +static bool contain_forbidden_var_clause_walker(Node *node, + GeneratePruningStepsContext *context); /* @@ -216,11 +226,14 @@ static void partkey_datum_from_expr(PartitionPruneContext *context, * of scan paths for its child rels. * 'prunequal' is a list of potential pruning quals (i.e., restriction * clauses that are applicable to the appendrel). + * 'available_rels' is the relid set of rels whose Vars may be used for + * pruning. */ PartitionPruneInfo * make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *subpaths, - List *prunequal) + List *prunequal, + Bitmapset *available_rels) { PartitionPruneInfo *pruneinfo; Bitmapset *allmatchedsubplans = NULL; @@ -313,6 +326,7 @@ make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, prunequal, partrelids, relid_subplan_map, + available_rels, &matchedsubplans); /* When pruning is possible, record the matched subplans */ @@ -360,6 +374,184 @@ make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, return pruneinfo; } +/* + * make_join_partition_pruneinfos + * Builds one JoinPartitionPruneInfo for each join at which join partition + * pruning is possible for this appendrel. + * + * 'parentrel' is the RelOptInfo for an appendrel, and 'subpaths' is the list + * of scan paths for its child rels. + */ +Bitmapset * +make_join_partition_pruneinfos(PlannerInfo *root, RelOptInfo *parentrel, + Path *best_path, List *subpaths) +{ + Bitmapset *result = NULL; + ListCell *lc; + + if (!IS_PARTITIONED_REL(parentrel)) + return NULL; + + foreach(lc, root->join_partition_prune_candidates) + { + JoinPartitionPruneCandidateInfo *candidate = + (JoinPartitionPruneCandidateInfo *) lfirst(lc); + PartitionPruneInfo *part_prune_info; + List *prunequal; + Relids joinrelids; + ListCell *l; + double prune_cost; + + if (candidate == NULL) + continue; + + /* + * Identify all joinclauses that are movable to this appendrel given + * this inner side relids. Only those clauses can be used for join + * partition pruning. + */ + joinrelids = bms_union(parentrel->relids, candidate->inner_relids); + prunequal = NIL; + foreach(l, candidate->joinrestrictinfo) + { + RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); + + if (join_clause_is_movable_into(rinfo, + parentrel->relids, + joinrelids)) + prunequal = lappend(prunequal, rinfo); + } + + if (prunequal == NIL) + continue; + + /* + * Check the overhead of this pruning + */ + prune_cost = compute_partprune_cost(root, + parentrel, + best_path->total_cost, + list_length(subpaths), + candidate->inner_relids, + candidate->inner_rows, + prunequal); + if (prune_cost > 0) + continue; + + part_prune_info = make_partition_pruneinfo(root, parentrel, + subpaths, + prunequal, + candidate->inner_relids); + + if (part_prune_info) + { + JoinPartitionPruneInfo *jpinfo; + + jpinfo = makeNode(JoinPartitionPruneInfo); + + jpinfo->part_prune_info = part_prune_info; + jpinfo->paramid = assign_special_exec_param(root); + jpinfo->nplans = list_length(subpaths); + + candidate->joinpartprune_info_list = + lappend(candidate->joinpartprune_info_list, jpinfo); + + result = bms_add_member(result, jpinfo->paramid); + } + } + + return result; +} + +/* + * prepare_join_partition_prune_candidate + * Check if join partition pruning is possible at this join and if so + * collect information required to build JoinPartitionPruneInfos. + * + * Note that we may build more than one JoinPartitionPruneInfo at one join, for + * different Append/MergeAppend paths. + */ +void +prepare_join_partition_prune_candidate(PlannerInfo *root, JoinPath *jpath) +{ + JoinPartitionPruneCandidateInfo *candidate; + + if (!enable_partition_pruning) + { + root->join_partition_prune_candidates = + lappend(root->join_partition_prune_candidates, NULL); + return; + } + + /* + * For now do not perform join partition pruning for parallel hashjoin. + */ + if (jpath->path.parallel_workers > 0) + { + root->join_partition_prune_candidates = + lappend(root->join_partition_prune_candidates, NULL); + return; + } + + /* + * We cannot perform join partition pruning if the outer is the + * non-nullable side. + */ + if (!(jpath->jointype == JOIN_INNER || + jpath->jointype == JOIN_SEMI || + jpath->jointype == JOIN_RIGHT || + jpath->jointype == JOIN_RIGHT_ANTI)) + { + root->join_partition_prune_candidates = + lappend(root->join_partition_prune_candidates, NULL); + return; + } + + /* + * For now we only support HashJoin. + */ + if (jpath->path.pathtype != T_HashJoin) + { + root->join_partition_prune_candidates = + lappend(root->join_partition_prune_candidates, NULL); + return; + } + + candidate = makeNode(JoinPartitionPruneCandidateInfo); + candidate->joinrestrictinfo = jpath->joinrestrictinfo; + candidate->inner_relids = jpath->innerjoinpath->parent->relids; + candidate->inner_rows = jpath->innerjoinpath->parent->rows; + candidate->joinpartprune_info_list = NIL; + + root->join_partition_prune_candidates = + lappend(root->join_partition_prune_candidates, candidate); +} + +/* + * get_join_partition_prune_candidate + * Pop out the JoinPartitionPruneCandidateInfo for this join and retrieve + * the JoinPartitionPruneInfos. + */ +List * +get_join_partition_prune_candidate(PlannerInfo *root) +{ + JoinPartitionPruneCandidateInfo *candidate; + List *result; + + candidate = llast(root->join_partition_prune_candidates); + root->join_partition_prune_candidates = + list_delete_last(root->join_partition_prune_candidates); + + if (candidate == NULL) + return NIL; + + result = candidate->joinpartprune_info_list; + + pfree(candidate); + + return result; +} + /* * add_part_relids * Add new info to a list of Bitmapsets of partitioned relids. @@ -428,6 +620,8 @@ add_part_relids(List *allpartrelids, Bitmapset *partrelids) * partrelids: Set of RT indexes identifying relevant partitioned tables * within a single partitioning hierarchy * relid_subplan_map[]: maps child relation relids to subplan indexes + * available_rels: the relid set of rels whose Vars may be used for + * pruning. * matchedsubplans: on success, receives the set of subplan indexes which * were matched to this partition hierarchy * @@ -440,6 +634,7 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *prunequal, Bitmapset *partrelids, int *relid_subplan_map, + Bitmapset *available_rels, Bitmapset **matchedsubplans) { RelOptInfo *targetpart = NULL; @@ -539,8 +734,8 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, * pruning steps and detects whether there's any possibly-useful quals * that would require per-scan pruning. */ - gen_partprune_steps(subpart, partprunequal, PARTTARGET_INITIAL, - &context); + gen_partprune_steps(subpart, partprunequal, available_rels, + PARTTARGET_INITIAL, &context); if (context.contradictory) { @@ -567,14 +762,15 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, initial_pruning_steps = NIL; /* - * If no exec Params appear in potentially-usable pruning clauses, - * then there's no point in even thinking about per-scan pruning. + * If no exec Params or available Vars appear in potentially-usable + * pruning clauses, then there's no point in even thinking about + * per-scan pruning. */ - if (context.has_exec_param) + if (context.has_exec_param || context.has_vars) { /* ... OK, we'd better think about it */ - gen_partprune_steps(subpart, partprunequal, PARTTARGET_EXEC, - &context); + gen_partprune_steps(subpart, partprunequal, available_rels, + PARTTARGET_EXEC, &context); if (context.contradictory) { @@ -587,11 +783,14 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, /* * Detect which exec Params actually got used; the fact that some * were in available clauses doesn't mean we actually used them. - * Skip per-scan pruning if there are none. */ execparamids = get_partkey_exec_paramids(exec_pruning_steps); - if (bms_is_empty(execparamids)) + /* + * Skip per-scan pruning if there are none used exec Params and + * there are none available Vars. + */ + if (bms_is_empty(execparamids) && !context.has_vars) exec_pruning_steps = NIL; } else @@ -703,6 +902,9 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, * Process 'clauses' (typically a rel's baserestrictinfo list of clauses) * and create a list of "partition pruning steps". * + * 'available_rels' is the relid set of rels whose Vars may be used for + * pruning. + * * 'target' tells whether to generate pruning steps for planning (use * immutable clauses only), or for executor startup (use any allowable * clause except ones containing PARAM_EXEC Params), or for executor @@ -712,12 +914,13 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, * some subsidiary flags; see the GeneratePruningStepsContext typedef. */ static void -gen_partprune_steps(RelOptInfo *rel, List *clauses, PartClauseTarget target, - GeneratePruningStepsContext *context) +gen_partprune_steps(RelOptInfo *rel, List *clauses, Bitmapset *available_rels, + PartClauseTarget target, GeneratePruningStepsContext *context) { /* Initialize all output values to zero/false/NULL */ memset(context, 0, sizeof(GeneratePruningStepsContext)); context->rel = rel; + context->available_rels = available_rels; context->target = target; /* @@ -773,7 +976,7 @@ prune_append_rel_partitions(RelOptInfo *rel) * If the clauses are found to be contradictory, we can return the empty * set. */ - gen_partprune_steps(rel, clauses, PARTTARGET_PLANNER, + gen_partprune_steps(rel, clauses, NULL, PARTTARGET_PLANNER, &gcontext); if (gcontext.contradictory) return NULL; @@ -1957,9 +2160,10 @@ match_clause_to_partition_key(GeneratePruningStepsContext *context, return PARTCLAUSE_UNSUPPORTED; /* - * We can never prune using an expression that contains Vars. + * We can never prune using an expression that contains Vars except + * for Vars belonging to context->available_rels. */ - if (contain_var_clause((Node *) expr)) + if (contain_forbidden_var_clause((Node *) expr, context)) return PARTCLAUSE_UNSUPPORTED; /* @@ -2155,9 +2359,10 @@ match_clause_to_partition_key(GeneratePruningStepsContext *context, return PARTCLAUSE_UNSUPPORTED; /* - * We can never prune using an expression that contains Vars. + * We can never prune using an expression that contains Vars except + * for Vars belonging to context->available_rels. */ - if (contain_var_clause((Node *) rightop)) + if (contain_forbidden_var_clause((Node *) rightop, context)) return PARTCLAUSE_UNSUPPORTED; /* @@ -3727,3 +3932,54 @@ partkey_datum_from_expr(PartitionPruneContext *context, *value = ExecEvalExprSwitchContext(exprstate, ectx, isnull); } } + +/* + * contain_forbidden_var_clause + * Recursively scan a clause to discover whether it contains any Var nodes + * (of the current query level) that do not belong to relations in + * context->available_rels. + * + * Returns true if any such varnode found. + * + * Does not examine subqueries, therefore must only be used after reduction + * of sublinks to subplans! + */ +static bool +contain_forbidden_var_clause(Node *node, GeneratePruningStepsContext *context) +{ + return contain_forbidden_var_clause_walker(node, context); +} + +static bool +contain_forbidden_var_clause_walker(Node *node, GeneratePruningStepsContext *context) +{ + if (node == NULL) + return false; + if (IsA(node, Var)) + { + Var *var = (Var *) node; + + if (var->varlevelsup != 0) + return false; + + if (!bms_is_member(var->varno, context->available_rels)) + return true; /* abort the tree traversal and return true */ + + context->has_vars = true; + + if (context->target != PARTTARGET_EXEC) + return true; /* abort the tree traversal and return true */ + + return false; + } + if (IsA(node, CurrentOfExpr)) + return true; + if (IsA(node, PlaceHolderVar)) + { + if (((PlaceHolderVar *) node)->phlevelsup == 0) + return true; /* abort the tree traversal and return true */ + /* else fall through to check the contained expr */ + } + return expression_tree_walker(node, contain_forbidden_var_clause_walker, + (void *) context); +} diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index c09bc83b2a..7e46f0baf6 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -121,11 +121,26 @@ typedef struct PartitionPruneState PartitionPruningData *partprunedata[FLEXIBLE_ARRAY_MEMBER]; } PartitionPruneState; +/* + * JoinPartitionPruneState - State object required for plan nodes to perform + * join partition pruning. + */ +typedef struct JoinPartitionPruneState +{ + PartitionPruneState *part_prune_state; + int paramid; + int nplans; + bool finished; + Bitmapset *part_prune_result; +} JoinPartitionPruneState; + extern PartitionPruneState *ExecInitPartitionPruning(PlanState *planstate, int n_total_subplans, PartitionPruneInfo *pruneinfo, Bitmapset **initially_valid_subplans); +extern List *ExecInitJoinpartpruneList(PlanState *planstate, List *joinpartprune_info_list); extern Bitmapset *ExecFindMatchingSubPlans(PartitionPruneState *prunestate, - bool initial_prune); + bool initial_prune, + PlanState *planstate); #endif /* EXECPARTITION_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 444a5f0fd5..8f02af1f10 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -2685,6 +2685,9 @@ typedef struct HashState /* Parallel hash state. */ struct ParallelHashJoinState *parallel_state; + + /* Infos for join partition pruning. */ + List *joinpartprune_state_list; } HashState; /* ---------------- diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 534692bee1..da7803448a 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -530,6 +530,9 @@ struct PlannerInfo /* not-yet-assigned NestLoopParams */ List *curOuterParams; + /* a stack of JoinPartitionPruneInfos */ + List *join_partition_prune_candidates; + /* * These fields are workspace for setrefs.c. Each is an array * corresponding to glob->subplans. (We could probably teach diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index b4ef6bc44c..964bc85123 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -275,6 +275,9 @@ typedef struct Append /* Info for run-time subplan pruning; NULL if we're not doing that */ struct PartitionPruneInfo *part_prune_info; + + /* Info for join partition pruning; NULL if we're not doing that */ + Bitmapset *join_prune_paramids; } Append; /* ---------------- @@ -310,6 +313,9 @@ typedef struct MergeAppend /* Info for run-time subplan pruning; NULL if we're not doing that */ struct PartitionPruneInfo *part_prune_info; + + /* Info for join partition pruning; NULL if we're not doing that */ + Bitmapset *join_prune_paramids; } MergeAppend; /* ---------------- @@ -1206,6 +1212,7 @@ typedef struct Hash bool skewInherit; /* is outer join rel an inheritance tree? */ /* all other info is in the parent HashJoin node */ Cardinality rows_total; /* estimate total rows if parallel_aware */ + List *joinpartprune_info_list; /* infos for join partition pruning */ } Hash; /* ---------------- @@ -1552,6 +1559,35 @@ typedef struct PartitionPruneStepCombine List *source_stepids; } PartitionPruneStepCombine; +/* + * JoinPartitionPruneCandidateInfo - Information required to build + * JoinPartitionPruneInfos. + */ +typedef struct JoinPartitionPruneCandidateInfo +{ + pg_node_attr(no_equal, no_query_jumble) + + NodeTag type; + List *joinrestrictinfo; + Bitmapset *inner_relids; + double inner_rows; + List *joinpartprune_info_list; +} JoinPartitionPruneCandidateInfo; + +/* + * JoinPartitionPruneInfo - Details required to allow the executor to prune + * partitions during join. + */ +typedef struct JoinPartitionPruneInfo +{ + pg_node_attr(no_equal, no_query_jumble) + + NodeTag type; + PartitionPruneInfo *part_prune_info; + int paramid; + int nplans; +} JoinPartitionPruneInfo; + /* * Plan invalidation info diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index b1c51a4e70..5ccd3c62d4 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -212,5 +212,9 @@ extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *targ extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, double loop_count, Cost *cost_p, double *tuples_p); +extern double compute_partprune_cost(PlannerInfo *root, RelOptInfo *appendrel, + Cost append_total_cost, int append_nplans, + Relids inner_relids, double inner_rows, + List *prunequal); #endif /* COST_H */ diff --git a/src/include/partitioning/partprune.h b/src/include/partitioning/partprune.h index bd490d154f..5187485c88 100644 --- a/src/include/partitioning/partprune.h +++ b/src/include/partitioning/partprune.h @@ -19,6 +19,8 @@ struct PlannerInfo; /* avoid including pathnodes.h here */ struct RelOptInfo; +struct Path; +struct JoinPath; /* @@ -73,7 +75,15 @@ typedef struct PartitionPruneContext extern PartitionPruneInfo *make_partition_pruneinfo(struct PlannerInfo *root, struct RelOptInfo *parentrel, List *subpaths, - List *prunequal); + List *prunequal, + Bitmapset *available_rels); +extern Bitmapset *make_join_partition_pruneinfos(struct PlannerInfo *root, + struct RelOptInfo *parentrel, + struct Path *best_path, + List *subpaths); +extern void prepare_join_partition_prune_candidate(struct PlannerInfo *root, + struct JoinPath *jpath); +extern List *get_join_partition_prune_candidate(struct PlannerInfo *root); extern Bitmapset *prune_append_rel_partitions(struct RelOptInfo *rel); extern Bitmapset *get_matching_partitions(PartitionPruneContext *context, List *pruning_steps); diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index 9a4c48c055..a08e7a1f0a 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -3003,6 +3003,92 @@ order by tbl1.col1, tprt.col1; ------+------ (0 rows) +-- join partition pruning +-- The 'Memory Usage' from the Hash node can vary between machines. Let's just +-- replace the number with an 'N'. +-- We need to run EXPLAIN ANALYZE because we need to see '(never executed)' +-- notations because that's the only way to verify runtime pruning. +create function explain_join_partition_pruning(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, verbose, costs off, summary off, timing off) %s', + $1) + loop + ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N'); + return next ln; + end loop; +end; +$$; +delete from tbl1; +insert into tbl1 values (501), (505); +analyze tbl1, tprt; +set enable_nestloop = off; +set enable_mergejoin = off; +set enable_hashjoin = on; +select explain_join_partition_pruning(' +select * from tprt p1 + inner join tprt p2 on p1.col1 = p2.col1 + right join tbl1 t on p1.col1 = t.col1 and p2.col1 = t.col1;'); + explain_join_partition_pruning +-------------------------------------------------------------------------------- + Hash Right Join (actual rows=2 loops=1) + Output: p1.col1, p2.col1, t.col1 + Hash Cond: ((p1.col1 = t.col1) AND (p2.col1 = t.col1)) + -> Hash Join (actual rows=3 loops=1) + Output: p1.col1, p2.col1 + Hash Cond: (p1.col1 = p2.col1) + -> Append (actual rows=3 loops=1) + Join Partition Pruning: $0 + -> Seq Scan on public.tprt_1 p1_1 (never executed) + Output: p1_1.col1 + -> Seq Scan on public.tprt_2 p1_2 (actual rows=3 loops=1) + Output: p1_2.col1 + -> Seq Scan on public.tprt_3 p1_3 (never executed) + Output: p1_3.col1 + -> Seq Scan on public.tprt_4 p1_4 (never executed) + Output: p1_4.col1 + -> Seq Scan on public.tprt_5 p1_5 (never executed) + Output: p1_5.col1 + -> Seq Scan on public.tprt_6 p1_6 (never executed) + Output: p1_6.col1 + -> Hash (actual rows=3 loops=1) + Output: p2.col1 + Buckets: 1024 Batches: 1 Memory Usage: NkB + -> Append (actual rows=3 loops=1) + Join Partition Pruning: $1 + -> Seq Scan on public.tprt_1 p2_1 (never executed) + Output: p2_1.col1 + -> Seq Scan on public.tprt_2 p2_2 (actual rows=3 loops=1) + Output: p2_2.col1 + -> Seq Scan on public.tprt_3 p2_3 (never executed) + Output: p2_3.col1 + -> Seq Scan on public.tprt_4 p2_4 (never executed) + Output: p2_4.col1 + -> Seq Scan on public.tprt_5 p2_5 (never executed) + Output: p2_5.col1 + -> Seq Scan on public.tprt_6 p2_6 (never executed) + Output: p2_6.col1 + -> Hash (actual rows=2 loops=1) + Output: t.col1 + Buckets: 1024 Batches: 1 Memory Usage: NkB + Partition Prune: $0, $1 + -> Seq Scan on public.tbl1 t (actual rows=2 loops=1) + Output: t.col1 +(43 rows) + +select * from tprt p1 + inner join tprt p2 on p1.col1 = p2.col1 + right join tbl1 t on p1.col1 = t.col1 and p2.col1 = t.col1; + col1 | col1 | col1 +------+------+------ + 501 | 501 | 501 + 505 | 505 | 505 +(2 rows) + drop table tbl1, tprt; -- Test with columns defined in varying orders between each level create table part_abc (a int not null, b int not null, c int not null) partition by list (a); diff --git a/src/test/regress/sql/partition_prune.sql b/src/test/regress/sql/partition_prune.sql index 7bf3920827..fc5982edcf 100644 --- a/src/test/regress/sql/partition_prune.sql +++ b/src/test/regress/sql/partition_prune.sql @@ -727,6 +727,45 @@ select tbl1.col1, tprt.col1 from tbl1 inner join tprt on tbl1.col1 = tprt.col1 order by tbl1.col1, tprt.col1; +-- join partition pruning + +-- The 'Memory Usage' from the Hash node can vary between machines. Let's just +-- replace the number with an 'N'. +-- We need to run EXPLAIN ANALYZE because we need to see '(never executed)' +-- notations because that's the only way to verify runtime pruning. +create function explain_join_partition_pruning(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, verbose, costs off, summary off, timing off) %s', + $1) + loop + ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N'); + return next ln; + end loop; +end; +$$; + +delete from tbl1; +insert into tbl1 values (501), (505); +analyze tbl1, tprt; + +set enable_nestloop = off; +set enable_mergejoin = off; +set enable_hashjoin = on; + +select explain_join_partition_pruning(' +select * from tprt p1 + inner join tprt p2 on p1.col1 = p2.col1 + right join tbl1 t on p1.col1 = t.col1 and p2.col1 = t.col1;'); + +select * from tprt p1 + inner join tprt p2 on p1.col1 = p2.col1 + right join tbl1 t on p1.col1 = t.col1 and p2.col1 = t.col1; + drop table tbl1, tprt; -- Test with columns defined in varying orders between each level -- 2.31.0 ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-06-07 13:18 Julien Tachoires <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: Julien Tachoires @ 2024-06-07 13:18 UTC (permalink / raw) To: Tomas Vondra <[email protected]>; +Cc: [email protected] Le ven. 7 juin 2024 à 05:59, Tomas Vondra <[email protected]> a écrit : > > On 6/6/24 12:58, Julien Tachoires wrote: > > ... > > > > When compiled with LZ4 support (--with-lz4), this patch enables data > > compression/decompression of these temporary files. Each transaction > > change that must be written on disk (ReorderBufferDiskChange) is now > > compressed and encapsulated in a new structure. > > > > I'm a bit confused, but why tie this to having lz4? Why shouldn't this > be supported even for pglz, or whatever algorithms we add in the future? That's right, reworking this patch in that sense. Regards, JT ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-15 18:50 Julien Tachoires <[email protected]> parent: Julien Tachoires <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: Julien Tachoires @ 2024-07-15 18:50 UTC (permalink / raw) To: Tomas Vondra <[email protected]>; +Cc: [email protected] Hi, Le ven. 7 juin 2024 à 06:18, Julien Tachoires <[email protected]> a écrit : > > Le ven. 7 juin 2024 à 05:59, Tomas Vondra > <[email protected]> a écrit : > > > > On 6/6/24 12:58, Julien Tachoires wrote: > > > ... > > > > > > When compiled with LZ4 support (--with-lz4), this patch enables data > > > compression/decompression of these temporary files. Each transaction > > > change that must be written on disk (ReorderBufferDiskChange) is now > > > compressed and encapsulated in a new structure. > > > > > > > I'm a bit confused, but why tie this to having lz4? Why shouldn't this > > be supported even for pglz, or whatever algorithms we add in the future? > > That's right, reworking this patch in that sense. Please find a new version of this patch adding support for LZ4, pglz and ZSTD. It introduces the new GUC logical_decoding_spill_compression which is used to set the compression method. In order to stay aligned with the other server side GUCs related to compression methods (wal_compression, default_toast_compression), the compression level is not exposed to users. The last patch of this set is still in WIP, it adds the machinery required for setting the compression methods as a subscription option: CREATE SUBSCRIPTION ... WITH (spill_compression = ...); I think there is a major problem with this approach: the logical decoding context is tied to one replication slot, but multiple subscriptions can use the same replication slot. How should this work if 2 subscriptions want to use the same replication slot but different compression methods? At this point, compression is only available for the changes spilled on disk. It is still not clear to me if the compression of data transiting through the streaming protocol should be addressed by this patch set or by another one. Thought ? Regards, JT Attachments: [application/octet-stream] v2-0004-Compress-ReorderBuffer-spill-files-using-PGLZ.patch (5.8K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/2-v2-0004-Compress-ReorderBuffer-spill-files-using-PGLZ.patch) download | inline diff: From d7daa87489b1cc2583d643db3396872f902a2d15 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Tue, 25 Jun 2024 05:34:43 -0700 Subject: [PATCH 4/7] Compress ReorderBuffer spill files using PGLZ --- doc/src/sgml/config.sgml | 2 +- .../logical/reorderbuffer_compression.c | 58 +++++++++++++++++++ src/backend/utils/misc/guc_tables.c | 5 ++ .../replication/reorderbuffer_compression.h | 2 + 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 955f4f4a8b..2697ebc435 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2017,7 +2017,7 @@ include_dir 'conf.d' set to <varname>on</varname> or <varname>parallel</varname>, then the transaction are not fully decoded on the publisher, then, this parameter has not effect if there is no data to spill on disk. - The supported methods are <literal>lz4</literal> (if + The supported methods are <literal>pglz</literal>, <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>) and <literal>off></literal>. The default value is <literal>off</literal>. diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 77f5c76929..a05393cc61 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -13,6 +13,8 @@ */ #include "postgres.h" +#include "common/pg_lzcompress.h" + #ifdef USE_LZ4 #include <lz4.h> #endif @@ -313,6 +315,7 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) return lz4_NewCompressorState(context); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: return NULL; break; @@ -333,6 +336,7 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, return lz4_FreeCompressorState(context, compressor_state); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: break; } @@ -421,6 +425,40 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* PGLZ compression */ + case REORDER_BUFFER_PGLZ_COMPRESSION: + { + int32 dst_size = 0; + char *dst = NULL; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + int32 src_size = data_size - sizeof(ReorderBufferDiskHeader); + int32 max_size = PGLZ_MAX_OUTPUT(src_size); + + dst = (char *) palloc0(max_size); + dst_size = pglz_compress(src, src_size, dst, PGLZ_strategy_always); + + if (dst_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("PGLZ compression failed"))); + + ReorderBufferReserve(rb, (Size) (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_PGLZ; + hdr->size = (Size) dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = (Size) src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -495,6 +533,26 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, */ break; } + /* PGLZ decompression */ + case REORDER_BUFFER_STRAT_PGLZ: + { + char *buf; + int32 src_size = (int32) header->size - sizeof(ReorderBufferDiskHeader); + int32 buf_size = (int32) header->raw_size; + int32 decBytes; + + /* Decompress data directly into the ReorderBuffer */ + buf = (char *) rb->outbuf; + buf += sizeof(ReorderBufferDiskHeader); + + decBytes = pglz_decompress(data, src_size, buf, buf_size, false); + + if (decBytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed PGLZ data is corrupted"))); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 27ce376fd4..0209a3a517 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -489,10 +489,15 @@ static const struct config_enum_entry logical_decoding_spill_compression_options #ifdef USE_LZ4 {"lz4", REORDER_BUFFER_LZ4_COMPRESSION, false}, #endif + {"pglz", REORDER_BUFFER_PGLZ_COMPRESSION, false}, {"off", REORDER_BUFFER_NO_COMPRESSION, false}, + {"on", REORDER_BUFFER_PGLZ_COMPRESSION, false}, {"false", REORDER_BUFFER_NO_COMPRESSION, true}, + {"true", REORDER_BUFFER_PGLZ_COMPRESSION, true}, {"no", REORDER_BUFFER_NO_COMPRESSION, true}, + {"yes", REORDER_BUFFER_PGLZ_COMPRESSION, true}, {"0", REORDER_BUFFER_NO_COMPRESSION, true}, + {"1", REORDER_BUFFER_PGLZ_COMPRESSION, true}, {NULL, 0, false} }; diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index d59e9543a8..ea77ed1358 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -27,6 +27,7 @@ typedef enum ReorderBufferCompressionMethod { REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, + REORDER_BUFFER_PGLZ_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -37,6 +38,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_UNCOMPRESSED, REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, + REORDER_BUFFER_STRAT_PGLZ, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ -- 2.43.0 [application/octet-stream] v2-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch (32.8K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/3-v2-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch) download | inline diff: From 2423e35294425d2415d456b5ad920e1dea22279d Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 6 Jun 2024 00:57:38 -0700 Subject: [PATCH 1/7] Compress ReorderBuffer spill files using LZ4 When the content of a large transaction (size exceeding logical_decoding_work_mem) and its sub-transactions has to be reordered during logical decoding, then, all the changes are written on disk in temporary files located in pg_replslot/<slot_name>. This behavior happens only when the subscriber's option "streaming" is set to "off", which is the default value. In this case, large transactions decoding by multiple replication slots can lead to disk space saturation and high I/O utilization. When compiled with LZ4 support (--with-lz4), this patch enables data compression/decompression of these temporary files. Each transaction change that must be written on disk is now compressed and wrapped in a new structure named ReorderBufferDiskHeader. 3 different compression strategies are currently implemented: 1. LZ4 streaming compression is the preferred one and works efficiently for small individual changes. 2. LZ4 regular compression when the changes are too large for using LZ4 streaming API. 3. No compression. --- src/backend/replication/logical/Makefile | 1 + src/backend/replication/logical/meson.build | 1 + .../replication/logical/reorderbuffer.c | 201 ++++--- .../logical/reorderbuffer_compression.c | 502 ++++++++++++++++++ src/include/replication/reorderbuffer.h | 6 + .../replication/reorderbuffer_compression.h | 95 ++++ 6 files changed, 723 insertions(+), 83 deletions(-) create mode 100644 src/backend/replication/logical/reorderbuffer_compression.c create mode 100644 src/include/replication/reorderbuffer_compression.h diff --git a/src/backend/replication/logical/Makefile b/src/backend/replication/logical/Makefile index ba03eeff1c..88bf698a53 100644 --- a/src/backend/replication/logical/Makefile +++ b/src/backend/replication/logical/Makefile @@ -25,6 +25,7 @@ OBJS = \ proto.o \ relation.o \ reorderbuffer.o \ + reorderbuffer_compression.o \ slotsync.o \ snapbuild.o \ tablesync.o \ diff --git a/src/backend/replication/logical/meson.build b/src/backend/replication/logical/meson.build index 3dec36a6de..f0dd82bae2 100644 --- a/src/backend/replication/logical/meson.build +++ b/src/backend/replication/logical/meson.build @@ -11,6 +11,7 @@ backend_sources += files( 'proto.c', 'relation.c', 'reorderbuffer.c', + 'reorderbuffer_compression.c', 'slotsync.c', 'snapbuild.c', 'tablesync.c', diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 00a8327e77..4e08167d03 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -102,6 +102,7 @@ #include "pgstat.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */ #include "storage/bufmgr.h" @@ -112,6 +113,13 @@ #include "utils/rel.h" #include "utils/relfilenumbermap.h" +/* GUC */ +#ifdef USE_LZ4 +int logical_decoding_spill_compression = REORDER_BUFFER_LZ4_COMPRESSION; +#else +int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; +#endif + /* entry for a hash table we use to map from xid to our transaction state */ typedef struct ReorderBufferTXNByIdEnt { @@ -173,14 +181,6 @@ typedef struct ReorderBufferToastEnt * main tup */ } ReorderBufferToastEnt; -/* Disk serialization support datastructures */ -typedef struct ReorderBufferDiskChange -{ - Size size; - ReorderBufferChange change; - /* data follows */ -} ReorderBufferDiskChange; - #define IsSpecInsert(action) \ ( \ ((action) == REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT) \ @@ -255,6 +255,8 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *tx int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); +static bool ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno); static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data); static void ReorderBufferRestoreCleanup(ReorderBuffer *rb, ReorderBufferTXN *txn); @@ -427,6 +429,8 @@ ReorderBufferGetTXN(ReorderBuffer *rb) /* InvalidCommandId is not zero, so set it explicitly */ txn->command_id = InvalidCommandId; txn->output_plugin_private = NULL; + txn->compressor_state = ReorderBufferNewCompressorState(rb->context, + logical_decoding_spill_compression); return txn; } @@ -464,6 +468,10 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) txn->invalidations = NULL; } + ReorderBufferFreeCompressorState(rb->context, + logical_decoding_spill_compression, + txn->compressor_state); + /* Reset the toast hash */ ReorderBufferToastReset(rb, txn); @@ -3776,13 +3784,13 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { - ReorderBufferDiskChange *ondisk; - Size sz = sizeof(ReorderBufferDiskChange); + ReorderBufferDiskHeader *disk_hdr; + Size sz = sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); ReorderBufferSerializeReserve(rb, sz); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - memcpy(&ondisk->change, change, sizeof(ReorderBufferChange)); + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; + memcpy((char *)rb->outbuf + sizeof(ReorderBufferDiskHeader), change, sizeof(ReorderBufferChange)); switch (change->action) { @@ -3818,9 +3826,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; if (oldlen) { @@ -3850,10 +3858,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sizeof(Size) + sizeof(Size); ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; /* write the prefix including the size */ memcpy(data, &prefix_size, sizeof(Size)); @@ -3880,10 +3888,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sz += inval_size; ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.inval.invalidations, inval_size); data += inval_size; @@ -3902,9 +3910,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, snap, sizeof(SnapshotData)); data += sizeof(SnapshotData); @@ -3936,9 +3944,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.truncate.relids, size); data += size; @@ -3953,11 +3961,14 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, break; } - ondisk->size = sz; + /* Inplace ReorderBuffer content compression before writing it on disk */ + ReorderBufferCompress(rb, &disk_hdr, logical_decoding_spill_compression, + sz, txn->compressor_state); errno = 0; pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_WRITE); - if (write(fd, rb->outbuf, ondisk->size) != ondisk->size) + + if (write(fd, rb->outbuf, disk_hdr->size) != disk_hdr->size) { int save_errno = errno; @@ -3982,8 +3993,6 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; - - Assert(ondisk->change.action == change->action); } /* Returns true, if the output plugin supports streaming, false, otherwise. */ @@ -4252,9 +4261,6 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, while (restored < max_changes_in_memory && *segno <= last_segno) { - int readBytes; - ReorderBufferDiskChange *ondisk; - CHECK_FOR_INTERRUPTS(); if (*fd == -1) @@ -4293,60 +4299,15 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* - * Read the statically sized part of a change which has information - * about the total size. If we couldn't read a record, we're at the - * end of this file. + * Read the full change from disk. + * If ReorderBufferReadOndiskChange returns false, then we are at the + * eof, so, move the next segment. */ - ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange)); - readBytes = FileRead(file->vfd, rb->outbuf, - sizeof(ReorderBufferDiskChange), - file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); - - /* eof */ - if (readBytes == 0) + if (!ReorderBufferReadOndiskChange(rb, txn, file, segno)) { - FileClose(*fd); *fd = -1; - (*segno)++; continue; } - else if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) sizeof(ReorderBufferDiskChange)))); - - file->curOffset += readBytes; - - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - ReorderBufferSerializeReserve(rb, - sizeof(ReorderBufferDiskChange) + ondisk->size); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - readBytes = FileRead(file->vfd, - rb->outbuf + sizeof(ReorderBufferDiskChange), - ondisk->size - sizeof(ReorderBufferDiskChange), - file->curOffset, - WAIT_EVENT_REORDER_BUFFER_READ); - - if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != ondisk->size - sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) (ondisk->size - sizeof(ReorderBufferDiskChange))))); - - file->curOffset += readBytes; /* * ok, read a full change from disk, now restore it into proper @@ -4359,6 +4320,83 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, return restored; } +/* + * Read a change spilled to disk and decompress it if compressed. + */ +static bool +ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno) +{ + int readBytes; + ReorderBufferDiskHeader *disk_hdr; + char *header; /* disk header buffer*/ + char *data; /* data buffer */ + + /* + * Read the statically sized part of a change which has information about + * the total size and compression method. If we couldn't read a record, + * we're at the end of this file. + */ + header = (char *) palloc0(sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, header, + sizeof(ReorderBufferDiskHeader), + file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); + + /* eof */ + if (readBytes == 0) + { + + FileClose(file->vfd); + (*segno)++; + pfree(header); + + return false; + } + else if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != sizeof(ReorderBufferDiskHeader)) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) sizeof(ReorderBufferDiskHeader)))); + + file->curOffset += readBytes; + + disk_hdr = (ReorderBufferDiskHeader *) header; + + /* Read ondisk data */ + data = (char *) palloc0(disk_hdr->size - sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, + data, + disk_hdr->size - sizeof(ReorderBufferDiskHeader), + file->curOffset, + WAIT_EVENT_REORDER_BUFFER_READ); + + if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != (disk_hdr->size - sizeof(ReorderBufferDiskHeader))) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) (disk_hdr->size - sizeof(ReorderBufferDiskHeader))))); + + /* Decompress data */ + ReorderBufferDecompress(rb, data, disk_hdr, txn->compressor_state); + + pfree(data); + pfree(header); + + file->curOffset += readBytes; + + return true; +} + /* * Convert change from its on-disk format to in-memory format and queue it onto * the TXN's ->changes list. @@ -4371,17 +4409,14 @@ static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data) { - ReorderBufferDiskChange *ondisk; ReorderBufferChange *change; - ondisk = (ReorderBufferDiskChange *) data; - change = ReorderBufferGetChange(rb); /* copy static part */ - memcpy(change, &ondisk->change, sizeof(ReorderBufferChange)); + memcpy(change, data + sizeof(ReorderBufferDiskHeader), sizeof(ReorderBufferChange)); - data += sizeof(ReorderBufferDiskChange); + data += sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* restore individual stuff */ switch (change->action) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c new file mode 100644 index 0000000000..77f5c76929 --- /dev/null +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -0,0 +1,502 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.c + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * src/backend/access/common/reorderbuffer_compression.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +#include "replication/reorderbuffer_compression.h" + +#define NO_LZ4_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method lz4 not supported"), \ + errdetail("This functionality requires the server to be built with lz4 support."))) + +/* + * Allocate a new LZ4StreamingCompressorState. + */ +static void * +lz4_NewCompressorState(MemoryContext context) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + LZ4StreamingCompressorState *cstate; + + cstate = (LZ4StreamingCompressorState *) + MemoryContextAlloc(context, sizeof(LZ4StreamingCompressorState)); + + /* + * We do not allocate LZ4 ring buffers and streaming handlers at this + * point because we have no guarantee that we will need them later. Let's + * allocate only when we are about to use them. + */ + cstate->lz4_in_buf = NULL; + cstate->lz4_out_buf = NULL; + cstate->lz4_in_buf_offset = 0; + cstate->lz4_out_buf_offset = 0; + cstate->lz4_stream = NULL; + cstate->lz4_stream_decode = NULL; + + return (void *) cstate; +#endif +} + +/* + * Free LZ4 memory resources and the compressor state. + */ +static void +lz4_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + if (cstate->lz4_in_buf != NULL) + { + pfree(cstate->lz4_in_buf); + LZ4_freeStream(cstate->lz4_stream); + } + if (cstate->lz4_out_buf != NULL) + { + pfree(cstate->lz4_out_buf); + LZ4_freeStreamDecode(cstate->lz4_stream_decode); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_LZ4 +/* + * Allocate LZ4 input ring buffer and create the streaming compression handler. + */ +static void +lz4_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_in_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream = LZ4_createStream(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_LZ4 +/* + * Allocate LZ4 output ring buffer and create the streaming decompression + * handler. + */ +static void +lz4_CreateStreamDecodeCompressorState(MemoryContext context, + void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_out_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream_decode = LZ4_createStreamDecode(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using LZ4 streaming API. + * Caller must ensure that the source data can fit in LZ4 input ring buffer, + * this checking must be done by lz4_CanDoStreamingCompression(). + */ +static void +lz4_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + char *lz4_in_bufPtr; /* input ring buffer pointer */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 input ring buffer and streaming compression handler */ + if (cstate->lz4_in_buf == NULL) + lz4_CreateStreamCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_in_buf_offset + src_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_in_buf_offset = 0; + + /* Get the pointer of the next entry in the ring buffer */ + lz4_in_bufPtr = cstate->lz4_in_buf + cstate->lz4_in_buf_offset; + + /* Copy data that should be compressed into LZ4 input ring buffer */ + memcpy(lz4_in_bufPtr, src, src_size); + + /* Allocate space for compressed data */ + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 streaming compression API */ + lz4_cmp_size = LZ4_compress_fast_continue(cstate->lz4_stream, + lz4_in_bufPtr, buf, src_size, + buf_size, 1); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + /* Move the input ring buffer offset */ + cstate->lz4_in_buf_offset += src_size; + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data compression using LZ4 API. + */ +static void +lz4_CompressData(char *src, Size src_size, char **dst, Size *dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 regular compression API */ + lz4_cmp_size = LZ4_compress_default(src, buf, src_size, buf_size); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data decompression using LZ4 streaming API. + * LZ4 decompression uses the output ring buffer to store decompressed data, + * thus, we don't need to create a new buffer. We return the pointer to data + * location. + */ +static void +lz4_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + char *lz4_out_bufPtr; /* output ring buffer pointer */ + int lz4_dec_size; /* decompressed data size */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 output ring buffer and streaming decompression handler */ + if (cstate->lz4_out_buf == NULL) + lz4_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_out_buf_offset + dst_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_out_buf_offset = 0; + + /* Get current entry pointer in the ring buffer */ + lz4_out_bufPtr = cstate->lz4_out_buf + cstate->lz4_out_buf_offset; + + lz4_dec_size = LZ4_decompress_safe_continue(cstate->lz4_stream_decode, + src, + lz4_out_bufPtr, + src_size, + dst_size); + + Assert(lz4_dec_size == dst_size); + + if (lz4_dec_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_size != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + /* Move the output ring buffer offset */ + cstate->lz4_out_buf_offset += lz4_dec_size; + + /* Point to the decompressed data location */ + *dst = lz4_out_bufPtr; +#endif +} + +/* + * Data decompression using LZ4 API. + */ +static void +lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_dec_bytes; + char *buf; + + buf = (char *) palloc0(dst_size); + + lz4_dec_bytes = LZ4_decompress_safe(src, buf, src_size, dst_size); + + Assert(lz4_dec_bytes == dst_size); + + if (lz4_dec_bytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_bytes != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + *dst = buf; +#endif +} + +/* + * Allocate a new Compressor State, depending on the compression method. + */ +void * +ReorderBufferNewCompressorState(MemoryContext context, int compression_method) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_NewCompressorState(context); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + return NULL; + break; + } +} + +/* + * Free memory allocated to a Compressor State, depending on the compression + * method. + */ +void +ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, + void *compressor_state) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_FreeCompressorState(context, compressor_state); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + break; + } +} + +/* + * Ensure the IO buffer is >= sz. + */ +static void +ReorderBufferReserve(ReorderBuffer *rb, Size sz) +{ + if (rb->outbufsize < sz) + { + rb->outbuf = repalloc(rb->outbuf, sz); + rb->outbufsize = sz; + } +} + +/* + * Compress ReorderBuffer content. This function is called in order to compress + * data before spilling on disk. + */ +void +ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state) +{ + ReorderBufferDiskHeader *hdr = *header; + + switch (compression_method) + { + /* No compression */ + case REORDER_BUFFER_NO_COMPRESSION: + { + hdr->comp_strat = REORDER_BUFFER_STRAT_UNCOMPRESSED; + hdr->size = data_size; + hdr->raw_size = data_size - sizeof(ReorderBufferDiskHeader); + + break; + } + /* LZ4 Compression */ + case REORDER_BUFFER_LZ4_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + ReorderBufferCompressionStrategy strat; + + if (lz4_CanDoStreamingCompression(src_size)) + { + /* Use LZ4 streaming compression if possible */ + lz4_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + strat = REORDER_BUFFER_STRAT_LZ4_STREAMING; + } + else + { + /* Fallback to LZ4 regular compression */ + lz4_CompressData(src, src_size, &dst, &dst_size); + strat = REORDER_BUFFER_STRAT_LZ4_REGULAR; + } + + /* + * Make sure the ReorderBuffer has enough space to store compressed + * data. Compressed data must be smaller than raw data, so, the + * ReorderBuffer should already have room for compressed data, but + * we do this to avoid buffer overflow risks. + */ + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = strat; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + /* + * Update header: hdr pointer has potentially changed due to + * ReorderBufferReserve() + */ + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + + break; + } + } +} + +/* + * Decompress data read from disk and copy it into the ReorderBuffer. + */ +void +ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, void *compressor_state) +{ + Size raw_outbufsize = header->raw_size + sizeof(ReorderBufferDiskHeader); + /* + * Make sure the output reorder buffer has enough space to store + * decompressed/raw data. + */ + if (rb->outbufsize < raw_outbufsize) + { + rb->outbuf = repalloc(rb->outbuf, raw_outbufsize); + rb->outbufsize = raw_outbufsize; + } + + /* Make a copy of the header read on disk into the ReorderBuffer */ + memcpy(rb->outbuf, (char *) header, sizeof(ReorderBufferDiskHeader)); + + switch (header->comp_strat) + { + /* No decompression */ + case REORDER_BUFFER_STRAT_UNCOMPRESSED: + { + /* + * Make a copy of what was read on disk into the reorder + * buffer. + */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + data, header->raw_size); + break; + } + /* LZ4 regular decompression */ + case REORDER_BUFFER_STRAT_LZ4_REGULAR: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_DecompressData(data, src_size, &buf, buf_size); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + + pfree(buf); + break; + } + /* LZ4 streaming decompression */ + case REORDER_BUFFER_STRAT_LZ4_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + /* + * Not necessary to free buf in this case: it points to the + * decompressed data stored in LZ4 output ring buffer. + */ + break; + } + default: + /* Other compression methods not yet supported */ + break; + } +} diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 851a001c8b..bf979e0b14 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -9,6 +9,10 @@ #ifndef REORDERBUFFER_H #define REORDERBUFFER_H +#ifdef USE_LZ4 +#include <lz4.h> +#endif + #include "access/htup_details.h" #include "lib/ilist.h" #include "lib/pairingheap.h" @@ -422,6 +426,8 @@ typedef struct ReorderBufferTXN * Private data pointer of the output plugin. */ void *output_plugin_private; + + void *compressor_state; } ReorderBufferTXN; /* so we can define the callbacks used inside struct ReorderBuffer itself */ diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h new file mode 100644 index 0000000000..9aa8aea56f --- /dev/null +++ b/src/include/replication/reorderbuffer_compression.h @@ -0,0 +1,95 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.h + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * src/include/access/reorderbuffer_compression.h + * + *------------------------------------------------------------------------- + */ + +#ifndef REORDERBUFFER_COMPRESSION_H +#define REORDERBUFFER_COMPRESSION_H + +#include "replication/reorderbuffer.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +/* ReorderBuffer on disk compression algorithms */ +typedef enum ReorderBufferCompressionMethod +{ + REORDER_BUFFER_NO_COMPRESSION, + REORDER_BUFFER_LZ4_COMPRESSION, +} ReorderBufferCompressionMethod; + +/* + * Compression strategy applied to ReorderBuffer records spilled on disk + */ +typedef enum ReorderBufferCompressionStrategy +{ + REORDER_BUFFER_STRAT_UNCOMPRESSED, + REORDER_BUFFER_STRAT_LZ4_STREAMING, + REORDER_BUFFER_STRAT_LZ4_REGULAR, +} ReorderBufferCompressionStrategy; + +/* Disk serialization support datastructures */ +typedef struct ReorderBufferDiskHeader +{ + ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ + Size size; /* Ondisk size */ + Size raw_size; /* Raw/uncompressed data size */ + /* ReorderBufferChange + data follows */ +} ReorderBufferDiskHeader; + +#ifdef USE_LZ4 +/* + * We use a fairly small LZ4 ring buffer size (64kB). Using a larger buffer + * size provide better compression ratio, but as long as we have to allocate + * two LZ4 ring buffers per ReorderBufferTXN, we should keep it small. + */ +#define LZ4_RING_BUFFER_SIZE (64 * 1024) + +/* + * Use LZ4 streaming compression iff we can keep at least 2 uncompressed + * records into the LZ4 input ring buffer. If raw data size is too large, let's + * use regular LZ4 compression. + */ +#define lz4_CanDoStreamingCompression(s) (s < (LZ4_RING_BUFFER_SIZE / 2)) + +/* + * LZ4 streaming compression/decompression handlers and ring + * buffers. + */ +typedef struct LZ4StreamingCompressorState { + /* Streaming compression handler */ + LZ4_stream_t *lz4_stream; + /* Streaming decompression handler */ + LZ4_streamDecode_t *lz4_stream_decode; + /* LZ4 in/out ring buffers used for streaming compression */ + char *lz4_in_buf; + int lz4_in_buf_offset; + char *lz4_out_buf; + int lz4_out_buf_offset; +} LZ4StreamingCompressorState; +#else +#define lz4_CanDoStreamingCompression(s) (false) +#endif + +extern void *ReorderBufferNewCompressorState(MemoryContext context, + int compression_method); +extern void ReorderBufferFreeCompressorState(MemoryContext context, + int compression_method, + void *compressor_state); +extern void ReorderBufferCompress(ReorderBuffer *rb, + ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state); +extern void ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, + void *compressor_state); + +#endif /* REORDERBUFFER_COMPRESSION_H */ -- 2.43.0 [application/octet-stream] v2-0002-Add-GUC-logical_decoding_spill_compression.patch (5.6K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/4-v2-0002-Add-GUC-logical_decoding_spill_compression.patch) download | inline diff: From 557c21a0255144af3deff45caf61b8aac7cb2c51 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Sun, 23 Jun 2024 08:22:10 -0700 Subject: [PATCH 2/7] Add GUC logical_decoding_spill_compression This new GUC defines the compression method used to compress decoded changes spilled on disk during logical decoding. Default value is 'off', meaning no compression involved. --- doc/src/sgml/config.sgml | 25 +++++++++++++++++++ .../replication/logical/reorderbuffer.c | 4 --- src/backend/utils/misc/guc_tables.c | 22 ++++++++++++++++ src/backend/utils/misc/postgresql.conf.sample | 1 + .../replication/reorderbuffer_compression.h | 3 +++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index b14c5d81a1..955f4f4a8b 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2002,6 +2002,31 @@ include_dir 'conf.d' </listitem> </varlistentry> + <varlistentry id="guc-logical-decoding-spill-files-compression" xreflabel="logical_decoding_spill_compression"> + <term><varname>logical_decoding_spill_compression</varname> (<type>enum</type>) + <indexterm> + <primary><varname>logical_decoding_spill_compression</varname> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + This parameter enables compression of decoded changes written to local + disk by logical decoding when the transaction size does not fit in + <xref linkend="guc-logical-decoding-work-mem"/>. + When the subscribtion is created with the option <varname>streaming</varname> + set to <varname>on</varname> or <varname>parallel</varname>, then + the transaction are not fully decoded on the publisher, then, this + parameter has not effect if there is no data to spill on disk. + The supported methods are <literal>lz4</literal> (if + <productname>PostgreSQL</productname> was compiled with + <option>--with-lz4</option>) and <literal>off></literal>. + The default value is <literal>off</literal>. + Only superusers and users with the appropriate <literal>SET</literal> + privilege can change this setting. + </para> + </listitem> + </varlistentry> + <varlistentry id="guc-commit-timestamp-buffers" xreflabel="commit_timestamp_buffers"> <term><varname>commit_timestamp_buffers</varname> (<type>integer</type>) <indexterm> diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 4e08167d03..ef2cd8bdf3 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -114,11 +114,7 @@ #include "utils/relfilenumbermap.h" /* GUC */ -#ifdef USE_LZ4 -int logical_decoding_spill_compression = REORDER_BUFFER_LZ4_COMPRESSION; -#else int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; -#endif /* entry for a hash table we use to map from xid to our transaction state */ typedef struct ReorderBufferTXNByIdEnt diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 630ed0f162..27ce376fd4 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -67,6 +67,7 @@ #include "postmaster/walsummarizer.h" #include "postmaster/walwriter.h" #include "replication/logicallauncher.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/slotsync.h" #include "replication/syncrep.h" @@ -484,6 +485,17 @@ static const struct config_enum_entry wal_compression_options[] = { {NULL, 0, false} }; +static const struct config_enum_entry logical_decoding_spill_compression_options[] = { +#ifdef USE_LZ4 + {"lz4", REORDER_BUFFER_LZ4_COMPRESSION, false}, +#endif + {"off", REORDER_BUFFER_NO_COMPRESSION, false}, + {"false", REORDER_BUFFER_NO_COMPRESSION, true}, + {"no", REORDER_BUFFER_NO_COMPRESSION, true}, + {"0", REORDER_BUFFER_NO_COMPRESSION, true}, + {NULL, 0, false} +}; + /* * Options for enum values stored in other modules */ @@ -5120,6 +5132,16 @@ struct config_enum ConfigureNamesEnum[] = NULL, NULL, NULL }, + { + {"logical_decoding_spill_compression", PGC_SUSET, RESOURCES_DISK, + gettext_noop("Compresses logical decoding spill files."), + NULL + }, + &logical_decoding_spill_compression, + REORDER_BUFFER_NO_COMPRESSION, logical_decoding_spill_compression_options, + NULL, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 9ec9f97e92..a3a35c4ad8 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -335,6 +335,7 @@ #wal_sender_timeout = 60s # in milliseconds; 0 disables #track_commit_timestamp = off # collect timestamp of transaction commit # (change requires restart) +#logical_decoding_spill_compression = off # Compress decoded changes spilled on disk # - Primary Server - diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 9aa8aea56f..d59e9543a8 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -19,6 +19,9 @@ #include <lz4.h> #endif +/* GUC support */ +extern PGDLLIMPORT int logical_decoding_spill_compression; + /* ReorderBuffer on disk compression algorithms */ typedef enum ReorderBufferCompressionMethod { -- 2.43.0 [application/octet-stream] v2-0005-Compress-ReorderBuffer-spill-files-using-ZSTD.patch (16.1K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/5-v2-0005-Compress-ReorderBuffer-spill-files-using-ZSTD.patch) download | inline diff: From 79753deeef3ebf971df70dbaa974c9ec8a1f74b6 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Fri, 5 Jul 2024 05:25:48 -0700 Subject: [PATCH 5/7] Compress ReorderBuffer spill files using ZSTD --- doc/src/sgml/config.sgml | 4 +- .../logical/reorderbuffer_compression.c | 364 ++++++++++++++++++ src/backend/utils/misc/guc_tables.c | 3 + .../replication/reorderbuffer_compression.h | 39 ++ 4 files changed, 409 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 2697ebc435..7629e10f45 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2019,7 +2019,9 @@ include_dir 'conf.d' parameter has not effect if there is no data to spill on disk. The supported methods are <literal>pglz</literal>, <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with - <option>--with-lz4</option>) and <literal>off></literal>. + <option>--with-lz4</option>), <literal>zstd</literal> (if + <productname>PostgreSQL</productname> was compiled with + <option>--with-zstd</option>) and <literal>off</literal>. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index a05393cc61..9bda286cb8 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -19,6 +19,10 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + #include "replication/reorderbuffer_compression.h" #define NO_LZ4_SUPPORT() \ @@ -27,6 +31,12 @@ errmsg("compression method lz4 not supported"), \ errdetail("This functionality requires the server to be built with lz4 support."))) +#define NO_ZSTD_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method zstd not supported"), \ + errdetail("This functionality requires the server to be built with zstd support."))) + /* * Allocate a new LZ4StreamingCompressorState. */ @@ -303,6 +313,309 @@ lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) #endif } +/* + * Allocate a new ZSTDStreamingCompressorState. + */ +static void * +zstd_NewCompressorState(MemoryContext context) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + ZSTDStreamingCompressorState *cstate; + + cstate = (ZSTDStreamingCompressorState *) + MemoryContextAlloc(context, sizeof(ZSTDStreamingCompressorState)); + + /* + * We do not allocate ZSTD buffers and contexts at this point because we + * have no guarantee that we will need them later. Let's allocate only when + * we are about to use them. + */ + cstate->zstd_c_ctx = NULL; + cstate->zstd_c_in_buf = NULL; + cstate->zstd_c_in_buf_size = 0; + cstate->zstd_c_out_buf = NULL; + cstate->zstd_c_out_buf_size = 0; + cstate->zstd_frame_size = 0; + cstate->zstd_d_ctx = NULL; + cstate->zstd_d_in_buf = NULL; + cstate->zstd_d_in_buf_size = 0; + cstate->zstd_d_out_buf = NULL; + cstate->zstd_d_out_buf_size = 0; + + return (void *) cstate; +#endif +} + +/* + * Free ZSTD memory resources and the compressor state. + */ +static void +zstd_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + + if (cstate->zstd_c_ctx != NULL) + { + /* Compressor state was used for compression */ + pfree(cstate->zstd_c_in_buf); + pfree(cstate->zstd_c_out_buf); + ZSTD_freeCCtx(cstate->zstd_c_ctx); + } + if (cstate->zstd_d_ctx != NULL) + { + /* Compressor state was used for decompression */ + pfree(cstate->zstd_d_in_buf); + pfree(cstate->zstd_d_out_buf); + ZSTD_freeDCtx(cstate->zstd_d_ctx); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_ZSTD +/* + * Allocate ZSTD compression buffers and create the ZSTD compression context. + */ +static void +zstd_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_c_in_buf_size = ZSTD_CStreamInSize(); + cstate->zstd_c_in_buf = (char *) palloc0(cstate->zstd_c_in_buf_size); + cstate->zstd_c_out_buf_size = ZSTD_CStreamOutSize(); + cstate->zstd_c_out_buf = (char *) palloc0(cstate->zstd_c_out_buf_size); + cstate->zstd_c_ctx = ZSTD_createCCtx(); + + if (cstate->zstd_c_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD compression context"))); + + /* Set compression level */ + ZSTD_CCtx_setParameter(cstate->zstd_c_ctx, ZSTD_c_compressionLevel, + ZSTD_COMPRESSION_LEVEL); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_ZSTD +/* + * Allocate ZSTD decompression buffers and create the ZSTD decompression + * context. + */ +static void +zstd_CreateStreamDecodeCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_d_in_buf_size = ZSTD_DStreamInSize(); + cstate->zstd_d_in_buf = (char *) palloc0(cstate->zstd_d_in_buf_size); + cstate->zstd_d_out_buf_size = ZSTD_DStreamOutSize(); + cstate->zstd_d_out_buf = (char *) palloc0(cstate->zstd_d_out_buf_size); + cstate->zstd_d_ctx = ZSTD_createDCtx(); + + if (cstate->zstd_d_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD decompression context"))); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using ZSTD streaming API. + */ +static void +zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_c_ctx == NULL) + zstd_CreateStreamCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store compressed data */ + *dst = (char *) palloc0(ZSTD_compressBound(src_size)); + + dst_data = *dst; + *dst_size = 0; + + /* + * ZSTD streaming compression works with chunks: the source data needs to + * be splitted out in chunks, each of them is then copied into ZSTD input + * buffer. + * For each chunk, we proceed with compression. Streaming compression is + * not intended to compress the whole input chunk, so we have the call + * ZSTD_compressStream2() multiple times until the entire chunk is + * consumed. + */ + while (toCpy > 0) + { + /* Are we on the last chunk? */ + bool last_chunk = (toCpy < cstate->zstd_c_in_buf_size); + /* Size of the data copied into ZSTD input buffer */ + Size cpySize = last_chunk ? toCpy : cstate->zstd_c_in_buf_size; + bool finished = false; + ZSTD_inBuffer input; + ZSTD_EndDirective mode = last_chunk ? ZSTD_e_flush : ZSTD_e_continue; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_c_in_buf, src, cpySize); + + /* + * Close the frame when we are on the last chunk and we've reached max + * frame size. + */ + if (last_chunk && (cstate->zstd_frame_size > ZSTD_MAX_FRAME_SIZE)) + { + mode = ZSTD_e_end; + cstate->zstd_frame_size = 0; + } + + cstate->zstd_frame_size += cpySize; + + input.src = cstate->zstd_c_in_buf; + input.size = cpySize; + input.pos = 0; + + do + { + Size remaining; + ZSTD_outBuffer output; + + output.dst = cstate->zstd_c_out_buf; + output.size = cstate->zstd_c_out_buf_size; + output.pos = 0; + + remaining = ZSTD_compressStream2(cstate->zstd_c_ctx, &output, + &input, mode); + + if (ZSTD_isError(remaining)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD compression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_c_out_buf, output.pos); + + dst_data += output.pos; + *dst_size += output.pos; + + /* + * Compression is done when we are working on the last chunk and + * there is nothing left to compress, or, when we reach the end of + * the chunk. + */ + finished = last_chunk ? (remaining == 0) : (input.pos == input.size); + } while (!finished); + + src += cpySize; + toCpy -= cpySize; + } +#endif +} + +/* + * Data decompression using ZSTD streaming API. + */ +static void +zstd_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + Size decBytes = 0; /* Size of decompressed data */ + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_d_ctx == NULL) + zstd_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store decompressed data */ + *dst = (char *) palloc0(dst_size); + + dst_data = *dst; + + while (toCpy > 0) + { + ZSTD_inBuffer input; + Size cpySize = (toCpy > cstate->zstd_d_in_buf_size) ? cstate->zstd_d_in_buf_size : toCpy; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_d_in_buf, src, cpySize); + + input.src = cstate->zstd_d_in_buf; + input.size = cpySize; + input.pos = 0; + + while (input.pos < input.size) + { + ZSTD_outBuffer output; + Size ret; + + output.dst = cstate->zstd_d_out_buf; + output.size = cstate->zstd_d_out_buf_size; + output.pos = 0; + + ret = ZSTD_decompressStream(cstate->zstd_d_ctx, &output , &input); + + if (ZSTD_isError(ret)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD decompression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_d_out_buf, output.pos); + + dst_data += output.pos; + decBytes += output.pos; + } + + src += cpySize; + toCpy -= cpySize; + } + + Assert(dst_size == decBytes); +#endif +} + /* * Allocate a new Compressor State, depending on the compression method. */ @@ -314,6 +627,9 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_NewCompressorState(context); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_NewCompressorState(context); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -335,6 +651,9 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_FreeCompressorState(context, compressor_state); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_FreeCompressorState(context, compressor_state); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -459,6 +778,35 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* ZSTD Compression */ + case REORDER_BUFFER_ZSTD_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + + /* Use ZSTD streaming compression */ + zstd_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_ZSTD_STREAMING; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -553,6 +901,22 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, errmsg_internal("compressed PGLZ data is corrupted"))); break; } + /* ZSTD streaming decompression */ + case REORDER_BUFFER_STRAT_ZSTD_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + zstd_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + pfree(buf); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 0209a3a517..16023fb686 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -488,6 +488,9 @@ static const struct config_enum_entry wal_compression_options[] = { static const struct config_enum_entry logical_decoding_spill_compression_options[] = { #ifdef USE_LZ4 {"lz4", REORDER_BUFFER_LZ4_COMPRESSION, false}, +#endif +#ifdef USE_ZSTD + {"zstd", REORDER_BUFFER_ZSTD_COMPRESSION, false}, #endif {"pglz", REORDER_BUFFER_PGLZ_COMPRESSION, false}, {"off", REORDER_BUFFER_NO_COMPRESSION, false}, diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index ea77ed1358..d3a847b770 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -19,6 +19,10 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + /* GUC support */ extern PGDLLIMPORT int logical_decoding_spill_compression; @@ -28,6 +32,7 @@ typedef enum ReorderBufferCompressionMethod REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, REORDER_BUFFER_PGLZ_COMPRESSION, + REORDER_BUFFER_ZSTD_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -39,6 +44,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, REORDER_BUFFER_STRAT_PGLZ, + REORDER_BUFFER_STRAT_ZSTD_STREAMING, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ @@ -84,6 +90,39 @@ typedef struct LZ4StreamingCompressorState { #define lz4_CanDoStreamingCompression(s) (false) #endif +#ifdef USE_ZSTD +/* + * Low compression level provides high compression speed and decent compression + * rate. Minimum level is 1, maximum is 22. + */ +#define ZSTD_COMPRESSION_LEVEL 1 + +/* + * Maximum volume of data encoded in the current ZSTD frame. When this + * threshold is reached then we close the current frame and start a new one. + */ +#define ZSTD_MAX_FRAME_SIZE (64 * 1024) + +/* + * ZSTD streaming compression/decompression handlers and buffers. + */ +typedef struct ZSTDStreamingCompressorState { + /* Compression */ + ZSTD_CCtx *zstd_c_ctx; + Size zstd_c_in_buf_size; + char *zstd_c_in_buf; + Size zstd_c_out_buf_size; + char *zstd_c_out_buf; + Size zstd_frame_size; + /* Decompression */ + ZSTD_DCtx *zstd_d_ctx; + Size zstd_d_in_buf_size; + char *zstd_d_in_buf; + Size zstd_d_out_buf_size; + char *zstd_d_out_buf; +} ZSTDStreamingCompressorState; +#endif + extern void *ReorderBufferNewCompressorState(MemoryContext context, int compression_method); extern void ReorderBufferFreeCompressorState(MemoryContext context, -- 2.43.0 [application/octet-stream] v2-0003-Fix-spill_bytes-counter.patch (2.8K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/6-v2-0003-Fix-spill_bytes-counter.patch) download | inline diff: From f80182d643b23ff2706dac87e2d0a03e31789c2d Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Sun, 23 Jun 2024 14:42:04 -0700 Subject: [PATCH 3/7] Fix spill_bytes counter The spill_bytes counter considers now the fact that decoded changes are spilled on disk compressed. --- src/backend/replication/logical/reorderbuffer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index ef2cd8bdf3..b4a42c615f 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -247,7 +247,7 @@ static void ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMe */ static void ReorderBufferCheckMemoryLimit(ReorderBuffer *rb); static void ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn); -static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); @@ -3690,6 +3690,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) XLogSegNo curOpenSegNo = 0; Size spilled = 0; Size size = txn->size; + Size spillBytes = 0; elog(DEBUG2, "spill %u changes in XID %u to disk", (uint32) txn->nentries_mem, txn->xid); @@ -3741,7 +3742,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) errmsg("could not open file \"%s\": %m", path))); } - ReorderBufferSerializeChange(rb, txn, fd, change); + spillBytes += ReorderBufferSerializeChange(rb, txn, fd, change); dlist_delete(&change->node); ReorderBufferReturnChange(rb, change, false); @@ -3755,7 +3756,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) if (spilled) { rb->spillCount += 1; - rb->spillBytes += size; + rb->spillBytes += spillBytes; /* don't consider already serialized transactions */ rb->spillTxns += (rbtxn_is_serialized(txn) || rbtxn_is_serialized_clear(txn)) ? 0 : 1; @@ -3776,7 +3777,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) /* * Serialize individual change to disk. */ -static void +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { @@ -3989,6 +3990,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; + + /* Return data size written to disk */ + return disk_hdr->size; } /* Returns true, if the output plugin supports streaming, false, otherwise. */ -- 2.43.0 [application/octet-stream] v2-0007-WIP-Add-the-subscription-option-spill_compression.patch (51.5K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/7-v2-0007-WIP-Add-the-subscription-option-spill_compression.patch) download | inline diff: From a77ec048092ccca0ce574f3ad6c8649d48faad01 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Mon, 15 Jul 2024 03:07:38 -0700 Subject: [PATCH 7/7] WIP Add the subscription option spill_compression --- src/backend/catalog/pg_subscription.c | 10 ++ src/backend/catalog/system_views.sql | 3 +- src/backend/commands/subscriptioncmds.c | 37 ++++- src/bin/pg_dump/pg_dump.c | 21 ++- src/bin/pg_dump/pg_dump.h | 1 + src/bin/pg_dump/t/002_pg_dump.pl | 8 +- src/bin/psql/describe.c | 7 +- src/include/catalog/pg_subscription.h | 4 + src/test/regress/expected/subscription.out | 157 +++++++++++---------- src/test/regress/sql/subscription.sql | 4 + 10 files changed, 166 insertions(+), 86 deletions(-) diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 9efc9159f2..b0a08254db 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -110,6 +110,16 @@ GetSubscription(Oid subid, bool missing_ok) /* Is the subscription owner a superuser? */ sub->ownersuperuser = superuser_arg(sub->owner); + /* Get splillcompression */ + datum = SysCacheGetAttr(SUBSCRIPTIONOID, + tup, + Anum_pg_subscription_subspillcompression, + &isnull); + if (!isnull) + sub->spillcompression = TextDatumGetCString(datum); + else + sub->spillcompression = NULL; + ReleaseSysCache(tup); return sub; diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 19cabc9a47..c84c283b9f 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1356,7 +1356,8 @@ REVOKE ALL ON pg_subscription FROM public; GRANT SELECT (oid, subdbid, subskiplsn, subname, subowner, subenabled, subbinary, substream, subtwophasestate, subdisableonerr, subpasswordrequired, subrunasowner, subfailover, - subslotname, subsynccommit, subpublications, suborigin) + subslotname, subsynccommit, subpublications, suborigin, + subspillcompression) ON pg_subscription TO public; CREATE VIEW pg_stat_subscription_stats AS diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 16d83b3253..a19b256d96 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -72,6 +72,7 @@ #define SUBOPT_FAILOVER 0x00002000 #define SUBOPT_LSN 0x00004000 #define SUBOPT_ORIGIN 0x00008000 +#define SUBOPT_SPILL_COMPRESSION 0x00010000 /* check if the 'val' has 'bits' set */ #define IsSet(val, bits) (((val) & (bits)) == (bits)) @@ -99,6 +100,7 @@ typedef struct SubOpts bool failover; char *origin; XLogRecPtr lsn; + char *spill_compression; } SubOpts; static List *fetch_table_list(WalReceiverConn *wrconn, List *publications); @@ -366,6 +368,24 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, opts->specified_opts |= SUBOPT_LSN; opts->lsn = lsn; } + else if (IsSet(supported_opts, SUBOPT_SPILL_COMPRESSION) && + strcmp(defel->defname, "spill_compression") == 0) + { + if (IsSet(opts->specified_opts, SUBOPT_SPILL_COMPRESSION)) + errorConflictingDefElem(defel, pstate); + + opts->specified_opts |= SUBOPT_SPILL_COMPRESSION; + opts->spill_compression = defGetString(defel); + + /* + * Test if the given value is valid for + * logical_decoding_spill_compression GUC. + */ + (void) set_config_option("logical_decoding_spill_compression", + opts->spill_compression, PGC_BACKEND, + PGC_S_TEST, GUC_ACTION_SET, false, 0, + false); + } else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -603,7 +623,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | SUBOPT_STREAMING | SUBOPT_TWOPHASE_COMMIT | SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | - SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN); + SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN | + SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); /* @@ -723,6 +744,11 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, publicationListToArray(publications); values[Anum_pg_subscription_suborigin - 1] = CStringGetTextDatum(opts.origin); + if (opts.spill_compression) + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); + else + nulls[Anum_pg_subscription_subspillcompression - 1] = true; tup = heap_form_tuple(RelationGetDescr(rel), values, nulls); @@ -1148,7 +1174,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, SUBOPT_STREAMING | SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | - SUBOPT_ORIGIN); + SUBOPT_ORIGIN | SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); @@ -1265,6 +1291,13 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, replaces[Anum_pg_subscription_suborigin - 1] = true; } + if (opts.spill_compression) + { + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); + replaces[Anum_pg_subscription_subspillcompression - 1] = true; + } + update_tuple = true; break; } diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b8b1888bd3..aed50f1674 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -4760,6 +4760,7 @@ getSubscriptions(Archive *fout) int i_suboriginremotelsn; int i_subenabled; int i_subfailover; + int i_subspillcompression; int i, ntups; @@ -4832,10 +4833,17 @@ getSubscriptions(Archive *fout) if (fout->remoteVersion >= 170000) appendPQExpBufferStr(query, - " s.subfailover\n"); + " s.subfailover,\n"); else appendPQExpBuffer(query, - " false AS subfailover\n"); + " false AS subfailover,\n"); + + if (fout->remoteVersion >= 180000) + appendPQExpBufferStr(query, + " s.subspillcompression\n"); + else + appendPQExpBuffer(query, + " 'off' AS subspillcompression\n"); appendPQExpBufferStr(query, "FROM pg_subscription s\n"); @@ -4875,6 +4883,7 @@ getSubscriptions(Archive *fout) i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn"); i_subenabled = PQfnumber(res, "subenabled"); i_subfailover = PQfnumber(res, "subfailover"); + i_subspillcompression = PQfnumber(res, "subspillcompression"); subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo)); @@ -4921,6 +4930,11 @@ getSubscriptions(Archive *fout) pg_strdup(PQgetvalue(res, i, i_subenabled)); subinfo[i].subfailover = pg_strdup(PQgetvalue(res, i, i_subfailover)); + if (PQgetisnull(res, i, i_subspillcompression)) + subinfo[i].subspillcompression = NULL; + else + subinfo[i].subspillcompression = + pg_strdup(PQgetvalue(res, i, i_subspillcompression)); /* Decide whether we want to dump it */ selectDumpableObject(&(subinfo[i].dobj), fout); @@ -5167,6 +5181,9 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo) if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0) appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin); + if (subinfo->subspillcompression) + appendPQExpBuffer(query, ", spill_compression = %s", fmtId(subinfo->subspillcompression)); + appendPQExpBufferStr(query, ");\n"); /* diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 4b2e5870a9..12588070f4 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -671,6 +671,7 @@ typedef struct _SubscriptionInfo char *suborigin; char *suboriginremotelsn; char *subfailover; + char *subspillcompression; } SubscriptionInfo; /* diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d3dd8784d6..abf1d76d09 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2965,9 +2965,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub2 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = none);', + WITH (connect = false, origin = none, spill_compression = off);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none);\E + \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none, spill_compression = off);\E /xm, like => { %full_runs, section_post_data => 1, }, }, @@ -2976,9 +2976,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub3 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = any);', + WITH (connect = false, origin = any, spill_compression = pglz);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3');\E + \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', spill_compression = pglz);\E /xm, like => { %full_runs, section_post_data => 1, }, }, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7c9a1f234c..495a065849 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6539,7 +6539,7 @@ describeSubscriptions(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, - false}; + false, false}; if (pset.sversion < 100000) { @@ -6619,6 +6619,11 @@ describeSubscriptions(const char *pattern, bool verbose) appendPQExpBuffer(&buf, ", subskiplsn AS \"%s\"\n", gettext_noop("Skip LSN")); + + if (pset.sversion >= 180000) + appendPQExpBuffer(&buf, + ", subspillcompression AS \"%s\"\n", + gettext_noop("Spill files compression")); } /* Only display subscriptions in current database. */ diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h index 0aa14ec4a2..63bc527083 100644 --- a/src/include/catalog/pg_subscription.h +++ b/src/include/catalog/pg_subscription.h @@ -113,6 +113,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW /* Only publish data originating from the specified origin */ text suborigin BKI_DEFAULT(LOGICALREP_ORIGIN_ANY); + + /* Spill files compression algorithm */ + text subspillcompression BKI_FORCE_NULL; #endif } FormData_pg_subscription; @@ -157,6 +160,7 @@ typedef struct Subscription List *publications; /* List of publication names to subscribe to */ char *origin; /* Only publish data originating from the * specified origin */ + char *spillcompression; /* Spill files compression algorithm */ } Subscription; /* Disallow streaming in-progress transactions. */ diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 5c2f1ee517..5e9b55baf9 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -116,18 +116,18 @@ CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PU WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub4 SET (origin = any); \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) DROP SUBSCRIPTION regress_testsub3; @@ -145,10 +145,10 @@ ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar'; ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false); @@ -157,10 +157,10 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (password_required = true); @@ -176,10 +176,10 @@ ERROR: unrecognized subscription parameter: "create_slot" -- ok ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345'); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 | (1 row) -- ok - with lsn = NONE @@ -188,10 +188,10 @@ ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE); ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0'); ERROR: invalid WAL location (LSN): 0/0 \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 | (1 row) BEGIN; @@ -222,11 +222,16 @@ ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); ERROR: invalid value for parameter "synchronous_commit": "foobar" HINT: Available values: local, remote_write, remote_apply, on, off. +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); +ERROR: invalid value for parameter "logical_decoding_spill_compression": "foobar" +HINT: Available values: lz4, zstd, pglz, off, on. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ----------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +---------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 | off (1 row) -- rename back to keep the rest simple @@ -255,19 +260,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (binary = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) DROP SUBSCRIPTION regress_testsub; @@ -279,27 +284,27 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) -- fail - publication already exists @@ -314,10 +319,10 @@ ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refr ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false); ERROR: publication "testpub1" is already in subscription "regress_testsub" \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) -- fail - publication used more than once @@ -332,10 +337,10 @@ ERROR: publication "testpub3" is not in subscription "regress_testsub" -- ok - delete publications ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) DROP SUBSCRIPTION regress_testsub; @@ -371,10 +376,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) --fail - alter of two_phase option not supported. @@ -383,10 +388,10 @@ ERROR: unrecognized subscription parameter: "two_phase" -- but can alter streaming when two_phase enabled ALTER SUBSCRIPTION regress_testsub SET (streaming = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -396,10 +401,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -412,18 +417,18 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 3e5ba4cb8c..2d891b2c06 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -140,6 +140,10 @@ ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo; ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); + \dRs+ -- rename back to keep the rest simple -- 2.43.0 [application/octet-stream] v2-0006-Add-ReorderBuffer-ondisk-compression-tests.patch (5.0K, ../../CAFEQCbF6fi7wKRwrS58nY1BUZaVdgYOPJah08o_SDGQUvRyEyw@mail.gmail.com/8-v2-0006-Add-ReorderBuffer-ondisk-compression-tests.patch) download | inline diff: From 78564cd0731586c99ce579b0c6f1b7eba76da06c Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Sat, 6 Jul 2024 07:51:54 -0700 Subject: [PATCH 6/7] Add ReorderBuffer ondisk compression tests --- src/test/subscription/Makefile | 2 + src/test/subscription/meson.build | 7 +- .../t/034_reorderbuffer_compression.pl | 100 ++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/test/subscription/t/034_reorderbuffer_compression.pl diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile index ce1ca43009..9341f1493c 100644 --- a/src/test/subscription/Makefile +++ b/src/test/subscription/Makefile @@ -16,6 +16,8 @@ include $(top_builddir)/src/Makefile.global EXTRA_INSTALL = contrib/hstore export with_icu +export with_lz4 +export with_zstd check: $(prove_check) diff --git a/src/test/subscription/meson.build b/src/test/subscription/meson.build index c591cd7d61..772eeb817f 100644 --- a/src/test/subscription/meson.build +++ b/src/test/subscription/meson.build @@ -5,7 +5,11 @@ tests += { 'sd': meson.current_source_dir(), 'bd': meson.current_build_dir(), 'tap': { - 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + 'env': { + 'with_icu': icu.found() ? 'yes' : 'no', + 'with_lz4': lz4.found() ? 'yes' : 'no', + 'with_zstd': zstd.found() ? 'yes' : 'no', + }, 'tests': [ 't/001_rep_changes.pl', 't/002_types.pl', @@ -40,6 +44,7 @@ tests += { 't/031_column_list.pl', 't/032_subscribe_use_index.pl', 't/033_run_as_table_owner.pl', + 't/034_reorderbuffer_compression.pl', 't/100_bugs.pl', ], }, diff --git a/src/test/subscription/t/034_reorderbuffer_compression.pl b/src/test/subscription/t/034_reorderbuffer_compression.pl new file mode 100644 index 0000000000..4d18b4e661 --- /dev/null +++ b/src/test/subscription/t/034_reorderbuffer_compression.pl @@ -0,0 +1,100 @@ + +# Copyright (c) 2024, PostgreSQL Global Development Group + +# Test ReorderBuffer compression +use strict; +use warnings FATAL => 'all'; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +sub test_reorderbuffer_compression +{ + my ($node_publisher, $node_subscriber, $appname, $compression) = @_; + + # Set logical_decoding_spill_compression + $node_publisher->safe_psql('postgres', + "ALTER SYSTEM SET logical_decoding_spill_compression TO $compression"); + $node_publisher->reload; + + # Make sure the table is empty + $node_publisher->safe_psql('postgres', 'TRUNCATE test_tab'); + + # Reset replication slot stats + $node_publisher->safe_psql('postgres', + "SELECT pg_stat_reset_replication_slot('tap_sub')"); + + # Insert 1 million rows in the table + $node_publisher->safe_psql('postgres', + "INSERT INTO test_tab SELECT i, 'Message number #'||i::TEXT FROM generate_series(1, 1000000) as i" + ); + + $node_publisher->wait_for_catchup($appname); + + # Check if table content is replicated + my $result = + $node_subscriber->safe_psql('postgres', + "SELECT count(*) FROM test_tab"); + is($result, qq(1000000), 'check data was copied to subscriber'); + + # Check if some changes were spilled on disk + my $res_stats = + $node_publisher->safe_psql('postgres', + "SELECT spill_txns FROM pg_catalog.pg_stat_get_replication_slot('tap_sub');"); + is($res_stats, qq(1), 'check if the transaction was spilled on disk'); +} + +# Create publisher node +my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher->init(allows_streaming => 'logical'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64'); +$node_publisher->start; + +# Create subscriber node +my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); +$node_subscriber->init; +$node_subscriber->start; + +# Setup structure on publisher +$node_publisher->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup structure on subscriber +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup logical replication +my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); + +my $appname = 'tap_sub'; + +$node_subscriber->safe_psql('postgres', + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = off)" +); + +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'off'); +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'pglz'); + +SKIP: +{ + skip "LZ4 not supported by this build", 2 if ($ENV{with_lz4} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'lz4'); +} + +SKIP: +{ + skip "ZSTD not supported by this build", 2 if ($ENV{with_zstd} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'zstd'); +} + +$node_subscriber->stop; +$node_publisher->stop; + +done_testing(); -- 2.43.0 ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-15 19:28 Tomas Vondra <[email protected]> parent: Julien Tachoires <[email protected]> 0 siblings, 2 replies; 112+ messages in thread From: Tomas Vondra @ 2024-07-15 19:28 UTC (permalink / raw) To: Julien Tachoires <[email protected]>; +Cc: [email protected] On 7/15/24 20:50, Julien Tachoires wrote: > Hi, > > Le ven. 7 juin 2024 à 06:18, Julien Tachoires <[email protected]> a écrit : >> >> Le ven. 7 juin 2024 à 05:59, Tomas Vondra >> <[email protected]> a écrit : >>> >>> On 6/6/24 12:58, Julien Tachoires wrote: >>>> ... >>>> >>>> When compiled with LZ4 support (--with-lz4), this patch enables data >>>> compression/decompression of these temporary files. Each transaction >>>> change that must be written on disk (ReorderBufferDiskChange) is now >>>> compressed and encapsulated in a new structure. >>>> >>> >>> I'm a bit confused, but why tie this to having lz4? Why shouldn't this >>> be supported even for pglz, or whatever algorithms we add in the future? >> >> That's right, reworking this patch in that sense. > > Please find a new version of this patch adding support for LZ4, pglz > and ZSTD. It introduces the new GUC logical_decoding_spill_compression > which is used to set the compression method. In order to stay aligned > with the other server side GUCs related to compression methods > (wal_compression, default_toast_compression), the compression level is > not exposed to users. > Sounds reasonable. I wonder if it might be useful to allow specifying the compression level in those places, but that's clearly not something this patch needs to do. > The last patch of this set is still in WIP, it adds the machinery > required for setting the compression methods as a subscription option: > CREATE SUBSCRIPTION ... WITH (spill_compression = ...); > I think there is a major problem with this approach: the logical > decoding context is tied to one replication slot, but multiple > subscriptions can use the same replication slot. How should this work > if 2 subscriptions want to use the same replication slot but different > compression methods? > Do we really support multiple subscriptions sharing the same slot? I don't think we do, but maybe I'm missing something. > At this point, compression is only available for the changes spilled > on disk. It is still not clear to me if the compression of data > transiting through the streaming protocol should be addressed by this > patch set or by another one. Thought ? > I'd stick to only compressing the data spilled to disk. It might be useful to compress the streamed data too, but why shouldn't we compress the regular (non-streamed) transactions too? Yeah, it's more efficient to compress larger chunks, but we can fit quite large transactions into logical_decoding_work_mem without spilling. FWIW I'd expect that to be handled at the libpq level - there's already a patch for that, but I haven't checked if it would handle this. But maybe more importantly, I think compressing streamed data might need to handle some sort of negotiation of the compression algorithm, which seems fairly complex. To conclude, I'd leave this out of scope for this patch. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-16 08:08 Julien Tachoires <[email protected]> parent: Tomas Vondra <[email protected]> 1 sibling, 0 replies; 112+ messages in thread From: Julien Tachoires @ 2024-07-16 08:08 UTC (permalink / raw) To: Tomas Vondra <[email protected]>; +Cc: [email protected] Le lun. 15 juil. 2024 à 12:28, Tomas Vondra <[email protected]> a écrit : > > On 7/15/24 20:50, Julien Tachoires wrote: > > The last patch of this set is still in WIP, it adds the machinery > > required for setting the compression methods as a subscription option: > > CREATE SUBSCRIPTION ... WITH (spill_compression = ...); > > I think there is a major problem with this approach: the logical > > decoding context is tied to one replication slot, but multiple > > subscriptions can use the same replication slot. How should this work > > if 2 subscriptions want to use the same replication slot but different > > compression methods? > > > > Do we really support multiple subscriptions sharing the same slot? I > don't think we do, but maybe I'm missing something. You are right, it's not supported, the following error is raised in this case: ERROR: replication slot "sub1" is active for PID 51735 I was distracted by the fact that nothing prevents the configuration of multiple subscriptions sharing the same replication slot. Thanks, JT ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-16 12:52 Amit Kapila <[email protected]> parent: Tomas Vondra <[email protected]> 1 sibling, 1 reply; 112+ messages in thread From: Amit Kapila @ 2024-07-16 12:52 UTC (permalink / raw) To: Tomas Vondra <[email protected]>; +Cc: Julien Tachoires <[email protected]>; [email protected] On Tue, Jul 16, 2024 at 12:58 AM Tomas Vondra <[email protected]> wrote: > > On 7/15/24 20:50, Julien Tachoires wrote: > > Hi, > > > > Le ven. 7 juin 2024 à 06:18, Julien Tachoires <[email protected]> a écrit : > >> > >> Le ven. 7 juin 2024 à 05:59, Tomas Vondra > >> <[email protected]> a écrit : > >>> > >>> On 6/6/24 12:58, Julien Tachoires wrote: > >>>> ... > >>>> > >>>> When compiled with LZ4 support (--with-lz4), this patch enables data > >>>> compression/decompression of these temporary files. Each transaction > >>>> change that must be written on disk (ReorderBufferDiskChange) is now > >>>> compressed and encapsulated in a new structure. > >>>> > >>> > >>> I'm a bit confused, but why tie this to having lz4? Why shouldn't this > >>> be supported even for pglz, or whatever algorithms we add in the future? > >> > >> That's right, reworking this patch in that sense. > > > > Please find a new version of this patch adding support for LZ4, pglz > > and ZSTD. It introduces the new GUC logical_decoding_spill_compression > > which is used to set the compression method. In order to stay aligned > > with the other server side GUCs related to compression methods > > (wal_compression, default_toast_compression), the compression level is > > not exposed to users. > > > > Sounds reasonable. I wonder if it might be useful to allow specifying > the compression level in those places, but that's clearly not something > this patch needs to do. > > > The last patch of this set is still in WIP, it adds the machinery > > required for setting the compression methods as a subscription option: > > CREATE SUBSCRIPTION ... WITH (spill_compression = ...); > > I think there is a major problem with this approach: the logical > > decoding context is tied to one replication slot, but multiple > > subscriptions can use the same replication slot. How should this work > > if 2 subscriptions want to use the same replication slot but different > > compression methods? > > > > Do we really support multiple subscriptions sharing the same slot? I > don't think we do, but maybe I'm missing something. > > > At this point, compression is only available for the changes spilled > > on disk. It is still not clear to me if the compression of data > > transiting through the streaming protocol should be addressed by this > > patch set or by another one. Thought ? > > > > I'd stick to only compressing the data spilled to disk. It might be > useful to compress the streamed data too, but why shouldn't we compress > the regular (non-streamed) transactions too? Yeah, it's more efficient > to compress larger chunks, but we can fit quite large transactions into > logical_decoding_work_mem without spilling. > > FWIW I'd expect that to be handled at the libpq level - there's already > a patch for that, but I haven't checked if it would handle this. But > maybe more importantly, I think compressing streamed data might need to > handle some sort of negotiation of the compression algorithm, which > seems fairly complex. > > To conclude, I'd leave this out of scope for this patch. > Your point sounds reasonable to me. OTOH, if we want to support compression for spill case then shouldn't there be a question how frequent such an option would be required? Users currently have an option to stream large transactions for parallel apply or otherwise in which case no spilling is required. I feel sooner or later we will make such behavior (streaming=parallel) as default, and then spilling should happen in very few cases. Is it worth adding this new option and GUC if that is true? -- With Regards, Amit Kapila. ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-16 14:01 Tomas Vondra <[email protected]> parent: Amit Kapila <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: Tomas Vondra @ 2024-07-16 14:01 UTC (permalink / raw) To: Amit Kapila <[email protected]>; +Cc: Julien Tachoires <[email protected]>; [email protected] On 7/16/24 14:52, Amit Kapila wrote: > On Tue, Jul 16, 2024 at 12:58 AM Tomas Vondra > <[email protected]> wrote: >> >> On 7/15/24 20:50, Julien Tachoires wrote: >>> Hi, >>> >>> Le ven. 7 juin 2024 à 06:18, Julien Tachoires <[email protected]> a écrit : >>>> >>>> Le ven. 7 juin 2024 à 05:59, Tomas Vondra >>>> <[email protected]> a écrit : >>>>> >>>>> On 6/6/24 12:58, Julien Tachoires wrote: >>>>>> ... >>>>>> >>>>>> When compiled with LZ4 support (--with-lz4), this patch enables data >>>>>> compression/decompression of these temporary files. Each transaction >>>>>> change that must be written on disk (ReorderBufferDiskChange) is now >>>>>> compressed and encapsulated in a new structure. >>>>>> >>>>> >>>>> I'm a bit confused, but why tie this to having lz4? Why shouldn't this >>>>> be supported even for pglz, or whatever algorithms we add in the future? >>>> >>>> That's right, reworking this patch in that sense. >>> >>> Please find a new version of this patch adding support for LZ4, pglz >>> and ZSTD. It introduces the new GUC logical_decoding_spill_compression >>> which is used to set the compression method. In order to stay aligned >>> with the other server side GUCs related to compression methods >>> (wal_compression, default_toast_compression), the compression level is >>> not exposed to users. >>> >> >> Sounds reasonable. I wonder if it might be useful to allow specifying >> the compression level in those places, but that's clearly not something >> this patch needs to do. >> >>> The last patch of this set is still in WIP, it adds the machinery >>> required for setting the compression methods as a subscription option: >>> CREATE SUBSCRIPTION ... WITH (spill_compression = ...); >>> I think there is a major problem with this approach: the logical >>> decoding context is tied to one replication slot, but multiple >>> subscriptions can use the same replication slot. How should this work >>> if 2 subscriptions want to use the same replication slot but different >>> compression methods? >>> >> >> Do we really support multiple subscriptions sharing the same slot? I >> don't think we do, but maybe I'm missing something. >> >>> At this point, compression is only available for the changes spilled >>> on disk. It is still not clear to me if the compression of data >>> transiting through the streaming protocol should be addressed by this >>> patch set or by another one. Thought ? >>> >> >> I'd stick to only compressing the data spilled to disk. It might be >> useful to compress the streamed data too, but why shouldn't we compress >> the regular (non-streamed) transactions too? Yeah, it's more efficient >> to compress larger chunks, but we can fit quite large transactions into >> logical_decoding_work_mem without spilling. >> >> FWIW I'd expect that to be handled at the libpq level - there's already >> a patch for that, but I haven't checked if it would handle this. But >> maybe more importantly, I think compressing streamed data might need to >> handle some sort of negotiation of the compression algorithm, which >> seems fairly complex. >> >> To conclude, I'd leave this out of scope for this patch. >> > > Your point sounds reasonable to me. OTOH, if we want to support > compression for spill case then shouldn't there be a question how > frequent such an option would be required? Users currently have an > option to stream large transactions for parallel apply or otherwise in > which case no spilling is required. I feel sooner or later we will > make such behavior (streaming=parallel) as default, and then spilling > should happen in very few cases. Is it worth adding this new option > and GUC if that is true? > I don't know, but streaming is 'off' by default, and I'm not aware of any proposals to change this, so when you suggest "sooner or later" we'll change this, I'd probably bet on "later or never". I haven't been following the discussions about parallel apply very closely, but my impression from dealing with similar stuff in other tools is that it's rather easy to run into issues with some workloads, which just makes me more skeptical about "streamin=parallel" by default. But as I said, I'm out of the loop so I may be wrong ... As for whether the GUC is needed, I don't know. I guess we might do the same thing we do for streaming - we don't have a GUC to enable this, but we default to 'off' and the client has to request that when opening the replication connection. So it'd be specified at the subscription level, more or less. But then how would we specify compression for cases that invoke decoding directly by pg_logical_slot_get_changes()? Through options? BTW if we specify this at subscription level, will it be possible to change the compression method? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-17 09:12 Amit Kapila <[email protected]> parent: Tomas Vondra <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: Amit Kapila @ 2024-07-17 09:12 UTC (permalink / raw) To: Tomas Vondra <[email protected]>; +Cc: Julien Tachoires <[email protected]>; [email protected] On Tue, Jul 16, 2024 at 7:31 PM Tomas Vondra <[email protected]> wrote: > > On 7/16/24 14:52, Amit Kapila wrote: > > On Tue, Jul 16, 2024 at 12:58 AM Tomas Vondra > > <[email protected]> wrote: > >> > >> FWIW I'd expect that to be handled at the libpq level - there's already > >> a patch for that, but I haven't checked if it would handle this. But > >> maybe more importantly, I think compressing streamed data might need to > >> handle some sort of negotiation of the compression algorithm, which > >> seems fairly complex. > >> > >> To conclude, I'd leave this out of scope for this patch. > >> > > > > Your point sounds reasonable to me. OTOH, if we want to support > > compression for spill case then shouldn't there be a question how > > frequent such an option would be required? Users currently have an > > option to stream large transactions for parallel apply or otherwise in > > which case no spilling is required. I feel sooner or later we will > > make such behavior (streaming=parallel) as default, and then spilling > > should happen in very few cases. Is it worth adding this new option > > and GUC if that is true? > > > > I don't know, but streaming is 'off' by default, and I'm not aware of > any proposals to change this, so when you suggest "sooner or later" > we'll change this, I'd probably bet on "later or never". > > I haven't been following the discussions about parallel apply very > closely, but my impression from dealing with similar stuff in other > tools is that it's rather easy to run into issues with some workloads, > which just makes me more skeptical about "streamin=parallel" by default. > But as I said, I'm out of the loop so I may be wrong ... > It is difficult to say whether enabling it by default will have issues or not but till now we haven't seen many reports for the streaming = 'parallel' option. It could be due to the reason that not many people enable it in their workloads. We can probably find out by enabling it by default. > As for whether the GUC is needed, I don't know. I guess we might do the > same thing we do for streaming - we don't have a GUC to enable this, but > we default to 'off' and the client has to request that when opening the > replication connection. So it'd be specified at the subscription level, > more or less. > > But then how would we specify compression for cases that invoke decoding > directly by pg_logical_slot_get_changes()? Through options? > If we decide to go with this then yeah that is one way, another possibility is to make it a slot's property, so we can allow to take a new parameter in pg_create_logical_replication_slot(). We can even think of inventing a new API to alter the slot's properties if we decide to go this route. > BTW if we specify this at subscription level, will it be possible to > change the compression method? > This needs analysis but offhand I can't see the problems with it. -- With Regards, Amit Kapila. ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-07-19 22:05 Julien Tachoires <[email protected]> parent: Amit Kapila <[email protected]> 0 siblings, 1 reply; 112+ messages in thread From: Julien Tachoires @ 2024-07-19 22:05 UTC (permalink / raw) To: Amit Kapila <[email protected]>; +Cc: Tomas Vondra <[email protected]>; [email protected] Le mer. 17 juil. 2024 à 02:12, Amit Kapila <[email protected]> a écrit : > > On Tue, Jul 16, 2024 at 7:31 PM Tomas Vondra > <[email protected]> wrote: > > > > On 7/16/24 14:52, Amit Kapila wrote: > > > On Tue, Jul 16, 2024 at 12:58 AM Tomas Vondra > > > <[email protected]> wrote: > > >> > > >> FWIW I'd expect that to be handled at the libpq level - there's already > > >> a patch for that, but I haven't checked if it would handle this. But > > >> maybe more importantly, I think compressing streamed data might need to > > >> handle some sort of negotiation of the compression algorithm, which > > >> seems fairly complex. > > >> > > >> To conclude, I'd leave this out of scope for this patch. > > >> > > > > > > Your point sounds reasonable to me. OTOH, if we want to support > > > compression for spill case then shouldn't there be a question how > > > frequent such an option would be required? Users currently have an > > > option to stream large transactions for parallel apply or otherwise in > > > which case no spilling is required. I feel sooner or later we will > > > make such behavior (streaming=parallel) as default, and then spilling > > > should happen in very few cases. Is it worth adding this new option > > > and GUC if that is true? > > > > > > > I don't know, but streaming is 'off' by default, and I'm not aware of > > any proposals to change this, so when you suggest "sooner or later" > > we'll change this, I'd probably bet on "later or never". > > > > I haven't been following the discussions about parallel apply very > > closely, but my impression from dealing with similar stuff in other > > tools is that it's rather easy to run into issues with some workloads, > > which just makes me more skeptical about "streamin=parallel" by default. > > But as I said, I'm out of the loop so I may be wrong ... > > > > It is difficult to say whether enabling it by default will have issues > or not but till now we haven't seen many reports for the streaming = > 'parallel' option. It could be due to the reason that not many people > enable it in their workloads. We can probably find out by enabling it > by default. > > > As for whether the GUC is needed, I don't know. I guess we might do the > > same thing we do for streaming - we don't have a GUC to enable this, but > > we default to 'off' and the client has to request that when opening the > > replication connection. So it'd be specified at the subscription level, > > more or less. > > > > But then how would we specify compression for cases that invoke decoding > > directly by pg_logical_slot_get_changes()? Through options? > > > > If we decide to go with this then yeah that is one way, another > possibility is to make it a slot's property, so we can allow to take a > new parameter in pg_create_logical_replication_slot(). We can even > think of inventing a new API to alter the slot's properties if we > decide to go this route. Please find a new version of this patch set. The compression method is now set on subscriber level via CREATE SUBSCRIPTION or ALTER SUBSCRIPTION and can be passed to pg_logical_slot_get_changes()/pg_logical_slot_get_binary_changes() through the option spill_compression. > > BTW if we specify this at subscription level, will it be possible to > > change the compression method? > > > > This needs analysis but offhand I can't see the problems with it. I didn't notice any issue, the compression method can be changed even when a decoding is in progress, in this case, the replication worker restart due to parameter change. JT Attachments: [application/octet-stream] v3-0002-Fix-spill_bytes-counter.patch (2.8K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/2-v3-0002-Fix-spill_bytes-counter.patch) download | inline diff: From a09269f20c7e3d273590d0f0c9d83cccdee645dc Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Sun, 23 Jun 2024 14:42:04 -0700 Subject: [PATCH 2/6] Fix spill_bytes counter The spill_bytes counter considers now the fact that decoded changes are spilled on disk compressed. --- src/backend/replication/logical/reorderbuffer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 2519f799bc..964a861bbf 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -246,7 +246,7 @@ static void ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMe */ static void ReorderBufferCheckMemoryLimit(ReorderBuffer *rb); static void ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn); -static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); @@ -3689,6 +3689,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) XLogSegNo curOpenSegNo = 0; Size spilled = 0; Size size = txn->size; + Size spillBytes = 0; elog(DEBUG2, "spill %u changes in XID %u to disk", (uint32) txn->nentries_mem, txn->xid); @@ -3740,7 +3741,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) errmsg("could not open file \"%s\": %m", path))); } - ReorderBufferSerializeChange(rb, txn, fd, change); + spillBytes += ReorderBufferSerializeChange(rb, txn, fd, change); dlist_delete(&change->node); ReorderBufferReturnChange(rb, change, false); @@ -3754,7 +3755,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) if (spilled) { rb->spillCount += 1; - rb->spillBytes += size; + rb->spillBytes += spillBytes; /* don't consider already serialized transactions */ rb->spillTxns += (rbtxn_is_serialized(txn) || rbtxn_is_serialized_clear(txn)) ? 0 : 1; @@ -3775,7 +3776,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) /* * Serialize individual change to disk. */ -static void +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { @@ -3988,6 +3989,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; + + /* Return data size written to disk */ + return disk_hdr->size; } /* Returns true, if the output plugin supports streaming, false, otherwise. */ -- 2.43.0 [application/octet-stream] v3-0004-Compress-ReorderBuffer-spill-files-using-ZSTD.patch (14.5K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/3-v3-0004-Compress-ReorderBuffer-spill-files-using-ZSTD.patch) download | inline diff: From cc267b2da6ff05860144bed0b0bac0bbd856830f Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:39:25 -0700 Subject: [PATCH 4/6] Compress ReorderBuffer spill files using ZSTD --- .../logical/reorderbuffer_compression.c | 364 ++++++++++++++++++ .../replication/reorderbuffer_compression.h | 39 ++ 2 files changed, 403 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index a05393cc61..9bda286cb8 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -19,6 +19,10 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + #include "replication/reorderbuffer_compression.h" #define NO_LZ4_SUPPORT() \ @@ -27,6 +31,12 @@ errmsg("compression method lz4 not supported"), \ errdetail("This functionality requires the server to be built with lz4 support."))) +#define NO_ZSTD_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method zstd not supported"), \ + errdetail("This functionality requires the server to be built with zstd support."))) + /* * Allocate a new LZ4StreamingCompressorState. */ @@ -303,6 +313,309 @@ lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) #endif } +/* + * Allocate a new ZSTDStreamingCompressorState. + */ +static void * +zstd_NewCompressorState(MemoryContext context) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + ZSTDStreamingCompressorState *cstate; + + cstate = (ZSTDStreamingCompressorState *) + MemoryContextAlloc(context, sizeof(ZSTDStreamingCompressorState)); + + /* + * We do not allocate ZSTD buffers and contexts at this point because we + * have no guarantee that we will need them later. Let's allocate only when + * we are about to use them. + */ + cstate->zstd_c_ctx = NULL; + cstate->zstd_c_in_buf = NULL; + cstate->zstd_c_in_buf_size = 0; + cstate->zstd_c_out_buf = NULL; + cstate->zstd_c_out_buf_size = 0; + cstate->zstd_frame_size = 0; + cstate->zstd_d_ctx = NULL; + cstate->zstd_d_in_buf = NULL; + cstate->zstd_d_in_buf_size = 0; + cstate->zstd_d_out_buf = NULL; + cstate->zstd_d_out_buf_size = 0; + + return (void *) cstate; +#endif +} + +/* + * Free ZSTD memory resources and the compressor state. + */ +static void +zstd_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + + if (cstate->zstd_c_ctx != NULL) + { + /* Compressor state was used for compression */ + pfree(cstate->zstd_c_in_buf); + pfree(cstate->zstd_c_out_buf); + ZSTD_freeCCtx(cstate->zstd_c_ctx); + } + if (cstate->zstd_d_ctx != NULL) + { + /* Compressor state was used for decompression */ + pfree(cstate->zstd_d_in_buf); + pfree(cstate->zstd_d_out_buf); + ZSTD_freeDCtx(cstate->zstd_d_ctx); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_ZSTD +/* + * Allocate ZSTD compression buffers and create the ZSTD compression context. + */ +static void +zstd_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_c_in_buf_size = ZSTD_CStreamInSize(); + cstate->zstd_c_in_buf = (char *) palloc0(cstate->zstd_c_in_buf_size); + cstate->zstd_c_out_buf_size = ZSTD_CStreamOutSize(); + cstate->zstd_c_out_buf = (char *) palloc0(cstate->zstd_c_out_buf_size); + cstate->zstd_c_ctx = ZSTD_createCCtx(); + + if (cstate->zstd_c_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD compression context"))); + + /* Set compression level */ + ZSTD_CCtx_setParameter(cstate->zstd_c_ctx, ZSTD_c_compressionLevel, + ZSTD_COMPRESSION_LEVEL); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_ZSTD +/* + * Allocate ZSTD decompression buffers and create the ZSTD decompression + * context. + */ +static void +zstd_CreateStreamDecodeCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_d_in_buf_size = ZSTD_DStreamInSize(); + cstate->zstd_d_in_buf = (char *) palloc0(cstate->zstd_d_in_buf_size); + cstate->zstd_d_out_buf_size = ZSTD_DStreamOutSize(); + cstate->zstd_d_out_buf = (char *) palloc0(cstate->zstd_d_out_buf_size); + cstate->zstd_d_ctx = ZSTD_createDCtx(); + + if (cstate->zstd_d_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD decompression context"))); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using ZSTD streaming API. + */ +static void +zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_c_ctx == NULL) + zstd_CreateStreamCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store compressed data */ + *dst = (char *) palloc0(ZSTD_compressBound(src_size)); + + dst_data = *dst; + *dst_size = 0; + + /* + * ZSTD streaming compression works with chunks: the source data needs to + * be splitted out in chunks, each of them is then copied into ZSTD input + * buffer. + * For each chunk, we proceed with compression. Streaming compression is + * not intended to compress the whole input chunk, so we have the call + * ZSTD_compressStream2() multiple times until the entire chunk is + * consumed. + */ + while (toCpy > 0) + { + /* Are we on the last chunk? */ + bool last_chunk = (toCpy < cstate->zstd_c_in_buf_size); + /* Size of the data copied into ZSTD input buffer */ + Size cpySize = last_chunk ? toCpy : cstate->zstd_c_in_buf_size; + bool finished = false; + ZSTD_inBuffer input; + ZSTD_EndDirective mode = last_chunk ? ZSTD_e_flush : ZSTD_e_continue; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_c_in_buf, src, cpySize); + + /* + * Close the frame when we are on the last chunk and we've reached max + * frame size. + */ + if (last_chunk && (cstate->zstd_frame_size > ZSTD_MAX_FRAME_SIZE)) + { + mode = ZSTD_e_end; + cstate->zstd_frame_size = 0; + } + + cstate->zstd_frame_size += cpySize; + + input.src = cstate->zstd_c_in_buf; + input.size = cpySize; + input.pos = 0; + + do + { + Size remaining; + ZSTD_outBuffer output; + + output.dst = cstate->zstd_c_out_buf; + output.size = cstate->zstd_c_out_buf_size; + output.pos = 0; + + remaining = ZSTD_compressStream2(cstate->zstd_c_ctx, &output, + &input, mode); + + if (ZSTD_isError(remaining)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD compression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_c_out_buf, output.pos); + + dst_data += output.pos; + *dst_size += output.pos; + + /* + * Compression is done when we are working on the last chunk and + * there is nothing left to compress, or, when we reach the end of + * the chunk. + */ + finished = last_chunk ? (remaining == 0) : (input.pos == input.size); + } while (!finished); + + src += cpySize; + toCpy -= cpySize; + } +#endif +} + +/* + * Data decompression using ZSTD streaming API. + */ +static void +zstd_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + Size decBytes = 0; /* Size of decompressed data */ + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_d_ctx == NULL) + zstd_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store decompressed data */ + *dst = (char *) palloc0(dst_size); + + dst_data = *dst; + + while (toCpy > 0) + { + ZSTD_inBuffer input; + Size cpySize = (toCpy > cstate->zstd_d_in_buf_size) ? cstate->zstd_d_in_buf_size : toCpy; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_d_in_buf, src, cpySize); + + input.src = cstate->zstd_d_in_buf; + input.size = cpySize; + input.pos = 0; + + while (input.pos < input.size) + { + ZSTD_outBuffer output; + Size ret; + + output.dst = cstate->zstd_d_out_buf; + output.size = cstate->zstd_d_out_buf_size; + output.pos = 0; + + ret = ZSTD_decompressStream(cstate->zstd_d_ctx, &output , &input); + + if (ZSTD_isError(ret)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD decompression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_d_out_buf, output.pos); + + dst_data += output.pos; + decBytes += output.pos; + } + + src += cpySize; + toCpy -= cpySize; + } + + Assert(dst_size == decBytes); +#endif +} + /* * Allocate a new Compressor State, depending on the compression method. */ @@ -314,6 +627,9 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_NewCompressorState(context); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_NewCompressorState(context); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -335,6 +651,9 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_FreeCompressorState(context, compressor_state); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_FreeCompressorState(context, compressor_state); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -459,6 +778,35 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* ZSTD Compression */ + case REORDER_BUFFER_ZSTD_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + + /* Use ZSTD streaming compression */ + zstd_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_ZSTD_STREAMING; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -553,6 +901,22 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, errmsg_internal("compressed PGLZ data is corrupted"))); break; } + /* ZSTD streaming decompression */ + case REORDER_BUFFER_STRAT_ZSTD_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + zstd_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + pfree(buf); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 5abc875ac4..b668f33d5a 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -19,12 +19,17 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + /* ReorderBuffer on disk compression algorithms */ typedef enum ReorderBufferCompressionMethod { REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, REORDER_BUFFER_PGLZ_COMPRESSION, + REORDER_BUFFER_ZSTD_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -36,6 +41,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, REORDER_BUFFER_STRAT_PGLZ, + REORDER_BUFFER_STRAT_ZSTD_STREAMING, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ @@ -81,6 +87,39 @@ typedef struct LZ4StreamingCompressorState { #define lz4_CanDoStreamingCompression(s) (false) #endif +#ifdef USE_ZSTD +/* + * Low compression level provides high compression speed and decent compression + * rate. Minimum level is 1, maximum is 22. + */ +#define ZSTD_COMPRESSION_LEVEL 1 + +/* + * Maximum volume of data encoded in the current ZSTD frame. When this + * threshold is reached then we close the current frame and start a new one. + */ +#define ZSTD_MAX_FRAME_SIZE (64 * 1024) + +/* + * ZSTD streaming compression/decompression handlers and buffers. + */ +typedef struct ZSTDStreamingCompressorState { + /* Compression */ + ZSTD_CCtx *zstd_c_ctx; + Size zstd_c_in_buf_size; + char *zstd_c_in_buf; + Size zstd_c_out_buf_size; + char *zstd_c_out_buf; + Size zstd_frame_size; + /* Decompression */ + ZSTD_DCtx *zstd_d_ctx; + Size zstd_d_in_buf_size; + char *zstd_d_in_buf; + Size zstd_d_out_buf_size; + char *zstd_d_out_buf; +} ZSTDStreamingCompressorState; +#endif + extern void *ReorderBufferNewCompressorState(MemoryContext context, int compression_method); extern void ReorderBufferFreeCompressorState(MemoryContext context, -- 2.43.0 [application/octet-stream] v3-0003-Compress-ReorderBuffer-spill-files-using-PGLZ.patch (4.1K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/4-v3-0003-Compress-ReorderBuffer-spill-files-using-PGLZ.patch) download | inline diff: From ef6ad37d547e158f11b4fc73439ebcd9c9bd253f Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:36:04 -0700 Subject: [PATCH 3/6] Compress ReorderBuffer spill files using PGLZ --- .../logical/reorderbuffer_compression.c | 58 +++++++++++++++++++ .../replication/reorderbuffer_compression.h | 2 + 2 files changed, 60 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 77f5c76929..a05393cc61 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -13,6 +13,8 @@ */ #include "postgres.h" +#include "common/pg_lzcompress.h" + #ifdef USE_LZ4 #include <lz4.h> #endif @@ -313,6 +315,7 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) return lz4_NewCompressorState(context); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: return NULL; break; @@ -333,6 +336,7 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, return lz4_FreeCompressorState(context, compressor_state); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: break; } @@ -421,6 +425,40 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* PGLZ compression */ + case REORDER_BUFFER_PGLZ_COMPRESSION: + { + int32 dst_size = 0; + char *dst = NULL; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + int32 src_size = data_size - sizeof(ReorderBufferDiskHeader); + int32 max_size = PGLZ_MAX_OUTPUT(src_size); + + dst = (char *) palloc0(max_size); + dst_size = pglz_compress(src, src_size, dst, PGLZ_strategy_always); + + if (dst_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("PGLZ compression failed"))); + + ReorderBufferReserve(rb, (Size) (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_PGLZ; + hdr->size = (Size) dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = (Size) src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -495,6 +533,26 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, */ break; } + /* PGLZ decompression */ + case REORDER_BUFFER_STRAT_PGLZ: + { + char *buf; + int32 src_size = (int32) header->size - sizeof(ReorderBufferDiskHeader); + int32 buf_size = (int32) header->raw_size; + int32 decBytes; + + /* Decompress data directly into the ReorderBuffer */ + buf = (char *) rb->outbuf; + buf += sizeof(ReorderBufferDiskHeader); + + decBytes = pglz_decompress(data, src_size, buf, buf_size, false); + + if (decBytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed PGLZ data is corrupted"))); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 9aa8aea56f..5abc875ac4 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -24,6 +24,7 @@ typedef enum ReorderBufferCompressionMethod { REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, + REORDER_BUFFER_PGLZ_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -34,6 +35,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_UNCOMPRESSED, REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, + REORDER_BUFFER_STRAT_PGLZ, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ -- 2.43.0 [application/octet-stream] v3-0005-Add-the-subscription-option-spill_compression.patch (67.4K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/5-v3-0005-Add-the-subscription-option-spill_compression.patch) download | inline diff: From bca6a7c9e2b09638376d179452863006d1ebc20f Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:45:43 -0700 Subject: [PATCH 5/6] Add the subscription option spill_compression --- doc/src/sgml/ref/alter_subscription.sgml | 5 +- doc/src/sgml/ref/create_subscription.sgml | 24 +++ src/backend/catalog/pg_subscription.c | 6 + src/backend/catalog/system_views.sql | 3 +- src/backend/commands/subscriptioncmds.c | 31 +++- .../libpqwalreceiver/libpqwalreceiver.c | 5 + src/backend/replication/logical/logical.c | 4 + .../replication/logical/reorderbuffer.c | 15 +- .../logical/reorderbuffer_compression.c | 57 +++++++ src/backend/replication/logical/worker.c | 13 +- src/backend/replication/pgoutput/pgoutput.c | 28 ++++ src/bin/pg_dump/pg_dump.c | 18 +- src/bin/pg_dump/pg_dump.h | 1 + src/bin/pg_dump/t/002_pg_dump.pl | 8 +- src/bin/psql/describe.c | 7 +- src/bin/psql/tab-complete.c | 5 +- src/include/catalog/pg_subscription.h | 4 + src/include/replication/logical.h | 2 + src/include/replication/pgoutput.h | 1 + .../replication/reorderbuffer_compression.h | 4 + src/include/replication/walreceiver.h | 1 + src/test/regress/expected/subscription.out | 156 +++++++++--------- src/test/regress/sql/subscription.sql | 4 + 23 files changed, 308 insertions(+), 94 deletions(-) diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 476f195622..44df09b854 100644 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -228,8 +228,9 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < <link linkend="sql-createsubscription-params-with-disable-on-error"><literal>disable_on_error</literal></link>, <link linkend="sql-createsubscription-params-with-password-required"><literal>password_required</literal></link>, <link linkend="sql-createsubscription-params-with-run-as-owner"><literal>run_as_owner</literal></link>, - <link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>, and - <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>. + <link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>, + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>, and + <link linkend="sql-createsubscription-params-with-spill-compression"><literal>spill_compression</literal></link>. Only a superuser can set <literal>password_required = false</literal>. </para> diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index 740b7d9421..56f733eaf8 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -428,6 +428,30 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl </para> </listitem> </varlistentry> + + <varlistentry id="sql-createsubscription-params-with-spill-compression"> + <term><literal>spill_compression</literal> (<type>enum</type>)</term> + <listitem> + <para> + Specifies whether the decoded changes that eventually need to be + temporarily written on disk by the publisher are compressed or not. + Default value is <literal>off</literal> meaning no data compression + involved. Setting <literal>spill_compression</literal> to + <literal>on</literal> or <literal>pglz</literal> means that the + decoded changes are compressed using the internal + <literal>PGLZ</literal> compression algorithm. + </para> + + <para> + If the <productname>PostgreSQL</productname> server running the + publisher node supports the external compression libraries + <productname>LZ4</productname> or + <productname>Zstandard</productname>, + <literal>spill_compression</literal> can be set respectively to + <literal>lz4</literal> or <literal>zstd</literal>. + </para> + </listitem> + </varlistentry> </variablelist></para> </listitem> diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 9efc9159f2..a3329043dc 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -110,6 +110,12 @@ GetSubscription(Oid subid, bool missing_ok) /* Is the subscription owner a superuser? */ sub->ownersuperuser = superuser_arg(sub->owner); + /* Get spill_compression */ + datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID, + tup, + Anum_pg_subscription_subspillcompression); + sub->spill_compression = TextDatumGetCString(datum); + ReleaseSysCache(tup); return sub; diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 19cabc9a47..c84c283b9f 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1356,7 +1356,8 @@ REVOKE ALL ON pg_subscription FROM public; GRANT SELECT (oid, subdbid, subskiplsn, subname, subowner, subenabled, subbinary, substream, subtwophasestate, subdisableonerr, subpasswordrequired, subrunasowner, subfailover, - subslotname, subsynccommit, subpublications, suborigin) + subslotname, subsynccommit, subpublications, suborigin, + subspillcompression) ON pg_subscription TO public; CREATE VIEW pg_stat_subscription_stats AS diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 16d83b3253..b2d35eac53 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -39,6 +39,7 @@ #include "replication/logicallauncher.h" #include "replication/logicalworker.h" #include "replication/origin.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/walreceiver.h" #include "replication/walsender.h" @@ -72,6 +73,7 @@ #define SUBOPT_FAILOVER 0x00002000 #define SUBOPT_LSN 0x00004000 #define SUBOPT_ORIGIN 0x00008000 +#define SUBOPT_SPILL_COMPRESSION 0x00010000 /* check if the 'val' has 'bits' set */ #define IsSet(val, bits) (((val) & (bits)) == (bits)) @@ -99,6 +101,7 @@ typedef struct SubOpts bool failover; char *origin; XLogRecPtr lsn; + char *spill_compression; } SubOpts; static List *fetch_table_list(WalReceiverConn *wrconn, List *publications); @@ -161,6 +164,8 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, opts->failover = false; if (IsSet(supported_opts, SUBOPT_ORIGIN)) opts->origin = pstrdup(LOGICALREP_ORIGIN_ANY); + if (IsSet(supported_opts, SUBOPT_SPILL_COMPRESSION)) + opts->spill_compression = "off"; /* Parse options */ foreach(lc, stmt_options) @@ -366,6 +371,18 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, opts->specified_opts |= SUBOPT_LSN; opts->lsn = lsn; } + else if (IsSet(supported_opts, SUBOPT_SPILL_COMPRESSION) && + strcmp(defel->defname, "spill_compression") == 0) + { + if (IsSet(opts->specified_opts, SUBOPT_SPILL_COMPRESSION)) + errorConflictingDefElem(defel, pstate); + + opts->specified_opts |= SUBOPT_SPILL_COMPRESSION; + opts->spill_compression = defGetString(defel); + + ReorderBufferValidateCompressionMethod(opts->spill_compression, + ERROR); + } else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -603,7 +620,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | SUBOPT_STREAMING | SUBOPT_TWOPHASE_COMMIT | SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | - SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN); + SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN | + SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); /* @@ -723,6 +741,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, publicationListToArray(publications); values[Anum_pg_subscription_suborigin - 1] = CStringGetTextDatum(opts.origin); + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); tup = heap_form_tuple(RelationGetDescr(rel), values, nulls); @@ -1148,7 +1168,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, SUBOPT_STREAMING | SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | - SUBOPT_ORIGIN); + SUBOPT_ORIGIN | SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); @@ -1265,6 +1285,13 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, replaces[Anum_pg_subscription_suborigin - 1] = true; } + if (IsSet(opts.specified_opts, SUBOPT_SPILL_COMPRESSION)) + { + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); + replaces[Anum_pg_subscription_subspillcompression - 1] = true; + } + update_tuple = true; break; } diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 6c42c209d2..fda751da14 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -620,6 +620,11 @@ libpqrcv_startstreaming(WalReceiverConn *conn, PQserverVersion(conn->streamConn) >= 140000) appendStringInfoString(&cmd, ", binary 'true'"); + if (options->proto.logical.spill_compression && + PQserverVersion(conn->streamConn) >= 180000) + appendStringInfo(&cmd, ", spill_compression '%s'", + options->proto.logical.spill_compression); + appendStringInfoChar(&cmd, ')'); } else diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index f8ef5d56d2..05eae65cca 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -36,6 +36,7 @@ #include "replication/decode.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slotsync.h" #include "replication/snapbuild.h" #include "storage/proc.h" @@ -298,6 +299,9 @@ StartupDecodingContext(List *output_plugin_options, ctx->fast_forward = fast_forward; + /* No spill files compression by default */ + ctx->spill_compression_method = REORDER_BUFFER_NO_COMPRESSION; + MemoryContextSwitchTo(old_context); return ctx; diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 964a861bbf..328c26e994 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -404,6 +404,15 @@ ReorderBufferFree(ReorderBuffer *rb) ReorderBufferCleanupSerializedTXNs(NameStr(MyReplicationSlot->data.name)); } +/* Returns spill files compression method */ +static inline uint8 +ReorderBufferSpillCompressionMethod(ReorderBuffer *rb) +{ + LogicalDecodingContext *ctx = rb->private_data; + + return ctx->spill_compression_method; +} + /* * Get an unused, possibly preallocated, ReorderBufferTXN. */ @@ -425,7 +434,7 @@ ReorderBufferGetTXN(ReorderBuffer *rb) txn->command_id = InvalidCommandId; txn->output_plugin_private = NULL; txn->compressor_state = ReorderBufferNewCompressorState(rb->context, - logical_decoding_spill_compression); + ReorderBufferSpillCompressionMethod(rb)); return txn; } @@ -464,7 +473,7 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) } ReorderBufferFreeCompressorState(rb->context, - logical_decoding_spill_compression, + ReorderBufferSpillCompressionMethod(rb), txn->compressor_state); /* Reset the toast hash */ @@ -3958,7 +3967,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* Inplace ReorderBuffer content compression before writing it on disk */ - ReorderBufferCompress(rb, &disk_hdr, logical_decoding_spill_compression, + ReorderBufferCompress(rb, &disk_hdr, ReorderBufferSpillCompressionMethod(rb), sz, txn->compressor_state); errno = 0; diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 9bda286cb8..bf0d206095 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -922,3 +922,60 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, break; } } + +/* + * According to a given compression method (as string representation), returns + * the corresponding ReorderBufferCompressionMethod + */ +ReorderBufferCompressionMethod +ReorderBufferParseCompressionMethod(const char *method) +{ + if (pg_strcasecmp(method, "on") == 0) + return REORDER_BUFFER_PGLZ_COMPRESSION; + else if (pg_strcasecmp(method, "pglz") == 0) + return REORDER_BUFFER_PGLZ_COMPRESSION; + else if (pg_strcasecmp(method, "off") == 0) + return REORDER_BUFFER_NO_COMPRESSION; +#ifdef USE_LZ4 + else if (pg_strcasecmp(method, "lz4") == 0) + return REORDER_BUFFER_LZ4_COMPRESSION; +#endif +#ifdef USE_ZSTD + else if (pg_strcasecmp(method, "zstd") == 0) + return REORDER_BUFFER_ZSTD_COMPRESSION; +#endif + else + return REORDER_BUFFER_INVALID_COMPRESSION; +} + +/* + * Check whether the passed compression method is valid and report errors at + * elevel. + * + * As this validation is intended to be executed on subscriber side, then we + * actually don't know if the server running the publisher supports external + * compression libraries. We only check if the compression method is + * potentially supported. The real validation is done by the publisher when + * the replication starts, an error is then triggered if the compression method + * is not supported. + */ +void +ReorderBufferValidateCompressionMethod(const char *method, int elevel) +{ + bool valid = false; + char methods[5][5] = {"on", "off", "pglz", "lz4", "zstd"}; + + for (int i = 0; i < 5; i++) + { + if (pg_strcasecmp(method, methods[i]) == 0) + { + valid = true; + break; + } + } + + if (!valid) + ereport(elevel, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("compression method \"%s\" not valid", method))); +} diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index c0bda6269b..dea3be009a 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -3929,7 +3929,8 @@ maybe_reread_subscription(void) newsub->passwordrequired != MySubscription->passwordrequired || strcmp(newsub->origin, MySubscription->origin) != 0 || newsub->owner != MySubscription->owner || - !equal(newsub->publications, MySubscription->publications)) + !equal(newsub->publications, MySubscription->publications) || + strcmp(newsub->spill_compression, MySubscription->spill_compression) != 0) { if (am_parallel_apply_worker()) ereport(LOG, @@ -4377,6 +4378,16 @@ set_stream_options(WalRcvStreamOptions *options, MyLogicalRepWorker->parallel_apply = false; } + if (server_version >= 180000 && + MySubscription->stream == LOGICALREP_STREAM_OFF && + MySubscription->spill_compression != NULL) + { + options->proto.logical.spill_compression = + pstrdup(MySubscription->spill_compression); + } + else + options->proto.logical.spill_compression = NULL; + options->proto.logical.twophase = false; options->proto.logical.origin = pstrdup(MySubscription->origin); } diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index abef4eaf68..d9469f45f6 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -27,6 +27,7 @@ #include "replication/logicalproto.h" #include "replication/origin.h" #include "replication/pgoutput.h" +#include "replication/reorderbuffer_compression.h" #include "utils/builtins.h" #include "utils/inval.h" #include "utils/lsyscache.h" @@ -283,11 +284,13 @@ parse_output_parameters(List *options, PGOutputData *data) bool streaming_given = false; bool two_phase_option_given = false; bool origin_option_given = false; + bool spill_compression_option_given = false; data->binary = false; data->streaming = LOGICALREP_STREAM_OFF; data->messages = false; data->two_phase = false; + data->spill_compression_method = REORDER_BUFFER_NO_COMPRESSION; foreach(lc, options) { @@ -396,6 +399,28 @@ parse_output_parameters(List *options, PGOutputData *data) errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized origin value: \"%s\"", origin)); } + else if (strcmp(defel->defname, "spill_compression") == 0) + { + uint8 method; + char *method_str; + + if (spill_compression_option_given) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("conflicting or redundant options"))); + spill_compression_option_given = true; + + method_str = defGetString(defel); + method = ReorderBufferParseCompressionMethod(method_str); + + if (method == REORDER_BUFFER_INVALID_COMPRESSION) + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid spill files compression method: \"%s\"", + method_str)); + + data->spill_compression_method = method; + } else elog(ERROR, "unrecognized pgoutput option: %s", defel->defname); } @@ -508,6 +533,9 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, data->publications = NIL; publications_valid = false; + /* Init spill files compression method */ + ctx->spill_compression_method = data->spill_compression_method; + /* * Register callback for pg_publication if we didn't already do that * during some previous call in this process. diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index b8b1888bd3..d8508bb684 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -4760,6 +4760,7 @@ getSubscriptions(Archive *fout) int i_suboriginremotelsn; int i_subenabled; int i_subfailover; + int i_subspillcompression; int i, ntups; @@ -4832,10 +4833,17 @@ getSubscriptions(Archive *fout) if (fout->remoteVersion >= 170000) appendPQExpBufferStr(query, - " s.subfailover\n"); + " s.subfailover,\n"); else appendPQExpBuffer(query, - " false AS subfailover\n"); + " false AS subfailover,\n"); + + if (fout->remoteVersion >= 180000) + appendPQExpBufferStr(query, + " s.subspillcompression\n"); + else + appendPQExpBuffer(query, + " 'off' AS subspillcompression\n"); appendPQExpBufferStr(query, "FROM pg_subscription s\n"); @@ -4875,6 +4883,7 @@ getSubscriptions(Archive *fout) i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn"); i_subenabled = PQfnumber(res, "subenabled"); i_subfailover = PQfnumber(res, "subfailover"); + i_subspillcompression = PQfnumber(res, "subspillcompression"); subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo)); @@ -4921,6 +4930,8 @@ getSubscriptions(Archive *fout) pg_strdup(PQgetvalue(res, i, i_subenabled)); subinfo[i].subfailover = pg_strdup(PQgetvalue(res, i, i_subfailover)); + subinfo[i].subspillcompression = + pg_strdup(PQgetvalue(res, i, i_subspillcompression)); /* Decide whether we want to dump it */ selectDumpableObject(&(subinfo[i].dobj), fout); @@ -5167,6 +5178,9 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo) if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0) appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin); + if (strcmp(subinfo->subspillcompression, "off") != 0) + appendPQExpBuffer(query, ", spill_compression = %s", subinfo->subspillcompression); + appendPQExpBufferStr(query, ");\n"); /* diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 4b2e5870a9..12588070f4 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -671,6 +671,7 @@ typedef struct _SubscriptionInfo char *suborigin; char *suboriginremotelsn; char *subfailover; + char *subspillcompression; } SubscriptionInfo; /* diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d3dd8784d6..8fd71f5cf6 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2965,9 +2965,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub2 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = none);', + WITH (connect = false, origin = none, spill_compression = on);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none);\E + \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none, spill_compression = on);\E /xm, like => { %full_runs, section_post_data => 1, }, }, @@ -2976,9 +2976,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub3 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = any);', + WITH (connect = false, origin = any, spill_compression = pglz);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3');\E + \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', spill_compression = pglz);\E /xm, like => { %full_runs, section_post_data => 1, }, }, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7c9a1f234c..495a065849 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6539,7 +6539,7 @@ describeSubscriptions(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, - false}; + false, false}; if (pset.sversion < 100000) { @@ -6619,6 +6619,11 @@ describeSubscriptions(const char *pattern, bool verbose) appendPQExpBuffer(&buf, ", subskiplsn AS \"%s\"\n", gettext_noop("Skip LSN")); + + if (pset.sversion >= 180000) + appendPQExpBuffer(&buf, + ", subspillcompression AS \"%s\"\n", + gettext_noop("Spill files compression")); } /* Only display subscriptions in current database. */ diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d453e224d9..011ec52550 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1948,7 +1948,7 @@ psql_completion(const char *text, int start, int end) else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "(")) COMPLETE_WITH("binary", "disable_on_error", "failover", "origin", "password_required", "run_as_owner", "slot_name", - "streaming", "synchronous_commit"); + "spill_compression", "streaming", "synchronous_commit"); /* ALTER SUBSCRIPTION <name> SKIP ( */ else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SKIP", "(")) COMPLETE_WITH("lsn"); @@ -3365,7 +3365,8 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("binary", "connect", "copy_data", "create_slot", "disable_on_error", "enabled", "failover", "origin", "password_required", "run_as_owner", "slot_name", - "streaming", "synchronous_commit", "two_phase"); + "spill_compression", "streaming", "synchronous_commit", + "two_phase"); /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */ diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h index 0aa14ec4a2..61c284349c 100644 --- a/src/include/catalog/pg_subscription.h +++ b/src/include/catalog/pg_subscription.h @@ -113,6 +113,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW /* Only publish data originating from the specified origin */ text suborigin BKI_DEFAULT(LOGICALREP_ORIGIN_ANY); + + /* Spill files compression algorithm */ + text subspillcompression BKI_FORCE_NOT_NULL; #endif } FormData_pg_subscription; @@ -157,6 +160,7 @@ typedef struct Subscription List *publications; /* List of publication names to subscribe to */ char *origin; /* Only publish data originating from the * specified origin */ + char *spill_compression; /* Spill files compression algorithm */ } Subscription; /* Disallow streaming in-progress transactions. */ diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h index aff38e8d04..75c17866c3 100644 --- a/src/include/replication/logical.h +++ b/src/include/replication/logical.h @@ -112,6 +112,8 @@ typedef struct LogicalDecodingContext /* Do we need to process any change in fast_forward mode? */ bool processing_required; + /* Compression method used to compress spill files */ + uint8 spill_compression_method; } LogicalDecodingContext; diff --git a/src/include/replication/pgoutput.h b/src/include/replication/pgoutput.h index 89f94e1147..eabcca62af 100644 --- a/src/include/replication/pgoutput.h +++ b/src/include/replication/pgoutput.h @@ -33,6 +33,7 @@ typedef struct PGOutputData bool messages; bool two_phase; bool publish_no_origin; + uint8 spill_compression_method; } PGOutputData; #endif /* PGOUTPUT_H */ diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index b668f33d5a..2f0d5b8bd9 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -26,6 +26,7 @@ /* ReorderBuffer on disk compression algorithms */ typedef enum ReorderBufferCompressionMethod { + REORDER_BUFFER_INVALID_COMPRESSION, REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, REORDER_BUFFER_PGLZ_COMPRESSION, @@ -132,5 +133,8 @@ extern void ReorderBufferCompress(ReorderBuffer *rb, extern void ReorderBufferDecompress(ReorderBuffer *rb, char *data, ReorderBufferDiskHeader *header, void *compressor_state); +extern ReorderBufferCompressionMethod ReorderBufferParseCompressionMethod(const char *method); +extern void ReorderBufferValidateCompressionMethod(const char *method, + int elevel); #endif /* REORDERBUFFER_COMPRESSION_H */ diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index 12f71fa99b..b027e4ce89 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -186,6 +186,7 @@ typedef struct * prepare time */ char *origin; /* Only publish data originating from the * specified origin */ + char *spill_compression; /* Spill files compression algo */ } logical; } proto; } WalRcvStreamOptions; diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 5c2f1ee517..b108ed3113 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -116,18 +116,18 @@ CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PU WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub4 SET (origin = any); \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub3; @@ -145,10 +145,10 @@ ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar'; ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false); @@ -157,10 +157,10 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (password_required = true); @@ -176,10 +176,10 @@ ERROR: unrecognized subscription parameter: "create_slot" -- ok ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345'); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 | off (1 row) -- ok - with lsn = NONE @@ -188,10 +188,10 @@ ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE); ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0'); ERROR: invalid WAL location (LSN): 0/0 \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 | off (1 row) BEGIN; @@ -222,11 +222,15 @@ ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); ERROR: invalid value for parameter "synchronous_commit": "foobar" HINT: Available values: local, remote_write, remote_apply, on, off. +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); +ERROR: compression method "foobar" not valid \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ----------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +---------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 | off (1 row) -- rename back to keep the rest simple @@ -255,19 +259,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (binary = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub; @@ -279,27 +283,27 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) -- fail - publication already exists @@ -314,10 +318,10 @@ ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refr ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false); ERROR: publication "testpub1" is already in subscription "regress_testsub" \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) -- fail - publication used more than once @@ -332,10 +336,10 @@ ERROR: publication "testpub3" is not in subscription "regress_testsub" -- ok - delete publications ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub; @@ -371,10 +375,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) --fail - alter of two_phase option not supported. @@ -383,10 +387,10 @@ ERROR: unrecognized subscription parameter: "two_phase" -- but can alter streaming when two_phase enabled ALTER SUBSCRIPTION regress_testsub SET (streaming = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -396,10 +400,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -412,18 +416,18 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 3e5ba4cb8c..2d891b2c06 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -140,6 +140,10 @@ ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo; ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); + \dRs+ -- rename back to keep the rest simple -- 2.43.0 [application/octet-stream] v3-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch (32.7K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/6-v3-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch) download | inline diff: From 31875f6ae2301b3c981fefcac8d33748a051631c Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 6 Jun 2024 00:57:38 -0700 Subject: [PATCH 1/6] Compress ReorderBuffer spill files using LZ4 When the content of a large transaction (size exceeding logical_decoding_work_mem) and its sub-transactions has to be reordered during logical decoding, then, all the changes are written on disk in temporary files located in pg_replslot/<slot_name>. This behavior happens only when the subscriber's option "streaming" is set to "off", which is the default value. In this case, large transactions decoding by multiple replication slots can lead to disk space saturation and high I/O utilization. When compiled with LZ4 support (--with-lz4), this patch enables data compression/decompression of these temporary files. Each transaction change that must be written on disk is now compressed and wrapped in a new structure named ReorderBufferDiskHeader. 3 different compression strategies are currently implemented: 1. LZ4 streaming compression is the preferred one and works efficiently for small individual changes. 2. LZ4 regular compression when the changes are too large for using LZ4 streaming API. 3. No compression. --- src/backend/replication/logical/Makefile | 1 + src/backend/replication/logical/meson.build | 1 + .../replication/logical/reorderbuffer.c | 196 ++++--- .../logical/reorderbuffer_compression.c | 502 ++++++++++++++++++ src/include/replication/reorderbuffer.h | 6 + .../replication/reorderbuffer_compression.h | 95 ++++ 6 files changed, 718 insertions(+), 83 deletions(-) create mode 100644 src/backend/replication/logical/reorderbuffer_compression.c create mode 100644 src/include/replication/reorderbuffer_compression.h diff --git a/src/backend/replication/logical/Makefile b/src/backend/replication/logical/Makefile index ba03eeff1c..88bf698a53 100644 --- a/src/backend/replication/logical/Makefile +++ b/src/backend/replication/logical/Makefile @@ -25,6 +25,7 @@ OBJS = \ proto.o \ relation.o \ reorderbuffer.o \ + reorderbuffer_compression.o \ slotsync.o \ snapbuild.o \ tablesync.o \ diff --git a/src/backend/replication/logical/meson.build b/src/backend/replication/logical/meson.build index 3dec36a6de..f0dd82bae2 100644 --- a/src/backend/replication/logical/meson.build +++ b/src/backend/replication/logical/meson.build @@ -11,6 +11,7 @@ backend_sources += files( 'proto.c', 'relation.c', 'reorderbuffer.c', + 'reorderbuffer_compression.c', 'slotsync.c', 'snapbuild.c', 'tablesync.c', diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 00a8327e77..2519f799bc 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -102,6 +102,7 @@ #include "pgstat.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */ #include "storage/bufmgr.h" @@ -112,6 +113,8 @@ #include "utils/rel.h" #include "utils/relfilenumbermap.h" +int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; + /* entry for a hash table we use to map from xid to our transaction state */ typedef struct ReorderBufferTXNByIdEnt { @@ -173,14 +176,6 @@ typedef struct ReorderBufferToastEnt * main tup */ } ReorderBufferToastEnt; -/* Disk serialization support datastructures */ -typedef struct ReorderBufferDiskChange -{ - Size size; - ReorderBufferChange change; - /* data follows */ -} ReorderBufferDiskChange; - #define IsSpecInsert(action) \ ( \ ((action) == REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT) \ @@ -255,6 +250,8 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *tx int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); +static bool ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno); static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data); static void ReorderBufferRestoreCleanup(ReorderBuffer *rb, ReorderBufferTXN *txn); @@ -427,6 +424,8 @@ ReorderBufferGetTXN(ReorderBuffer *rb) /* InvalidCommandId is not zero, so set it explicitly */ txn->command_id = InvalidCommandId; txn->output_plugin_private = NULL; + txn->compressor_state = ReorderBufferNewCompressorState(rb->context, + logical_decoding_spill_compression); return txn; } @@ -464,6 +463,10 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) txn->invalidations = NULL; } + ReorderBufferFreeCompressorState(rb->context, + logical_decoding_spill_compression, + txn->compressor_state); + /* Reset the toast hash */ ReorderBufferToastReset(rb, txn); @@ -3776,13 +3779,13 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { - ReorderBufferDiskChange *ondisk; - Size sz = sizeof(ReorderBufferDiskChange); + ReorderBufferDiskHeader *disk_hdr; + Size sz = sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); ReorderBufferSerializeReserve(rb, sz); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - memcpy(&ondisk->change, change, sizeof(ReorderBufferChange)); + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; + memcpy((char *)rb->outbuf + sizeof(ReorderBufferDiskHeader), change, sizeof(ReorderBufferChange)); switch (change->action) { @@ -3818,9 +3821,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; if (oldlen) { @@ -3850,10 +3853,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sizeof(Size) + sizeof(Size); ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; /* write the prefix including the size */ memcpy(data, &prefix_size, sizeof(Size)); @@ -3880,10 +3883,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sz += inval_size; ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.inval.invalidations, inval_size); data += inval_size; @@ -3902,9 +3905,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, snap, sizeof(SnapshotData)); data += sizeof(SnapshotData); @@ -3936,9 +3939,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.truncate.relids, size); data += size; @@ -3953,11 +3956,14 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, break; } - ondisk->size = sz; + /* Inplace ReorderBuffer content compression before writing it on disk */ + ReorderBufferCompress(rb, &disk_hdr, logical_decoding_spill_compression, + sz, txn->compressor_state); errno = 0; pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_WRITE); - if (write(fd, rb->outbuf, ondisk->size) != ondisk->size) + + if (write(fd, rb->outbuf, disk_hdr->size) != disk_hdr->size) { int save_errno = errno; @@ -3982,8 +3988,6 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; - - Assert(ondisk->change.action == change->action); } /* Returns true, if the output plugin supports streaming, false, otherwise. */ @@ -4252,9 +4256,6 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, while (restored < max_changes_in_memory && *segno <= last_segno) { - int readBytes; - ReorderBufferDiskChange *ondisk; - CHECK_FOR_INTERRUPTS(); if (*fd == -1) @@ -4293,60 +4294,15 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* - * Read the statically sized part of a change which has information - * about the total size. If we couldn't read a record, we're at the - * end of this file. + * Read the full change from disk. + * If ReorderBufferReadOndiskChange returns false, then we are at the + * eof, so, move the next segment. */ - ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange)); - readBytes = FileRead(file->vfd, rb->outbuf, - sizeof(ReorderBufferDiskChange), - file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); - - /* eof */ - if (readBytes == 0) + if (!ReorderBufferReadOndiskChange(rb, txn, file, segno)) { - FileClose(*fd); *fd = -1; - (*segno)++; continue; } - else if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) sizeof(ReorderBufferDiskChange)))); - - file->curOffset += readBytes; - - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - ReorderBufferSerializeReserve(rb, - sizeof(ReorderBufferDiskChange) + ondisk->size); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - readBytes = FileRead(file->vfd, - rb->outbuf + sizeof(ReorderBufferDiskChange), - ondisk->size - sizeof(ReorderBufferDiskChange), - file->curOffset, - WAIT_EVENT_REORDER_BUFFER_READ); - - if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != ondisk->size - sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) (ondisk->size - sizeof(ReorderBufferDiskChange))))); - - file->curOffset += readBytes; /* * ok, read a full change from disk, now restore it into proper @@ -4359,6 +4315,83 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, return restored; } +/* + * Read a change spilled to disk and decompress it if compressed. + */ +static bool +ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno) +{ + int readBytes; + ReorderBufferDiskHeader *disk_hdr; + char *header; /* disk header buffer*/ + char *data; /* data buffer */ + + /* + * Read the statically sized part of a change which has information about + * the total size and compression method. If we couldn't read a record, + * we're at the end of this file. + */ + header = (char *) palloc0(sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, header, + sizeof(ReorderBufferDiskHeader), + file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); + + /* eof */ + if (readBytes == 0) + { + + FileClose(file->vfd); + (*segno)++; + pfree(header); + + return false; + } + else if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != sizeof(ReorderBufferDiskHeader)) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) sizeof(ReorderBufferDiskHeader)))); + + file->curOffset += readBytes; + + disk_hdr = (ReorderBufferDiskHeader *) header; + + /* Read ondisk data */ + data = (char *) palloc0(disk_hdr->size - sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, + data, + disk_hdr->size - sizeof(ReorderBufferDiskHeader), + file->curOffset, + WAIT_EVENT_REORDER_BUFFER_READ); + + if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != (disk_hdr->size - sizeof(ReorderBufferDiskHeader))) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) (disk_hdr->size - sizeof(ReorderBufferDiskHeader))))); + + /* Decompress data */ + ReorderBufferDecompress(rb, data, disk_hdr, txn->compressor_state); + + pfree(data); + pfree(header); + + file->curOffset += readBytes; + + return true; +} + /* * Convert change from its on-disk format to in-memory format and queue it onto * the TXN's ->changes list. @@ -4371,17 +4404,14 @@ static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data) { - ReorderBufferDiskChange *ondisk; ReorderBufferChange *change; - ondisk = (ReorderBufferDiskChange *) data; - change = ReorderBufferGetChange(rb); /* copy static part */ - memcpy(change, &ondisk->change, sizeof(ReorderBufferChange)); + memcpy(change, data + sizeof(ReorderBufferDiskHeader), sizeof(ReorderBufferChange)); - data += sizeof(ReorderBufferDiskChange); + data += sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* restore individual stuff */ switch (change->action) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c new file mode 100644 index 0000000000..77f5c76929 --- /dev/null +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -0,0 +1,502 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.c + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * src/backend/access/common/reorderbuffer_compression.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +#include "replication/reorderbuffer_compression.h" + +#define NO_LZ4_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method lz4 not supported"), \ + errdetail("This functionality requires the server to be built with lz4 support."))) + +/* + * Allocate a new LZ4StreamingCompressorState. + */ +static void * +lz4_NewCompressorState(MemoryContext context) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + LZ4StreamingCompressorState *cstate; + + cstate = (LZ4StreamingCompressorState *) + MemoryContextAlloc(context, sizeof(LZ4StreamingCompressorState)); + + /* + * We do not allocate LZ4 ring buffers and streaming handlers at this + * point because we have no guarantee that we will need them later. Let's + * allocate only when we are about to use them. + */ + cstate->lz4_in_buf = NULL; + cstate->lz4_out_buf = NULL; + cstate->lz4_in_buf_offset = 0; + cstate->lz4_out_buf_offset = 0; + cstate->lz4_stream = NULL; + cstate->lz4_stream_decode = NULL; + + return (void *) cstate; +#endif +} + +/* + * Free LZ4 memory resources and the compressor state. + */ +static void +lz4_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + if (cstate->lz4_in_buf != NULL) + { + pfree(cstate->lz4_in_buf); + LZ4_freeStream(cstate->lz4_stream); + } + if (cstate->lz4_out_buf != NULL) + { + pfree(cstate->lz4_out_buf); + LZ4_freeStreamDecode(cstate->lz4_stream_decode); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_LZ4 +/* + * Allocate LZ4 input ring buffer and create the streaming compression handler. + */ +static void +lz4_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_in_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream = LZ4_createStream(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_LZ4 +/* + * Allocate LZ4 output ring buffer and create the streaming decompression + * handler. + */ +static void +lz4_CreateStreamDecodeCompressorState(MemoryContext context, + void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_out_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream_decode = LZ4_createStreamDecode(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using LZ4 streaming API. + * Caller must ensure that the source data can fit in LZ4 input ring buffer, + * this checking must be done by lz4_CanDoStreamingCompression(). + */ +static void +lz4_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + char *lz4_in_bufPtr; /* input ring buffer pointer */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 input ring buffer and streaming compression handler */ + if (cstate->lz4_in_buf == NULL) + lz4_CreateStreamCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_in_buf_offset + src_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_in_buf_offset = 0; + + /* Get the pointer of the next entry in the ring buffer */ + lz4_in_bufPtr = cstate->lz4_in_buf + cstate->lz4_in_buf_offset; + + /* Copy data that should be compressed into LZ4 input ring buffer */ + memcpy(lz4_in_bufPtr, src, src_size); + + /* Allocate space for compressed data */ + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 streaming compression API */ + lz4_cmp_size = LZ4_compress_fast_continue(cstate->lz4_stream, + lz4_in_bufPtr, buf, src_size, + buf_size, 1); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + /* Move the input ring buffer offset */ + cstate->lz4_in_buf_offset += src_size; + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data compression using LZ4 API. + */ +static void +lz4_CompressData(char *src, Size src_size, char **dst, Size *dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 regular compression API */ + lz4_cmp_size = LZ4_compress_default(src, buf, src_size, buf_size); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data decompression using LZ4 streaming API. + * LZ4 decompression uses the output ring buffer to store decompressed data, + * thus, we don't need to create a new buffer. We return the pointer to data + * location. + */ +static void +lz4_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + char *lz4_out_bufPtr; /* output ring buffer pointer */ + int lz4_dec_size; /* decompressed data size */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 output ring buffer and streaming decompression handler */ + if (cstate->lz4_out_buf == NULL) + lz4_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_out_buf_offset + dst_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_out_buf_offset = 0; + + /* Get current entry pointer in the ring buffer */ + lz4_out_bufPtr = cstate->lz4_out_buf + cstate->lz4_out_buf_offset; + + lz4_dec_size = LZ4_decompress_safe_continue(cstate->lz4_stream_decode, + src, + lz4_out_bufPtr, + src_size, + dst_size); + + Assert(lz4_dec_size == dst_size); + + if (lz4_dec_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_size != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + /* Move the output ring buffer offset */ + cstate->lz4_out_buf_offset += lz4_dec_size; + + /* Point to the decompressed data location */ + *dst = lz4_out_bufPtr; +#endif +} + +/* + * Data decompression using LZ4 API. + */ +static void +lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_dec_bytes; + char *buf; + + buf = (char *) palloc0(dst_size); + + lz4_dec_bytes = LZ4_decompress_safe(src, buf, src_size, dst_size); + + Assert(lz4_dec_bytes == dst_size); + + if (lz4_dec_bytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_bytes != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + *dst = buf; +#endif +} + +/* + * Allocate a new Compressor State, depending on the compression method. + */ +void * +ReorderBufferNewCompressorState(MemoryContext context, int compression_method) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_NewCompressorState(context); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + return NULL; + break; + } +} + +/* + * Free memory allocated to a Compressor State, depending on the compression + * method. + */ +void +ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, + void *compressor_state) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_FreeCompressorState(context, compressor_state); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + break; + } +} + +/* + * Ensure the IO buffer is >= sz. + */ +static void +ReorderBufferReserve(ReorderBuffer *rb, Size sz) +{ + if (rb->outbufsize < sz) + { + rb->outbuf = repalloc(rb->outbuf, sz); + rb->outbufsize = sz; + } +} + +/* + * Compress ReorderBuffer content. This function is called in order to compress + * data before spilling on disk. + */ +void +ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state) +{ + ReorderBufferDiskHeader *hdr = *header; + + switch (compression_method) + { + /* No compression */ + case REORDER_BUFFER_NO_COMPRESSION: + { + hdr->comp_strat = REORDER_BUFFER_STRAT_UNCOMPRESSED; + hdr->size = data_size; + hdr->raw_size = data_size - sizeof(ReorderBufferDiskHeader); + + break; + } + /* LZ4 Compression */ + case REORDER_BUFFER_LZ4_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + ReorderBufferCompressionStrategy strat; + + if (lz4_CanDoStreamingCompression(src_size)) + { + /* Use LZ4 streaming compression if possible */ + lz4_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + strat = REORDER_BUFFER_STRAT_LZ4_STREAMING; + } + else + { + /* Fallback to LZ4 regular compression */ + lz4_CompressData(src, src_size, &dst, &dst_size); + strat = REORDER_BUFFER_STRAT_LZ4_REGULAR; + } + + /* + * Make sure the ReorderBuffer has enough space to store compressed + * data. Compressed data must be smaller than raw data, so, the + * ReorderBuffer should already have room for compressed data, but + * we do this to avoid buffer overflow risks. + */ + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = strat; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + /* + * Update header: hdr pointer has potentially changed due to + * ReorderBufferReserve() + */ + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + + break; + } + } +} + +/* + * Decompress data read from disk and copy it into the ReorderBuffer. + */ +void +ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, void *compressor_state) +{ + Size raw_outbufsize = header->raw_size + sizeof(ReorderBufferDiskHeader); + /* + * Make sure the output reorder buffer has enough space to store + * decompressed/raw data. + */ + if (rb->outbufsize < raw_outbufsize) + { + rb->outbuf = repalloc(rb->outbuf, raw_outbufsize); + rb->outbufsize = raw_outbufsize; + } + + /* Make a copy of the header read on disk into the ReorderBuffer */ + memcpy(rb->outbuf, (char *) header, sizeof(ReorderBufferDiskHeader)); + + switch (header->comp_strat) + { + /* No decompression */ + case REORDER_BUFFER_STRAT_UNCOMPRESSED: + { + /* + * Make a copy of what was read on disk into the reorder + * buffer. + */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + data, header->raw_size); + break; + } + /* LZ4 regular decompression */ + case REORDER_BUFFER_STRAT_LZ4_REGULAR: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_DecompressData(data, src_size, &buf, buf_size); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + + pfree(buf); + break; + } + /* LZ4 streaming decompression */ + case REORDER_BUFFER_STRAT_LZ4_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + /* + * Not necessary to free buf in this case: it points to the + * decompressed data stored in LZ4 output ring buffer. + */ + break; + } + default: + /* Other compression methods not yet supported */ + break; + } +} diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 851a001c8b..bf979e0b14 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -9,6 +9,10 @@ #ifndef REORDERBUFFER_H #define REORDERBUFFER_H +#ifdef USE_LZ4 +#include <lz4.h> +#endif + #include "access/htup_details.h" #include "lib/ilist.h" #include "lib/pairingheap.h" @@ -422,6 +426,8 @@ typedef struct ReorderBufferTXN * Private data pointer of the output plugin. */ void *output_plugin_private; + + void *compressor_state; } ReorderBufferTXN; /* so we can define the callbacks used inside struct ReorderBuffer itself */ diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h new file mode 100644 index 0000000000..9aa8aea56f --- /dev/null +++ b/src/include/replication/reorderbuffer_compression.h @@ -0,0 +1,95 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.h + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * src/include/access/reorderbuffer_compression.h + * + *------------------------------------------------------------------------- + */ + +#ifndef REORDERBUFFER_COMPRESSION_H +#define REORDERBUFFER_COMPRESSION_H + +#include "replication/reorderbuffer.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +/* ReorderBuffer on disk compression algorithms */ +typedef enum ReorderBufferCompressionMethod +{ + REORDER_BUFFER_NO_COMPRESSION, + REORDER_BUFFER_LZ4_COMPRESSION, +} ReorderBufferCompressionMethod; + +/* + * Compression strategy applied to ReorderBuffer records spilled on disk + */ +typedef enum ReorderBufferCompressionStrategy +{ + REORDER_BUFFER_STRAT_UNCOMPRESSED, + REORDER_BUFFER_STRAT_LZ4_STREAMING, + REORDER_BUFFER_STRAT_LZ4_REGULAR, +} ReorderBufferCompressionStrategy; + +/* Disk serialization support datastructures */ +typedef struct ReorderBufferDiskHeader +{ + ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ + Size size; /* Ondisk size */ + Size raw_size; /* Raw/uncompressed data size */ + /* ReorderBufferChange + data follows */ +} ReorderBufferDiskHeader; + +#ifdef USE_LZ4 +/* + * We use a fairly small LZ4 ring buffer size (64kB). Using a larger buffer + * size provide better compression ratio, but as long as we have to allocate + * two LZ4 ring buffers per ReorderBufferTXN, we should keep it small. + */ +#define LZ4_RING_BUFFER_SIZE (64 * 1024) + +/* + * Use LZ4 streaming compression iff we can keep at least 2 uncompressed + * records into the LZ4 input ring buffer. If raw data size is too large, let's + * use regular LZ4 compression. + */ +#define lz4_CanDoStreamingCompression(s) (s < (LZ4_RING_BUFFER_SIZE / 2)) + +/* + * LZ4 streaming compression/decompression handlers and ring + * buffers. + */ +typedef struct LZ4StreamingCompressorState { + /* Streaming compression handler */ + LZ4_stream_t *lz4_stream; + /* Streaming decompression handler */ + LZ4_streamDecode_t *lz4_stream_decode; + /* LZ4 in/out ring buffers used for streaming compression */ + char *lz4_in_buf; + int lz4_in_buf_offset; + char *lz4_out_buf; + int lz4_out_buf_offset; +} LZ4StreamingCompressorState; +#else +#define lz4_CanDoStreamingCompression(s) (false) +#endif + +extern void *ReorderBufferNewCompressorState(MemoryContext context, + int compression_method); +extern void ReorderBufferFreeCompressorState(MemoryContext context, + int compression_method, + void *compressor_state); +extern void ReorderBufferCompress(ReorderBuffer *rb, + ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state); +extern void ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, + void *compressor_state); + +#endif /* REORDERBUFFER_COMPRESSION_H */ -- 2.43.0 [application/octet-stream] v3-0006-Add-ReorderBuffer-ondisk-compression-tests.patch (5.0K, ../../CAFEQCbH6gj3QHVjhkf7o=FcxCx4EZTJggqeODfsWa+OcpqJ=Tg@mail.gmail.com/7-v3-0006-Add-ReorderBuffer-ondisk-compression-tests.patch) download | inline diff: From a12ff0b1debf76823c4c68cbc9a5570ceb9c28dd Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:51:29 -0700 Subject: [PATCH 6/6] Add ReorderBuffer ondisk compression tests --- src/test/subscription/Makefile | 2 + src/test/subscription/meson.build | 7 +- .../t/034_reorderbuffer_compression.pl | 99 +++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/test/subscription/t/034_reorderbuffer_compression.pl diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile index ce1ca43009..9341f1493c 100644 --- a/src/test/subscription/Makefile +++ b/src/test/subscription/Makefile @@ -16,6 +16,8 @@ include $(top_builddir)/src/Makefile.global EXTRA_INSTALL = contrib/hstore export with_icu +export with_lz4 +export with_zstd check: $(prove_check) diff --git a/src/test/subscription/meson.build b/src/test/subscription/meson.build index c591cd7d61..772eeb817f 100644 --- a/src/test/subscription/meson.build +++ b/src/test/subscription/meson.build @@ -5,7 +5,11 @@ tests += { 'sd': meson.current_source_dir(), 'bd': meson.current_build_dir(), 'tap': { - 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + 'env': { + 'with_icu': icu.found() ? 'yes' : 'no', + 'with_lz4': lz4.found() ? 'yes' : 'no', + 'with_zstd': zstd.found() ? 'yes' : 'no', + }, 'tests': [ 't/001_rep_changes.pl', 't/002_types.pl', @@ -40,6 +44,7 @@ tests += { 't/031_column_list.pl', 't/032_subscribe_use_index.pl', 't/033_run_as_table_owner.pl', + 't/034_reorderbuffer_compression.pl', 't/100_bugs.pl', ], }, diff --git a/src/test/subscription/t/034_reorderbuffer_compression.pl b/src/test/subscription/t/034_reorderbuffer_compression.pl new file mode 100644 index 0000000000..65c9be14a2 --- /dev/null +++ b/src/test/subscription/t/034_reorderbuffer_compression.pl @@ -0,0 +1,99 @@ + +# Copyright (c) 2024, PostgreSQL Global Development Group + +# Test ReorderBuffer compression +use strict; +use warnings FATAL => 'all'; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +sub test_reorderbuffer_compression +{ + my ($node_publisher, $node_subscriber, $appname, $compression) = @_; + + # Set subscriber's spill_compression option + $node_subscriber->safe_psql('postgres', + "ALTER SUBSCRIPTION tap_sub SET (spill_compression = $compression)"); + + # Make sure the table is empty + $node_publisher->safe_psql('postgres', 'TRUNCATE test_tab'); + + # Reset replication slot stats + $node_publisher->safe_psql('postgres', + "SELECT pg_stat_reset_replication_slot('tap_sub')"); + + # Insert 1 million rows in the table + $node_publisher->safe_psql('postgres', + "INSERT INTO test_tab SELECT i, 'Message number #'||i::TEXT FROM generate_series(1, 1000000) as i" + ); + + $node_publisher->wait_for_catchup($appname); + + # Check if table content is replicated + my $result = + $node_subscriber->safe_psql('postgres', + "SELECT count(*) FROM test_tab"); + is($result, qq(1000000), 'check data was copied to subscriber'); + + # Check if the transaction was spilled on disk + my $res_stats = + $node_publisher->safe_psql('postgres', + "SELECT spill_txns FROM pg_catalog.pg_stat_get_replication_slot('tap_sub');"); + is($res_stats, qq(1), 'check if the transaction was spilled on disk'); +} + +# Create publisher node +my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher->init(allows_streaming => 'logical'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64'); +$node_publisher->start; + +# Create subscriber node +my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); +$node_subscriber->init; +$node_subscriber->start; + +# Setup structure on publisher +$node_publisher->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup structure on subscriber +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup logical replication +my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); + +my $appname = 'tap_sub'; + +$node_subscriber->safe_psql('postgres', + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = off)" +); + +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'off'); +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'pglz'); + +SKIP: +{ + skip "LZ4 not supported by this build", 2 if ($ENV{with_lz4} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'lz4'); +} + +SKIP: +{ + skip "ZSTD not supported by this build", 2 if ($ENV{with_zstd} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'zstd'); +} + +$node_subscriber->stop; +$node_publisher->stop; + +done_testing(); -- 2.43.0 ^ permalink raw reply [nested|flat] 112+ messages in thread
* Re: Compress ReorderBuffer spill files using LZ4 @ 2024-09-17 18:48 Tomas Vondra <[email protected]> parent: Julien Tachoires <[email protected]> 0 siblings, 0 replies; 112+ messages in thread From: Tomas Vondra @ 2024-09-17 18:48 UTC (permalink / raw) To: Julien Tachoires <[email protected]>; Amit Kapila <[email protected]>; +Cc: Tomas Vondra <[email protected]>; [email protected] Hi Julien, Thanks for the last patch version and sorry for the delay. Here's a quick review, I plan to do a bit of additional testing, hopefully sometime this week. Attached is v4, which is your v3 rebased to current master, with a couple "review" commits, adding comments to relevant places, which I find easier to follow. There's also a "pgindent" commit at the end, showing some formatting issues, adding structs to typedefs, etc. This needs to be applied to the earlier patches, I didn't want to have too many pgindent commits. v4-0002-review.patch -------------------- 1) I don't think we need to rename ReorderBufferDiskChange to ReorderBufferDiskHeader. It seems we could easily just add a field to ReorderBufferDiskChange, and keep using that, no? It's still just a wrapper for ReorderBufferChange, even if it's compressed. 2) Likewise, I don't see the point in moving ReorderBufferDiskChange to a different file. It seems like something that should remain private to reorderbuffer.c. IMHO the correct thing would be to move the various ReorderBuffer* funct from reorderbuffer_compress.c to reorderbuffer.c. The compression is something the ReorderBuffer is responsible for, so reorderbuffer.c is the right place for that. 3) That means the reorderbuffer_compress.c would have only the actual compression code. But wouldn't it be better to have one file for each compression algorithm, similar to src/fe_utils/astreamer_{pglz,lz4,...}? Just a suggestion, though. Not sure. 4) logical_decoding_spill_compression moved a bit, next to the variables for other logical_decoding GUCs. It's also missing the definition in a header file, so I get a compiler warning, so add it to reorderbuffer.h. 5) Won't the code in ReorderBufferCompress() do palloc/pfree for each piece of data we compress? That seems it might be pretty expensive, at least for records that happen to be large (>8kB), because oversized chunks are not cached in the context. IMHO this should use a single buffer, similarly to what astreamer_lz4_compressor_content does. 6) I'm really confused by having "streaming" and "regular" compression. I know lz4 supports different modes, but I'd expect only one of them being really suitable for this, so why support both? But even more importantly, ReorderBufferCompress() sets the strategy using #define lz4_CanDoStreamingCompression(s) \ (s < (LZ4_RING_BUFFER_SIZE / 2)) But it does that with "s" being the "change size", and that can vary wildly. Doesn't that means the strategy will change withing a single file? Does that even make sense? v4-0004-review.patch -------------------- 7) I'm not sure the "Fix spill_bytes counter" is actually a fix. Even now (i.e. without compression) it tracks the size of transactions, not the bytes written to disk exactly, because it doesn't include the bytes for the size field, so maybe we should not change that ... v4-0006-review.patch -------------------- 8) It seems a bit strange that we add lz4 first, and only later pglz. IMHO it should be the other way around, as pglz is the default algorithm we can rely to have, while lz4 etc. are optional. One question I have is whether it might be better to compress stuff at a lower layer - not in reorderbuffer.c, but for the whole file. But maybe there are reasons why that would be difficult, I haven't tried that. regards -- Tomas Vondra Attachments: [text/x-patch] v4-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch (32.7K, ../../[email protected]/2-v4-0001-Compress-ReorderBuffer-spill-files-using-LZ4.patch) download | inline diff: From c677ca6271b3b433a65f089a19c371b568bf7a0b Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 6 Jun 2024 00:57:38 -0700 Subject: [PATCH v4 01/11] Compress ReorderBuffer spill files using LZ4 When the content of a large transaction (size exceeding logical_decoding_work_mem) and its sub-transactions has to be reordered during logical decoding, then, all the changes are written on disk in temporary files located in pg_replslot/<slot_name>. This behavior happens only when the subscriber's option "streaming" is set to "off", which is the default value. In this case, large transactions decoding by multiple replication slots can lead to disk space saturation and high I/O utilization. When compiled with LZ4 support (--with-lz4), this patch enables data compression/decompression of these temporary files. Each transaction change that must be written on disk is now compressed and wrapped in a new structure named ReorderBufferDiskHeader. 3 different compression strategies are currently implemented: 1. LZ4 streaming compression is the preferred one and works efficiently for small individual changes. 2. LZ4 regular compression when the changes are too large for using LZ4 streaming API. 3. No compression. --- src/backend/replication/logical/Makefile | 1 + src/backend/replication/logical/meson.build | 1 + .../replication/logical/reorderbuffer.c | 196 ++++--- .../logical/reorderbuffer_compression.c | 502 ++++++++++++++++++ src/include/replication/reorderbuffer.h | 6 + .../replication/reorderbuffer_compression.h | 95 ++++ 6 files changed, 718 insertions(+), 83 deletions(-) create mode 100644 src/backend/replication/logical/reorderbuffer_compression.c create mode 100644 src/include/replication/reorderbuffer_compression.h diff --git a/src/backend/replication/logical/Makefile b/src/backend/replication/logical/Makefile index 1e08bbbd4eb..6f9b0c6f8a1 100644 --- a/src/backend/replication/logical/Makefile +++ b/src/backend/replication/logical/Makefile @@ -26,6 +26,7 @@ OBJS = \ proto.o \ relation.o \ reorderbuffer.o \ + reorderbuffer_compression.o \ slotsync.o \ snapbuild.o \ tablesync.o \ diff --git a/src/backend/replication/logical/meson.build b/src/backend/replication/logical/meson.build index 3d36249d8ad..3f8ff4d798f 100644 --- a/src/backend/replication/logical/meson.build +++ b/src/backend/replication/logical/meson.build @@ -12,6 +12,7 @@ backend_sources += files( 'proto.c', 'relation.c', 'reorderbuffer.c', + 'reorderbuffer_compression.c', 'slotsync.c', 'snapbuild.c', 'tablesync.c', diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 22bcf171ff0..c36179d44b5 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -102,6 +102,7 @@ #include "pgstat.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */ #include "storage/bufmgr.h" @@ -112,6 +113,8 @@ #include "utils/rel.h" #include "utils/relfilenumbermap.h" +int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; + /* entry for a hash table we use to map from xid to our transaction state */ typedef struct ReorderBufferTXNByIdEnt { @@ -173,14 +176,6 @@ typedef struct ReorderBufferToastEnt * main tup */ } ReorderBufferToastEnt; -/* Disk serialization support datastructures */ -typedef struct ReorderBufferDiskChange -{ - Size size; - ReorderBufferChange change; - /* data follows */ -} ReorderBufferDiskChange; - #define IsSpecInsert(action) \ ( \ ((action) == REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT) \ @@ -255,6 +250,8 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *tx int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); +static bool ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno); static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data); static void ReorderBufferRestoreCleanup(ReorderBuffer *rb, ReorderBufferTXN *txn); @@ -427,6 +424,8 @@ ReorderBufferGetTXN(ReorderBuffer *rb) /* InvalidCommandId is not zero, so set it explicitly */ txn->command_id = InvalidCommandId; txn->output_plugin_private = NULL; + txn->compressor_state = ReorderBufferNewCompressorState(rb->context, + logical_decoding_spill_compression); return txn; } @@ -464,6 +463,10 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) txn->invalidations = NULL; } + ReorderBufferFreeCompressorState(rb->context, + logical_decoding_spill_compression, + txn->compressor_state); + /* Reset the toast hash */ ReorderBufferToastReset(rb, txn); @@ -3800,13 +3803,13 @@ static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { - ReorderBufferDiskChange *ondisk; - Size sz = sizeof(ReorderBufferDiskChange); + ReorderBufferDiskHeader *disk_hdr; + Size sz = sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); ReorderBufferSerializeReserve(rb, sz); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - memcpy(&ondisk->change, change, sizeof(ReorderBufferChange)); + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; + memcpy((char *)rb->outbuf + sizeof(ReorderBufferDiskHeader), change, sizeof(ReorderBufferChange)); switch (change->action) { @@ -3842,9 +3845,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; if (oldlen) { @@ -3874,10 +3877,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sizeof(Size) + sizeof(Size); ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; /* write the prefix including the size */ memcpy(data, &prefix_size, sizeof(Size)); @@ -3904,10 +3907,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, sz += inval_size; ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.inval.invalidations, inval_size); data += inval_size; @@ -3926,9 +3929,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, snap, sizeof(SnapshotData)); data += sizeof(SnapshotData); @@ -3960,9 +3963,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, /* make sure we have enough space */ ReorderBufferSerializeReserve(rb, sz); - data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* might have been reallocated above */ - ondisk = (ReorderBufferDiskChange *) rb->outbuf; + disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; memcpy(data, change->data.truncate.relids, size); data += size; @@ -3977,11 +3980,14 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, break; } - ondisk->size = sz; + /* Inplace ReorderBuffer content compression before writing it on disk */ + ReorderBufferCompress(rb, &disk_hdr, logical_decoding_spill_compression, + sz, txn->compressor_state); errno = 0; pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_WRITE); - if (write(fd, rb->outbuf, ondisk->size) != ondisk->size) + + if (write(fd, rb->outbuf, disk_hdr->size) != disk_hdr->size) { int save_errno = errno; @@ -4006,8 +4012,6 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; - - Assert(ondisk->change.action == change->action); } /* Returns true, if the output plugin supports streaming, false, otherwise. */ @@ -4276,9 +4280,6 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, while (restored < max_changes_in_memory && *segno <= last_segno) { - int readBytes; - ReorderBufferDiskChange *ondisk; - CHECK_FOR_INTERRUPTS(); if (*fd == -1) @@ -4317,60 +4318,15 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* - * Read the statically sized part of a change which has information - * about the total size. If we couldn't read a record, we're at the - * end of this file. + * Read the full change from disk. + * If ReorderBufferReadOndiskChange returns false, then we are at the + * eof, so, move the next segment. */ - ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange)); - readBytes = FileRead(file->vfd, rb->outbuf, - sizeof(ReorderBufferDiskChange), - file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); - - /* eof */ - if (readBytes == 0) + if (!ReorderBufferReadOndiskChange(rb, txn, file, segno)) { - FileClose(*fd); *fd = -1; - (*segno)++; continue; } - else if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) sizeof(ReorderBufferDiskChange)))); - - file->curOffset += readBytes; - - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - ReorderBufferSerializeReserve(rb, - sizeof(ReorderBufferDiskChange) + ondisk->size); - ondisk = (ReorderBufferDiskChange *) rb->outbuf; - - readBytes = FileRead(file->vfd, - rb->outbuf + sizeof(ReorderBufferDiskChange), - ondisk->size - sizeof(ReorderBufferDiskChange), - file->curOffset, - WAIT_EVENT_REORDER_BUFFER_READ); - - if (readBytes < 0) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: %m"))); - else if (readBytes != ondisk->size - sizeof(ReorderBufferDiskChange)) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", - readBytes, - (uint32) (ondisk->size - sizeof(ReorderBufferDiskChange))))); - - file->curOffset += readBytes; /* * ok, read a full change from disk, now restore it into proper @@ -4383,6 +4339,83 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, return restored; } +/* + * Read a change spilled to disk and decompress it if compressed. + */ +static bool +ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, + TXNEntryFile *file, XLogSegNo *segno) +{ + int readBytes; + ReorderBufferDiskHeader *disk_hdr; + char *header; /* disk header buffer*/ + char *data; /* data buffer */ + + /* + * Read the statically sized part of a change which has information about + * the total size and compression method. If we couldn't read a record, + * we're at the end of this file. + */ + header = (char *) palloc0(sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, header, + sizeof(ReorderBufferDiskHeader), + file->curOffset, WAIT_EVENT_REORDER_BUFFER_READ); + + /* eof */ + if (readBytes == 0) + { + + FileClose(file->vfd); + (*segno)++; + pfree(header); + + return false; + } + else if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != sizeof(ReorderBufferDiskHeader)) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) sizeof(ReorderBufferDiskHeader)))); + + file->curOffset += readBytes; + + disk_hdr = (ReorderBufferDiskHeader *) header; + + /* Read ondisk data */ + data = (char *) palloc0(disk_hdr->size - sizeof(ReorderBufferDiskHeader)); + readBytes = FileRead(file->vfd, + data, + disk_hdr->size - sizeof(ReorderBufferDiskHeader), + file->curOffset, + WAIT_EVENT_REORDER_BUFFER_READ); + + if (readBytes < 0) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: %m"))); + else if (readBytes != (disk_hdr->size - sizeof(ReorderBufferDiskHeader))) + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not read from reorderbuffer spill file: read %d instead of %u bytes", + readBytes, + (uint32) (disk_hdr->size - sizeof(ReorderBufferDiskHeader))))); + + /* Decompress data */ + ReorderBufferDecompress(rb, data, disk_hdr, txn->compressor_state); + + pfree(data); + pfree(header); + + file->curOffset += readBytes; + + return true; +} + /* * Convert change from its on-disk format to in-memory format and queue it onto * the TXN's ->changes list. @@ -4395,17 +4428,14 @@ static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data) { - ReorderBufferDiskChange *ondisk; ReorderBufferChange *change; - ondisk = (ReorderBufferDiskChange *) data; - change = ReorderBufferGetChange(rb); /* copy static part */ - memcpy(change, &ondisk->change, sizeof(ReorderBufferChange)); + memcpy(change, data + sizeof(ReorderBufferDiskHeader), sizeof(ReorderBufferChange)); - data += sizeof(ReorderBufferDiskChange); + data += sizeof(ReorderBufferDiskHeader) + sizeof(ReorderBufferChange); /* restore individual stuff */ switch (change->action) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c new file mode 100644 index 00000000000..77f5c76929b --- /dev/null +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -0,0 +1,502 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.c + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * src/backend/access/common/reorderbuffer_compression.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +#include "replication/reorderbuffer_compression.h" + +#define NO_LZ4_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method lz4 not supported"), \ + errdetail("This functionality requires the server to be built with lz4 support."))) + +/* + * Allocate a new LZ4StreamingCompressorState. + */ +static void * +lz4_NewCompressorState(MemoryContext context) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + LZ4StreamingCompressorState *cstate; + + cstate = (LZ4StreamingCompressorState *) + MemoryContextAlloc(context, sizeof(LZ4StreamingCompressorState)); + + /* + * We do not allocate LZ4 ring buffers and streaming handlers at this + * point because we have no guarantee that we will need them later. Let's + * allocate only when we are about to use them. + */ + cstate->lz4_in_buf = NULL; + cstate->lz4_out_buf = NULL; + cstate->lz4_in_buf_offset = 0; + cstate->lz4_out_buf_offset = 0; + cstate->lz4_stream = NULL; + cstate->lz4_stream_decode = NULL; + + return (void *) cstate; +#endif +} + +/* + * Free LZ4 memory resources and the compressor state. + */ +static void +lz4_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + if (cstate->lz4_in_buf != NULL) + { + pfree(cstate->lz4_in_buf); + LZ4_freeStream(cstate->lz4_stream); + } + if (cstate->lz4_out_buf != NULL) + { + pfree(cstate->lz4_out_buf); + LZ4_freeStreamDecode(cstate->lz4_stream_decode); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_LZ4 +/* + * Allocate LZ4 input ring buffer and create the streaming compression handler. + */ +static void +lz4_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_in_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream = LZ4_createStream(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_LZ4 +/* + * Allocate LZ4 output ring buffer and create the streaming decompression + * handler. + */ +static void +lz4_CreateStreamDecodeCompressorState(MemoryContext context, + void *compressor_state) +{ + LZ4StreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (LZ4StreamingCompressorState *) compressor_state; + cstate->lz4_out_buf = (char *) palloc0(LZ4_RING_BUFFER_SIZE); + cstate->lz4_stream_decode = LZ4_createStreamDecode(); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using LZ4 streaming API. + * Caller must ensure that the source data can fit in LZ4 input ring buffer, + * this checking must be done by lz4_CanDoStreamingCompression(). + */ +static void +lz4_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + char *lz4_in_bufPtr; /* input ring buffer pointer */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 input ring buffer and streaming compression handler */ + if (cstate->lz4_in_buf == NULL) + lz4_CreateStreamCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_in_buf_offset + src_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_in_buf_offset = 0; + + /* Get the pointer of the next entry in the ring buffer */ + lz4_in_bufPtr = cstate->lz4_in_buf + cstate->lz4_in_buf_offset; + + /* Copy data that should be compressed into LZ4 input ring buffer */ + memcpy(lz4_in_bufPtr, src, src_size); + + /* Allocate space for compressed data */ + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 streaming compression API */ + lz4_cmp_size = LZ4_compress_fast_continue(cstate->lz4_stream, + lz4_in_bufPtr, buf, src_size, + buf_size, 1); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + /* Move the input ring buffer offset */ + cstate->lz4_in_buf_offset += src_size; + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data compression using LZ4 API. + */ +static void +lz4_CompressData(char *src, Size src_size, char **dst, Size *dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_cmp_size = 0; /* compressed size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + + buf_size = LZ4_COMPRESSBOUND(src_size); + buf = (char *) palloc0(buf_size); + + /* Use LZ4 regular compression API */ + lz4_cmp_size = LZ4_compress_default(src, buf, src_size, buf_size); + + if (lz4_cmp_size <= 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("LZ4 compression failed"))); + + *dst_size = lz4_cmp_size; + *dst = buf; +#endif +} + +/* + * Data decompression using LZ4 streaming API. + * LZ4 decompression uses the output ring buffer to store decompressed data, + * thus, we don't need to create a new buffer. We return the pointer to data + * location. + */ +static void +lz4_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + LZ4StreamingCompressorState *cstate; + char *lz4_out_bufPtr; /* output ring buffer pointer */ + int lz4_dec_size; /* decompressed data size */ + + cstate = (LZ4StreamingCompressorState *) compressor_state; + + /* Allocate LZ4 output ring buffer and streaming decompression handler */ + if (cstate->lz4_out_buf == NULL) + lz4_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Ring buffer offset wraparound */ + if ((cstate->lz4_out_buf_offset + dst_size) > LZ4_RING_BUFFER_SIZE) + cstate->lz4_out_buf_offset = 0; + + /* Get current entry pointer in the ring buffer */ + lz4_out_bufPtr = cstate->lz4_out_buf + cstate->lz4_out_buf_offset; + + lz4_dec_size = LZ4_decompress_safe_continue(cstate->lz4_stream_decode, + src, + lz4_out_bufPtr, + src_size, + dst_size); + + Assert(lz4_dec_size == dst_size); + + if (lz4_dec_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_size != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + /* Move the output ring buffer offset */ + cstate->lz4_out_buf_offset += lz4_dec_size; + + /* Point to the decompressed data location */ + *dst = lz4_out_bufPtr; +#endif +} + +/* + * Data decompression using LZ4 API. + */ +static void +lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) +{ +#ifndef USE_LZ4 + NO_LZ4_SUPPORT(); +#else + int lz4_dec_bytes; + char *buf; + + buf = (char *) palloc0(dst_size); + + lz4_dec_bytes = LZ4_decompress_safe(src, buf, src_size, dst_size); + + Assert(lz4_dec_bytes == dst_size); + + if (lz4_dec_bytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed LZ4 data is corrupted"))); + else if (lz4_dec_bytes != dst_size) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); + + *dst = buf; +#endif +} + +/* + * Allocate a new Compressor State, depending on the compression method. + */ +void * +ReorderBufferNewCompressorState(MemoryContext context, int compression_method) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_NewCompressorState(context); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + return NULL; + break; + } +} + +/* + * Free memory allocated to a Compressor State, depending on the compression + * method. + */ +void +ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, + void *compressor_state) +{ + switch (compression_method) + { + case REORDER_BUFFER_LZ4_COMPRESSION: + return lz4_FreeCompressorState(context, compressor_state); + break; + case REORDER_BUFFER_NO_COMPRESSION: + default: + break; + } +} + +/* + * Ensure the IO buffer is >= sz. + */ +static void +ReorderBufferReserve(ReorderBuffer *rb, Size sz) +{ + if (rb->outbufsize < sz) + { + rb->outbuf = repalloc(rb->outbuf, sz); + rb->outbufsize = sz; + } +} + +/* + * Compress ReorderBuffer content. This function is called in order to compress + * data before spilling on disk. + */ +void +ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state) +{ + ReorderBufferDiskHeader *hdr = *header; + + switch (compression_method) + { + /* No compression */ + case REORDER_BUFFER_NO_COMPRESSION: + { + hdr->comp_strat = REORDER_BUFFER_STRAT_UNCOMPRESSED; + hdr->size = data_size; + hdr->raw_size = data_size - sizeof(ReorderBufferDiskHeader); + + break; + } + /* LZ4 Compression */ + case REORDER_BUFFER_LZ4_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + ReorderBufferCompressionStrategy strat; + + if (lz4_CanDoStreamingCompression(src_size)) + { + /* Use LZ4 streaming compression if possible */ + lz4_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + strat = REORDER_BUFFER_STRAT_LZ4_STREAMING; + } + else + { + /* Fallback to LZ4 regular compression */ + lz4_CompressData(src, src_size, &dst, &dst_size); + strat = REORDER_BUFFER_STRAT_LZ4_REGULAR; + } + + /* + * Make sure the ReorderBuffer has enough space to store compressed + * data. Compressed data must be smaller than raw data, so, the + * ReorderBuffer should already have room for compressed data, but + * we do this to avoid buffer overflow risks. + */ + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = strat; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + /* + * Update header: hdr pointer has potentially changed due to + * ReorderBufferReserve() + */ + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + + break; + } + } +} + +/* + * Decompress data read from disk and copy it into the ReorderBuffer. + */ +void +ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, void *compressor_state) +{ + Size raw_outbufsize = header->raw_size + sizeof(ReorderBufferDiskHeader); + /* + * Make sure the output reorder buffer has enough space to store + * decompressed/raw data. + */ + if (rb->outbufsize < raw_outbufsize) + { + rb->outbuf = repalloc(rb->outbuf, raw_outbufsize); + rb->outbufsize = raw_outbufsize; + } + + /* Make a copy of the header read on disk into the ReorderBuffer */ + memcpy(rb->outbuf, (char *) header, sizeof(ReorderBufferDiskHeader)); + + switch (header->comp_strat) + { + /* No decompression */ + case REORDER_BUFFER_STRAT_UNCOMPRESSED: + { + /* + * Make a copy of what was read on disk into the reorder + * buffer. + */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + data, header->raw_size); + break; + } + /* LZ4 regular decompression */ + case REORDER_BUFFER_STRAT_LZ4_REGULAR: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_DecompressData(data, src_size, &buf, buf_size); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + + pfree(buf); + break; + } + /* LZ4 streaming decompression */ + case REORDER_BUFFER_STRAT_LZ4_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + lz4_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + /* + * Not necessary to free buf in this case: it points to the + * decompressed data stored in LZ4 output ring buffer. + */ + break; + } + default: + /* Other compression methods not yet supported */ + break; + } +} diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index e332635f70b..f1562a77719 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -9,6 +9,10 @@ #ifndef REORDERBUFFER_H #define REORDERBUFFER_H +#ifdef USE_LZ4 +#include <lz4.h> +#endif + #include "access/htup_details.h" #include "lib/ilist.h" #include "lib/pairingheap.h" @@ -427,6 +431,8 @@ typedef struct ReorderBufferTXN * Private data pointer of the output plugin. */ void *output_plugin_private; + + void *compressor_state; } ReorderBufferTXN; /* so we can define the callbacks used inside struct ReorderBuffer itself */ diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h new file mode 100644 index 00000000000..9aa8aea56f4 --- /dev/null +++ b/src/include/replication/reorderbuffer_compression.h @@ -0,0 +1,95 @@ +/*------------------------------------------------------------------------- + * + * reorderbuffer_compression.h + * Functions for ReorderBuffer compression. + * + * Copyright (c) 2024-2024, PostgreSQL Global Development Group + * + * src/include/access/reorderbuffer_compression.h + * + *------------------------------------------------------------------------- + */ + +#ifndef REORDERBUFFER_COMPRESSION_H +#define REORDERBUFFER_COMPRESSION_H + +#include "replication/reorderbuffer.h" + +#ifdef USE_LZ4 +#include <lz4.h> +#endif + +/* ReorderBuffer on disk compression algorithms */ +typedef enum ReorderBufferCompressionMethod +{ + REORDER_BUFFER_NO_COMPRESSION, + REORDER_BUFFER_LZ4_COMPRESSION, +} ReorderBufferCompressionMethod; + +/* + * Compression strategy applied to ReorderBuffer records spilled on disk + */ +typedef enum ReorderBufferCompressionStrategy +{ + REORDER_BUFFER_STRAT_UNCOMPRESSED, + REORDER_BUFFER_STRAT_LZ4_STREAMING, + REORDER_BUFFER_STRAT_LZ4_REGULAR, +} ReorderBufferCompressionStrategy; + +/* Disk serialization support datastructures */ +typedef struct ReorderBufferDiskHeader +{ + ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ + Size size; /* Ondisk size */ + Size raw_size; /* Raw/uncompressed data size */ + /* ReorderBufferChange + data follows */ +} ReorderBufferDiskHeader; + +#ifdef USE_LZ4 +/* + * We use a fairly small LZ4 ring buffer size (64kB). Using a larger buffer + * size provide better compression ratio, but as long as we have to allocate + * two LZ4 ring buffers per ReorderBufferTXN, we should keep it small. + */ +#define LZ4_RING_BUFFER_SIZE (64 * 1024) + +/* + * Use LZ4 streaming compression iff we can keep at least 2 uncompressed + * records into the LZ4 input ring buffer. If raw data size is too large, let's + * use regular LZ4 compression. + */ +#define lz4_CanDoStreamingCompression(s) (s < (LZ4_RING_BUFFER_SIZE / 2)) + +/* + * LZ4 streaming compression/decompression handlers and ring + * buffers. + */ +typedef struct LZ4StreamingCompressorState { + /* Streaming compression handler */ + LZ4_stream_t *lz4_stream; + /* Streaming decompression handler */ + LZ4_streamDecode_t *lz4_stream_decode; + /* LZ4 in/out ring buffers used for streaming compression */ + char *lz4_in_buf; + int lz4_in_buf_offset; + char *lz4_out_buf; + int lz4_out_buf_offset; +} LZ4StreamingCompressorState; +#else +#define lz4_CanDoStreamingCompression(s) (false) +#endif + +extern void *ReorderBufferNewCompressorState(MemoryContext context, + int compression_method); +extern void ReorderBufferFreeCompressorState(MemoryContext context, + int compression_method, + void *compressor_state); +extern void ReorderBufferCompress(ReorderBuffer *rb, + ReorderBufferDiskHeader **header, + int compression_method, Size data_size, + void *compressor_state); +extern void ReorderBufferDecompress(ReorderBuffer *rb, char *data, + ReorderBufferDiskHeader *header, + void *compressor_state); + +#endif /* REORDERBUFFER_COMPRESSION_H */ -- 2.46.0 [text/x-patch] v4-0002-review.patch (5.6K, ../../[email protected]/3-v4-0002-review.patch) download | inline diff: From 17aed41dfdd452727643a40e5dba6c0c4705c64a Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 16:37:49 +0200 Subject: [PATCH v4 02/11] review --- .../replication/logical/reorderbuffer.c | 10 ++++++++-- .../logical/reorderbuffer_compression.c | 18 +++++++++++++++++- src/include/replication/reorderbuffer.h | 2 ++ .../replication/reorderbuffer_compression.h | 8 ++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index c36179d44b5..f5c51316d9d 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -113,8 +113,6 @@ #include "utils/rel.h" #include "utils/relfilenumbermap.h" -int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; - /* entry for a hash table we use to map from xid to our transaction state */ typedef struct ReorderBufferTXNByIdEnt { @@ -176,6 +174,11 @@ typedef struct ReorderBufferToastEnt * main tup */ } ReorderBufferToastEnt; +/* + * XXX seems wrong to move ReorderBufferDiskChange typedef, it should be private + * in this file, even with compression IMHO + */ + #define IsSpecInsert(action) \ ( \ ((action) == REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT) \ @@ -210,6 +213,9 @@ static const Size max_changes_in_memory = 4096; /* XXX for restore only */ /* GUC variable */ int debug_logical_replication_streaming = DEBUG_LOGICAL_REP_STREAMING_BUFFERED; +/* Compression strategy for spilled data. */ +int logical_decoding_spill_compression = REORDER_BUFFER_NO_COMPRESSION; + /* --------------------------------------- * primary reorderbuffer support routines * --------------------------------------- diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 77f5c76929b..b4fea15ebd9 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -9,6 +9,8 @@ * IDENTIFICATION * src/backend/access/common/reorderbuffer_compression.c * + * + * XXX I'd rename this to reorderbuffer_lz4 or something like that. *------------------------------------------------------------------------- */ #include "postgres.h" @@ -301,6 +303,8 @@ lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) #endif } +/* XXX The rest should be in reorderbuffer.c, with the rest of ReorderBuffer functions */ + /* * Allocate a new Compressor State, depending on the compression method. */ @@ -376,6 +380,12 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, /* LZ4 Compression */ case REORDER_BUFFER_LZ4_COMPRESSION: { + /* + * XXX Won't this cause a lot of palloc/pfree traffic? We allocate a new + * buffer for every compression, only to immediately throw it away. Look + * at what astreamer_lz4_compressor_content does to reuse a buffer, maybe + * we should do that here too? + */ char *dst = NULL; Size dst_size = 0; char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); @@ -428,6 +438,12 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, /* * Decompress data read from disk and copy it into the ReorderBuffer. + * + * XXX Does it make sense to support both "regular" and "streaming" for lz4? + * Isn't one of those clearly better for this use case? + * + * XXX Also, we only ever create LZ4StreamingCompressorState, so does that + * work for non-streaming state? */ void ReorderBufferDecompress(ReorderBuffer *rb, char *data, @@ -479,7 +495,7 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, /* LZ4 streaming decompression */ case REORDER_BUFFER_STRAT_LZ4_STREAMING: { - char *buf; + char *buf; /* XXX shouldn't this be set to NULL explicitly? */ Size src_size = header->size - sizeof(ReorderBufferDiskHeader); Size buf_size = header->raw_size; diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index f1562a77719..1a2ccda2eca 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -9,6 +9,7 @@ #ifndef REORDERBUFFER_H #define REORDERBUFFER_H +/* XXX we don't need any lz4 stuff in this header, right? */ #ifdef USE_LZ4 #include <lz4.h> #endif @@ -30,6 +31,7 @@ /* GUC variables */ extern PGDLLIMPORT int logical_decoding_work_mem; extern PGDLLIMPORT int debug_logical_replication_streaming; +extern PGDLLIMPORT int logical_decoding_spill_compression; /* possible values for debug_logical_replication_streaming */ typedef enum diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 9aa8aea56f4..be739d9ebeb 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -37,6 +37,14 @@ typedef enum ReorderBufferCompressionStrategy } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ + +/* XXX but what does ReorderBufferDiskHeader represent? what is it for? + * XXX Also, shouldn't it be ReorderBufferDiskChangeHeader? It's a header + * for a change, not for a disk. + * XXX I don't quite understand why we renamed this, DiskChange seems quite + * fine to me, even if it gets new fields for compression. Still, I'd keep + * it as private in reorderbuffer.c. + */ typedef struct ReorderBufferDiskHeader { ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ -- 2.46.0 [text/x-patch] v4-0003-Fix-spill_bytes-counter.patch (2.8K, ../../[email protected]/4-v4-0003-Fix-spill_bytes-counter.patch) download | inline diff: From 487eea83f36dc8731bb486dac1336b4598048471 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Sun, 23 Jun 2024 14:42:04 -0700 Subject: [PATCH v4 03/11] Fix spill_bytes counter The spill_bytes counter considers now the fact that decoded changes are spilled on disk compressed. --- src/backend/replication/logical/reorderbuffer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index f5c51316d9d..19b72e90af8 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -252,7 +252,7 @@ static void ReorderBufferExecuteInvalidations(uint32 nmsgs, SharedInvalidationMe */ static void ReorderBufferCheckMemoryLimit(ReorderBuffer *rb); static void ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn); -static void ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change); static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); @@ -3719,6 +3719,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) XLogSegNo curOpenSegNo = 0; Size spilled = 0; Size size = txn->size; + Size spillBytes = 0; elog(DEBUG2, "spill %u changes in XID %u to disk", (uint32) txn->nentries_mem, txn->xid); @@ -3770,7 +3771,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) errmsg("could not open file \"%s\": %m", path))); } - ReorderBufferSerializeChange(rb, txn, fd, change); + spillBytes += ReorderBufferSerializeChange(rb, txn, fd, change); dlist_delete(&change->node); ReorderBufferReturnChange(rb, change, false); @@ -3784,7 +3785,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) if (spilled) { rb->spillCount += 1; - rb->spillBytes += size; + rb->spillBytes += spillBytes; /* don't consider already serialized transactions */ rb->spillTxns += (rbtxn_is_serialized(txn) || rbtxn_is_serialized_clear(txn)) ? 0 : 1; @@ -3805,7 +3806,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) /* * Serialize individual change to disk. */ -static void +static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, int fd, ReorderBufferChange *change) { @@ -4018,6 +4019,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (txn->final_lsn < change->lsn) txn->final_lsn = change->lsn; + + /* Return data size written to disk */ + return disk_hdr->size; } /* Returns true, if the output plugin supports streaming, false, otherwise. */ -- 2.46.0 [text/x-patch] v4-0004-review.patch (1.2K, ../../[email protected]/5-v4-0004-review.patch) download | inline diff: From 2e120c01baa97e82a62fd8c6936612f23dd4ac3c Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 16:47:55 +0200 Subject: [PATCH v4 04/11] review --- src/backend/replication/logical/reorderbuffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 19b72e90af8..168956d944a 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -3805,6 +3805,14 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) /* * Serialize individual change to disk. + * + * Returns the amount of data written to disk (with compression, this is the + * size of the compressed representation). + * + * XXX But is this actually the right thing to do? Even without compression we + * don't really count the bytes written to the disk (we don't account for the + * DiskChange header), but rather the memory representation. So why should we + * do that with compression? Seems a bit strange. */ static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, -- 2.46.0 [text/x-patch] v4-0005-Compress-ReorderBuffer-spill-files-using-PGLZ.patch (4.1K, ../../[email protected]/6-v4-0005-Compress-ReorderBuffer-spill-files-using-PGLZ.patch) download | inline diff: From fbbc3693210041e3840e362e2892cdf94fbec709 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:36:04 -0700 Subject: [PATCH v4 05/11] Compress ReorderBuffer spill files using PGLZ --- .../logical/reorderbuffer_compression.c | 58 +++++++++++++++++++ .../replication/reorderbuffer_compression.h | 2 + 2 files changed, 60 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index b4fea15ebd9..8d158aa51da 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -15,6 +15,8 @@ */ #include "postgres.h" +#include "common/pg_lzcompress.h" + #ifdef USE_LZ4 #include <lz4.h> #endif @@ -317,6 +319,7 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) return lz4_NewCompressorState(context); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: return NULL; break; @@ -337,6 +340,7 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, return lz4_FreeCompressorState(context, compressor_state); break; case REORDER_BUFFER_NO_COMPRESSION: + case REORDER_BUFFER_PGLZ_COMPRESSION: default: break; } @@ -431,6 +435,40 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* PGLZ compression */ + case REORDER_BUFFER_PGLZ_COMPRESSION: + { + int32 dst_size = 0; + char *dst = NULL; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + int32 src_size = data_size - sizeof(ReorderBufferDiskHeader); + int32 max_size = PGLZ_MAX_OUTPUT(src_size); + + dst = (char *) palloc0(max_size); + dst_size = pglz_compress(src, src_size, dst, PGLZ_strategy_always); + + if (dst_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("PGLZ compression failed"))); + + ReorderBufferReserve(rb, (Size) (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_PGLZ; + hdr->size = (Size) dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = (Size) src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -511,6 +549,26 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, */ break; } + /* PGLZ decompression */ + case REORDER_BUFFER_STRAT_PGLZ: + { + char *buf; + int32 src_size = (int32) header->size - sizeof(ReorderBufferDiskHeader); + int32 buf_size = (int32) header->raw_size; + int32 decBytes; + + /* Decompress data directly into the ReorderBuffer */ + buf = (char *) rb->outbuf; + buf += sizeof(ReorderBufferDiskHeader); + + decBytes = pglz_decompress(data, src_size, buf, buf_size, false); + + if (decBytes < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("compressed PGLZ data is corrupted"))); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index be739d9ebeb..133513880e6 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -24,6 +24,7 @@ typedef enum ReorderBufferCompressionMethod { REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, + REORDER_BUFFER_PGLZ_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -34,6 +35,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_UNCOMPRESSED, REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, + REORDER_BUFFER_STRAT_PGLZ, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ -- 2.46.0 [text/x-patch] v4-0006-review.patch (1.2K, ../../[email protected]/7-v4-0006-review.patch) download | inline diff: From 8e243868ce9d6254480a239012bae730f4db77a9 Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 17:05:10 +0200 Subject: [PATCH v4 06/11] review --- .../replication/logical/reorderbuffer_compression.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 8d158aa51da..e8785d27e49 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -438,8 +438,16 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, break; } /* PGLZ compression */ + /* + * XXX I'd probably start by adding pglz first, and only then add lz4 as a + * separate patch, simply because pglz is the default and always supported, + * while lz4 requires extra flags. + */ case REORDER_BUFFER_PGLZ_COMPRESSION: { + /* + * XXX Same comment about palloc/pfree traffic as for lz4 ... + */ int32 dst_size = 0; char *dst = NULL; char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); -- 2.46.0 [text/x-patch] v4-0007-Compress-ReorderBuffer-spill-files-using-ZSTD.patch (14.6K, ../../[email protected]/8-v4-0007-Compress-ReorderBuffer-spill-files-using-ZSTD.patch) download | inline diff: From 8e55c5bf35de74c9a9bf09e0cd3c16c3599dabd5 Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:39:25 -0700 Subject: [PATCH v4 07/11] Compress ReorderBuffer spill files using ZSTD --- .../logical/reorderbuffer_compression.c | 364 ++++++++++++++++++ .../replication/reorderbuffer_compression.h | 39 ++ 2 files changed, 403 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index e8785d27e49..96751852ef8 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -21,6 +21,10 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + #include "replication/reorderbuffer_compression.h" #define NO_LZ4_SUPPORT() \ @@ -29,6 +33,12 @@ errmsg("compression method lz4 not supported"), \ errdetail("This functionality requires the server to be built with lz4 support."))) +#define NO_ZSTD_SUPPORT() \ + ereport(ERROR, \ + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \ + errmsg("compression method zstd not supported"), \ + errdetail("This functionality requires the server to be built with zstd support."))) + /* * Allocate a new LZ4StreamingCompressorState. */ @@ -307,6 +317,309 @@ lz4_DecompressData(char *src, Size src_size, char **dst, Size dst_size) /* XXX The rest should be in reorderbuffer.c, with the rest of ReorderBuffer functions */ +/* + * Allocate a new ZSTDStreamingCompressorState. + */ +static void * +zstd_NewCompressorState(MemoryContext context) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); + return NULL; /* keep compiler quiet */ +#else + ZSTDStreamingCompressorState *cstate; + + cstate = (ZSTDStreamingCompressorState *) + MemoryContextAlloc(context, sizeof(ZSTDStreamingCompressorState)); + + /* + * We do not allocate ZSTD buffers and contexts at this point because we + * have no guarantee that we will need them later. Let's allocate only when + * we are about to use them. + */ + cstate->zstd_c_ctx = NULL; + cstate->zstd_c_in_buf = NULL; + cstate->zstd_c_in_buf_size = 0; + cstate->zstd_c_out_buf = NULL; + cstate->zstd_c_out_buf_size = 0; + cstate->zstd_frame_size = 0; + cstate->zstd_d_ctx = NULL; + cstate->zstd_d_in_buf = NULL; + cstate->zstd_d_in_buf_size = 0; + cstate->zstd_d_out_buf = NULL; + cstate->zstd_d_out_buf_size = 0; + + return (void *) cstate; +#endif +} + +/* + * Free ZSTD memory resources and the compressor state. + */ +static void +zstd_FreeCompressorState(MemoryContext context, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext; + + if (compressor_state == NULL) + return; + + oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + + if (cstate->zstd_c_ctx != NULL) + { + /* Compressor state was used for compression */ + pfree(cstate->zstd_c_in_buf); + pfree(cstate->zstd_c_out_buf); + ZSTD_freeCCtx(cstate->zstd_c_ctx); + } + if (cstate->zstd_d_ctx != NULL) + { + /* Compressor state was used for decompression */ + pfree(cstate->zstd_d_in_buf); + pfree(cstate->zstd_d_out_buf); + ZSTD_freeDCtx(cstate->zstd_d_ctx); + } + + pfree(compressor_state); + + MemoryContextSwitchTo(oldcontext); +#endif +} + +#ifdef USE_ZSTD +/* + * Allocate ZSTD compression buffers and create the ZSTD compression context. + */ +static void +zstd_CreateStreamCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_c_in_buf_size = ZSTD_CStreamInSize(); + cstate->zstd_c_in_buf = (char *) palloc0(cstate->zstd_c_in_buf_size); + cstate->zstd_c_out_buf_size = ZSTD_CStreamOutSize(); + cstate->zstd_c_out_buf = (char *) palloc0(cstate->zstd_c_out_buf_size); + cstate->zstd_c_ctx = ZSTD_createCCtx(); + + if (cstate->zstd_c_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD compression context"))); + + /* Set compression level */ + ZSTD_CCtx_setParameter(cstate->zstd_c_ctx, ZSTD_c_compressionLevel, + ZSTD_COMPRESSION_LEVEL); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +#ifdef USE_ZSTD +/* + * Allocate ZSTD decompression buffers and create the ZSTD decompression + * context. + */ +static void +zstd_CreateStreamDecodeCompressorState(MemoryContext context, void *compressor_state) +{ + ZSTDStreamingCompressorState *cstate; + MemoryContext oldcontext = MemoryContextSwitchTo(context); + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + cstate->zstd_d_in_buf_size = ZSTD_DStreamInSize(); + cstate->zstd_d_in_buf = (char *) palloc0(cstate->zstd_d_in_buf_size); + cstate->zstd_d_out_buf_size = ZSTD_DStreamOutSize(); + cstate->zstd_d_out_buf = (char *) palloc0(cstate->zstd_d_out_buf_size); + cstate->zstd_d_ctx = ZSTD_createDCtx(); + + if (cstate->zstd_d_ctx == NULL) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("could not create ZSTD decompression context"))); + + MemoryContextSwitchTo(oldcontext); +} +#endif + +/* + * Data compression using ZSTD streaming API. + */ +static void +zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size *dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_c_ctx == NULL) + zstd_CreateStreamCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store compressed data */ + *dst = (char *) palloc0(ZSTD_compressBound(src_size)); + + dst_data = *dst; + *dst_size = 0; + + /* + * ZSTD streaming compression works with chunks: the source data needs to + * be splitted out in chunks, each of them is then copied into ZSTD input + * buffer. + * For each chunk, we proceed with compression. Streaming compression is + * not intended to compress the whole input chunk, so we have the call + * ZSTD_compressStream2() multiple times until the entire chunk is + * consumed. + */ + while (toCpy > 0) + { + /* Are we on the last chunk? */ + bool last_chunk = (toCpy < cstate->zstd_c_in_buf_size); + /* Size of the data copied into ZSTD input buffer */ + Size cpySize = last_chunk ? toCpy : cstate->zstd_c_in_buf_size; + bool finished = false; + ZSTD_inBuffer input; + ZSTD_EndDirective mode = last_chunk ? ZSTD_e_flush : ZSTD_e_continue; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_c_in_buf, src, cpySize); + + /* + * Close the frame when we are on the last chunk and we've reached max + * frame size. + */ + if (last_chunk && (cstate->zstd_frame_size > ZSTD_MAX_FRAME_SIZE)) + { + mode = ZSTD_e_end; + cstate->zstd_frame_size = 0; + } + + cstate->zstd_frame_size += cpySize; + + input.src = cstate->zstd_c_in_buf; + input.size = cpySize; + input.pos = 0; + + do + { + Size remaining; + ZSTD_outBuffer output; + + output.dst = cstate->zstd_c_out_buf; + output.size = cstate->zstd_c_out_buf_size; + output.pos = 0; + + remaining = ZSTD_compressStream2(cstate->zstd_c_ctx, &output, + &input, mode); + + if (ZSTD_isError(remaining)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD compression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_c_out_buf, output.pos); + + dst_data += output.pos; + *dst_size += output.pos; + + /* + * Compression is done when we are working on the last chunk and + * there is nothing left to compress, or, when we reach the end of + * the chunk. + */ + finished = last_chunk ? (remaining == 0) : (input.pos == input.size); + } while (!finished); + + src += cpySize; + toCpy -= cpySize; + } +#endif +} + +/* + * Data decompression using ZSTD streaming API. + */ +static void +zstd_StreamingDecompressData(MemoryContext context, char *src, Size src_size, + char **dst, Size dst_size, void *compressor_state) +{ +#ifndef USE_ZSTD + NO_ZSTD_SUPPORT(); +#else + ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ + Size toCpy = src_size; + char *dst_data; + Size decBytes = 0; /* Size of decompressed data */ + + cstate = (ZSTDStreamingCompressorState *) compressor_state; + /* Allocate ZSTD buffers and context */ + if (cstate->zstd_d_ctx == NULL) + zstd_CreateStreamDecodeCompressorState(context, compressor_state); + + /* Allocate memory that will be used to store decompressed data */ + *dst = (char *) palloc0(dst_size); + + dst_data = *dst; + + while (toCpy > 0) + { + ZSTD_inBuffer input; + Size cpySize = (toCpy > cstate->zstd_d_in_buf_size) ? cstate->zstd_d_in_buf_size : toCpy; + + /* Copy data from src into ZSTD input buffer */ + memcpy(cstate->zstd_d_in_buf, src, cpySize); + + input.src = cstate->zstd_d_in_buf; + input.size = cpySize; + input.pos = 0; + + while (input.pos < input.size) + { + ZSTD_outBuffer output; + Size ret; + + output.dst = cstate->zstd_d_out_buf; + output.size = cstate->zstd_d_out_buf_size; + output.pos = 0; + + ret = ZSTD_decompressStream(cstate->zstd_d_ctx, &output , &input); + + if (ZSTD_isError(ret)) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("ZSTD decompression failed"))); + + /* Copy back compressed data from ZSTD output buffer */ + memcpy(dst_data, (char *) cstate->zstd_d_out_buf, output.pos); + + dst_data += output.pos; + decBytes += output.pos; + } + + src += cpySize; + toCpy -= cpySize; + } + + Assert(dst_size == decBytes); +#endif +} + /* * Allocate a new Compressor State, depending on the compression method. */ @@ -318,6 +631,9 @@ ReorderBufferNewCompressorState(MemoryContext context, int compression_method) case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_NewCompressorState(context); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_NewCompressorState(context); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -339,6 +655,9 @@ ReorderBufferFreeCompressorState(MemoryContext context, int compression_method, case REORDER_BUFFER_LZ4_COMPRESSION: return lz4_FreeCompressorState(context, compressor_state); break; + case REORDER_BUFFER_ZSTD_COMPRESSION: + return zstd_FreeCompressorState(context, compressor_state); + break; case REORDER_BUFFER_NO_COMPRESSION: case REORDER_BUFFER_PGLZ_COMPRESSION: default: @@ -477,6 +796,35 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, pfree(dst); + break; + } + /* ZSTD Compression */ + case REORDER_BUFFER_ZSTD_COMPRESSION: + { + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + + /* Use ZSTD streaming compression */ + zstd_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_ZSTD_STREAMING; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; + + *header = hdr; + + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); + + pfree(dst); + break; } } @@ -577,6 +925,22 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, errmsg_internal("compressed PGLZ data is corrupted"))); break; } + /* ZSTD streaming decompression */ + case REORDER_BUFFER_STRAT_ZSTD_STREAMING: + { + char *buf; + Size src_size = header->size - sizeof(ReorderBufferDiskHeader); + Size buf_size = header->raw_size; + + zstd_StreamingDecompressData(rb->context, data, src_size, &buf, + buf_size, compressor_state); + + /* Copy decompressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), + buf, buf_size); + pfree(buf); + break; + } default: /* Other compression methods not yet supported */ break; diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 133513880e6..960064d571e 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -19,12 +19,17 @@ #include <lz4.h> #endif +#ifdef USE_ZSTD +#include <zstd.h> +#endif + /* ReorderBuffer on disk compression algorithms */ typedef enum ReorderBufferCompressionMethod { REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, REORDER_BUFFER_PGLZ_COMPRESSION, + REORDER_BUFFER_ZSTD_COMPRESSION, } ReorderBufferCompressionMethod; /* @@ -36,6 +41,7 @@ typedef enum ReorderBufferCompressionStrategy REORDER_BUFFER_STRAT_LZ4_STREAMING, REORDER_BUFFER_STRAT_LZ4_REGULAR, REORDER_BUFFER_STRAT_PGLZ, + REORDER_BUFFER_STRAT_ZSTD_STREAMING, } ReorderBufferCompressionStrategy; /* Disk serialization support datastructures */ @@ -89,6 +95,39 @@ typedef struct LZ4StreamingCompressorState { #define lz4_CanDoStreamingCompression(s) (false) #endif +#ifdef USE_ZSTD +/* + * Low compression level provides high compression speed and decent compression + * rate. Minimum level is 1, maximum is 22. + */ +#define ZSTD_COMPRESSION_LEVEL 1 + +/* + * Maximum volume of data encoded in the current ZSTD frame. When this + * threshold is reached then we close the current frame and start a new one. + */ +#define ZSTD_MAX_FRAME_SIZE (64 * 1024) + +/* + * ZSTD streaming compression/decompression handlers and buffers. + */ +typedef struct ZSTDStreamingCompressorState { + /* Compression */ + ZSTD_CCtx *zstd_c_ctx; + Size zstd_c_in_buf_size; + char *zstd_c_in_buf; + Size zstd_c_out_buf_size; + char *zstd_c_out_buf; + Size zstd_frame_size; + /* Decompression */ + ZSTD_DCtx *zstd_d_ctx; + Size zstd_d_in_buf_size; + char *zstd_d_in_buf; + Size zstd_d_out_buf_size; + char *zstd_d_out_buf; +} ZSTDStreamingCompressorState; +#endif + extern void *ReorderBufferNewCompressorState(MemoryContext context, int compression_method); extern void ReorderBufferFreeCompressorState(MemoryContext context, -- 2.46.0 [text/x-patch] v4-0008-review.patch (1.3K, ../../[email protected]/9-v4-0008-review.patch) download | inline diff: From 7cbf94f473454987410373b6ca78e44c06b5fe08 Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 17:08:35 +0200 Subject: [PATCH v4 08/11] review --- src/backend/replication/logical/reorderbuffer_compression.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 96751852ef8..67068db9d2c 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -801,6 +801,9 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, /* ZSTD Compression */ case REORDER_BUFFER_ZSTD_COMPRESSION: { + /* + * XXX Same comment about palloc/pfree traffic as for lz4 ... + */ char *dst = NULL; Size dst_size = 0; char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); @@ -928,7 +931,7 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, /* ZSTD streaming decompression */ case REORDER_BUFFER_STRAT_ZSTD_STREAMING: { - char *buf; + char *buf; /* XXX shouldn't this be set to NULL explicitly? */ Size src_size = header->size - sizeof(ReorderBufferDiskHeader); Size buf_size = header->raw_size; -- 2.46.0 [text/x-patch] v4-0009-Add-the-subscription-option-spill_compression.patch (66.0K, ../../[email protected]/10-v4-0009-Add-the-subscription-option-spill_compression.patch) download | inline diff: From 406e38977b0dd868b20ac31107c8bfbd89e5ad0d Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 15:30:53 +0200 Subject: [PATCH v4 09/11] Add the subscription option spill_compression --- doc/src/sgml/ref/create_subscription.sgml | 24 +++ src/backend/catalog/pg_subscription.c | 6 + src/backend/catalog/system_views.sql | 3 +- src/backend/commands/subscriptioncmds.c | 31 +++- .../libpqwalreceiver/libpqwalreceiver.c | 5 + src/backend/replication/logical/logical.c | 4 + .../replication/logical/reorderbuffer.c | 15 +- .../logical/reorderbuffer_compression.c | 57 +++++++ src/backend/replication/logical/worker.c | 13 +- src/backend/replication/pgoutput/pgoutput.c | 28 ++++ src/bin/pg_dump/pg_dump.c | 18 +- src/bin/pg_dump/pg_dump.h | 1 + src/bin/pg_dump/t/002_pg_dump.pl | 8 +- src/bin/psql/describe.c | 7 +- src/bin/psql/tab-complete.c | 5 +- src/include/catalog/pg_subscription.h | 4 + src/include/replication/logical.h | 2 + src/include/replication/pgoutput.h | 1 + .../replication/reorderbuffer_compression.h | 4 + src/include/replication/walreceiver.h | 1 + src/test/regress/expected/subscription.out | 156 +++++++++--------- src/test/regress/sql/subscription.sql | 4 + 22 files changed, 305 insertions(+), 92 deletions(-) diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index 740b7d94210..56f733eaf8d 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -428,6 +428,30 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl </para> </listitem> </varlistentry> + + <varlistentry id="sql-createsubscription-params-with-spill-compression"> + <term><literal>spill_compression</literal> (<type>enum</type>)</term> + <listitem> + <para> + Specifies whether the decoded changes that eventually need to be + temporarily written on disk by the publisher are compressed or not. + Default value is <literal>off</literal> meaning no data compression + involved. Setting <literal>spill_compression</literal> to + <literal>on</literal> or <literal>pglz</literal> means that the + decoded changes are compressed using the internal + <literal>PGLZ</literal> compression algorithm. + </para> + + <para> + If the <productname>PostgreSQL</productname> server running the + publisher node supports the external compression libraries + <productname>LZ4</productname> or + <productname>Zstandard</productname>, + <literal>spill_compression</literal> can be set respectively to + <literal>lz4</literal> or <literal>zstd</literal>. + </para> + </listitem> + </varlistentry> </variablelist></para> </listitem> diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 9efc9159f2c..a3329043dca 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -110,6 +110,12 @@ GetSubscription(Oid subid, bool missing_ok) /* Is the subscription owner a superuser? */ sub->ownersuperuser = superuser_arg(sub->owner); + /* Get spill_compression */ + datum = SysCacheGetAttrNotNull(SUBSCRIPTIONOID, + tup, + Anum_pg_subscription_subspillcompression); + sub->spill_compression = TextDatumGetCString(datum); + ReleaseSysCache(tup); return sub; diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 7fd5d256a18..40768a9ae9d 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1356,7 +1356,8 @@ REVOKE ALL ON pg_subscription FROM public; GRANT SELECT (oid, subdbid, subskiplsn, subname, subowner, subenabled, subbinary, substream, subtwophasestate, subdisableonerr, subpasswordrequired, subrunasowner, subfailover, - subslotname, subsynccommit, subpublications, suborigin) + subslotname, subsynccommit, subpublications, suborigin, + subspillcompression) ON pg_subscription TO public; CREATE VIEW pg_stat_subscription_stats AS diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 02ccc636b80..018f42494d0 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -40,6 +40,7 @@ #include "replication/logicallauncher.h" #include "replication/logicalworker.h" #include "replication/origin.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slot.h" #include "replication/walreceiver.h" #include "replication/walsender.h" @@ -73,6 +74,7 @@ #define SUBOPT_FAILOVER 0x00002000 #define SUBOPT_LSN 0x00004000 #define SUBOPT_ORIGIN 0x00008000 +#define SUBOPT_SPILL_COMPRESSION 0x00010000 /* check if the 'val' has 'bits' set */ #define IsSet(val, bits) (((val) & (bits)) == (bits)) @@ -100,6 +102,7 @@ typedef struct SubOpts bool failover; char *origin; XLogRecPtr lsn; + char *spill_compression; } SubOpts; static List *fetch_table_list(WalReceiverConn *wrconn, List *publications); @@ -164,6 +167,8 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, opts->failover = false; if (IsSet(supported_opts, SUBOPT_ORIGIN)) opts->origin = pstrdup(LOGICALREP_ORIGIN_ANY); + if (IsSet(supported_opts, SUBOPT_SPILL_COMPRESSION)) + opts->spill_compression = "off"; /* Parse options */ foreach(lc, stmt_options) @@ -357,6 +362,18 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, opts->specified_opts |= SUBOPT_LSN; opts->lsn = lsn; } + else if (IsSet(supported_opts, SUBOPT_SPILL_COMPRESSION) && + strcmp(defel->defname, "spill_compression") == 0) + { + if (IsSet(opts->specified_opts, SUBOPT_SPILL_COMPRESSION)) + errorConflictingDefElem(defel, pstate); + + opts->specified_opts |= SUBOPT_SPILL_COMPRESSION; + opts->spill_compression = defGetString(defel); + + ReorderBufferValidateCompressionMethod(opts->spill_compression, + ERROR); + } else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -594,7 +611,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | SUBOPT_STREAMING | SUBOPT_TWOPHASE_COMMIT | SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | - SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN); + SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN | + SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); /* @@ -714,6 +732,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, publicationListToArray(publications); values[Anum_pg_subscription_suborigin - 1] = CStringGetTextDatum(opts.origin); + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); tup = heap_form_tuple(RelationGetDescr(rel), values, nulls); @@ -1196,7 +1216,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, SUBOPT_DISABLE_ON_ERR | SUBOPT_PASSWORD_REQUIRED | SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | - SUBOPT_ORIGIN); + SUBOPT_ORIGIN | SUBOPT_SPILL_COMPRESSION); parse_subscription_options(pstate, stmt->options, supported_opts, &opts); @@ -1363,6 +1383,13 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, replaces[Anum_pg_subscription_suborigin - 1] = true; } + if (IsSet(opts.specified_opts, SUBOPT_SPILL_COMPRESSION)) + { + values[Anum_pg_subscription_subspillcompression - 1] = + CStringGetTextDatum(opts.spill_compression); + replaces[Anum_pg_subscription_subspillcompression - 1] = true; + } + update_tuple = true; break; } diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 97f957cd87b..20f5e4a83e8 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -620,6 +620,11 @@ libpqrcv_startstreaming(WalReceiverConn *conn, PQserverVersion(conn->streamConn) >= 140000) appendStringInfoString(&cmd, ", binary 'true'"); + if (options->proto.logical.spill_compression && + PQserverVersion(conn->streamConn) >= 180000) + appendStringInfo(&cmd, ", spill_compression '%s'", + options->proto.logical.spill_compression); + appendStringInfoChar(&cmd, ')'); } else diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 3fe1774a1e9..54fbbe6fea6 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -36,6 +36,7 @@ #include "replication/decode.h" #include "replication/logical.h" #include "replication/reorderbuffer.h" +#include "replication/reorderbuffer_compression.h" #include "replication/slotsync.h" #include "replication/snapbuild.h" #include "storage/proc.h" @@ -298,6 +299,9 @@ StartupDecodingContext(List *output_plugin_options, ctx->fast_forward = fast_forward; + /* No spill files compression by default */ + ctx->spill_compression_method = REORDER_BUFFER_NO_COMPRESSION; + MemoryContextSwitchTo(old_context); return ctx; diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 168956d944a..6545c310f7f 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -410,6 +410,15 @@ ReorderBufferFree(ReorderBuffer *rb) ReorderBufferCleanupSerializedTXNs(NameStr(MyReplicationSlot->data.name)); } +/* Returns spill files compression method */ +static inline uint8 +ReorderBufferSpillCompressionMethod(ReorderBuffer *rb) +{ + LogicalDecodingContext *ctx = rb->private_data; + + return ctx->spill_compression_method; +} + /* * Get an unused, possibly preallocated, ReorderBufferTXN. */ @@ -431,7 +440,7 @@ ReorderBufferGetTXN(ReorderBuffer *rb) txn->command_id = InvalidCommandId; txn->output_plugin_private = NULL; txn->compressor_state = ReorderBufferNewCompressorState(rb->context, - logical_decoding_spill_compression); + ReorderBufferSpillCompressionMethod(rb)); return txn; } @@ -470,7 +479,7 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) } ReorderBufferFreeCompressorState(rb->context, - logical_decoding_spill_compression, + ReorderBufferSpillCompressionMethod(rb), txn->compressor_state); /* Reset the toast hash */ @@ -3996,7 +4005,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* Inplace ReorderBuffer content compression before writing it on disk */ - ReorderBufferCompress(rb, &disk_hdr, logical_decoding_spill_compression, + ReorderBufferCompress(rb, &disk_hdr, ReorderBufferSpillCompressionMethod(rb), sz, txn->compressor_state); errno = 0; diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 67068db9d2c..707f35cff7c 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -949,3 +949,60 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, break; } } + +/* + * According to a given compression method (as string representation), returns + * the corresponding ReorderBufferCompressionMethod + */ +ReorderBufferCompressionMethod +ReorderBufferParseCompressionMethod(const char *method) +{ + if (pg_strcasecmp(method, "on") == 0) + return REORDER_BUFFER_PGLZ_COMPRESSION; + else if (pg_strcasecmp(method, "pglz") == 0) + return REORDER_BUFFER_PGLZ_COMPRESSION; + else if (pg_strcasecmp(method, "off") == 0) + return REORDER_BUFFER_NO_COMPRESSION; +#ifdef USE_LZ4 + else if (pg_strcasecmp(method, "lz4") == 0) + return REORDER_BUFFER_LZ4_COMPRESSION; +#endif +#ifdef USE_ZSTD + else if (pg_strcasecmp(method, "zstd") == 0) + return REORDER_BUFFER_ZSTD_COMPRESSION; +#endif + else + return REORDER_BUFFER_INVALID_COMPRESSION; +} + +/* + * Check whether the passed compression method is valid and report errors at + * elevel. + * + * As this validation is intended to be executed on subscriber side, then we + * actually don't know if the server running the publisher supports external + * compression libraries. We only check if the compression method is + * potentially supported. The real validation is done by the publisher when + * the replication starts, an error is then triggered if the compression method + * is not supported. + */ +void +ReorderBufferValidateCompressionMethod(const char *method, int elevel) +{ + bool valid = false; + char methods[5][5] = {"on", "off", "pglz", "lz4", "zstd"}; + + for (int i = 0; i < 5; i++) + { + if (pg_strcasecmp(method, methods[i]) == 0) + { + valid = true; + break; + } + } + + if (!valid) + ereport(elevel, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("compression method \"%s\" not valid", method))); +} diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 925dff9cc44..eb42e844f99 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -4021,7 +4021,8 @@ maybe_reread_subscription(void) newsub->passwordrequired != MySubscription->passwordrequired || strcmp(newsub->origin, MySubscription->origin) != 0 || newsub->owner != MySubscription->owner || - !equal(newsub->publications, MySubscription->publications)) + !equal(newsub->publications, MySubscription->publications) || + strcmp(newsub->spill_compression, MySubscription->spill_compression) != 0) { if (am_parallel_apply_worker()) ereport(LOG, @@ -4469,6 +4470,16 @@ set_stream_options(WalRcvStreamOptions *options, MyLogicalRepWorker->parallel_apply = false; } + if (server_version >= 180000 && + MySubscription->stream == LOGICALREP_STREAM_OFF && + MySubscription->spill_compression != NULL) + { + options->proto.logical.spill_compression = + pstrdup(MySubscription->spill_compression); + } + else + options->proto.logical.spill_compression = NULL; + options->proto.logical.twophase = false; options->proto.logical.origin = pstrdup(MySubscription->origin); } diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 00e7024563e..521b646bb60 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -27,6 +27,7 @@ #include "replication/logicalproto.h" #include "replication/origin.h" #include "replication/pgoutput.h" +#include "replication/reorderbuffer_compression.h" #include "utils/builtins.h" #include "utils/inval.h" #include "utils/lsyscache.h" @@ -283,11 +284,13 @@ parse_output_parameters(List *options, PGOutputData *data) bool streaming_given = false; bool two_phase_option_given = false; bool origin_option_given = false; + bool spill_compression_option_given = false; data->binary = false; data->streaming = LOGICALREP_STREAM_OFF; data->messages = false; data->two_phase = false; + data->spill_compression_method = REORDER_BUFFER_NO_COMPRESSION; foreach(lc, options) { @@ -396,6 +399,28 @@ parse_output_parameters(List *options, PGOutputData *data) errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized origin value: \"%s\"", origin)); } + else if (strcmp(defel->defname, "spill_compression") == 0) + { + uint8 method; + char *method_str; + + if (spill_compression_option_given) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("conflicting or redundant options"))); + spill_compression_option_given = true; + + method_str = defGetString(defel); + method = ReorderBufferParseCompressionMethod(method_str); + + if (method == REORDER_BUFFER_INVALID_COMPRESSION) + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid spill files compression method: \"%s\"", + method_str)); + + data->spill_compression_method = method; + } else elog(ERROR, "unrecognized pgoutput option: %s", defel->defname); } @@ -508,6 +533,9 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, data->publications = NIL; publications_valid = false; + /* Init spill files compression method */ + ctx->spill_compression_method = data->spill_compression_method; + /* * Register callback for pg_publication if we didn't already do that * during some previous call in this process. diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 6e07984e8d5..e660b3bd444 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -4847,6 +4847,7 @@ getSubscriptions(Archive *fout) int i_suboriginremotelsn; int i_subenabled; int i_subfailover; + int i_subspillcompression; int i, ntups; @@ -4919,10 +4920,17 @@ getSubscriptions(Archive *fout) if (fout->remoteVersion >= 170000) appendPQExpBufferStr(query, - " s.subfailover\n"); + " s.subfailover,\n"); else appendPQExpBuffer(query, - " false AS subfailover\n"); + " false AS subfailover,\n"); + + if (fout->remoteVersion >= 180000) + appendPQExpBufferStr(query, + " s.subspillcompression\n"); + else + appendPQExpBuffer(query, + " 'off' AS subspillcompression\n"); appendPQExpBufferStr(query, "FROM pg_subscription s\n"); @@ -4962,6 +4970,7 @@ getSubscriptions(Archive *fout) i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn"); i_subenabled = PQfnumber(res, "subenabled"); i_subfailover = PQfnumber(res, "subfailover"); + i_subspillcompression = PQfnumber(res, "subspillcompression"); subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo)); @@ -5008,6 +5017,8 @@ getSubscriptions(Archive *fout) pg_strdup(PQgetvalue(res, i, i_subenabled)); subinfo[i].subfailover = pg_strdup(PQgetvalue(res, i, i_subfailover)); + subinfo[i].subspillcompression = + pg_strdup(PQgetvalue(res, i, i_subspillcompression)); /* Decide whether we want to dump it */ selectDumpableObject(&(subinfo[i].dobj), fout); @@ -5254,6 +5265,9 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo) if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0) appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin); + if (strcmp(subinfo->subspillcompression, "off") != 0) + appendPQExpBuffer(query, ", spill_compression = %s", subinfo->subspillcompression); + appendPQExpBufferStr(query, ");\n"); /* diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 9f907ed5ad4..ecbf2c2e276 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -673,6 +673,7 @@ typedef struct _SubscriptionInfo char *suborigin; char *suboriginremotelsn; char *subfailover; + char *subspillcompression; } SubscriptionInfo; /* diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index ab6c8304913..dea2fc40eac 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -3001,9 +3001,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub2 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = none);', + WITH (connect = false, origin = none, spill_compression = on);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none);\E + \QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', origin = none, spill_compression = on);\E /xm, like => { %full_runs, section_post_data => 1, }, }, @@ -3012,9 +3012,9 @@ my %tests = ( create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub3 CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1 - WITH (connect = false, origin = any);', + WITH (connect = false, origin = any, spill_compression = pglz);', regexp => qr/^ - \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3');\E + \QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', spill_compression = pglz);\E /xm, like => { %full_runs, section_post_data => 1, }, }, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index faabecbc76f..9378a03bf23 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6547,7 +6547,7 @@ describeSubscriptions(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, - false}; + false, false}; if (pset.sversion < 100000) { @@ -6627,6 +6627,11 @@ describeSubscriptions(const char *pattern, bool verbose) appendPQExpBuffer(&buf, ", subskiplsn AS \"%s\"\n", gettext_noop("Skip LSN")); + + if (pset.sversion >= 180000) + appendPQExpBuffer(&buf, + ", subspillcompression AS \"%s\"\n", + gettext_noop("Spill files compression")); } /* Only display subscriptions in current database. */ diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index a7ccde6d7df..728f2bd771e 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1948,7 +1948,7 @@ psql_completion(const char *text, int start, int end) else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "(")) COMPLETE_WITH("binary", "disable_on_error", "failover", "origin", "password_required", "run_as_owner", "slot_name", - "streaming", "synchronous_commit", "two_phase"); + "spill_compression", "streaming", "synchronous_commit", "two_phase"); /* ALTER SUBSCRIPTION <name> SKIP ( */ else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SKIP", "(")) COMPLETE_WITH("lsn"); @@ -3345,7 +3345,8 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("binary", "connect", "copy_data", "create_slot", "disable_on_error", "enabled", "failover", "origin", "password_required", "run_as_owner", "slot_name", - "streaming", "synchronous_commit", "two_phase"); + "spill_compression", "streaming", "synchronous_commit", + "two_phase"); /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */ diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h index 0aa14ec4a27..61c284349ca 100644 --- a/src/include/catalog/pg_subscription.h +++ b/src/include/catalog/pg_subscription.h @@ -113,6 +113,9 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW /* Only publish data originating from the specified origin */ text suborigin BKI_DEFAULT(LOGICALREP_ORIGIN_ANY); + + /* Spill files compression algorithm */ + text subspillcompression BKI_FORCE_NOT_NULL; #endif } FormData_pg_subscription; @@ -157,6 +160,7 @@ typedef struct Subscription List *publications; /* List of publication names to subscribe to */ char *origin; /* Only publish data originating from the * specified origin */ + char *spill_compression; /* Spill files compression algorithm */ } Subscription; /* Disallow streaming in-progress transactions. */ diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h index aff38e8d049..75c17866c38 100644 --- a/src/include/replication/logical.h +++ b/src/include/replication/logical.h @@ -112,6 +112,8 @@ typedef struct LogicalDecodingContext /* Do we need to process any change in fast_forward mode? */ bool processing_required; + /* Compression method used to compress spill files */ + uint8 spill_compression_method; } LogicalDecodingContext; diff --git a/src/include/replication/pgoutput.h b/src/include/replication/pgoutput.h index 89f94e11472..eabcca62af9 100644 --- a/src/include/replication/pgoutput.h +++ b/src/include/replication/pgoutput.h @@ -33,6 +33,7 @@ typedef struct PGOutputData bool messages; bool two_phase; bool publish_no_origin; + uint8 spill_compression_method; } PGOutputData; #endif /* PGOUTPUT_H */ diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index 960064d571e..f72f0e0fbd7 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -26,6 +26,7 @@ /* ReorderBuffer on disk compression algorithms */ typedef enum ReorderBufferCompressionMethod { + REORDER_BUFFER_INVALID_COMPRESSION, REORDER_BUFFER_NO_COMPRESSION, REORDER_BUFFER_LZ4_COMPRESSION, REORDER_BUFFER_PGLZ_COMPRESSION, @@ -140,5 +141,8 @@ extern void ReorderBufferCompress(ReorderBuffer *rb, extern void ReorderBufferDecompress(ReorderBuffer *rb, char *data, ReorderBufferDiskHeader *header, void *compressor_state); +extern ReorderBufferCompressionMethod ReorderBufferParseCompressionMethod(const char *method); +extern void ReorderBufferValidateCompressionMethod(const char *method, + int elevel); #endif /* REORDERBUFFER_COMPRESSION_H */ diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index 132e789948b..b759b5807d8 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -186,6 +186,7 @@ typedef struct * prepare time */ char *origin; /* Only publish data originating from the * specified origin */ + char *spill_compression; /* Spill files compression algo */ } logical; } proto; } WalRcvStreamOptions; diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 17d48b16857..80ea7776513 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -116,18 +116,18 @@ CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PU WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub4 SET (origin = any); \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub4 | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub3; @@ -145,10 +145,10 @@ ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar'; ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false); @@ -157,10 +157,10 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (password_required = true); @@ -176,10 +176,10 @@ ERROR: unrecognized subscription parameter: "create_slot" -- ok ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345'); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 | off (1 row) -- ok - with lsn = NONE @@ -188,10 +188,10 @@ ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE); ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0'); ERROR: invalid WAL location (LSN): 0/0 \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 | off (1 row) BEGIN; @@ -222,11 +222,15 @@ ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); ERROR: invalid value for parameter "synchronous_commit": "foobar" HINT: Available values: local, remote_write, remote_apply, on, off. +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); +ERROR: compression method "foobar" not valid \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ----------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +---------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+----------+------------------------- + regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 | off (1 row) -- rename back to keep the rest simple @@ -255,19 +259,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | t | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (binary = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub; @@ -279,27 +283,27 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) -- fail - publication already exists @@ -314,10 +318,10 @@ ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refr ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false); ERROR: publication "testpub1" is already in subscription "regress_testsub" \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) -- fail - publication used more than once @@ -332,10 +336,10 @@ ERROR: publication "testpub3" is not in subscription "regress_testsub" -- ok - delete publications ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) DROP SUBSCRIPTION regress_testsub; @@ -371,19 +375,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) -- we can alter streaming when two_phase enabled ALTER SUBSCRIPTION regress_testsub SET (streaming = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -393,10 +397,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -409,18 +413,18 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN | Spill files compression +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+----------+------------------------- + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 | off (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 007c9e70374..368696f430c 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -140,6 +140,10 @@ ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo; ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local); ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = pglz); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = off); +ALTER SUBSCRIPTION regress_testsub_foo SET (spill_compression = foobar); + \dRs+ -- rename back to keep the rest simple -- 2.46.0 [text/x-patch] v4-0010-Add-ReorderBuffer-ondisk-compression-tests.patch (5.0K, ../../[email protected]/11-v4-0010-Add-ReorderBuffer-ondisk-compression-tests.patch) download | inline diff: From 238d391dfee9a1dc0020c17fe158f2a5d1bbf9da Mon Sep 17 00:00:00 2001 From: Julien Tachoires <[email protected]> Date: Thu, 18 Jul 2024 07:51:29 -0700 Subject: [PATCH v4 10/11] Add ReorderBuffer ondisk compression tests --- src/test/subscription/Makefile | 2 + src/test/subscription/meson.build | 7 +- .../t/034_reorderbuffer_compression.pl | 99 +++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/test/subscription/t/034_reorderbuffer_compression.pl diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile index ce1ca430095..9341f1493c5 100644 --- a/src/test/subscription/Makefile +++ b/src/test/subscription/Makefile @@ -16,6 +16,8 @@ include $(top_builddir)/src/Makefile.global EXTRA_INSTALL = contrib/hstore export with_icu +export with_lz4 +export with_zstd check: $(prove_check) diff --git a/src/test/subscription/meson.build b/src/test/subscription/meson.build index c591cd7d619..772eeb817f6 100644 --- a/src/test/subscription/meson.build +++ b/src/test/subscription/meson.build @@ -5,7 +5,11 @@ tests += { 'sd': meson.current_source_dir(), 'bd': meson.current_build_dir(), 'tap': { - 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + 'env': { + 'with_icu': icu.found() ? 'yes' : 'no', + 'with_lz4': lz4.found() ? 'yes' : 'no', + 'with_zstd': zstd.found() ? 'yes' : 'no', + }, 'tests': [ 't/001_rep_changes.pl', 't/002_types.pl', @@ -40,6 +44,7 @@ tests += { 't/031_column_list.pl', 't/032_subscribe_use_index.pl', 't/033_run_as_table_owner.pl', + 't/034_reorderbuffer_compression.pl', 't/100_bugs.pl', ], }, diff --git a/src/test/subscription/t/034_reorderbuffer_compression.pl b/src/test/subscription/t/034_reorderbuffer_compression.pl new file mode 100644 index 00000000000..65c9be14a22 --- /dev/null +++ b/src/test/subscription/t/034_reorderbuffer_compression.pl @@ -0,0 +1,99 @@ + +# Copyright (c) 2024, PostgreSQL Global Development Group + +# Test ReorderBuffer compression +use strict; +use warnings FATAL => 'all'; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +sub test_reorderbuffer_compression +{ + my ($node_publisher, $node_subscriber, $appname, $compression) = @_; + + # Set subscriber's spill_compression option + $node_subscriber->safe_psql('postgres', + "ALTER SUBSCRIPTION tap_sub SET (spill_compression = $compression)"); + + # Make sure the table is empty + $node_publisher->safe_psql('postgres', 'TRUNCATE test_tab'); + + # Reset replication slot stats + $node_publisher->safe_psql('postgres', + "SELECT pg_stat_reset_replication_slot('tap_sub')"); + + # Insert 1 million rows in the table + $node_publisher->safe_psql('postgres', + "INSERT INTO test_tab SELECT i, 'Message number #'||i::TEXT FROM generate_series(1, 1000000) as i" + ); + + $node_publisher->wait_for_catchup($appname); + + # Check if table content is replicated + my $result = + $node_subscriber->safe_psql('postgres', + "SELECT count(*) FROM test_tab"); + is($result, qq(1000000), 'check data was copied to subscriber'); + + # Check if the transaction was spilled on disk + my $res_stats = + $node_publisher->safe_psql('postgres', + "SELECT spill_txns FROM pg_catalog.pg_stat_get_replication_slot('tap_sub');"); + is($res_stats, qq(1), 'check if the transaction was spilled on disk'); +} + +# Create publisher node +my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher->init(allows_streaming => 'logical'); +$node_publisher->append_conf('postgresql.conf', + 'logical_decoding_work_mem = 64'); +$node_publisher->start; + +# Create subscriber node +my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); +$node_subscriber->init; +$node_subscriber->start; + +# Setup structure on publisher +$node_publisher->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup structure on subscriber +$node_subscriber->safe_psql('postgres', + "CREATE TABLE test_tab (a int primary key, b text)"); + +# Setup logical replication +my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION tap_pub FOR TABLE test_tab"); + +my $appname = 'tap_sub'; + +$node_subscriber->safe_psql('postgres', + "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = off)" +); + +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'off'); +test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'pglz'); + +SKIP: +{ + skip "LZ4 not supported by this build", 2 if ($ENV{with_lz4} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'lz4'); +} + +SKIP: +{ + skip "ZSTD not supported by this build", 2 if ($ENV{with_zstd} ne 'yes'); + test_reorderbuffer_compression($node_publisher, $node_subscriber, $appname, + 'zstd'); +} + +$node_subscriber->stop; +$node_publisher->stop; + +done_testing(); -- 2.46.0 [text/x-patch] v4-0011-pgindent.patch (21.5K, ../../[email protected]/12-v4-0011-pgindent.patch) download | inline diff: From db7367f9fe2bf1072793fedbb749422e4977b5e0 Mon Sep 17 00:00:00 2001 From: Tomas Vondra <[email protected]> Date: Tue, 17 Sep 2024 17:23:26 +0200 Subject: [PATCH v4 11/11] pgindent --- .../replication/logical/reorderbuffer.c | 11 +- .../logical/reorderbuffer_compression.c | 285 +++++++++--------- src/backend/replication/logical/worker.c | 4 +- .../replication/reorderbuffer_compression.h | 12 +- src/tools/pgindent/typedefs.list | 5 + 5 files changed, 166 insertions(+), 151 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 6545c310f7f..1b6ddecb83e 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -257,7 +257,7 @@ static Size ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *tx static Size ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, TXNEntryFile *file, XLogSegNo *segno); static bool ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, - TXNEntryFile *file, XLogSegNo *segno); + TXNEntryFile *file, XLogSegNo *segno); static void ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn, char *data); static void ReorderBufferRestoreCleanup(ReorderBuffer *rb, ReorderBufferTXN *txn); @@ -3833,7 +3833,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, ReorderBufferSerializeReserve(rb, sz); disk_hdr = (ReorderBufferDiskHeader *) rb->outbuf; - memcpy((char *)rb->outbuf + sizeof(ReorderBufferDiskHeader), change, sizeof(ReorderBufferChange)); + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), change, sizeof(ReorderBufferChange)); switch (change->action) { @@ -4345,9 +4345,8 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn, } /* - * Read the full change from disk. - * If ReorderBufferReadOndiskChange returns false, then we are at the - * eof, so, move the next segment. + * Read the full change from disk. If ReorderBufferReadOndiskChange + * returns false, then we are at the eof, so, move the next segment. */ if (!ReorderBufferReadOndiskChange(rb, txn, file, segno)) { @@ -4375,7 +4374,7 @@ ReorderBufferReadOndiskChange(ReorderBuffer *rb, ReorderBufferTXN *txn, { int readBytes; ReorderBufferDiskHeader *disk_hdr; - char *header; /* disk header buffer*/ + char *header; /* disk header buffer */ char *data; /* data buffer */ /* diff --git a/src/backend/replication/logical/reorderbuffer_compression.c b/src/backend/replication/logical/reorderbuffer_compression.c index 707f35cff7c..6d19c60b601 100644 --- a/src/backend/replication/logical/reorderbuffer_compression.c +++ b/src/backend/replication/logical/reorderbuffer_compression.c @@ -158,9 +158,9 @@ lz4_StreamingCompressData(MemoryContext context, char *src, Size src_size, #else LZ4StreamingCompressorState *cstate; int lz4_cmp_size = 0; /* compressed size */ - char *buf; /* buffer used for compression */ - Size buf_size; /* buffer size */ - char *lz4_in_bufPtr; /* input ring buffer pointer */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ + char *lz4_in_bufPtr; /* input ring buffer pointer */ cstate = (LZ4StreamingCompressorState *) compressor_state; @@ -204,14 +204,14 @@ lz4_StreamingCompressData(MemoryContext context, char *src, Size src_size, * Data compression using LZ4 API. */ static void -lz4_CompressData(char *src, Size src_size, char **dst, Size *dst_size) +lz4_CompressData(char *src, Size src_size, char **dst, Size *dst_size) { #ifndef USE_LZ4 NO_LZ4_SUPPORT(); #else int lz4_cmp_size = 0; /* compressed size */ - char *buf; /* buffer used for compression */ - Size buf_size; /* buffer size */ + char *buf; /* buffer used for compression */ + Size buf_size; /* buffer size */ buf_size = LZ4_COMPRESSBOUND(src_size); buf = (char *) palloc0(buf_size); @@ -243,8 +243,8 @@ lz4_StreamingDecompressData(MemoryContext context, char *src, Size src_size, NO_LZ4_SUPPORT(); #else LZ4StreamingCompressorState *cstate; - char *lz4_out_bufPtr; /* output ring buffer pointer */ - int lz4_dec_size; /* decompressed data size */ + char *lz4_out_bufPtr; /* output ring buffer pointer */ + int lz4_dec_size; /* decompressed data size */ cstate = (LZ4StreamingCompressorState *) compressor_state; @@ -273,8 +273,8 @@ lz4_StreamingDecompressData(MemoryContext context, char *src, Size src_size, errmsg_internal("compressed LZ4 data is corrupted"))); else if (lz4_dec_size != dst_size) ereport(ERROR, - (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("decompressed LZ4 data size differs from original size"))); + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("decompressed LZ4 data size differs from original size"))); /* Move the output ring buffer offset */ cstate->lz4_out_buf_offset += lz4_dec_size; @@ -334,8 +334,8 @@ zstd_NewCompressorState(MemoryContext context) /* * We do not allocate ZSTD buffers and contexts at this point because we - * have no guarantee that we will need them later. Let's allocate only when - * we are about to use them. + * have no guarantee that we will need them later. Let's allocate only + * when we are about to use them. */ cstate->zstd_c_ctx = NULL; cstate->zstd_c_in_buf = NULL; @@ -461,6 +461,7 @@ zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, NO_ZSTD_SUPPORT(); #else ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ Size toCpy = src_size; char *dst_data; @@ -479,16 +480,16 @@ zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, /* * ZSTD streaming compression works with chunks: the source data needs to * be splitted out in chunks, each of them is then copied into ZSTD input - * buffer. - * For each chunk, we proceed with compression. Streaming compression is - * not intended to compress the whole input chunk, so we have the call - * ZSTD_compressStream2() multiple times until the entire chunk is - * consumed. + * buffer. For each chunk, we proceed with compression. Streaming + * compression is not intended to compress the whole input chunk, so we + * have the call ZSTD_compressStream2() multiple times until the entire + * chunk is consumed. */ while (toCpy > 0) { /* Are we on the last chunk? */ bool last_chunk = (toCpy < cstate->zstd_c_in_buf_size); + /* Size of the data copied into ZSTD input buffer */ Size cpySize = last_chunk ? toCpy : cstate->zstd_c_in_buf_size; bool finished = false; @@ -556,12 +557,13 @@ zstd_StreamingCompressData(MemoryContext context, char *src, Size src_size, */ static void zstd_StreamingDecompressData(MemoryContext context, char *src, Size src_size, - char **dst, Size dst_size, void *compressor_state) + char **dst, Size dst_size, void *compressor_state) { #ifndef USE_ZSTD NO_ZSTD_SUPPORT(); #else ZSTDStreamingCompressorState *cstate; + /* Size of remaining data to be copied from src into ZSTD input buffer */ Size toCpy = src_size; char *dst_data; @@ -598,7 +600,7 @@ zstd_StreamingDecompressData(MemoryContext context, char *src, Size src_size, output.size = cstate->zstd_d_out_buf_size; output.pos = 0; - ret = ZSTD_decompressStream(cstate->zstd_d_ctx, &output , &input); + ret = ZSTD_decompressStream(cstate->zstd_d_ctx, &output, &input); if (ZSTD_isError(ret)) ereport(ERROR, @@ -691,145 +693,148 @@ ReorderBufferCompress(ReorderBuffer *rb, ReorderBufferDiskHeader **header, switch (compression_method) { - /* No compression */ + /* No compression */ case REORDER_BUFFER_NO_COMPRESSION: - { - hdr->comp_strat = REORDER_BUFFER_STRAT_UNCOMPRESSED; - hdr->size = data_size; - hdr->raw_size = data_size - sizeof(ReorderBufferDiskHeader); - - break; - } - /* LZ4 Compression */ - case REORDER_BUFFER_LZ4_COMPRESSION: - { - /* - * XXX Won't this cause a lot of palloc/pfree traffic? We allocate a new - * buffer for every compression, only to immediately throw it away. Look - * at what astreamer_lz4_compressor_content does to reuse a buffer, maybe - * we should do that here too? - */ - char *dst = NULL; - Size dst_size = 0; - char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); - Size src_size = data_size - sizeof(ReorderBufferDiskHeader); - ReorderBufferCompressionStrategy strat; - - if (lz4_CanDoStreamingCompression(src_size)) { - /* Use LZ4 streaming compression if possible */ - lz4_StreamingCompressData(rb->context, src, src_size, &dst, - &dst_size, compressor_state); - strat = REORDER_BUFFER_STRAT_LZ4_STREAMING; + hdr->comp_strat = REORDER_BUFFER_STRAT_UNCOMPRESSED; + hdr->size = data_size; + hdr->raw_size = data_size - sizeof(ReorderBufferDiskHeader); + + break; } - else + /* LZ4 Compression */ + case REORDER_BUFFER_LZ4_COMPRESSION: { - /* Fallback to LZ4 regular compression */ - lz4_CompressData(src, src_size, &dst, &dst_size); - strat = REORDER_BUFFER_STRAT_LZ4_REGULAR; - } + /* + * XXX Won't this cause a lot of palloc/pfree traffic? We + * allocate a new buffer for every compression, only to + * immediately throw it away. Look at what + * astreamer_lz4_compressor_content does to reuse a buffer, + * maybe we should do that here too? + */ + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + ReorderBufferCompressionStrategy strat; + + if (lz4_CanDoStreamingCompression(src_size)) + { + /* Use LZ4 streaming compression if possible */ + lz4_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); + strat = REORDER_BUFFER_STRAT_LZ4_STREAMING; + } + else + { + /* Fallback to LZ4 regular compression */ + lz4_CompressData(src, src_size, &dst, &dst_size); + strat = REORDER_BUFFER_STRAT_LZ4_REGULAR; + } - /* - * Make sure the ReorderBuffer has enough space to store compressed - * data. Compressed data must be smaller than raw data, so, the - * ReorderBuffer should already have room for compressed data, but - * we do this to avoid buffer overflow risks. - */ - ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + /* + * Make sure the ReorderBuffer has enough space to store + * compressed data. Compressed data must be smaller than raw + * data, so, the ReorderBuffer should already have room for + * compressed data, but we do this to avoid buffer overflow + * risks. + */ + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); - hdr = (ReorderBufferDiskHeader *) rb->outbuf; - hdr->comp_strat = strat; - hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); - hdr->raw_size = src_size; + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = strat; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; - /* - * Update header: hdr pointer has potentially changed due to - * ReorderBufferReserve() - */ - *header = hdr; + /* + * Update header: hdr pointer has potentially changed due to + * ReorderBufferReserve() + */ + *header = hdr; - /* Copy back compressed data into the ReorderBuffer */ - memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, - dst_size); + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); - pfree(dst); + pfree(dst); + + break; + } + /* PGLZ compression */ - break; - } - /* PGLZ compression */ - /* - * XXX I'd probably start by adding pglz first, and only then add lz4 as a - * separate patch, simply because pglz is the default and always supported, - * while lz4 requires extra flags. - */ - case REORDER_BUFFER_PGLZ_COMPRESSION: - { /* - * XXX Same comment about palloc/pfree traffic as for lz4 ... + * XXX I'd probably start by adding pglz first, and only then add + * lz4 as a separate patch, simply because pglz is the default and + * always supported, while lz4 requires extra flags. */ - int32 dst_size = 0; - char *dst = NULL; - char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); - int32 src_size = data_size - sizeof(ReorderBufferDiskHeader); - int32 max_size = PGLZ_MAX_OUTPUT(src_size); + case REORDER_BUFFER_PGLZ_COMPRESSION: + { + /* + * XXX Same comment about palloc/pfree traffic as for lz4 ... + */ + int32 dst_size = 0; + char *dst = NULL; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + int32 src_size = data_size - sizeof(ReorderBufferDiskHeader); + int32 max_size = PGLZ_MAX_OUTPUT(src_size); - dst = (char *) palloc0(max_size); - dst_size = pglz_compress(src, src_size, dst, PGLZ_strategy_always); + dst = (char *) palloc0(max_size); + dst_size = pglz_compress(src, src_size, dst, PGLZ_strategy_always); - if (dst_size < 0) - ereport(ERROR, - (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("PGLZ compression failed"))); + if (dst_size < 0) + ereport(ERROR, + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg_internal("PGLZ compression failed"))); - ReorderBufferReserve(rb, (Size) (dst_size + sizeof(ReorderBufferDiskHeader))); + ReorderBufferReserve(rb, (Size) (dst_size + sizeof(ReorderBufferDiskHeader))); - hdr = (ReorderBufferDiskHeader *) rb->outbuf; - hdr->comp_strat = REORDER_BUFFER_STRAT_PGLZ; - hdr->size = (Size) dst_size + sizeof(ReorderBufferDiskHeader); - hdr->raw_size = (Size) src_size; + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_PGLZ; + hdr->size = (Size) dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = (Size) src_size; - *header = hdr; + *header = hdr; - /* Copy back compressed data into the ReorderBuffer */ - memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, - dst_size); + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); - pfree(dst); + pfree(dst); - break; - } - /* ZSTD Compression */ + break; + } + /* ZSTD Compression */ case REORDER_BUFFER_ZSTD_COMPRESSION: - { - /* - * XXX Same comment about palloc/pfree traffic as for lz4 ... - */ - char *dst = NULL; - Size dst_size = 0; - char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); - Size src_size = data_size - sizeof(ReorderBufferDiskHeader); + { + /* + * XXX Same comment about palloc/pfree traffic as for lz4 ... + */ + char *dst = NULL; + Size dst_size = 0; + char *src = (char *) rb->outbuf + sizeof(ReorderBufferDiskHeader); + Size src_size = data_size - sizeof(ReorderBufferDiskHeader); - /* Use ZSTD streaming compression */ - zstd_StreamingCompressData(rb->context, src, src_size, &dst, - &dst_size, compressor_state); + /* Use ZSTD streaming compression */ + zstd_StreamingCompressData(rb->context, src, src_size, &dst, + &dst_size, compressor_state); - ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); + ReorderBufferReserve(rb, (dst_size + sizeof(ReorderBufferDiskHeader))); - hdr = (ReorderBufferDiskHeader *) rb->outbuf; - hdr->comp_strat = REORDER_BUFFER_STRAT_ZSTD_STREAMING; - hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); - hdr->raw_size = src_size; + hdr = (ReorderBufferDiskHeader *) rb->outbuf; + hdr->comp_strat = REORDER_BUFFER_STRAT_ZSTD_STREAMING; + hdr->size = dst_size + sizeof(ReorderBufferDiskHeader); + hdr->raw_size = src_size; - *header = hdr; + *header = hdr; - /* Copy back compressed data into the ReorderBuffer */ - memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, - dst_size); + /* Copy back compressed data into the ReorderBuffer */ + memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), dst, + dst_size); - pfree(dst); + pfree(dst); - break; - } + break; + } } } @@ -847,6 +852,7 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, ReorderBufferDiskHeader *header, void *compressor_state) { Size raw_outbufsize = header->raw_size + sizeof(ReorderBufferDiskHeader); + /* * Make sure the output reorder buffer has enough space to store * decompressed/raw data. @@ -862,7 +868,7 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, switch (header->comp_strat) { - /* No decompression */ + /* No decompression */ case REORDER_BUFFER_STRAT_UNCOMPRESSED: { /* @@ -873,7 +879,7 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, data, header->raw_size); break; } - /* LZ4 regular decompression */ + /* LZ4 regular decompression */ case REORDER_BUFFER_STRAT_LZ4_REGULAR: { char *buf; @@ -889,26 +895,28 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, pfree(buf); break; } - /* LZ4 streaming decompression */ + /* LZ4 streaming decompression */ case REORDER_BUFFER_STRAT_LZ4_STREAMING: { - char *buf; /* XXX shouldn't this be set to NULL explicitly? */ + char *buf; /* XXX shouldn't this be set to NULL + * explicitly? */ Size src_size = header->size - sizeof(ReorderBufferDiskHeader); Size buf_size = header->raw_size; lz4_StreamingDecompressData(rb->context, data, src_size, &buf, - buf_size, compressor_state); + buf_size, compressor_state); /* Copy decompressed data into the ReorderBuffer */ memcpy((char *) rb->outbuf + sizeof(ReorderBufferDiskHeader), buf, buf_size); + /* * Not necessary to free buf in this case: it points to the * decompressed data stored in LZ4 output ring buffer. */ break; } - /* PGLZ decompression */ + /* PGLZ decompression */ case REORDER_BUFFER_STRAT_PGLZ: { char *buf; @@ -928,10 +936,11 @@ ReorderBufferDecompress(ReorderBuffer *rb, char *data, errmsg_internal("compressed PGLZ data is corrupted"))); break; } - /* ZSTD streaming decompression */ + /* ZSTD streaming decompression */ case REORDER_BUFFER_STRAT_ZSTD_STREAMING: { - char *buf; /* XXX shouldn't this be set to NULL explicitly? */ + char *buf; /* XXX shouldn't this be set to NULL + * explicitly? */ Size src_size = header->size - sizeof(ReorderBufferDiskHeader); Size buf_size = header->raw_size; diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index eb42e844f99..32b38b94dd7 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -4471,8 +4471,8 @@ set_stream_options(WalRcvStreamOptions *options, } if (server_version >= 180000 && - MySubscription->stream == LOGICALREP_STREAM_OFF && - MySubscription->spill_compression != NULL) + MySubscription->stream == LOGICALREP_STREAM_OFF && + MySubscription->spill_compression != NULL) { options->proto.logical.spill_compression = pstrdup(MySubscription->spill_compression); diff --git a/src/include/replication/reorderbuffer_compression.h b/src/include/replication/reorderbuffer_compression.h index f72f0e0fbd7..3f69d2c2610 100644 --- a/src/include/replication/reorderbuffer_compression.h +++ b/src/include/replication/reorderbuffer_compression.h @@ -56,9 +56,9 @@ typedef enum ReorderBufferCompressionStrategy */ typedef struct ReorderBufferDiskHeader { - ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ - Size size; /* Ondisk size */ - Size raw_size; /* Raw/uncompressed data size */ + ReorderBufferCompressionStrategy comp_strat; /* Compression strategy */ + Size size; /* Ondisk size */ + Size raw_size; /* Raw/uncompressed data size */ /* ReorderBufferChange + data follows */ } ReorderBufferDiskHeader; @@ -81,7 +81,8 @@ typedef struct ReorderBufferDiskHeader * LZ4 streaming compression/decompression handlers and ring * buffers. */ -typedef struct LZ4StreamingCompressorState { +typedef struct LZ4StreamingCompressorState +{ /* Streaming compression handler */ LZ4_stream_t *lz4_stream; /* Streaming decompression handler */ @@ -112,7 +113,8 @@ typedef struct LZ4StreamingCompressorState { /* * ZSTD streaming compression/decompression handlers and buffers. */ -typedef struct ZSTDStreamingCompressorState { +typedef struct ZSTDStreamingCompressorState +{ /* Compression */ ZSTD_CCtx *zstd_c_ctx; Size zstd_c_in_buf_size; diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index ace5414fa5b..ea13d621f6c 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -1487,6 +1487,7 @@ LZ4F_decompressionContext_t LZ4F_errorCode_t LZ4F_preferences_t LZ4State +LZ4StreamingCompressorState LabelProvider LagTracker LargeObjectDesc @@ -2412,7 +2413,10 @@ ReorderBufferChange ReorderBufferChangeType ReorderBufferCommitCB ReorderBufferCommitPreparedCB +ReorderBufferCompressionMethod +ReorderBufferCompressionStrategy ReorderBufferDiskChange +ReorderBufferDiskHeader ReorderBufferIterTXNEntry ReorderBufferIterTXNState ReorderBufferMessageCB @@ -3247,6 +3251,7 @@ XmlTableBuilderData YYLTYPE YYSTYPE YY_BUFFER_STATE +ZSTDStreamingCompressorState ZSTD_CCtx ZSTD_CStream ZSTD_DCtx -- 2.46.0 ^ permalink raw reply [nested|flat] 112+ messages in thread
end of thread, other threads:[~2024-09-17 18:48 UTC | newest] Thread overview: 112+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/12] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH v7 4/9] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH v9 4/9] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH v8 4/9] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/12] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 4/8] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2021-03-11 23:36 [PATCH 04/10] wal_compression_method: default to zlib.. Justin Pryzby <[email protected]> 2024-01-27 03:29 Re: Support run-time partition pruning for hash join vignesh C <[email protected]> 2024-01-30 02:33 ` Re: Support run-time partition pruning for hash join Richard Guo <[email protected]> 2024-06-07 13:18 Re: Compress ReorderBuffer spill files using LZ4 Julien Tachoires <[email protected]> 2024-07-15 18:50 ` Re: Compress ReorderBuffer spill files using LZ4 Julien Tachoires <[email protected]> 2024-07-15 19:28 ` Re: Compress ReorderBuffer spill files using LZ4 Tomas Vondra <[email protected]> 2024-07-16 08:08 ` Re: Compress ReorderBuffer spill files using LZ4 Julien Tachoires <[email protected]> 2024-07-16 12:52 ` Re: Compress ReorderBuffer spill files using LZ4 Amit Kapila <[email protected]> 2024-07-16 14:01 ` Re: Compress ReorderBuffer spill files using LZ4 Tomas Vondra <[email protected]> 2024-07-17 09:12 ` Re: Compress ReorderBuffer spill files using LZ4 Amit Kapila <[email protected]> 2024-07-19 22:05 ` Re: Compress ReorderBuffer spill files using LZ4 Julien Tachoires <[email protected]> 2024-09-17 18:48 ` Re: Compress ReorderBuffer spill files using LZ4 Tomas Vondra <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox