6.3. Views #

6.3.1. Global Views
6.3.2. shardman.pg_stat_csn
6.3.3. shardman.pg_stat_monitor
6.3.4. shardman.pg_stat_netusage
6.3.5. Multiplexor Diagnostics Views

6.3.1. Global Views #

Shardman has a list of global views based on the PostgeSQL local views. The definition of global view columns is the same as in its corresponding local view. Fetching from a global view returns a union of rows from the corresponding local views. The rows are fetched from each of their cluster nodes. Another difference is that the global views have an added column rgid. The rgid value shows the replication group ID of the cluster node from which a row is fetched.

Below is the list of the global views with links to their corresponding local views:

Table 6.1. Global and local views

Global viewLocal viewDescription
shardman.gv_stat_activitypg_stat_activityOne row per server process, showing information related to he current activity of that process.
shardman.gv_stat_progress_vacuumpg_stat_progress_vacuumWhenever VACUUM is running, the pg_stat_progress_vacuum view will contain one row for each backend (including autovacuum worker processes) that is currently vacuuming.
shardman.gv_stat_replicationpg_stat_replicationOne row per WAL sender process, showing statistics about replication to that sender's connected standby server.
shardman.gv_stat_replication_slotspg_stat_replication_slotsOne row per replication slot, showing statistics about the replication slot's usage.
shardman.gv_stat_subscriptionpg_stat_subscriptionOne row per subscription for main worker (with null PID if the worker is not running), and additional rows for workers handling the initial data copy of the subscribed tables.
shardman.gv_stat_sslpg_stat_sslOne row per backend or WAL sender process, showing statistics about SSL usage on this connection.
shardman.gv_stat_gssapipg_stat_gssapiOne row per backend, showing information about GSSAPI usage on this connection.
shardman.gv_stat_archiverpg_stat_archiverOne row only, showing statistics about the WAL archiver process's activity.
shardman.gv_stat_bgwriterpg_stat_bgwriterOne row only, showing statistics about the background writer process's activity.
shardman.gv_stat_walpg_stat_walOne row only, showing statistics about WAL activity.
shardman.gv_stat_databasepg_stat_database_conflictsOne row per database, showing database-wide statistics about query cancels due to conflict with recovery on standby servers.
shardman.gv_stat_all_tablespg_stat_all_tablesOne row for each table in the current database, showing statistics about accesses to that specific table.
shardman.gv_stat_all_indexespg_stat_all_indexesOne row for each index in the current database, showing statistics about accesses to that specific index.
shardman.gv_statio_all_tablespg_statio_all_tablesOne row for each table in the current database, showing statistics about I/O on that specific table.
shardman.gv_statio_all_indexespg_statio_all_indexesOne row for each index in the current database, showing statistics about I/O on that specific index.
shardman.gv_statio_all_sequencespg_statio_all_sequencesOne row for each sequence in the current database, showing statistics about I/O on that specific sequence.
shardman.gv_stat_user_functionspg_stat_user_functionsOne row for each tracked function, showing statistics about executions of that function.
shardman.gv_stat_slrupg_stat_slruOne row per SLRU, showing statistics of operations.
shardman.gv_lockspg_locksThis view provides access to information about the locks held by active processes within the database server.
shardman.gv_shmem_allocationspg_shmem_allocationsThis view shows allocations made from the server's main shared memory segment.
shardman.gv_backend_memory_contextspg_backend_memory_contextsThis view displays all the memory contexts of the server process attached to the current session.
shardman.gv_stat_csnshardman.pg_stat_csnOne row showing statistics on delays that take place during import of CSN snapshots.
shardman.gv_silk_routesshardman.silk_routesThis view displays the current snapshot of the multiplexor routing table.
shardman.gv_silk_connectsshardman.silk_connectsThis view displays the current list of multiplexor connects.
shardman.gv_silk_backendsshardman.silk_backendsThis view displays the current list of processes of two kinds: backends that serve client connections and silkworm multiplexor workers, which interact with the multiplexor.
shardman.gv_silk_pending_jobsshardman.silk_pending_jobsThis view displays the current list of routes in the queue of multiplexor jobs that are not assigned to workers yet.
shardman.gv_stats_sdm_statementspgpro_stats_sdm_statements This view allows accessing the aggregated statistics for the distributed queries. This view can only be created if Shardman is installed for the database that has pgpro_stats. The pgpro_stats must be created on all the cluster nodes for the global view to work.

