Commit Graph

339 Commits (18cd97b6fcfb43fc37fe69365b3821adceeeaff0)

Author SHA1 Message Date
Jason Petersen 18cd97b6fc Merge pull request #673 from citusdata/feature/improve_sequence_support
Support SERIAL/BIGSERIAL non-partition columns

cr: @anarazel
2016-07-29 00:11:33 -06:00
Jason Petersen f19779b0ce Support SERIAL/BIGSERIAL non-partition columns
This adds support for SERIAL/BIGSERIAL column types. Because we now can
evaluate functions on the master (during execution), adding this is a
matter of ensuring the table creation step works properly.

To accomplish this, I've added some logic to detect sequences owned by
a table (i.e. those related to its columns). Simply creating a sequence
and using it in a default value is insufficient; users who do so must
ensure the sequence is owned by the column using it.

Fortunately, this is exactly what SERIAL and BIGSERIAL do, which is the
use case we're targeting with this feature. While testing this, I found
that worker_apply_shard_ddl_command actually adds shard identifiers to
sequence names, though I found no places that use or test this path. I
removed that code so that sequence names are not mutated and will match
those used by a SERIAL default value expression.

Our use of the new-to-9.5 CREATE SEQUENCE IF NOT EXISTS syntax means we
are dropping support for 9.4 (which is being done regardless, but makes
this change simpler). I've removed 9.4 from the Travis build matrix.

Some edge cases are possible in ALTER SEQUENCE, COPY FROM (on workers),
and CREATE SEQUENCE OWNED BY. I've added errors for each so that users
understand when and why certain operations are prohibited.
2016-07-28 23:55:40 -06:00
Metin Döşlü 5b63deebc5 Merge pull request #678 from citusdata/fix/fix_676_add_old_versions_of_api_functions_without_schema_parameter
Add old version(without schema name parameter) of api functions back
2016-07-28 21:59:44 +03:00
Burak Yucesoy 0a2c940ae5 Remove schema name parameter from API functions
We remove schema name parameter from worker_fetch_foreign_file and
worker_fetch_regular_table functions. We now send schema name
concatanated with table name.
2016-07-28 20:41:05 +03:00
Burak Yucesoy 98025110f0 Add old version(without schema name parameter) of api functions back
Fixes #676

We added old versions (i.e. without schema name) of worker_apply_shard_ddl_command,
worker_fetch_foreign_file and worker_fetch_regular_table back. During function call
of one of these functions, we set schema name as  public schema and call the newer
version of the functions.
2016-07-28 20:40:38 +03:00
Eren Başak 94830778e4 Merge pull request #686 from citusdata/allow_cancellation_on_ddl_commands
Tidy Up multi_ProcessUtility
2016-07-28 17:34:14 +03:00
Eren Başak 6f91d30e1c Remove AllFinalizedlacementsAccessible Function
This change removes AllFinalizedPlacementsAccessible function since,
we open connections to all shard placements before any command is
sent so we immediately error out if a shard placement is not accessible.
2016-07-28 17:24:37 +03:00
Eren Başak 90a1d8f67a Allow Cancellation During Distributed DDL Commands
This change allows users to interrupt long running DDL commands.
Interrupt requests are handled after each DDL command being propagated
to a shard placement, which means that generally the cancel request will
be processed right after the execution of the DDL is finished in the
current placement.
2016-07-28 17:12:07 +03:00
Murat Tuncer 01348b1c42 Merge pull request #647 from citusdata/501_use_relation_restrictions
Expand router planner coverage for single worker queries
2016-07-27 23:49:24 +03:00
Murat Tuncer 992997b8ad Expand router planner coverage
We can now support richer set of queries in router planner.
This allow us to support CTEs, joins, window function, subqueries
if they are known to be executed at a single worker with a single
task (all tables are filtered down to a single shard and a single
worker contains all table shards referenced in the query).

