Commit Graph

1030 Commits (eea8c51e1f25cba0dc711a299735e481f90c4c4b)

Author SHA1 Message Date
Burak Yucesoy eea8c51e1f Only error out on distributed queries when there is version mismatch
Before this commit, we were erroring out at almost all queries if there is a
version mismatch. With this commit, we started to error out only requested
operation touches distributed tables.

Normally we would need to use distributed cache to understand whether a table
is distributed or not. However, it is not safe to read our metadata tables when
there is a version mismatch, thus it is not safe to create distributed cache.
Therefore for this specific occasion, we directly read from pg_dist_partition
table. However; reading from catalog is costly and we should not use this
method in other places as much as possible.
2017-05-22 09:53:29 +03:00
Burak Yucesoy acb0d23717 Fix crash during upgrade from 5.2 to 6.2
This commit fixes the problem where we incorrectly try to reach distributed table
cache when the extension is not loaded completely. We tried to reach the cache
because we wanted to get reference table information to activate the node. However
it is actually not necessary to explicitly activate the nodes which come from
master_initialize_node_metadata. Because it only runs during extension creation and
at that time there are no reference tables and all nodes are considered as active.
2017-05-19 00:01:36 +03:00
Jason Petersen cc45712144 Bump extension and configure PACKAGE versions
Actually getting this done before the next dev cycle begins.
2017-05-17 15:25:30 -06:00
Burak Yucesoy b94285c575
Update CHANGELOG for v6.2.0
CHANGELOG changes for 6.2 release
2017-05-16 22:28:53 -06:00
Jason Petersen 209e2c48ec Merge pull request #1377 from citusdata/pg10_prep
Make minor tweaks to prepare for PostgreSQL 10