6.3.2. shardman.pg_stat_csn #

The shardman.pg_stat_csn view will have one row showing statistics on delays that take place during import of CSN snapshots. These delays occur because system clocks on Shardman cluster nodes may be out of sync. The delays negatively impact the performance by increasing the query latency. The shardman.pg_stat_csn view allows tracking these delays. The view data is based on The Statistics Collector. The columns of the view are shown in Table 6.2.

Table 6.2. shardman.pg_stat_csn Columns

NameTypeDescription
csn_snapshots_importedbigintTotal number of imported CSN snapshots
csn_total_import_delayintervalTotal duration of all delays in importing CSN snapshots, in microseconds
csn_max_shiftbigintMaximum registered snapshot CSN shift that caused a delay
global_oldest_csnbigintCSN of the oldest transaction in the cluster
global_oldest_xidxidXID of the oldest transaction in the cluster
global_oldest_rgidintegerNumber of the replication group with the oldest transaction in the cluster
local_oldest_csnbigintCSN of the oldest transaction on the current node
local_oldest_xidxidXID of the oldest transaction on the current node
CSNXidMap_head_csnbigintMost recent CSN in the CSNSnapshotXidMap
CSNXidMap_head_xidxidXID corresponding to the most recent CSN in the CSNSnapshotXidMap
CSNXidMap_tail_csnbigintOldest CSN in the CSNSnapshotXidMap
CSNXidMap_tail_xidxidXID corresponding to the oldest CSN in the CSNSnapshotXidMap
stats_resettimestamp with time zoneTime at which these statistics were last reset

To reset CSN-related statistics, call the pg_stat_reset_shared function with the only text argument equal to csn.

Note

Shardman functionality related to CSN snapshots is work in progress. So anticipate changes to the corresponding views in future releases.

6.3.3. shardman.pg_stat_monitor #

The shardman.pg_stat_monitor view will have one row showing metrics of the Shardman monitor. The view data is based on the Statistics Collector. The columns of the view are shown in Table 6.3.

Table 6.3. shardman.pg_stat_monitor Columns

NameTypeDescription
resolved_deadlocksbigintNumber of resolved distributed deadlocks
aborted_xactsbigintNumber of aborted outdated prepared transactions
committed_xactsbigintNumber of committed outdated prepared transactions
errorsbigintNumber of Shardman monitor errors
stats_resettimestamp with time zoneTime at which these statistics were last reset

6.3.4. shardman.pg_stat_netusage #

The shardman.pg_stat_netusage view will have one row showing the cumulative network traffic between Shardman cluster nodes. The view data is based on the Statistics Collector. The columns of the view are shown in Table 6.4.

Table 6.4. shardman.pg_stat_netusage Columns

NameTypeDescription
netusage_recv_bytesnumericTotal number of bytes received from other nodes through the network by each Shardman cluster node
netusage_sent_bytesnumericTotal number of bytes sent to other nodes through the network by each Shardman cluster node
stats_resettimestamp with time zoneTime at which these statistics were last reset

6.3.5. Multiplexor Diagnostics Views #

Views in this section provide various information related to Silk multiplexing. See Section 7.4 for details of silkroad multiplexing process.

6.3.5.1. shardman.silk_routes #

The shardman.silk_routes view displays the current snapshot of the multiplexor routing table. The columns of the view are shown in Table 6.5.

Table 6.5. shardman.silk_routes Columns

