Skip to content
Merged
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
15 changes: 15 additions & 0 deletions .github/workflows/run-python-tests-epas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ jobs:
run: |
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
sudo su -c "echo local all all trust > /etc/edb-as/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host all all 127.0.0.1/32 trust >> /etc/edb-as/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host all all ::1/128 trust >> /etc/edb-as/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host replication postgres 127.0.0.1/32 trust >> /etc/edb-as/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host replication postgres ::1/128 trust >> /etc/edb-as/${{ matrix.pgver }}/main/pg_hba.conf"
sudo sed -i "s/port = 544[0-9]/port = 58${{ matrix.pgver }}/g" /etc/edb-as/${{ matrix.pgver }}/main/postgresql.conf
sudo sed -i "s/shared_preload_libraries = '/shared_preload_libraries = '\$libdir\/plugin_debugger,/g" /etc/edb-as/${{ matrix.pgver }}/main/postgresql.conf
echo "wal_level = logical" | sudo tee -a /etc/edb-as/${{ matrix.pgver }}/main/postgresql.conf
sudo su - enterprisedb -c "mkdir -p /var/run/edb-as/${{ matrix.pgver }}-main.epas_stat_tmp"
sudo systemctl restart edb-as@${{ matrix.pgver }}-main

Expand All @@ -115,6 +120,16 @@ jobs:
sleep 2
done

- name: Start PostgreSQL on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo host replication postgres 127.0.0.1/32 trust >> "C:\EPAS\${{ matrix.pgver }}\data\pg_hba.conf"
echo host replication postgres ::1/128 trust >> "C:\EPAS\${{ matrix.pgver }}\data\pg_hba.conf"
echo wal_level = logical >> "C:\EPAS\${{ matrix.pgver }}\data\postgresql.conf"
net stop epas-${{ matrix.pgver }}
net start epas-${{ matrix.pgver }}
shell: cmd

- name: Create pgagent extension on Linux
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.pgver <= 16 }}
run: psql -U enterprisedb -d postgres -p 58${{ matrix.pgver }} -c 'CREATE EXTENSION IF NOT EXISTS pgagent;'
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/run-python-tests-pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ jobs:
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo su -c "echo local all all trust > /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host all all 127.0.0.1/32 trust >> /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host all all ::1/128 trust >> /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host replication postgres 127.0.0.1/32 trust >> /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
sudo su -c "echo host replication postgres ::1/128 trust >> /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
sudo sed -i "s/port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
echo "wal_level = logical" | sudo tee -a /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
sudo su - postgres -c "/usr/lib/postgresql/${{ matrix.pgver }}/bin/postgres -D /var/lib/postgresql/${{ matrix.pgver }}/main -c config_file=/etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf &"

until sudo runuser -l postgres -c "pg_isready -p 59${{ matrix.pgver }}" 2>/dev/null; do
Expand All @@ -133,7 +138,12 @@ jobs:
if: ${{ matrix.os == 'macos-latest' }}
run: |
echo local all all trust > /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
echo 'host all all 127.0.0.1/32 trust' >> /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
echo 'host all all ::1/128 trust' >> /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
echo 'host replication postgres 127.0.0.1/32 trust' >> /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
echo 'host replication postgres ::1/128 trust' >> /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf
sed -i '' "s/#port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /opt/homebrew/var/postgresql@${{ matrix.pgver }}/postgresql.conf
echo "wal_level = logical" >> /opt/homebrew/var/postgresql@${{ matrix.pgver }}/postgresql.conf
brew services restart postgresql@${{ matrix.pgver }}

until /opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin/pg_isready -p 59${{ matrix.pgver }} 2>/dev/null; do
Expand All @@ -143,6 +153,16 @@ jobs:

psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;'

- name: Start PostgreSQL on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
echo host replication postgres 127.0.0.1/32 trust >> "C:\PostgreSQL\${{ matrix.pgver }}\data\pg_hba.conf"
echo host replication postgres ::1/128 trust >> "C:\PostgreSQL\${{ matrix.pgver }}\data\pg_hba.conf"
echo wal_level = logical >> "C:\PostgreSQL\${{ matrix.pgver }}\data\postgresql.conf"
net stop postgresql-x64-${{ matrix.pgver }}
net start postgresql-x64-${{ matrix.pgver }}
shell: cmd