Fixes : #501
2016-07-27 23:35:38 +03:00
Murat Tuncer bc9d2000af Merge pull request #672 from citusdata/drop_pg_94_support
Drop PostgreSQL 9.4 support
2016-07-26 20:24:15 +03:00
Murat Tuncer 719e44d1f4 Remove PostgreSQL 9.4 support 2016-07-26 20:16:09 +03:00
Önder Kalacı 45ec84adee Merge pull request #642 from citusdata/bugfix/realtime_poll_timeout
Fix bug related to poll timeout
2016-07-26 10:21:37 +03:00
Onder Kalaci 0d3e85ce11 Fix bug related to poll timeout
This commit fixes a bug on setting polling timeout. The code
updated to comform to the comment that is already placed.
2016-07-26 09:55:47 +03:00
Burak Yücesoy 1c1f30c58e Merge pull request #665 from citusdata/remove_warnings_on_schema_creation
Remove warnings on schema creation
2016-07-22 19:03:44 +03:00
Burak Yucesoy 770ecffc8f Remove warnings on schema creation
Since now we support schema related operations, there is no need to warn user about
schema usage.
2016-07-22 18:24:23 +03:00
Burak Yücesoy 0531150785 Merge pull request #662 from citusdata/fix/fix_ALTER_TABLE_SET_SCHEMA
Fix ALTER TABLE SET SCHEMA
2016-07-22 18:07:39 +03:00
Burak Yucesoy 9df8300efa Fix ALTER TABLE SET SCHEMA
Fixes #132

We hook into ALTER ... SET SCHEMA and warn out if user tries to change schema of a
distributed table.

We also hook into ALTER TABLE ALL IN TABLE SPACE statements and warn out if citus has
been loaded.
2016-07-22 17:52:40 +03:00
Murat Tuncer cff2743f46 Merge pull request #660 from citusdata/outer_join_fix_for_flattened_queries
Prevent outer join crash when subquery is flatten
2016-07-22 17:16:33 +03:00
Murat Tuncer 461fefbdb2 Fix outer join crash when subquery is flatten 2016-07-22 17:01:19 +03:00
Jason Petersen 5ebba88c06 Merge pull request #653 from citusdata/fix/fix_worker_fetch_regular_table_with_schema
Fix worker_fetch_regular_table with schema

cr: @jasonmp85
2016-07-22 00:56:07 -06:00
Burak Yucesoy 444d4eb558 Fix worker_fetch_regular_table with schema
Fixes #504
Fixes #646

We changed signature of worker_fetch_regular_table to accept schema name as parameter to
make it work with schemas.
2016-07-22 00:44:02 -06:00
Jason Petersen e9eb1ae529 Merge pull request #627 from citusdata/feature/mod_in_xact
Permit "single-shard" transactions

cr: @anarazel
2016-07-21 16:37:38 -06:00
Jason Petersen 44e444ac6a Permit "single-shard" transactions
Allows the use of modification commands (INSERT/UPDATE/DELETE) within
transaction blocks (delimited by BEGIN and ROLLBACK/COMMIT), so long as
all modifications hit a subset of nodes involved in the first such com-
mand in the transaction. This does not circumvent the requirement that
each individual modification command must still target a single shard.

For instance, after sending BEGIN, a user might INSERT some rows to a
shard replicated on two nodes. Subsequent modifications can hit other
shards, so long as they are on one or both of these nodes.

SAVEPOINTs are supported, though if the user actually attempts to send
a ROLLBACK command that specifies a SAVEPOINT they will receive an
ERROR at the end of the topmost transaction.

Placements are only marked inactive if at least one replica succeeds
in a transaction where others fail. Non-atomic behavior is possible if
the shard targeted by the initial modification within a transaction has
a higher replication factor than another shard within the same block
and a node with the latter shard has a failure during the COMMIT phase.

