Commit Graph

346 Commits (c772dcd32e32ce4d7ba6dad94b1c78e561b96b7e)

Author SHA1 Message Date
Marco Slot c772dcd32e Run copy commands in worker_merge_files_into_table as superuser 2016-12-20 10:15:42 +01:00
Marco Slot 2ebd92de0a Set user as pg_merge_job_* schema owner 2016-12-20 10:15:42 +01:00
Murat Tuncer 6c95f0352e Make router planner active at all times
We used to disable router planner and executor
when task executor is set to task-tracker.

This change enables router planning and execution
at all times regardless of task execution mode.

We are introducing a hidden flag enable_router_execution
to enable/disable router execution. Its default value is
true. User may disable router planning by setting it to false.
2016-12-20 11:24:01 +03:00
Jason Petersen 54c2efccc1 Add targeted VACUUM/ANALYZE support
Adds support for VACUUM and ANALYZE commands which target a specific
distributed table. After grabbing the appropriate locks, this imple-
mentation sends VACUUM commands to each placement (using one connec-
tion per placement). These commands are sent in parallel, so users
with large tables will benefit from sharding. Except for VERBOSE, all
VACUUM and ANALYZE options are supported, including the explicit
column list used by ANALYZE.

As with many of our utility commands, the local command also runs. In
the VACUUM/ANALYZE case, the local command is executed before any re-
mote propagation. Because error handling is managed after local proc-
essing, this can result in a VACUUM completing locally but erroring
out when distributed processing commences: a minor technicality in all
cases, as there isn't really much reason to ever roll back a VACUUM (an
impossibility in any case, as VACUUM cannot run within a transaction).

Remote propagation of targeted VACUUM/ANALYZE is controlled by the
enable_ddl_propagation setting; warnings are emitted if such a command
is attempted when DDL propagation is disabled. Unqualified VACUUM or
ANALYZE is not handled, but a warning message informs the user of this.

Implementation note: this commit adds a "BARE" value to MultiShard-
CommitProtocol. When active, no BEGIN command is ever sent to remote
nodes, useful for commands such as VACUUM/ANALYZE which must not run in
a transaction block. This value is not user-facing and is reset at
transaction end.
2016-12-16 16:59:06 -07:00
Metin Doslu fc908a3ab6 Refactor distribution column type check for colocation 2016-12-16 15:24:45 +02:00
Metin Doslu d43a01ebae Don't allow tables with different replication models to be colocated 2016-12-16 15:23:49 +02:00
Metin Doslu 4ff550429f Add colocate_with option to create_distributed_table()
With this commit, we support three versions of colocate_with: i.default, ii.none
and iii. a specific table name.
2016-12-16 14:53:35 +02:00
Metin Doslu 15aeac0502 Move colocation related functions to colocation_utils.c 2016-12-16 14:52:40 +02:00
Marco Slot d733bfa044 Expose the column_to_column_name UDF to make partkey in pg_dist_partition human-readable 2016-12-14 10:46:33 +01:00
Eren Basak 7a9f9af9ea Add stop_metadata_sync_to_node UDF 2016-12-14 10:53:12 +03:00
Eren Basak 59b95a958d Propagate CREATE SCHEMA commands with the correct AUTHORIZATION clause in start_metadata_sync_to_node 2016-12-14 10:53:12 +03:00
Eren Basak 72e5e826b8 Make start_metadata_sync_to_node UDF to propagate foreign-key constraints 2016-12-14 10:53:12 +03:00
Eren Basak eea27619a0 Make truncate triggers propagated on start_metadata_sync_to_node call 2016-12-14 10:53:10 +03:00
Eren Basak 9b6d33f5b4 Prevent Transactions in start_metadata_sync_to_node 2016-12-13 10:48:03 +03:00
Eren Basak 1b812ec3b1 Add Regression Tests For start_metadata_sync_to_node 2016-12-13 10:48:03 +03:00
Eren Basak 9c415d4f34 Add start_metadata_sync_to_node UDF
This change adds `start_metadata_sync_to_node` UDF which copies the metadata about nodes and MX tables
from master to the specified worker, sets its local group ID and marks its hasmetadata to true to
allow it receive future DDL changes.
2016-12-13 10:48:03 +03:00
Andres Freund bed853664e Add support for running regression tests under valgrind.
Note that this only provides infrastructure for running tests under
valgrind - there's some spurious failures due to timeouts.
2016-12-12 15:42:11 -08:00
Andres Freund 90ad02f5fb Integrate router executor into transaction management framework.
One less place managing remote transactions. It also makes it fairly
easy to use 2PC for certain modifications (e.g. reference tables). Just
issue a CoordinatedTransactionUse2PC(). If every placement failure
should cause the whole transaction to abort, additionally mark the
relevant transactions as critical.
2016-12-12 15:18:12 -08:00
Andres Freund 21449ed0a0 Convert multi_shard_transaction.[ch] to new framework. 2016-12-12 15:18:12 -08:00
Andres Freund 7ac4a2bc94 Coordinated remote transaction management. 2016-12-12 15:18:12 -08:00
Andres Freund ccb2a35b6b Add PQgetResult() wrapper handling interrupts.
This makes it possible to implement cancelling queries blocked on
communication with remote nodes.
2016-12-12 15:18:12 -08:00
Andres Freund a26b9d3b8f Add support for running postgres tests against a database with citus loaded.
Not that this is not with the citus *extension* loaded, just the shared
library. The former runs (by adding --use-existing to the flags) but
has a bunch of trivial test differences.
2016-12-12 14:25:06 -08:00
Andres Freund 820f300de2 Make prepared transactions available if not configured. 2016-12-08 19:57:22 -08:00
Burak Yucesoy cdb725a561 Add Foreign Key Support to ALTER TABLE commands
With this PR, we add foreign key support to ALTER TABLE commands. For now,
we only support foreign constraint creation via ALTER TABLE query, if it
is only subcommand in ALTER TABLE subcommand list.