- name: Install Python dependencies on Linux and macOS
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-22.04' }}
run: make install-python-testing
Expand Down
Binary file modified docs/en_US/images/subscription_with_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/en_US/subscription_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Use the *With* tab to define some parameters for a subscription:
* Move the *Run as owner?* switch to *true* position to specify all replication actions are performed as the subscription owner. If *false*, replication workers will perform actions on each table as the owner of that table. The default is *false*. This option is available only on PostgreSQL 16 and above.
* Use the *Password required?* to specify whether connections to the publisher made as a result of this subscription must use password authentication. This setting is ignored when the subscription is owned by a superuser. The default is true. Only superusers can set this value to *false*. This option is available only on PostgreSQL 16 and above.
* Use the *Origin* to specify whether the subscription will request the publisher to only send changes that don't have an origin or send changes regardless of origin. The default is *any*. This option is available only on PostgreSQL 16 and above.
* Use the *Failover* to specify whether the replication slots associated with the subscription are enabled to be synced to the standbys so that logical replication can be resumed from the new primary after failover. The default is false. This option is available only on PostgreSQL 17 and above.

Click the *SQL* tab to continue.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,14 @@ def get_sql(self, data, subid=None, operation=None):
if len(res['rows']) == 0:
return gone(self._NOT_FOUND_PUB_INFORMATION)

if self.manager.version >= 150000:
res['rows'][0]['two_phase'] = \
self.two_phase_mapping[res['rows'][0]['two_phase']]

if self.manager.version >= 160000:
res['rows'][0]['streaming'] = \
self.streaming_mapping[res['rows'][0]['streaming']]

old_data = res['rows'][0]