cr: @anarazel
2017-05-16 11:44:39 -06:00
Jason Petersen 791cdd7648
Limit sequence SELECT to last_value
Unbounded column output differs by version.
2017-05-16 11:05:34 -06:00
Jason Petersen 51137184d9
Suppress hash index warning
Irrelevant to the test.
2017-05-16 11:05:34 -06:00
Jason Petersen 489aa73257
Add missing CCI call in metadata seq sync
Be explicit about the fact that we've made a modification: we need
subsequent commands to see this sequence.
2017-05-16 11:05:34 -06:00
Jason Petersen 97f8302c9c
Change version-sensitive tests to handle '10'
Previously assumed period in version; this makes tests future-proof.
2017-05-16 11:05:34 -06:00
Jason Petersen d6cccee5bc
Remove ALTER SEQUENCE from parallel groups
Removing these has no side effect, and in the (current) PostgreSQL 10,
an ERROR is printed during concurrent sequence modification.
2017-05-16 11:05:34 -06:00
Jason Petersen db11324ac7
Add unambiguous ORDER BY clauses to many tests
Queries which do not specify an order may arbitrarily change output
across PostgreSQL versions.
2017-05-16 11:05:34 -06:00
Jason Petersen b9bc3fdada
Update header comments to match new test names
Just keeping these in sync with the actual file name.
2017-05-16 11:05:33 -06:00
Jason Petersen 9f4a33eee1
Rename very long test files
In addition to not actually providing much information, these names can
cause problems in PostgreSQL 10.
2017-05-16 11:05:33 -06:00
Jason Petersen c9fa11b445
Use library and symbol name for bgw entry
PostgreSQL 10 takes away the ability to directly assign a function
pointer; the other approach (library and symbol name) is supported by
all versions.
2017-05-16 11:05:33 -06:00
Jason Petersen f86920f9d6
Add includes for missing standard headers
We use symbols from each of these and were relying on them being
included by other headers.
2017-05-16 11:05:33 -06:00
Jason Petersen 82b03d5cb6
Add explicit cast for argument to copyObject
PostgreSQL 10 adds a call to typeof, if supported.
2017-05-16 11:05:33 -06:00
Burak Yücesoy 40ebd93be3 Merge pull request #1412 from citusdata/fix_schema_owner_name
Send correct and quoted owner name while propagating schema creation
2017-05-15 06:11:08 -08:00
Burak Yucesoy 577ffb2bf2 Add tests for non-default schema owner 2017-05-15 16:49:37 +03:00
Burak Yucesoy 5a3a32d6df Quote schema's owner name
When we propogate the schema creation command to data nodes we add schema's
owner name too. Before this patch, we did not quote the owner's name which
causes problems with the names containing characters like '-'.
2017-05-15 16:26:32 +03:00
Burak Yucesoy 1b5560b2f7 Fix OwnerName function to work with schemas
We incorrectly try to use relation cache to find particular schema's owner and
when we cannot find the schema in the relation cache(i.e always), we automatically
used current user as the schema's owner. This means we always created schemas in
the data nodes with current user. With this patch we started to use namespace
cache to find schemas.
2017-05-15 16:26:32 +03:00
Önder Kalacı a7c65a3ed8 Add 9.5 output file for isolation test (#1413)
With commit we add one additional regression test output file which
has some output syntax differences with its 9.6 equivalence.
2017-05-15 15:27:37 +03:00
Jason Petersen fb836ee7cc Merge pull request #1343 from citusdata/test_custom_compiled_postgres
Use custom compiled PostgreSQL in Travis for merge commits

cr: @jasonmp85
2017-05-12 15:15:55 -06:00
Jason Petersen 05d42b01d3
Mark test failing in 9.5 as 'ignore'
This test was added this morning, but is failing in 9.5.
2017-05-12 15:00:42 -06:00
Burak Yucesoy 75d58cbf94
Travis merge jobs use custom-compiled PostgreSQL
With this commit, we start to use custom compiled PostgreSQL builds in
Travis for merge commits. This allows us to run isolation tests and
PostgreSQL's own regression tests along with our regression tests in
Travis.

Since manually compiling PostgreSQL takes more time and we also add new
tests, we only enable running these tests on merge commits.
2017-05-12 15:00:42 -06:00
Önder Kalacı 3adbbdcdcb Fix typo in the regression test (#1410) 2017-05-12 15:46:38 +03:00
Önder Kalacı e0257aecd9 Accept invalidation messages before accessing the metadata cache (#1406)
* Accept invalidation messages before accessing the metadata cache

This commit is crucial to prevent stale metadata reads from the
cache. Without this commit, some of the operations may use stale
metadata which could end up with various bugs such as crashes,
inconsistent/lost data etc.

As an example, consider that a COPY operation is blocked on shard
metadata lock. Another concurrent session updates the metadata and
invalidates the cache. However, since Citus doesn't accept invalidations,
COPY continues with the stale metadata once it acquires the lock.

With this commit, we make sure that invalidation messages are accepted
just before accessing the metadata cache and preventing any operation to
use stale metadata.

* Add isolation tests for placement changes and conccurrent operations

   - add node with reference table vs COPY/insert/update/DDL
   - repair shard vs COPY/insert/update/DDL
   - repair shard vs repair shard
2017-05-12 12:32:35 +03:00
Marco Slot 94151c9aef Merge pull request #1405 from citusdata/fix_copy_create_distributed_table
Ensure all preceding writes are visible in data migration
2017-05-11 10:05:15 +02:00
Marco Slot 6f9e18de24 Ensure all preceding writes are visible in data migration 2017-05-11 09:42:12 +02:00
Önder Kalacı 3ec502b286 Add support for parametrized execution for subquery pushdown (#1356)
Distributed query planning for subquery pushdown is done on the original
query. This prevents the usage of external parameters on the execution.
To overcome this, we manually replace the parameters on the original
query.
2017-05-10 09:38:48 +03:00
Marco Slot 97334a9123 Merge pull request #1382 from citusdata/fix_drop_locking
Fix locking in master_drop_all_shards / master_apply_delete_command
2017-05-08 18:07:03 +02:00
Metin Doslu 37026dc351 Add truncate first isolation tests 2017-05-08 17:26:55 +02:00
Marco Slot a8f368fced Fix locking in master_drop_all_shards / master_apply_delete_command 2017-05-08 17:26:55 +02:00
Jason Petersen 8e2dd3e1f3
Update CHANGELOG for v6.1.1 2017-05-04 17:49:57 -07:00
Jason Petersen 61fbcaeca7 Merge pull request #1360 from citusdata/fix_prepared_ddl
Don't change parse tree of DDL commands

cr: @anarazel, @jasonmp85
2017-05-04 13:44:46 -07:00
Marco Slot 853f07dd33 Don't change query tree of DDL commands 2017-05-04 21:34:28 +02:00
Jason Petersen f0c6c47c4e
Fix CREATE SEQUENCE generation bug
Apparently we've had a typo all this time causing us to pass the cache
value for the start value.
2017-05-03 21:47:06 -07:00
Önder Kalacı ef6d3587b6 Skip exhaustive test in CoPartitionedTables() if declared colocated (#1376)
That's considerably cheaper.
2017-05-02 03:33:21 +03:00
Önder Kalacı b74ed3c8e1 Subqueries in where -- updated (#1372)
* Support for subqueries in WHERE clause

This commit enables subqueries in WHERE clause to be pushed down
by the subquery pushdown logic.

The support covers:
  - Correlated subqueries with IN, NOT IN, EXISTS, NOT EXISTS,
    operator expressions such as (>, <, =, ALL, ANY etc.)
  - Non-correlated subqueries with (partition_key) IN (SELECT partition_key ..)
    (partition_key) =ANY (SELECT partition_key ...)

Note that this commit heavily utilizes the attribute equivalence logic introduced
in the 1cb6a34ba8. In general, this commit mostly
adjusts the logical planner not to error out on the subqueries in WHERE clause.

* Improve error checks for subquery pushdown and INSERT ... SELECT

Since we allow subqueries in WHERE clause with the previous commit,
we should apply the same limitations to those subqueries.

With this commit, we do not iterate on each subquery one by one.
Instead, we extract all the subqueries and apply the checks directly
on those subqueries. The aim of this change is to (i) Simplify the
code (ii) Make it close to the checks on INSERT .. SELECT code base.

* Extend checks for unresolved paramaters to include SubLinks

With the presence of subqueries in where clause (i.e., SubPlans on the
query) the existing way for checking unresolved parameters fail. The
reason is that the parameters for SubPlans are kept on the parent plan not
on the query itself (see primnodes.h for the details).

With this commit, instead of checking SubPlans on the modified plans
we start to use originalQuery, where SubLinks represent the subqueries
in where clause. The unresolved parameters can be found on the SubLinks.

* Apply code-review feedback

* Remove unnecessary copying of shard interval list

This commit removes unnecessary copying of shard interval list. Note
that there are no copyObject function implemented for shard intervals.
2017-05-01 17:20:21 +03:00
Marco Slot 8dab40da69 Merge pull request #1357 from citusdata/fix_gitignore
Add missing regression test output files to .gitignore
2017-04-28 19:13:26 -07:00
Marco Slot dee34c24fd Add missing regression test output files to .gitignore 2017-04-29 03:56:14 +02:00
Marco Slot 5ad8bd37f1 Merge pull request #1265 from citusdata/truncate_propagation
Honour enable_ddl_propagation in truncate trigger
2017-04-28 18:47:52 -07:00
Marco Slot 8edba5f309 Honour enable_ddl_propagation in truncate trigger 2017-04-29 03:32:52 +02:00
Brian Cloutier 22e7aa9a4f Fix crash in isolation tests
- There was a crash when the table a shardid belonged to changed during
  a session. Instead of crashing (a failed assert) we now throw an error
- Update the isolation test which was crashing to no longer exercise
  that code path
- Add a regression test to check that the error is thrown
2017-04-29 04:25:26 +03:00
Önder Kalacı ad5cd326a4 Subquery pushdown - main branch (#1323)
* Enabling physical planner for subquery pushdown changes

This commit applies the logic that exists in INSERT .. SELECT
planning to the subquery pushdown changes.

The main algorithm is followed as :
   - pick an anchor relation (i.e., target relation)
   - per each target shard interval
       - add the target shard interval's shard range
         as a restriction to the relations (if all relations
         joined on the partition keys)
        - Check whether the query is router plannable per
          target shard interval.
        - If router plannable, create a task

* Add union support within the JOINS

This commit adds support for UNION/UNION ALL subqueries that are
in the following form:

     .... (Q1 UNION Q2 UNION ...) as union_query JOIN (QN) ...

In other words, we currently do NOT support the queries that are
in the following form where union query is not JOINed with
other relations/subqueries :

     .... (Q1 UNION Q2 UNION ...) as union_query ....

* Subquery pushdown planner uses original query

With this commit, we change the input to the logical planner for
subquery pushdown. Before this commit, the planner was relying
on the query tree that is transformed by the postgresql planner.
After this commit, the planner uses the original query. The main
motivation behind this change is the simplify deparsing of
subqueries.

* Enable top level subquery join queries

This work enables
- Top level subquery joins
- Joins between subqueries and relations
- Joins involving more than 2 range table entries

A new regression test file is added to reflect enabled test cases

* Add top level union support

This commit adds support for UNION/UNION ALL subqueries that are
in the following form:

     .... (Q1 UNION Q2 UNION ...) as union_query ....

In other words, Citus supports allow top level
unions being wrapped into aggregations queries
and/or simple projection queries that only selects
some fields from the lower level queries.

* Disallow subqueries without a relation in the range table list for subquery pushdown

This commit disallows subqueries without relation in the range table
list. This commit is only applied for subquery pushdown. In other words,
we do not add this limitation for single table re-partition subqueries.

The reasoning behind this limitation is that if we allow pushing down
such queries, the result would include (shardCount * expectedResults)
where in a non distributed world the result would be (expectedResult)
only.

* Disallow subqueries without a relation in the range table list for INSERT .. SELECT

This commit disallows subqueries without relation in the range table
list. This commit is only applied for INSERT.. SELECT queries.

The reasoning behind this limitation is that if we allow pushing down
such queries, the result would include (shardCount * expectedResults)
where in a non distributed world the result would be (expectedResult)
only.

* Change behaviour of subquery pushdown flag (#1315)

This commit changes the behaviour of the citus.subquery_pushdown flag.
Before this commit, the flag is used to enable subquery pushdown logic. But,
with this commit, that behaviour is enabled by default. In other words, the
flag is now useless. We prefer to keep the flag since we don't want to break
the backward compatibility. Also, we may consider using that flag for other
purposes in the next commits.

* Require subquery_pushdown when limit is used in subquery

Using limit in subqueries may cause returning incorrect
results. Therefore we allow limits in subqueries only
if user explicitly set subquery_pushdown flag.

* Evaluate expressions on the LIMIT clause (#1333)

Subquery pushdown uses orignal query, the LIMIT and OFFSET clauses
are not evaluated. However, logical optimizer expects these expressions
are already evaluated by the standard planner. This commit manually
evaluates the functions on the logical planner for subquery pushdown.

* Better format subquery regression tests (#1340)

* Style fix for subquery pushdown regression tests

With this commit we intented a more consistent style for the
regression tests we've added in the
  - multi_subquery_union.sql
  - multi_subquery_complex_queries.sql
  - multi_subquery_behavioral_analytics.sql

* Enable the tests that are temporarily commented

This commit enables some of the regression tests that were commented
out until all the development is done.

* Fix merge conflicts (#1347)

 - Update regression tests to meet the changes in the regression
   test output.
 - Replace Ifs with Asserts given that the check is already done
 - Update shard pruning outputs

* Add view regression tests for increased subquery coverage (#1348)

- joins between views and tables
- joins between views
- union/union all queries involving views
- views with limit
- explain queries with view

* Improve btree operators for the subquery tests

This commit adds the missing comprasion for subquery composite key
btree comparator.
2017-04-29 04:09:48 +03:00
Andres Freund 0cc9171984 Merge pull request #1369 from citusdata/featurefix/better-range-pruning
Improve / Fix range pruning
2017-04-28 17:45:58 -07:00
Andres Freund 90b211267d Perform range based pruning if equality pruning has survivor.
We previously dismissed this as unimportant, but it turns out to be
very useful for the upcoming subquery pushdown, where a user might
specify an equality constraint in a subquery, and the subquery
pushdown machinery adds >= and <= restrictions on the shard boundary.
Previously the latter restriction was ignored.
2017-04-28 17:35:18 -07:00
Andres Freund 6c08fe72f9 Use stricter qual for pruning if both >/< and >=/<= are present.
Previously, if both =< and < (>= and < respectively) were specified,
we always used the latter restriction.  Instead use the stricter one.
2017-04-28 17:35:18 -07:00
Marco Slot e029724227 Merge pull request #1368 from citusdata/fix_get_live_node_count
Fix list length lookup in WorkerGetLiveNodeCount
2017-04-28 17:26:25 -07:00
Marco Slot 6e58067962 Fix list length lookup in WorkerGetLiveNodeCount 2017-04-29 02:13:20 +02:00
Marco Slot 022fc7bbcb Merge pull request #1349 from citusdata/fix_check_vanilla
Fix check-vanilla tests
2017-04-28 17:10:48 -07:00