SQLMutations v1
SQLMutations consist of a list of SQL queries to execute on the application
database via the superuser role after a PGD node joins the PGDgroup. Each
SQLMutation includes an isApplied
list of queries and an exec
list of
queries.
The isApplied
SQL queries are used to check if the mutation was already
applied. If any of the isApplied
queries return false, the exec
list of SQL
queries is added to the execution queue.
Here's a sample of SQLMutations:
SQLMutation types
The operator offers three types of SQLMutations, which you specify with spec.pgd.mutations[].type
. The default is always
.
beforeSubgroupRaft
always
writeLeader
The beforeSubgroupRaft
and always
mutations are evaluated in every reconcile loop. The difference between
the two mutations lies in their execution phase:
- For
always
mutations, they're run in each reconcile loop without any restrictions on the PGDgroup. beforeSubgroupRaft
mutations are executed only if the PGDgroup has defined data nodes and PGD proxies, and specifically before the subgroup Raft becomes ready.
Both beforeSubgroupRaft
and always
mutations can run on any PGD node in the PGDgroup, including witness nodes.
Therefore, don't use them for making data changes to the application database, as witness nodes don't contain
application database data.
The writeLeader
mutation is triggered and executed after the write leader is elected. The exec
operations
are carried out exclusively on the write leader node.
- On this page
- SQLMutation types