Other methods of denoting transaction blocks (multi-statement commands
sent all at once and functions written in e.g. PL/pgSQL or other such
languages) are not presently supported; their treatment remains the
same as before.
2016-07-21 15:57:22 -06:00
Joe Nelson 94160fc446 Update docs links (#663)
Thanks to @joerg84 for pointing out the broken links

Closes #658
2016-07-21 13:39:40 -07:00
Burak Yücesoy 25e2bf9714 Merge pull request #655 from citusdata/fix/fix_555_hll_with_schema
Fix COUNT DISTINCT approximation with schema
2016-07-21 18:01:33 +03:00
Burak Yucesoy 7df5a265c7 Fix COUNT DISTINCT approximation with schema
Fixes #555

Before this change, we were resolving HLL function and type Oid without qualified name.
Now we find the schema name where HLL objects are stored and generate qualified names for
each objects.

Similar fix is also applied for cstore_table_size function call.
2016-07-21 17:29:18 +03:00
Burak Yücesoy 7bb62a8d42 Merge pull request #644 from citusdata/fix/fix_73_master_apply_delete_command_with_schema
Fix master_apply_delete_command with schema
2016-07-21 15:13:39 +03:00
Burak Yucesoy 5a93a70e2d Fix master_apply_delete_command with schema
Fixes #73
2016-07-21 15:09:20 +03:00
Burak Yücesoy aeb26d433c Merge pull request #643 from citusdata/add_schema_name_to_worker_apply_shard_ddl_command
Add schema name to worker apply shard ddl command
2016-07-21 14:23:29 +03:00
Burak Yucesoy d0beacc4e1 Change worker_apply_shard_ddl_command to accept schema name as parameter
Fixes #565
Fixes #626

To add schema support to citus, we need to schema-prefix all table names, object names etc.
in the queries sent to worker nodes. However; query deparsing is not available for most of
DDL commands, therefore it is not easy to generate worker query in the master node.

As a solution we are sending schema names along with shard id and query to run to worker
nodes with worker_apply_shard_ddl_command.

To not break \STAGE command we pass public schema as paramater while calling
worker_apply_shard_ddl_command from there. This will not cause problem if user uses \STAGE
in different schema because passes schema name is used only if there is no schema name is
given in the query.
2016-07-21 14:17:26 +03:00
Metin Döşlü 10923f5409 Merge pull request #649 from citusdata/router_executor_prepare_support
Router executor prepare support for non-partition columns
2016-07-21 11:14:26 +03:00
Metin Doslu 28000a8203 Add support for prepared statements with parameterized non-partition columns in router executor 2016-07-21 11:09:28 +03:00
Marco Slot 5ef39f9369 Merge pull request #656 from citusdata/cleanup/commit-handler
Move CompleteShardPlacementTransactions to multi_shard_transaction.c
2016-07-20 12:50:06 +02:00
Marco Slot 7c093c5cef Move CompleteShardPlacementTransactions to multi_shard_transaction.c 2016-07-20 12:10:46 +02:00
Burak Yücesoy 5b3e0515b4 Merge pull request #637 from citusdata/always_schema_prefix_worker_queries
Always schema-prefix worker queries
2016-07-20 10:47:06 +03:00
Burak Yucesoy 71bb558641 Always schema-prefix worker queries
Fixes #215
Fixes #267
Fixes #502
Fixes #556
Fixes #557
Fixes #560
Fixes #568
Fixes #623
Fixes #624

With this change we schema-prefix table names, operator names and composite types.
2016-07-20 10:42:24 +03:00
Eren Başak d27cdfc773 Merge pull request #654 from citusdata/fix_unused_istoplevel_variable
Fix Unused Parameter isTopLevel in ExecuteDistributedDDLCommand
2016-07-19 14:27:29 +03:00
Eren Başak c559592da0 Fix Unused Parameter isTopLevel in ExecuteDistributedDDLCommand
This change fixes the unused variable problem in
`ExecuteDistributedDDLCommand` function (multi_utility.c). The
parameter is meant to be used in PreventTransactionChain call.
2016-07-19 14:14:02 +03:00
Eren Başak 68b9a5aa8c Merge pull request #618 from citusdata/ddl_propagation_2pc
Propagate DDL Commands via 2PC
2016-07-19 10:54:57 +03:00
Eren 692ef0964a Propagate DDL Commands with 2PC
Fixes #513

This change modifies the DDL Propagation logic so that DDL queries
are propagated via 2-Phase Commit protocol. This way, failures during
the execution of distributed DDL commands will not leave the table in
an intermediate state and the pending prepared transactions can be
commited manually.

DDL commands are not allowed inside other transaction blocks or functions.

DDL commands are performed with 2PC regardless of the value of
`citus.multi_shard_commit_protocol` parameter.

The workflow of the successful case is this:
1. Open individual connections to all shard placements and send `BEGIN`
2. Send `SELECT worker_apply_shard_ddl_command(<shardId>, <DDL Command>)`
to all connections, one by one, in a serial manner.
3. Send `PREPARE TRANSCATION <transaction_id>` to all connections.
4. Sedn `COMMIT` to all connections.

Failure cases:
- If a worker problem occurs before sending of all DDL commands is finished, then
all changes are rolled back.
- If a worker problem occurs after all DDL commands are sent but not after
`PREPARE TRANSACTION` commands are finished, then all changes are rolled back.
However, if a worker node is failed, then the prepared transactions in that worker
should be rolled back manually.
- If a worker problem occurs during `COMMIT PREPARED` statements are being sent,
then the prepared transactions on the failed workers should be commited manually.
- If master fails before the first 'PREPARE TRANSACTION' is sent, then nothing is
changed on workers.
- If master fails during `PREPARE TRANSACTION` commands are being sent, then the
prepared transactions on workers should be rolled back manually.
- If master fails during `COMMIT PREPARED` or `ROLLBACK PREPARED` commands are being
sent, then the remaining prepared transactions on the workers should be handled manually.

This change also helps with #480, since failed DDL changes no longer mark
failed placements as inactive.
2016-07-19 10:44:11 +03:00
Murat Tuncer 4fb6770495 Merge pull request #651 from citusdata/501_user_original_query_in_modify_task
Make router planner use original query
2016-07-19 07:45:40 +03:00
Murat Tuncer eae7f79a8b Make router planner use original query 2016-07-18 18:23:04 +03:00
Eren Başak 7aaf74c2e4 Merge pull request #596 from citusdata/limit_offset_support
Add LIMIT/OFFSET Support
2016-07-18 12:38:08 +03:00
Eren c92c81b550 Add LIMIT/OFFSET Support
Fixes #394

This change adds LIMIT/OFFSET support for non router-plannable
distributed queries.

In cases that we can push the LIMIT down, we add the OFFSET value to
that LIMIT in the worker queries. When a query with LIMIT x OFFSET y is issued,
the query is propagated to the workers as LIMIT (x+y) OFFSET 0, and on the
master table, the original LIMIT and OFFSET values are used. With this change,
we can use OFFSET wherever we can use LIMIT.
2016-07-18 12:00:24 +03:00
Andres Freund 802f19ab82 Merge pull request #488 from citusdata/213-support-stable-functions
Evaluate functions on master
2016-07-13 13:42:45 -07:00
Andres Freund bafafcd1bf citus_indent fixups 2016-07-13 11:45:51 -07:00
Brian Cloutier 728eefcf2b Simplify code and fix include guards in citus_clauses 2016-07-13 11:45:51 -07:00
Brian Cloutier 9a5e529f6f cosmetic changes 2016-07-13 11:45:51 -07:00
Brian Cloutier c46cb19cda Only reparse queries if the planner flags them for reparsing 2016-07-13 11:45:51 -07:00