Internal catalogs and views
===========================

Catalogs and views are presented here in alphabetical order.

bdr.ddl_epoch
^^^^^^^^^^^^^

An internal catalog table holding state per DDL epoch.

``bdr.ddl_epoch`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  ddl_epoch,int8,Monotonically increasing epoch number
  origin_node_id,oid,Internal node ID of the node that requested creation of this epoch
  epoch_consume_timeout,timestamptz,Timeout of this epoch
  epoch_consumed,boolean,Switches to true as soon as the local node has fully processed the epoch
  epoch_consumed_lsn,boolean,LSN at which the local node has processed the epoch

bdr.event_history
^^^^^^^^^^^^^^^^^

Internal catalog table that tracks cluster membership events for a given
PGD node. Specifically, it tracks:

-  Node joins (to the cluster)

-  Raft state changes (that is, whenever the node changes its role in
   the consensus protocol - leader, follower, or candidate to leader) -
   see :ref:`Monitoring Raft consensus <Monitoring Raft consensus>` 

-  Whenever a worker has errored out (see :ref:`bdr.workers <bdr.workers>` 

and :ref:`Monitoring PGD replication workers <Monitoring PGD replication workers>`  )

``bdr.event_history`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  event_node_id,oid,The ID of the node to which the event refers to
  event_type,int,"The type of the event (a node, raft or worker related event)"
  event_sub_type,int,"The sub-type of the event, i.e. if it's a join, a state change or an error"
  event_source,text,The name of the worker process where the event was sourced
  event_time,timestamptz,The timestamp at which the event occurred
  event_text,text,A textual representation of the event (e.g. the error of the worker)
  event_detail,text,"A more detailed description of the event (for now, only relevant for worker errors)"

bdr.event_summary
^^^^^^^^^^^^^^^^^

A view of the ``bdr.event_history`` catalog that displays the
information in a more human-friendly format. Specifically, it displays
the event types and subtypes as textual representations, rather than
integers.

bdr.node_config
^^^^^^^^^^^^^^^

An internal catalog table with per node configuration options.

``bdr.node_config`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_id,oid,The node ID
  node_route_priority,int,Priority assigned to this node
  node_route_fence,boolean,Switch to fence this node
  node_route_writes,boolean,Switch to allow writes
  node_route_reads,boolean,Switch to allow reads
  node_route_dsn,text,The interface of this node

bdr.node_group_config
^^^^^^^^^^^^^^^^^^^^^

An internal catalog table with per node group configuration options.

``bdr.node_group_config`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_group_id,oid,The node group ID
  route_writer_max_lag,bigint,Maximum write lag accepted
  route_reader_max_lag,bigint,Maximum read lag accepted
  route_writer_wait_flush,boolean,Switch if we need to wait for the flush

bdr.node_group_routing_config_summary
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Per-node-group routing configuration options.

``bdr.node_group_routing_config_summary`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_group_name,name,Node group name
  location,name,Node group location
  enable_proxy_routing,boolean,Group proxy routing enabled?
  node_group_type,text,"Node group type (one of ""global"", ""data"", or ""subscriber-only"")"
  route_writer_max_lag,bigint,Maximum write lag accepted
  route_reader_max_lag,bigint,Maximum read lag accepted
  route_writer_wait_flush,boolean,Wait for flush

bdr.node_group_routing_info
^^^^^^^^^^^^^^^^^^^^^^^^^^^

An internal catalog table holding current routing information for a
proxy.

``bdr.node_group_routing_info`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_group_id,oid,The node group ID
  write_node_id,oid,Current write node
  prev_write_node_id,oid,Previous write node
  read_node_ids,oid[],List of read-only nodes IDs

bdr.node_group_routing_summary
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A view of ``bdr.node_group_routing_info`` catalog that shows the
information in more friendly way.

