Skip to content

Commit

Permalink
Added support for viewing Log Based Clusters. pgadmin-org#7216
Browse files Browse the repository at this point in the history
  • Loading branch information
adityatoshniwal committed Mar 26, 2024
1 parent 1bcf343 commit 4dba72f
Show file tree
Hide file tree
Showing 38 changed files with 1,264 additions and 159 deletions.
Binary file added docs/en_US/images/replica_nodes_general.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/replica_nodes_replication.png
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/managing_cluster_objects.rst
Expand Up @@ -18,4 +18,5 @@ database, right-click on the *Databases* node, and select *Create Database...*
resource_group_dialog
role_dialog
tablespace_dialog
replica_nodes_dialog
role_reassign_dialog
46 changes: 46 additions & 0 deletions docs/en_US/replica_nodes_dialog.rst
@@ -0,0 +1,46 @@
.. _replica_nodes_dialog:

****************************
`Replica Node Dialog`:index:
****************************

Use The *Replica Node* dialog to view a standby instance being replicated
using log based streaming replication. Streaming replication allows a standby
server to stay more up-to-date than is possible with file-based log shipping.
The standby connects to the primary, which streams WAL records to the standby as
they're generated, without waiting for the WAL file to be filled.

The *Replica Node* dialog organizes the information through the following tabs:
*General*, *Replication Slot*

.. image:: images/replica_nodes_general.png
:alt: Replica Node dialog general tab
:align: center

* The *PID* field is the process ID of a WAL sender process.
* The *Username* field is the name of the user logged into this WAL sender process.
* The *App Name* field is the name of the application that is connected to this WAL sender.
* The *Client Address* field is the IP address of the client connected to this WAL sender.
If this field is null, it indicates that the client is connected via a Unix socket on the server machine.
* The *Client Hostname* field is the host name of the connected client, as reported by a reverse DNS lookup
of client_addr.This field will only be non-null for IP connections, and only when log_hostname is enabled.
* The *Client Port* field is the TCP port number that the client is using for communication with
this WAL sender, or -1 if a Unix socket is used.
* The *State* field is the current WAL sender state.

Click the *Replication Slot* tab to continue.

.. image:: images/replica_nodes_replication.png
:alt: Replica Node dialog replication slot tab
:align: center

* The *Slot Name* field is a unique, cluster-wide identifier for the replication slot.
* The *Slot Type* field is the slot type - physical or logical
* The *Active* field is True if this slot is currently actively being used.

Other buttons:

* Click the *Info* button (i) to access online help.
* Click the *Save* button to save work.
* Click the *Close* button to exit without saving work.
* Click the *Reset* button to restore configuration parameters.
20 changes: 18 additions & 2 deletions web/pgadmin/browser/server_groups/servers/__init__.py
Expand Up @@ -15,6 +15,7 @@
from flask_babel import gettext
from flask_security import current_user, login_required
from psycopg.conninfo import make_conninfo, conninfo_to_dict

from pgadmin.browser.server_groups.servers.types import ServerType
from pgadmin.browser.utils import PGChildNodeView
from pgadmin.utils.ajax import make_json_response, bad_request, forbidden, \
Expand All @@ -30,7 +31,8 @@
from pgadmin.utils.master_password import get_crypt_key
from pgadmin.utils.exception import CryptKeyMissing
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.browser.server_groups.servers.utils import is_valid_ipaddress
from pgadmin.browser.server_groups.servers.utils import \
is_valid_ipaddress, get_replication_type
from pgadmin.utils.constants import UNAUTH_REQ, MIMETYPE_APP_JS, \
SERVER_CONNECTION_CLOSED
from sqlalchemy import or_
Expand Down Expand Up @@ -343,6 +345,9 @@ def register(self, app, options):
from .tablespaces import blueprint as module
self.submodules.append(module)

from .replica_nodes import blueprint as module
self.submodules.append(module)

super().register(app, options)

# We do not have any preferences for server node.
Expand Down Expand Up @@ -469,7 +474,7 @@ class ServerNode(PGChildNodeView):
}],
'check_pgpass': [{'get': 'check_pgpass'}],
'clear_saved_password': [{'put': 'clear_saved_password'}],
'clear_sshtunnel_password': [{'put': 'clear_sshtunnel_password'}]
'clear_sshtunnel_password': [{'put': 'clear_sshtunnel_password'}],
})
SSL_MODES = ['prefer', 'require', 'verify-ca', 'verify-full']

Expand Down Expand Up @@ -1247,6 +1252,7 @@ def create(self, gid):
connected = False
user = None
manager = None
replication_type = None

if 'connect_now' in data and data['connect_now']:
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
Expand Down Expand Up @@ -1324,6 +1330,8 @@ def create(self, gid):
server.id),
tunnel_password)

replication_type = get_replication_type(conn,
manager.version)
user = manager.user_info
connected = True

Expand All @@ -1337,6 +1345,7 @@ def create(self, gid):
username=server.username,
user=user,
connected=connected,
replication_type=replication_type,
shared=server.shared,
server_type=manager.server_type
if manager and manager.server_type
Expand Down Expand Up @@ -1427,6 +1436,7 @@ def connect_status(self, gid, sid):
in_recovery = None
wal_paused = None
errmsg = None
replication_type = None
if connected:
status, result, in_recovery, wal_paused =\
recovery_state(conn, manager.version)
Expand All @@ -1436,10 +1446,13 @@ def connect_status(self, gid, sid):
manager.release()
errmsg = "{0} : {1}".format(server.name, result)

replication_type = get_replication_type(conn, manager.version)

return make_json_response(
data={
'icon': server_icon_and_background(connected, manager, server),
'connected': connected,
'replication_type': replication_type,
'in_recovery': in_recovery,
'wal_pause': wal_paused,
'server_type': manager.server_type if connected else "pg",
Expand Down Expand Up @@ -1709,13 +1722,16 @@ def connect(self, gid, sid):
_, _, in_recovery, wal_paused =\
recovery_state(conn, manager.version)

replication_type = get_replication_type(conn, manager.version)

return make_json_response(
success=1,
info=gettext("Server connected."),
data={
'icon': server_icon_and_background(True, manager, server),
'connected': True,
'server_type': manager.server_type,
'replication_type': replication_type,
'type': manager.server_type,
'version': manager.version,
'db': manager.db,
Expand Down

0 comments on commit 4dba72f

Please sign in to comment.