data, old_data = self.get_required_details(data, old_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ export default class SubscriptionSchema extends BaseUISchema{
binary:false,
two_phase:false,
disable_on_error:false,
streaming:false,
streaming: (node_info?.node_info?.version >= 180000) ? 'parallel' : false,
password_required:true,
run_as_owner:false,
origin:'any',
failover:false,
copy_data_after_refresh:false,
sync:'off',
refresh_pub: false,
Expand Down Expand Up @@ -72,13 +73,7 @@ export default class SubscriptionSchema extends BaseUISchema{
(this.node_info['node_info'].host == 'localhost' || this.node_info['node_info'].host == '127.0.0.1')){
host = this.node_info['node_info'].host;
}
if (host == this.node_info['node_info'].host && port == this.node_info['node_info'].port){
state.create_slot = false;
return true;
} else {
state.create_slot = true;
}
return false;
return (host == this.node_info['node_info'].host && port == this.node_info['node_info'].port);
}
isAllConnectionDataEnter(state){
let host = state.host,
Expand Down Expand Up @@ -317,6 +312,14 @@ export default class SubscriptionSchema extends BaseUISchema{
readonly: obj.isConnect, deps :['connect', 'host', 'port'],
helpMessage: gettext('Specifies whether the command should create the replication slot on the publisher.This field will be disabled and set to false if subscription connects to same database.Otherwise, the CREATE SUBSCRIPTION call will hang.'),
helpMessageMode: ['edit', 'create'],
depChange: (state) => {
// Set create_slot to false if same DB, else true
if(obj.isSameDB(state)) {
state.create_slot = false;
} else {
state.create_slot = true;
}
},
},
{
id: 'enabled', label: gettext('Enabled?'),
Expand Down Expand Up @@ -419,9 +422,18 @@ export default class SubscriptionSchema extends BaseUISchema{
helpMessageMode: ['edit', 'create'],
},
{
id: 'two_phase', label: gettext('Two phase?'),
type: 'switch', mode: ['create', 'properties'],
id: 'two_phase',
label: gettext('Two phase?'),
type: 'switch',
group: gettext('With'),
mode: (() => {
if (obj.version >= 180000) {
return ['create', 'edit', 'properties'];
} else if (obj.version >= 150000 && obj.version < 180000) {
return ['create', 'properties'];
}
return [];
})(),
min_version: 150000,
helpMessage: gettext('Specifies whether two-phase commit is enabled for this subscription.'),
helpMessageMode: ['edit', 'create'],
Expand Down Expand Up @@ -465,6 +477,14 @@ export default class SubscriptionSchema extends BaseUISchema{
helpMessage: gettext('Specifies whether the subscription will request the publisher to only send changes that do not have an origin or send changes regardless of origin. Setting origin to none means that the subscription will request the publisher to only send changes that do not have an origin. Setting origin to any means that the publisher sends changes regardless of their origin.'),
helpMessageMode: ['edit', 'create'],
},
{
id: 'failover', label: gettext('Failover'),
type: 'switch', mode: ['create', 'edit', 'properties'],
group: gettext('With'),
min_version: 170000,
helpMessage: gettext('Specifies whether the replication slots associated with the subscription are enabled to be synced to the standbys so that logical replication can be resumed from the new primary after failover'),
helpMessageMode: ['edit', 'create'],
},
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% if data.copy_data is defined or data.create_slot is defined or data.slot_name is defined or data.sync is defined %}
{% set add_semicolon_after_enabled = 'enabled' %}
{% endif %}
{% if data.create_slot is defined or data.slot_name is defined %}
{% set add_semicolon_after_copy_data = 'copy_data' %}
{% endif %}
{% if data.slot_name is defined or data.sync is defined %}
{% set add_semicolon_after_create_slot = 'create_slot' %}
{% endif %}
{% if data.sync is defined %}
{% set add_semicolon_after_slot_name = 'slot_name' %}
{% endif %}

CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
{% if data.host or data.port or data.username or data.password or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl%}
CONNECTION '{% if data.host %}host={{data.host}}{% endif %}{% if data.port %} port={{ data.port }}{% endif %}{% if data.username %} user={{ data.username }}{% endif %}{% if data.db %} dbname={{ data.db }}{% endif %}{% if data.connect_timeout %} connect_timeout={{ data.connect_timeout }}{% endif %}{% if data.passfile %} passfile={{ data.passfile }}{% endif %}{% if data.password %} {% if dummy %}password=xxxxxx{% else %}password={{ data.password}}{% endif %}{% endif %}{% if data.sslmode %} sslmode={{ data.sslmode }}{% endif %}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}'
{% endif %}
{% if data.pub %}
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
{% endif %}

WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data is defined %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
{% if data.slot_name is defined and data.slot_name != ''%}slot_name = {{ data.slot_name }}{% if add_semicolon_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync %}synchronous_commit = '{{ data.sync }}', {% endif %}binary = {{ data.binary|lower}}, streaming = '{{ data.streaming}}', two_phase = {{ data.two_phase|lower}}, disable_on_error = {{ data.disable_on_error|lower}}, run_as_owner = {{ data.run_as_owner|lower}}, password_required = {{ data.password_required|lower}}, origin = '{{ data.origin}}', failover = {{ data.failover|lower}});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SELECT sub.oid as oid,
subname as name,
subpublications as pub,
subpublications as proppub,
sub.subsynccommit as sync,
pga.rolname as subowner,
subslotname as slot_name,
subenabled as enabled,
subbinary as binary,
substream as streaming,
subtwophasestate as two_phase,
subdisableonerr as disable_on_error,
subpasswordrequired as password_required,
subrunasowner as run_as_owner,
suborigin as origin,
subfailover as failover,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,' port',1), '=',2) as host,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'port=',2), ' ',1) as port,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'user=',2), ' ',1) as username,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'dbname=',2), ' ',1) as db,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'connect_timeout=',2), ' ',1) as connect_timeout,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'passfile=',2), ' ',1) as passfile,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslmode=',2), ' ',1) as sslmode,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcompression=',2), ' ',1) as sslcompression,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcert=',2), ' ',1) as sslcert,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslkey=',2), ' ',1) as sslkey,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslrootcert=',2), ' ',1) as sslrootcert,
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcrl=',2), ' ',1) as sslcrl
FROM pg_catalog.pg_subscription sub join pg_catalog.pg_roles pga on sub.subowner= pga.oid
WHERE
{% if subid %}
sub.oid = {{ subid }};
{% else %}
sub.subdbid = {{ did }};
{% endif %}
Loading
Loading