``bdr.node_group_routing_summary`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_group_name,name,The node group name
  write_lead,name,The current write lead
  previous_write_lead,name,The previous write lead
  read_nodes,name[],The current read-only nodes

bdr.node_routing_config_summary
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A friendly view of the per node routing configuration options. Shows the
node name rather than the oid and shorter field names.

``bdr.node_routing_config_summary`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  node_name,name,The node name
  route_priority,int,Priority assigned to this node
  route_fence,boolean,Switch to fence this node
  route_writes,boolean,Switch to allow writes
  route_reads,boolean,Switch to allow reads
  route_dsn,text,The interface of this node

bdr.proxy_config
^^^^^^^^^^^^^^^^

An internal catalog table holding proxy specific configurations.

``bdr.proxy_config`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  proxy_name,name,The name of the proxy
  node_group_id,oid,The node group ID that this proxy uses
  listen_port,int,Port that the proxy uses for read-write connections (set to 0 disables port)
  max_client_conn,int,Number of maximum read-write client connections that the proxy accepts
  max_server_conn,int,Number of maximum read-write connections that the server accepts
  server_conn_timeout,interval,Timeout for the read-write server connections
  server_conn_keepalive,interval,Interval between the server connection keep alive
  fallback_group_timeout,interval,Timeout needed for the fallback
  fallback_group_ids,oid[],List of group IDs to be used for the fallback
  listen_addrs,text[],Listen address
  read_listen_port,int,Port that the proxy uses for read-only connections (set to 0 disables port)
  read_max_client_conn,int,Number of maximum read-only client connections that the proxy accepts
  read_max_server_conn,int,Number of maximum read-only connections that the server accepts
  read_server_conn_timeout,interval,Timeout for the server read-only connections
  read_server_conn_keepalive,interval,Interval between the server read-only connection keep alive
  read_listen_addrs,text[],Listen address for read-only connections
  read_consensus_grace_period,interval,Duration for which proxy continues to route even upon loss of consensus

bdr.proxy_config_summary
^^^^^^^^^^^^^^^^^^^^^^^^

A friendly view of per proxy instance specific configuration options.

``bdr.proxy_config_summary`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  proxy_name,name,The name of the proxy
  node_group_name,name,The node group name that this proxy uses
  listen_port,int,Port that the proxy uses for read-write connections (set to -1 disables port)
  max_client_conn,int,Number of maximum read-write client connections that the proxy accepts
  max_server_conn,int,Number of maximum read-write connections that the server accepts
  server_conn_timeout,interval,Timeout for the read-write server connections
  server_conn_keepalive,interval,Interval between the server connection keep alive
  node_group_enable_proxy_routing,boolean,Does the group the proxy is in enable proxy routing
  node_group_location,name,The group's location value
  fallback_group_timeout,interval,Timeout needed for the fallback
  fallback_group_ids,oid[],List of group IDs to be used for the fallback
  listen_addrs,text[],Listen address
  read_listen_port,int,Port that the proxy uses for read-only connections (set to -1 disables port)
  read_max_client_conn,int,Number of maximum read-only client connections that the proxy accepts
  read_max_server_conn,int,Number of maximum read-only connections that the server accepts
  read_server_conn_timeout,interval,Timeout for the server read-only connections
  read_server_conn_keepalive,interval,Interval between the server read-only connection keep alive
  read_listen_addrs,text[],Listen address for read-only connections
  read_consensus_grace_period,interval,Duration for which proxy continues to route even upon loss of consensus

bdr.sequence_kind
^^^^^^^^^^^^^^^^^

An internal state table storing the type of each non-local sequence. We
recommend the view ``bdr.sequences`` for diagnostic purposes.

``bdr.sequence_kind`` columns
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Name,Type,Description
  :widths: 12,15,25 
  :align: left
  :class: longtable

  seqid,oid,Internal OID of the sequence
  seqkind,char,"Internal sequence kind ('l'=local,'t'=timeshard,'s'=snowflakeid,'g'=galloc)"
