Skip to content

Commit

Permalink
Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'm…
Browse files Browse the repository at this point in the history
…ax_prepared' for GROUP COMMIT SCOPE.
  • Loading branch information
dougortiz committed Aug 23, 2023
1 parent b6d0b9c commit 158ba9d
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 28 deletions.
13 changes: 13 additions & 0 deletions roles/init_dbserver/tasks/verify_pgd_settings.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---
<<<<<<< HEAD
=======
- name: Check 'pgd_commit_scopes' dictionary length
ansible.builtin.assert:
that:
- pgd_commit_scopes | length > 0
msg: "The 'pgd_commit_scopes' list should have at least one dictionary."

>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- name: Check if cs_type is consistent and the sampe 'cs_type' across the entire list
ansible.builtin.assert:
that:
Expand Down Expand Up @@ -36,7 +45,11 @@
when: true_count | int > 1

- name: Check default_group_cs
<<<<<<< HEAD
ansible.builtin.assert:
=======
assert:
>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
that:
- pgd_commit_scopes | map(attribute='default_group_cs') | select("equalto", true) | list | count > 0
fail_msg: "At least one 'default_group_cs' value should be set to true."
28 changes: 0 additions & 28 deletions roles/setup_pgd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,35 +132,7 @@ configured beforehand with the `setup_repo` role. At least one lead primary must
and a database cluster must be initialized on that node.
=======

### `PGD Commit Scopes Configuration`

The code below is part of the [roles/setup_pgd/defaults/main.yml](./defaults/main.yml), and
example for configuring two PGD commit scopes is listed below.

The configuration requirements for PGD through the configuration setting variables are:
1. Only one scope can be configured as default at a time. The variable to configure is: `default_group_cs`
2. The length of the `member_nodes` for a `camo` commit scope is exactly `two`
3. No node in `member_nodes` for either commit scope can belong to the other commit scope
4. All nodes in `member_nodes` must belong to a `parent_group`
5. The `cs_rule` parameter must be: valid, correctly formatted, and adhere to the correct syntax

```yaml
pgd_commit_scopes:
- cs_name: 'camo_scope_1'
cs_type: 'CAMO' # either camo or group_commit
parent_group: 'pgd_cluster' # this group is present in cluster
cs_origin_node_group: 'pgd_two_nodes' # this group may or may not be present
member_nodes: ['edb-primary1', 'edb-primary2']
default_group_cs: true # don't make mandatory, default('false') if not present in array
cs_rule: "ALL ( pgd_two_nodes ) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC"
- cs_name: 'groupcommit_scope_1'
cs_type: 'GROUP_COMMIT'
parent_group: 'pgd_cluster'
cs_origin_node_group: 'pgd_remaining_nodes'
member_nodes: ['edb-primary3']
default_group_cs: false
cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT"
```


Example Playbook
Expand Down
35 changes: 35 additions & 0 deletions roles/setup_pgd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ supported_pg_version:
supported_pgd_version:
- 5

<<<<<<< HEAD
<<<<<<< HEAD
# For CAMO Commit Scopes
max_prepared_transactions: 100
Expand All @@ -154,3 +155,37 @@ pgd_commit_scopes:
default_group_cs: false
cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT"
>>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.)
=======
# The following parameters must be configured in the 'pgd_commit_scopes' list
# the values below are examples and should be adjusted to your requirements
# for CAMO
# - cs_type: 'CAMO'
# for GROUP_COMMIT
# - cs_type: 'GROUP_COMMIT'
# for CAMO
# - cs_name: 'camo_scope_1'
# for GROUP_COMMIT
# - cs_name: 'group_commit_scope_1'
# - parent_group: 'pgd_cluster'
# for CAMO
# - cs_origin_node_group: 'pgd_two_nodes'
# for GROUP_COMMIT
# - cs_origin_node_group: 'pgd_gc_nodes'
# for CAMO
# - member_nodes: ['edb-primary1', 'edb-primary2']
# for GROUP_COMMIT
# - member_nodes: ['edb-primary3']
# - default_group_cs: true
# for CAMO
# - cs_rule: "ALL ( pgd_two_nodes ) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC"
# for GROUP_COMMIT
# - cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT"
pgd_commit_scopes:
- cs_name: ''
cs_type: ''
parent_group: ''
cs_origin_node_group: ''
member_nodes: ['']
default_group_cs: true
cs_rule: ""
>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
3 changes: 3 additions & 0 deletions roles/setup_pgd/tasks/pgd_camo_commitscope_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
ignore_query_execution_error: false
when:
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- item.default_group_cs|bool
- item.cs_type|string == 'CAMO'
- _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1
Expand Down
3 changes: 3 additions & 0 deletions roles/setup_pgd/tasks/pgd_group_commitscope_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
ignore_query_execution_error: false
when:
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- item.default_group_cs|bool
- item.cs_type|string == 'GROUP_COMMIT'
- _pgd_groupcommitscope_exists|int == 1 and _pgd_groupcommit_originnodegroup_exists|int == 1
Expand Down
4 changes: 4 additions & 0 deletions roles/setup_pgd/tasks/pgd_parallel_processes_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@

- name: Calculate required setting for max_worker_processes
ansible.builtin.set_fact:
<<<<<<< HEAD
<<<<<<< HEAD
_base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int-1 )) + _twice_pgd_nodes | int }}"
=======
_base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int - 1 )) + _twice_pgd_nodes | int }}"
>>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.)
=======
_base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int-1 )) + _twice_pgd_nodes | int }}"
>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)

- name: Evaluate the current setting of max_worker_processes, max_replication_slots and max_wal_senders
ansible.builtin.set_fact:
Expand Down
12 changes: 12 additions & 0 deletions roles/setup_pgd/tasks/rm_pgd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
block:
- name: Gather PGD node information with state
ansible.builtin.include_tasks: verify_pgd_node_group.yml
<<<<<<< HEAD
=======

>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- name: Part node from PGD cluster
ansible.builtin.include_role:
name: manage_dbserver
Expand All @@ -32,6 +36,10 @@
- _pgd_extension_exists == 1
- _pgd_local_node_created == 1
- _pgd_cluster_group_joined == 1
<<<<<<< HEAD
=======

>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- name: Drop node from PGD cluster
ansible.builtin.include_role:
name: manage_dbserver
Expand All @@ -50,6 +58,10 @@
- _pgd_extension_exists == 1
- _pgd_local_node_created == 1
- _pgd_cluster_group_joined == 1
<<<<<<< HEAD
=======

>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- name: Drop database in PGD Node
ansible.builtin.include_role:
name: manage_dbserver
Expand Down
14 changes: 14 additions & 0 deletions roles/setup_pgd/tasks/setup_pgd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@
- name: Configure SSL if not exists
ansible.builtin.import_tasks: pg_ssl_config.yml

<<<<<<< HEAD
=======
- name: Import validate tasks
ansible.builtin.import_tasks: validate_setup_pgd.yml
when:
- validate_only|bool or use_validation|bool

# setup oidentd authentication
- name: Start service oidentd, if not started
ansible.builtin.service:
name: oidentd
state: started

>>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.)
- name: Filter items based on cs_type 'CAMO'
set_fact:
filtered_items_camo: "{{ pgd_commit_scopes | selectattr('cs_type', 'equalto', 'CAMO') | list }}"
Expand Down

0 comments on commit 158ba9d

Please sign in to comment.