From 6e44372477663364bc2e9da866b6340aea55867b Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:56:44 +0300 Subject: [PATCH 1/4] Fix: Prevent division by zero in HugePages calculation --- automation/roles/pre-checks/tasks/huge_pages.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/automation/roles/pre-checks/tasks/huge_pages.yml b/automation/roles/pre-checks/tasks/huge_pages.yml index 1c5b0fa87..25cc41199 100644 --- a/automation/roles/pre-checks/tasks/huge_pages.yml +++ b/automation/roles/pre-checks/tasks/huge_pages.yml @@ -55,8 +55,12 @@ ansible.builtin.set_fact: huge_pages_required: >- {{ - ((shared_buffers_gb | default(0) | int + (additional_huge_pages_gb | default(1))) - * 1024 * 1024) // huge_page_size.stdout | default(2048) | int + ( + (shared_buffers_gb | default(0) | int + + additional_huge_pages_gb | default(1)) + * 1024 * 1024 + ) + // (huge_page_size.stdout | int if huge_page_size.stdout | int > 0 else 2048) }} when: - shared_buffers_gb | default(0) | int >= (min_shared_buffers_gb | default(8)) From 64a95823f8a6dc155873cbd9f77078949797fa0c Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:04:38 +0300 Subject: [PATCH 2/4] Perform pre-checks for huge_pages only if huge_pages_auto_conf is enabled --- automation/roles/pre-checks/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/automation/roles/pre-checks/tasks/main.yml b/automation/roles/pre-checks/tasks/main.yml index b95235850..73b1d2a4e 100644 --- a/automation/roles/pre-checks/tasks/main.yml +++ b/automation/roles/pre-checks/tasks/main.yml @@ -33,6 +33,7 @@ ansible.builtin.import_tasks: huge_pages.yml when: - inventory_hostname in groups['postgres_cluster'] + - huge_pages_auto_conf | bool - name: Perform pre-checks for pgbackrest ansible.builtin.import_tasks: pgbackrest.yml From 507ae673d9afb91512f31326c401accbe7152142 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:05:57 +0300 Subject: [PATCH 3/4] Add default for huge_pages_auto_conf variable --- automation/roles/pre-checks/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/roles/pre-checks/tasks/main.yml b/automation/roles/pre-checks/tasks/main.yml index 73b1d2a4e..a8ffd30bd 100644 --- a/automation/roles/pre-checks/tasks/main.yml +++ b/automation/roles/pre-checks/tasks/main.yml @@ -33,7 +33,7 @@ ansible.builtin.import_tasks: huge_pages.yml when: - inventory_hostname in groups['postgres_cluster'] - - huge_pages_auto_conf | bool + - huge_pages_auto_conf | default(false) | bool - name: Perform pre-checks for pgbackrest ansible.builtin.import_tasks: pgbackrest.yml From 7938db294d7f2f93daf408e143eaf952fa6ea589 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:29:30 +0300 Subject: [PATCH 4/4] Update main.yml --- automation/roles/pre-checks/tasks/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/automation/roles/pre-checks/tasks/main.yml b/automation/roles/pre-checks/tasks/main.yml index a8ffd30bd..b95235850 100644 --- a/automation/roles/pre-checks/tasks/main.yml +++ b/automation/roles/pre-checks/tasks/main.yml @@ -33,7 +33,6 @@ ansible.builtin.import_tasks: huge_pages.yml when: - inventory_hostname in groups['postgres_cluster'] - - huge_pages_auto_conf | default(false) | bool - name: Perform pre-checks for pgbackrest ansible.builtin.import_tasks: pgbackrest.yml