Skip to content

[TEST] Try to prune defaults from config #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
PATRONI_CONF_PATH,
PATRONI_PASSWORD_KEY,
PEER,
PGPARAMS_DEFAULTS,
PLUGIN_OVERRIDES,
POSTGRESQL_SNAP_NAME,
RAFT_PASSWORD_KEY,
Expand Down Expand Up @@ -1996,6 +1997,12 @@ def update_config(self, is_creating_backup: bool = False, no_peers: bool = False
pg_parameters = self.postgresql.build_postgresql_parameters(
self.model.config, self.get_available_memory(), limit_memory
)
defaults = []
for pg_param in pg_parameters:
if PGPARAMS_DEFAULTS.get(pg_param) == pg_parameters[pg_param]:
defaults.append(pg_param)
for key in defaults:
del pg_parameters[key]

# Update and reload configuration based on TLS files availability.
self._patroni.render_patroni_yml_file(
Expand Down
65 changes: 65 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,68 @@
SPI_MODULE = ["refint", "autoinc", "insert_username", "moddatetime"]

PGBACKREST_LOGROTATE_FILE = "/etc/logrotate.d/pgbackrest.logrotate"

PGPARAMS_DEFAULTS = {
"authentication_timeout": 60,
"statement_timeout": 0,
"parallel_leader_participation": True,
"synchronous_commit": "on",
"wal_keep_size": 0,
"default_text_search_config": "pg_catalog.simple",
"max_locks_per_transaction": 64,
"password_encryption": "scram-sha-256",
"synchronize_seqscans": True,
"client_min_messages": "notice",
"log_connections": False,
"log_disconnections": False,
"log_lock_waits": False,
"log_min_duration_statement": -1,
"track_functions": "none",
"maintenance_work_mem": 65536,
"max_prepared_transactions": 0,
"temp_buffers": 1024,
"work_mem": 4096,
"constraint_exclusion": "partition",
"cpu_index_tuple_cost": 0.005,
"cpu_operator_cost": 0.0025,
"cpu_tuple_cost": 0.01,
"cursor_tuple_fraction": 0.1,
"default_statistics_target": 100,
"enable_async_append": True,
"enable_bitmapscan": True,
"enable_gathermerge": True,
"enable_hashagg": True,
"enable_hashjoin": True,
"enable_incremental_sort": True,
"enable_indexonlyscan": True,
"enable_indexscan": True,
"enable_material": True,
"enable_memoize": True,
"enable_mergejoin": True,
"enable_nestloop": True,
"enable_parallel_append": True,
"enable_parallel_hash": True,
"enable_partition_pruning": True,
"enable_partitionwise_aggregate": False,
"enable_partitionwise_join": False,
"enable_seqscan": True,
"enable_sort": True,
"enable_tidscan": True,
"from_collapse_limit": 8,
"geqo": True,
"geqo_effort": 5,
"geqo_generations": 0,
"geqo_pool_size": 0,
"geqo_seed": 0,
"geqo_selection_bias": 2,
"geqo_threshold": 12,
"jit": True,
"jit_above_cost": 100000,
"jit_inline_above_cost": 500000,
"jit_optimize_above_cost": 500000,
"join_collapse_limit": 8,
"min_parallel_index_scan_size": 64,
"min_parallel_table_scan_size": 1024,
"parallel_setup_cost": 1000,
"parallel_tuple_cost": 0.1,
}
3 changes: 0 additions & 3 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pytest_operator.plugin import OpsTest
from tenacity import Retrying, stop_after_delay, wait_fixed

from .. import markers
from ..helpers import (
CHARM_BASE,
db_connect,
Expand Down Expand Up @@ -381,7 +380,6 @@ async def test_forceful_restart_without_data_and_transaction_logs(


@pytest.mark.abort_on_fail
@markers.amd64_only
async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_timeout):
"""Completely cut and restore network."""
# Locate primary unit.
Expand Down Expand Up @@ -470,7 +468,6 @@ async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_t


@pytest.mark.abort_on_fail
@markers.amd64_only
async def test_network_cut_without_ip_change(
ops_test: OpsTest, continuous_writes, primary_start_timeout
):
Expand Down
Loading