We also only allow foreign key creation if replication factor is 1.
2016-12-08 15:03:25 +02:00
Andres Freund 3754e74acb Move multi_client_executor.[ch] ontop of connection_management.[ch].
That way connections can be automatically closed after errors and such,
and the connection management infrastructure gets wider testing.  It
also fixes a few issues around connection string building.
2016-12-07 11:44:24 -08:00
Andres Freund c7f19f6c83 Use connection_management.c from within connection_cache.c.
This is a temporary step towards removing connection_cache.c.
2016-12-07 11:44:24 -08:00
Andres Freund 7bc7284b61 Add initial helpers to make interactions with MultiConnection et al. easier.
This includes basic infrastructure for logging of commands sent to
remote/worker nodes. Note that this has no effect as of yet, since no
callers are converted to the new infrastructure.
2016-12-07 11:44:24 -08:00
Andres Freund 8e32951eb9 Centralized Connection Lifetime Management.
Connections are tracked and released by integrating into postgres'
transaction handling. That allows to to use connections without having
to resort to having to disable interrupts or using PG_TRY/CATCH blocks
to avoid leaking connections.

This is intended to eventually replace multi_client_executor.c and
connection_cache.c, and to provide the basis of a centralized
transaction management.

The newly introduced transaction hook should, in the future, be the only
one in citus, to allow for proper ordering between operations.  For now
this central handler is responsible for releasing connections and
resetting XactModificationLevel after a transaction.
2016-12-07 11:43:18 -08:00
Andres Freund 9564e1e7fc Add some basic helpers to make use of dynahash hashtables easier. 2016-12-06 14:15:36 -08:00
Marco Slot 6cff558896 Use READ_UINT64_FIELD for placement ID in ReadShardPlacement 2016-12-05 17:22:23 +01:00
Murat Tuncer 6abc1eecbd Add new tests for non-relational filters in queries 2016-12-05 14:27:36 +03:00
Marco Slot 5b5bceb5ed Take shard metadata lock in master_append_table_to_shard 2016-12-02 15:56:30 +01:00
Eren Basak 517db3648a Propagate node add/remove to the nodes with hasmetadata=true
This change propagates the changes done by `master_add_node` and `master_remove_node`
to the workers that contain metadata.
2016-12-02 14:43:32 +03:00
Brian Cloutier 14b47b769c Remove dead code: ResponsiveWorkerNodeList 2016-12-02 13:14:11 +03:00
Andres Freund 36df62157e Use system psql if available, to fix travis build errors.
On some systems a new libpq is available than what we're compiling
against, but until now we used psql in the version we're compiling
against.  That' a problem, because (quoting Jason):

  With 9.6, libpq's default handling of CONTEXT changed: it is hidden
  unless the level is ERROR or higher. We addressed this ourselves using
  the SHOW_CONTEXT variable (by setting "always" in pg_regress_multi): in
  9.5, this is ignored (and unneeded), in 9.6, it ensures old behavior is
  preserved.

For 9.6 we'd already worked around the problem by specifying that
context should always be shown, but < 9.6 psql doesn't know how to do
that.