NameTypeDescription
hashvalueintegerInternal unique route identifier. Can be used to join with other Silk diagnostics views.
origin_ipinetIP address of the source node, which generated this route
origin_portint2External TCP connection port of the source node, which generated this route
channel_idintegerRoute sequential number within the node that generated this route. channel_id is unique for the pair origin_ip + origin_port. This pair is a unique node identifier within the Shardman cluster and hence the origin_ip + origin_port + channel_id tuple is a unique route identifier within the Shardman cluster.
from_cnintegerConnect index in the shardman.silk_connects view for incoming routes, that is, not generated by this node, and -1 for routes generated by this node.
backend_idintegerID of the local process that is currently using this route: either the ID of the backend that generated this route or the ID of the silkworm worker assigned to this route. Equals -1 for queued incoming routes that have not been assigned a worker yet.
pending_queue_bytesbigintSize of the queue of delayed messages (awaiting a free worker) for this route, in bytes. This value is only meaningful for incoming routes of each node that are not assigned to a worker yet.
pending_queue_messagesbigintNumber of messages in the queue of delayed messages (awaiting a free worker) for this route. This value is only meaningful for incoming routes of each node that are not assigned to a worker yet.
connectsinteger[]List of indexes of connects that are currently using this route.

6.3.5.2. shardman.silk_connects #

The shardman.silk_connects view displays the current list of multiplexor connects. The columns of the view are shown in Table 6.6.

Table 6.6. shardman.silk_connects Columns

NameTypeDescription
cn_indexintegerUnique connect index
reg_ipinetRegistration IP address of the node with which the connection is established. See Notes for details.
reg_portint2Registration TCP port of the node with which the connection is established. See Notes for details.
read_ev_activebooleantrue if the multiplexor is ready to receive data to the incoming queue. See Notes for details.
write_ev_activebooleantrue if the multiplexor filled the queue of non-sent messages and is waiting for it to get free. See Notes for details.
is_outgoingbooleantrue if the connection is outgoing, that is, created by connect, and false for incoming connects, that is, created by accept. Only used during the handshaking.
statetextCurrent state of the connect: connected — if the connection is established, in progress — if the client has already connected, but handshaking has not happened yet, free — if the client has already disconnected, but the connect structure for the disconnected client has not been destroyed yet.
pending_queue_bytesbigintSize of the queue of non-sent messages for this connect, in bytes
pending_queue_messagesbigintNumber of messages in the queue of non-sent messages for this connect
blocked_by_backendintegerID of the backend that blocked this connect
blocks_backendsinteger[]List of IDs of backends that are blocked by this connect
routesinteger[]List of unique IDs of routes that use this connect

6.3.5.3. shardman.silk_backends #

The shardman.silk_backends view displays the current list of processes of two kinds: backends that serve client connections and silkworm multiplexor workers, which interact with the multiplexor. The columns of the view are shown in Table 6.7.

Table 6.7. shardman.silk_backends Columns

NameTypeDescription
backend_idintegerUnique backend/worker identifier
pidintegerOS process ID
read_ev_activebooleantrue if the backend/worker is ready to receive data to the incoming queue. See Notes for details.
write_ev_activebooleantrue if the backend/worker filled the queue of non-sent messages and is waiting for it to get free. See Notes for details.
is_workerbooleantrue if this process is a silkworm multiplexor worker and false otherwise
pending_queue_bytesbigintSize of the queue of messages being sent to this backend/worker, in bytes
pending_queue_messagesbigintNumber of messages in the queue of messages being sent to this backend/worker
blocked_by_connectintegerIndex of the connect that blocks this backend/worker
blocks_connectsinteger[]List of indexes of connects that are blocked by this backend/worker
routesinteger[]List of unique IDs of routes that are used by this backend/worker

6.3.5.4. shardman.silk_pending_jobs #

The shardman.silk_pending_jobs view displays the current list of routes in the queue of delayed multiplexor jobs, that is, jobs that are not assigned to workers yet. The columns of the view are shown in Table 6.8.

Table 6.8. shardman.silk_pending_jobs Columns

NameTypeDescription
hashvalueintegerInternal unique route identifier
origin_ipinetIP address of the node that generated this route
origin_portint2TCP connection port of the node that generated this route
channel_idintegerRoute sequential number within the node that generated this route
from_cnintegerIndex of the connect from which a message was received that caused generation of this route

6.3.5.5. Notes #

reg_ip and reg_port values are not actual network addresses, but the addresses by which the multiplexor accesses the node. They are determined during a handshake between multiplexor nodes and are equal to the corresponding parameters of an appropriate server in the pg_foreign_server table.

All the read_ev_active values are true and all the write_ev_active values are false when the multiplexor is in the idle state.