Commit Graph

3291 Commits (2abbc8fa32f18668eb0b8097988231a84f590c8e)

Author SHA1 Message Date
Jelte Fennema 2abbc8fa32 Fix compilation issues with safestringlib
Based on 92d7a40d1d

(cherry picked from commit dc2a371d9f)
2020-03-25 09:22:46 +01:00
Jelte Fennema d86e4d2587 Update safestringlib
(cherry picked from commit 9a79935f1f)
2020-03-25 09:22:41 +01:00
Jelte Fennema 909711548b Compile safestringlib using regular configure
This is needed to automatically generate .bc (bitcode) files when
postgres is compiled with llvmjit support.

It also has the advantage that cmake is not required for the build
anymore.

(cherry picked from commit 6db7d87618)
2020-03-25 09:22:33 +01:00
Jelte Fennema 0103fed310 Make building safestringlib on some distros easier (#3616)
On some distros (e.g. Redhat 7) there is cmake version 2 and cmake version 3,
safestringlib requires cmake version 3. On those distros the binary is called
cmake3, so try to use that one before falling back to regular cmake binary.

(cherry picked from commit 99c5b0add7)
2020-03-25 09:22:26 +01:00
Jelte Fennema 9e5c84514a Semmle: Protect against theoretical race in recursive directory… (#3559)
In between stat at the start of the loop and unlink/rmdir at the end the
item that the filename references might have changed. In some cases this
can be a security bug, but since we only delete the file/directory it
should not be for us as far as I can tell. It could in theory still
cause errors though if the a file is changed into a directory by some
other process. This commit makes the code robust against that, by not
using stat and only rely on error codes and retries.

(cherry picked from commit ca8f7119fe)
2020-03-25 09:22:07 +01:00
Jelte Fennema 2eea8cb741 Fix some bugs in string to int functions (#3602)
This fixes 3 bugs:
1. `strtoul` never underflows, so that branch was useless
2. `strtoul` has ULONG_MAX instead of LONG_MAX when it overflows
3. `long` and `unsigned long` are not necessarily 64bit, they can be
    either more or less. So now `strtoll` and `strtoull` are used 
    and 64 bit bounds are checked.

(cherry picked from commit c7aa6eddf3)
2020-03-25 09:20:34 +01:00
Philip Dubé c45589bbcd Add runtime type checking to AGGREGATE_CUSTOM_COMBINE helper functions
(cherry picked from commit 11b968bc30)
2020-03-25 09:20:29 +01:00
Jelte Fennema bab0f268d3 Semmle: Ensure stack memory is not leaked through uninitialized… (#3561)
New stack memory can contain anything including passwords/private keys.
In these functions we return structs that can have their padding
bytes uninitialized. By first zeroing out the struct fully, we try to
ensure that any data that is in these padding bytes is at least
overwritten once. It might not be zero anymore after setting the fields,
but at least it shouldn't be private data anymore.

(cherry picked from commit c4cc26ed37)
2020-03-25 09:20:22 +01:00
Jelte Fennema 20782c5ff5 Semmle: Actively check one possible NULL deref case (#3560)
Calling ErrorIfUnsupportedConstraint was still giving errors on Semmle. This
makes sure that we check for NULL at runtime. This way we can safely ignore all
errors created by this function.

(cherry picked from commit e0bbe1ca38)
2020-03-25 09:20:15 +01:00
Jelte Fennema e4e0c65203 Semmle: Check for NULL in some places where it might occur (#3509)
Semmle reported quite some places where we use a value that could be NULL. Most of these are not actually a real issue, but better to be on the safe side with these things and make the static analysis happy.

(cherry picked from commit 685b54b3de)
2020-03-25 09:19:15 +01:00
Jelte Fennema 0a1845a05c Add new vendor README update instructions
(cherry picked from commit 0cad263c82)
2020-03-25 09:17:27 +01:00
Jelte Fennema 5dd61c8319 Fix Makefile so that it builds safestringlib correctly on OSX
(cherry picked from commit eb8e099f09)
2020-03-25 09:17:22 +01:00
Jelte Fennema 2ad9ca6726 Add clean-full to also clean full builds of vendored libraries
(cherry picked from commit 8e7eaaf949)
2020-03-25 09:17:16 +01:00
Jelte Fennema 7969849598 Fix safestringlib build on OSX
(cherry picked from commit 92d7a40d1d)
2020-03-25 09:17:10 +01:00
Jelte Fennema 1d0c3f36fc Make SafeSnprintf work on PG11
(cherry picked from commit 62bf571ced)
2020-03-25 09:16:51 +01:00
Jelte Fennema d0e4bc5d22 Add pg11 snprintf file to repo for use in pg11 when it's not compiled
(cherry picked from commit 7d24cebc80)
2020-03-25 09:16:43 +01:00
Jelte Fennema 2f063d0316 Convert unsafe APIs to safe ones
(cherry picked from commit 8de8b62669)
2020-03-25 09:16:31 +01:00
Jelte Fennema 1216e079fa vendor github.com/intel/safestringlib
(cherry picked from commit b7841267dc)
2020-03-25 09:12:41 +01:00
Jelte Fennema e0736d3da7 Remove READFUNCs (#3536)
We don't actually use these functions anymore since merging #1477.

Advantages of removing:
1. They add work whenever we add a new node.
2. They contain some usage of stdlib APIs that are banned by Microsoft.
   Removing it means we don't have to replace those with safe ones.

(cherry picked from commit 2a9fccc7a0)
2020-03-25 09:12:26 +01:00
Jelte Fennema b451c31c4c Semmle: Fix obvious issues (#3502)
Fixes some obvious issues found by the Semmle static analysis tool.

(cherry picked from commit 00d667c41d)
2020-03-25 09:11:27 +01:00
Jelte Fennema e2d49c6122 Semmle: Fix possible infite loops caused by overflow (#3503)
Comparison between differently sized integers in loop conditions can cause
infinite loops. This can happen when doing something like this:

```c
int64 very_big = MAX_INT32 + 1;
for (int32 i = 0; i < very_big; i++) {
    // do something
}
// never reached because i overflows before it can reach the value of very_big
```

(cherry picked from commit 3f7c5a5cf6)
2020-03-25 09:11:21 +01:00
Jelte Fennema 568f057ba0 Semmle: Ensure permissions of private keys are 0600 (#3506)
When using --allow-group-access option from initdb our keys and
certificates would be created with 0640 permissions. Which is a pretty
serious security issue: This changes that. This would not be exploitable
though, since postgres would not actually enable SSL and would output
the following message in the logs:

```
DETAIL:  File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root.
```

Since citus still expected the cluster to have SSL enabled handshakes
between workers and coordinator would fail. So instead of a security
issue the cluster would simply be unusable.

(cherry picked from commit 15f1173b1d)
2020-03-25 09:11:13 +01:00
Onder Kalaci db1a0835f3 Improve definition of RelationInfoContainsOnlyRecurringTuples
Before this commit, we considered !ContainsRecurringRTE() enough
for NotContainsOnlyRecurringTuples. However, instead, we can check
for existince of any distributed table.

DESCRIPTION: Fixes a bug that causes wrong results with complex outer joins
2020-03-09 17:29:13 +01:00
Hanefi Onaldi f2035b9f33 Bump version to 9.2.2 2020-03-05 18:36:28 +03:00
Hanefi Onaldi 00e0148a9c Update CHANGELOG for 9.2.2 2020-03-05 18:36:28 +03:00
Hanefi Onaldi 8d979b4752
Fix early exit bug on intermediate result pruning
There are 2 problems with our early exit strategy that this commit fixes:

1- When we decide that a subplan results are sent to all worker nodes,
we used to skip traversing the whole distributed plan, instead of
skipping only the subplan.

2- We used to consider all available nodes in the cluster (secondaries
and inactive nodes as well as active primaries) when deciding on early
exit strategy. This resulted in failures to early exit when there are
secondaries or inactive nodes.

(cherry picked from commit c0ad44f975)
2020-03-05 16:47:58 +03:00
Onder Kalaci 1bba516b56 Expand test coverage for combinations of master evalution, deferred pruning, parameters, local execution
- Router           & Remote & Requires Master Evaluation & With Param & Without Param
- Fast Path Router & Remote & Requires Master Evaluation & With Param & Without Param
2020-03-05 13:04:39 +01:00
Marco Slot ca44697723 Refactor CitusBeginScan into separate DML / SELECT paths 2020-03-05 13:04:39 +01:00
Marco Slot 975c0a8405 Add some distribution column = composite type prepared statement tests 2020-03-05 13:04:39 +01:00
Onder Kalaci fd89760a29 For composite types, add cast to the parameter to ease remote node detect
the type.
2020-03-05 13:04:39 +01:00
SaitTalhaNisanci a96ff3cd6c create temp schemas in parallel (#3540)
(cherry picked from commit 82d22b34fe)
2020-03-03 17:13:09 +03:00
SaitTalhaNisanci 741ca1d33e send repartition cleanup jobs in parallel to all workers (#3485)
* send repartition cleanup jobs in parallel to all workers

* add review items

(cherry picked from commit d94c3fd43d)
2020-03-03 17:13:02 +03:00
Marco Slot 946b7a1a49 Make merge tables during re-partitioning unlogged
(cherry picked from commit c7f123947e)
2020-03-03 17:12:54 +03:00
Onur Tirtir 7188574c62 Update CHANGELOG for 9.2.1 (#3501)
(cherry picked from commit e4dd5ac2ad)
2020-02-14 13:50:54 +03:00
Onur Tirtir d4004a495c Bump version to 9.2.1 2020-02-14 13:08:29 +03:00
Onder Kalaci bcc675cf84 Do not prune shards if the distribution key is NULL
The root of the problem is that, standard_planner() converts the following qual

```
   {OPEXPR
   :opno 98
   :opfuncid 67
   :opresulttype 16
   :opretset false
   :opcollid 0
   :inputcollid 100
   :args (
      {VAR
      :varno 1
      :varattno 1
      :vartype 25
      :vartypmod -1
      :varcollid 100
      :varlevelsup 0
      :varnoold 1
      :varoattno 1
      :location 45
      }
      {CONST
      :consttype 25
      :consttypmod -1
      :constcollid 100
      :constlen -1
      :constbyval false
      :constisnull true
      :location 51
      :constvalue <>
      }
   )
   :location 49
   }
```

To

```
(
   {CONST
   :consttype 16
   :consttypmod -1
   :constcollid 0
   :constlen 1
   :constbyval true
   :constisnull true
   :location -1
   :constvalue <>
   }
)
```

So, Citus doesn't deal with NULL values in real-time or non-fast path router queries.

And, in the FastPathRouter planner, we check constisnull in DistKeyInSimpleOpExpression().
However, in deferred pruning case, we do not check for isnull for const.

Thus, the fix consists of two parts:
- Let PruneShards() not crash when NULL parameter is passed
- For deferred shard pruning in fast-path queries, explicitly check that we have CONST which is not NULL
2020-02-13 17:22:49 +01:00
Onur Tirtir 6522965963 Bump Citus version to 9.2.0 2020-02-10 11:26:21 +03:00
Onur Tirtir e660f4f854 Add changelog entry for 9.2.0 (#3463) 2020-02-10 11:03:39 +03:00
Onur Tirtir 39df51e903
Introduce objects to dist. infrastructure when updating Citus (#3477)
Mark existing objects that are not included in distributed object infrastructure
in older versions of Citus (but now should be) as distributed, after updating
Citus successfully.
2020-02-07 18:07:59 +03:00
Nils Dijk d5433400f9
Fix: Unnecessary repartition on joins with more than 4 tables (#3473)
DESCRIPTION: Fix unnecessary repartition on joins with more than 4 tables

In 9.1 we have introduced support for all CH-benCHmark queries by widening our definitions of joins to include joins with expressions in them. This had the undesired side effect of Q5 regressing on its plan by implementing a repartition join.

It turned out this regression was not directly related to widening of the join clause, nor the schema employed by CH-benCHmark. Instead it had to do with 4 or more tables being joined in a chain. A chain meaning:

```sql
SELECT * FROM a,b,c,d WHERE a.part = b.part AND b.part = c.part AND ....
```

Due to how our join order planner was implemented it would only keep track of 1 of the partition columns when comparing if the join could be executed locally. This manifested in a join chain of 4 tables to _always_ be executed as a repartition join. 3 tables joined in a chain would have the middle table shared by the two outer tables causing the local join possibility to be found.

With this patch we keep a  unique list (or set) of all partition columns participating in the join. When a candidate table is checked for a possibility to execute a local join it will check if there is any partition column in that set that matches an equality join clause on the partition column of the candidate table.

By taking into account all partition columns in the left relation it will now find the local join path on >= 4 tables joined in a chain. 

fixes: #3276
2020-02-06 15:07:07 +01:00
Philip Dubé 345455d765
Merge pull request #3461 from citusdata/fix-adaptive-repartition-join-leak
Fix adaptive repartition join leak
2020-02-05 17:43:23 +00:00
Philip Dubé ecad4aa5e6 Fill in jobIdList field of DistributedExecution
Pass down jobIdList from ExecuteTasksInDependencyOrder

Also clean up comment for ExecuteTaskListOutsideTransaction
2020-02-05 17:32:22 +00:00
Philip Dubé c252811884 dont: don't, wont: won't, acylic: acyclic 2020-02-05 17:32:22 +00:00
Halil Ozan Akgül fff3866844
Merge pull request #3472 from citusdata/grant_on_public_schema
Fixes the bug of grants on public schema propagation
2020-02-05 18:40:45 +03:00
Halil Ozan Akgul 8ce4f20061 Fixes the bug of grants on public schema propagation 2020-02-05 18:05:58 +03:00
SaitTalhaNisanci 89dc7d5e41
remove outdated information in citus upgrade readme (#3471) 2020-02-05 13:31:02 +03:00
Marco Slot 8c972dc614
Merge pull request #3470 from citusdata/insert_select_issue
Rename discarded target list items in repartitioned INSERT/SELECT
2020-02-05 11:21:05 +01:00
Marco Slot 64ca5c9acb Add additional INSERT..SELECT repartition tests 2020-02-05 11:06:44 +01:00
Hadi Moshayedi 9dd14fa90d Rename discarded target list items in repartitioned INSERT/SELECT 2020-02-05 11:06:44 +01:00
Önder Kalacı 1aa89d3242
Merge pull request #3467 from citusdata/fix_crash_numeric
Improve single hash-repartitioning with numeric (or non-int) types
2020-02-05 09:12:41 +01:00