As there's no csql anymore, which strictly tied us to a specific version
of psql/csql, we can now just use the system's psql if available. We
still fall back to the psql of the installation we're compiling against,
if there's no other psql in PATH.
2016-12-01 15:58:23 -08:00
Onder Kalaci bbced1d704 Bugfix for deparsing INSERT..SELECT queries which involve constant values
This commit fixes a bug when the SELECT target list includes a constant
value.

Previous behaviour of target list re-ordering:
  * Iterate over the INSERT target list
    * If it includes a Var, find the corresponding SELECT entry
      and update its resno accordingly
    * If it does not include a Var (which we only considered to be
      DEFAULTs), generate a new SELECT target entry
  * If the processed target entry count in SELECT target list is less
    than the original SELECT target list (GROUP BY elements not included in
    the SELECT target entry), add them in the SELECT target list and
    update the resnos accordingly.
     * However, this step was leading to add the CONST SELECT target entries
       twice. The reason is that when CONST target list entries appear in the
       SELECT target list, the INSERT target list doesn't include a Var. Instead,
       it includes CONST as it does for DEFAULTs.

New behaviour of target list re-ordering:
  * Iterate over the INSERT target list
    * If it includes a Var, find the corresponding SELECT entry
      and update its resno accordingly
    * If it does not include a Var (which we consider to be
      DEFAULTs and CONSTs on the SELECT), generate a new SELECT
      target entry
  * If any target entry remains on the SELECT target list which are resjunk,
    (GROUP BY elements not included in the SELECT target entry), keep them
    in the SELECT target list by updating the resnos.
2016-12-01 10:41:56 +02:00
Murat Tuncer 33375944d6 Add support for filters
Ensures filter clauses are stripped from master query, and pushed
down to worker queries.
2016-12-01 08:53:46 +03:00
Sumedh Pathak b9cbb52c06 Change DDL error message to say "unsupported" instead of "supported" 2016-11-26 10:30:09 +01:00
Murat Tuncer 9bc833f335 Fix failures during pg_upgrade
- fix error in CitusHasBeenLoaded()
- allow creation of pg_catalog tables during upgrade
2016-11-11 17:22:45 -08:00
Marco Slot 40b1e8c039 Pass down the correct type for null parameters 2016-11-11 07:14:08 +01:00
Metin Doslu 670e2bc0dd Use AccessShareLock on the source table while creating a colocated table
While creating a colocated table, we don't want the source table to be dropped.
However, using a ShareLock blocks DML statements on the source table, and
using AccessShareLock is enough to prevent DROP. Therefore, we just loosened
the lock to AccessShareLock.
2016-11-10 09:17:05 -08:00
Eren Basak 4c5b97995a Add Column Definition List for Output Columns for master_add_node
This change allows seeing the names of columns of `master_add_node`,
using `SELECT * FROM master_add_node(...)` by specifying output
columns in UDF definition.
2016-11-07 14:08:58 -08:00
Marco Slot 28a1a88e9c Disallow SendCommandListToWorkerInSingleTransaction when modifications have occurred 2016-11-02 12:26:56 +01:00
Marco Slot 1d3caceda4 Use co-located shard ID in multi_shard_transaction 2016-11-02 11:01:19 +01:00
Samay Sharma 69bd7fc8de Avoid error during CREATE INDEX IF NOT EXISTS
Previously, we threw an error when we ran CREATE INDEX IF NOT EXISTS
with an already existing index. This change enables expected behavior by
checking if the statement has IF NOT EXISTS before throwing the error.
We also ensure that we don't execute the command on the workers, if an
index already exists on the master.
2016-11-01 14:51:19 -07:00
Burak Yucesoy 0e7d753b1f Fix typo in error message 2016-11-01 16:58:27 +02:00
Burak Yucesoy dbe717780c Change error message we displayed for foreign constraints if RF > 1
At the moment, we do not support foreign constraints if replication factor is greater
than 1. However foreign constraints can be used in cloud with high availability option.
Therefore we do not want to create an impression such that foreign constraints with
high availability is not supported at all. We call users to action with this error
message.
2016-11-01 15:47:19 +02:00
Önder Kalacı 34fa711b14 Always CASCADE while dropping a shard 2016-11-01 10:16:34 +01:00
Brian Cloutier 762468f0e3 Copy raw_parse_tree before using it
Address citusdata/citus#922.

Fixes a segfault in PG's installcheck caused by our reuse of
raw_parse_tree when handling EXPLAIN EXECUTE.
2016-10-27 18:25:49 +03:00
Onder Kalaci b8ad613325 Improve error semantics for INSERT..SELECT
With this commit, we error out if a worker query cannot be executed
on all placements of a target insert shard interval.
2016-10-27 14:09:05 +03:00