10 Commits

Author SHA1 Message Date
Mats Kindahl
6e9f644714 Require host parameter in add_data_node
Change `add_data_node` so that host parameter is required. If the host
parameter is not provided, or is `NULL`, an error will be printed.

Also change logic for how the default value for `port` is picked. Now
it will by default use the port given in the configuration file.

The commit update all the result files, add the `host` parameter to all
calls of `add_data_node` and add a few tests to check that an error is
given when `host` is not provided.
2020-05-27 17:31:09 +02:00
Ruslan Fomkin
9438c1c075 Verify that connections are to a TimescaleDB node
Checks that a data node connection is created with the TimescaleDB
foreign data wrapper. Refactors existing code to remove duplicated
code related to TimescaleDB foreign data wrapper.
2020-05-27 17:31:09 +02:00
Dmitry Simonenko
c8563b2d46 Add distributed_exec() function
This function allows users to execute a SQL query on a list of data
nodes. The purpose is to provide users a way to, e.g., create roles on
data nodes.

The current implementation is quite straightforward. Just execute any
provided query on a list of data nodes. The query will execute with
the current user role. The function does not return or print any
result values. In case of error, it will print the data node name and
a related error message.
2020-05-27 17:31:09 +02:00
Dmitry Simonenko
f7a39c6deb Support SSL with Certificate Based Authentication
Add a tunable way to support SSL connections to data nodes
with optional certificate based authentication.

Switch test suite to use pre-generated certificates.
2020-05-27 17:31:09 +02:00
Dmitry Simonenko
79f6223631 Replace UserMappings with a connection ID
This change replace UserMappings with newly introduced TSConnectionId
object, which represent a pair of foreign server id and local user id.

Authentication has been moved to non-password based, since original
UserMappings were used to store a data node user passwords as
well. This is a temporary step, until introduction of certificate
based authentication.

List of changes:

* add_data_node() password and bootstrap_password arguments removed

* introduced authentication using pgpass file

* RemoteTxn format string which represents tx changed to
  tx-version-xid-server_id-user_id

* data_node_dispatch, remote transaction cache, connection cache hash
  tables keys switched to TSConnectionId instead of user mappings

* remote_connection_open() been rework to exclude user options

* Tests upgraded, user mappings and passwords usage has been excluded
2020-05-27 17:31:09 +02:00
Erik Nordström
b07461ec00 Refactor and harden data node management
This change refactors and hardens parts of data node management
functionality.

* A number of of permissions checks have been added to data node
  management functions. This includes checking that the user has
  proper permissions for both table and server objects.
* Permissions checks are now done when creating remote chunks on data
  nodes.
* The add_data_node() API function has been simplified and now returns
  more intuitive status about created objects (foreign server,
  database, extension). It is no longer necessary to specify a user to
  connect with as this is always assumed to be the current user. The
  bootstrap user can still be specified explicitly, however, as that
  user might require elevated permissions on the remote node to
  bootstrap.
* Functions that capture exceptions without re-throwing, such as
  `ping_data_node()` and `get_user_mapping()`, have been refactored to
  not do this as the transaction state and memory contexts are not in
  states where it is safe to proceed as normal.
* Data node management functions now consistently check that any
  foreign servers operated on are actually TimescaleDB server objects.
* Tests now run with a superuser a regular user specific to
  clustering. These users have password auth enabled in `pg_hba.conf`,
  which is required by the connection library when connecting as a
  non-superuser. Tests have been refactored to bootstrap data nodes
  using these user roles.
2020-05-27 17:31:09 +02:00
Brian Rowe
79fb46456f Rename server to data node
The timescale clustering code so far has been written referring to the
remote databases as 'servers'.  This terminology is a bit overloaded,
and in particular we don't enforce any network topology limitations
that the term 'server' would suggest.  In light of this we've decided
to change to use the term 'node' when referring to the different
databases in a distributed database.  Specifically we refer to the
frontend as an 'access node' and to the backends as 'data nodes',
though we may omit the access or data qualifier where it's unambiguous.

As the vast bulk of the code so far has been written for the case where
there was a single access node, almost all instances of 'server' were
references to data nodes.  This change has updated the code to rename
those instances.
2020-05-27 17:31:09 +02:00
Dmitry Simonenko
96727fa5c4 Add support for distributed peer ID
This change makes it possible for a data node to distinguish between
regular client connections and distributed database connections (from
the access node).

This functionality will be needed for decision making based on the
connection type, for example allow or block a DDL commands on a data
node.
2020-05-27 17:31:09 +02:00
Dmitry Simonenko
d8982c3e15 Add add_server() support for remote server bootstrapping
This patch adds functionality for automatic database and extension
creation on remote server. New function arguments: bootstrap_database, bootstrap_user
and bootstrap_password.
2020-05-27 17:31:09 +02:00
Brian Rowe
db82c25d44 Add an API to invoke SQL on backend servers
This change adds a new function that will invoke the passed in command
on any specified backend servers (defaulting to all). The command
will be run asynchronously with transactional semantics (it either
succeeds on all targets or is rolled back).
2020-05-27 17:31:09 +02:00