4099 Commits

Author SHA1 Message Date
Alexander Kuzmenkov
d088b3a5d9 Do not add broken compressed join clauses
We used to add join clauses that referenced a compressed column at the
level of the compressed scan, and later remove them. This is wrong and
useless, just don't add them.
2023-08-16 11:58:11 +02:00
Alexander Kuzmenkov
22a2f49a2f Fix filtering of the redundant decompress chunk clauses
We just had a bad cast inside is_redundant_derived_clause before,
because it doesn't work with IndexClauses. Filtering didn't work as a
result.
2023-08-16 11:58:11 +02:00
Alexander Kuzmenkov
3a27669c84 Simplify compressed pathkey lookup
When looking up a pathkey for compressed scan, we used to do a lot of
work, including a quadratic lookup through all the equivalence members,
to always arrive at the same canonical pathkey we started from. Just
remove this useless code for a significant planning speedup.

This uncovers two bugs in parameterization of decompressed paths and
generation of equivalence members for segmentby columns, fix them as
well.
2023-08-15 14:54:36 +02:00
Alexander Kuzmenkov
04ce1bc498 Use cached Chunk struct when considering compressed paths
Full catalog lookups for a Chunk are expensive, avoiding them speeds up
the planning.
2023-08-15 14:11:43 +02:00
Sven Klemm
fb617e4150 Bump Postgres versions used in CI
Bump postgres version used to 13.12, 14.9 and 15.4
2023-08-15 12:00:43 +02:00
Jan Nidzwetzki
154bbbb01a Perform startup chunk exclusion in parallel leader
The parallel version of the ChunkAppend node uses shared memory to
coordinate the plan selection for the parallel workers. If the workers
perform the startup exclusion individually, it may choose different
subplans for each worker (e.g., due to a "constant" function that claims
to be constant but returns different results). In that case, we have a
disagreement about the plans between the workers.  This would lead to
hard-to-debug problems and out-of-bounds reads when pstate->next_plan is
used for subplan selection.

With this patch, startup exclusion is only performed in the parallel
leader. The leader stores this information in shared memory. The
parallel workers read the information from shared memory and don't
perform startup exclusion.
2023-08-15 10:25:46 +02:00
Mats Kindahl
1102d34f42 Remove telemetry isolation test
The telemetry isolation test `telemetry_iso` does not test anything and
does not seem to work, so it is removed. The debug waitpoint was taken
in the same session, so the waitpoint was not waited on.
2023-08-14 14:42:47 +02:00
Mats Kindahl
71b0168ab7 Add debug utilities to debug builds
This will move the definitions of `debug_waitpoint_enable`,
`debug_waitpoint_disable`, and `debug_waitpoint_id` to always be
defined for debug builds and modify existing tests accordingly.

This means that it is no longer necessary to generate isolation test
files from templates (in most cases), and it will be straightforward to
use these functions in debug builds.

The debug utilities can be disabled by setting the option
`ENABLE_DEBUG_UTILS` to `OFF`.
2023-08-14 14:42:47 +02:00
Lakshmi Narayanan Sreethar
4bd704f3fc Further code cleanup after PG12 removal
Removed PG12 specific code guarded by the PG13_LT and PG13_GE macros.
2023-08-11 00:31:48 +05:30
Konstantina Skovola
2cb42a62f9 Remove test_status calls from telemetry test
Due to the postman-echo endpoint redirecting http requests to https, we
get an unexpected 301 response in the tests, leading to repeated test
failures. This commit removes these function calls.
2023-08-10 18:04:01 +03:00
Jan Nidzwetzki
9a2dfbfb83 Improved parallel DecompressChunk worker selection
This PR improves the way the number of parallel workers for the
DecompressChunk node are calculated. Since
1a93c2d482b50a43c105427ad99e6ecb58fcac7f, no partial paths for small
relations are generated, which could cause a fallback to a sequential
plan and a performance regression. This patch ensures that for all
relations, a partial path is created again.
2023-08-10 12:38:14 +02:00
Konstantina Skovola
44eab9cf9b Release 2.11.2
This release contains bug fixes since the 2.11.1 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #5923 Feature flags for TimescaleDB features

**Bugfixes**
* #5680 Fix DISTINCT query with JOIN on multiple segmentby columns
* #5774 Fixed two bugs in decompression sorted merge code
* #5786 Ensure pg_config --cppflags are passed
* #5906 Fix quoting owners in sql scripts.
* #5912 Fix crash in 1-step integer policy creation

**Thanks**
* @mrksngl for submitting a PR to fix extension upgrade scripts
* @ericdevries for reporting an issue with DISTINCT queries using
segmentby columns of compressed hypertable
2023-08-09 19:24:21 +03:00
Lakshmi Narayanan Sreethar
b96d170921 Revert "PG16: Use new function to check vacuum permission"
This reverts commit 8b0ab4164 as the commit that introduced the new
function has been reverted upstream.

postgres/postgres@95744599
2023-08-09 20:24:19 +05:30
noctarius aka Christoph Engelbert
b5b46a3e58
Make logrepl markers for (partial) decompressions (#5805)
Added logical replication messages (PG14+) as markers for (partial)
decompression events (mutual compression), which makes it possible to
differentiate inserts happening as part of the decompression vs actual
inserts by the user, and filter the former out of the event stream.
While some tools may be interested in all events, synching the pure
"state" (without internal behavior) is required for others.

As of now this PR is missing tests. I wonder if anyone has a good idea
how to create an automatic test for it.
2023-08-09 13:28:54 +02:00
Lakshmi Narayanan Sreethar
a9505b4095 PG16: Replace pg_class_ownercheck() with object_ownercheck
PG16 replaces pg_foo_ownercheck() functions with a common
object_ownercheck() function. Added a new compat function for
pg_class_ownercheck() function affected by this change and replaced all
its callers.

postgres/postgres@afbfc029
2023-08-09 15:21:23 +05:30
Lakshmi Narayanan Sreethar
22ea5771ad PG16: Make aclcheck function calls compatible with PG16
PG16 replaced most of the aclcheck functions with a common object_aclcheck
function. Updated the various aclcheck calls in the code to use the new
function when compiled with PG16.

postgres/postgres@c727f511
2023-08-09 15:21:23 +05:30
Lakshmi Narayanan Sreethar
b2b3acf6ac PG16: No need to pass create_new_ph flag to find_placeholder_info
PG16 also optimized the PlaceFolderInfo lookups to perform in constant
time, so there is no need to do an additional cheap/quick test using
bms_overlap to see if the PHV might be evaluated in the outer rels.

postgres/postgres@6569ca439
postgres/postgres@b3ff6c742
2023-08-09 14:15:26 +05:30
Lakshmi Narayanan Sreethar
8abe148072 PG16: stringToQualifiedNameList requires escontext parameter
postgres/postgres@858e776c84
2023-08-09 14:15:26 +05:30
Nikhil Sontakke
592da23633 Fix assert in debug wait points
Need to ensure that we should try to take a lock only if a valid
transaction is around. Otherwise assert is hit due to an error within
an error.

Fixes #5917
2023-08-09 13:02:13 +05:30
Lakshmi Narayanan Sreethar
2eb0a3883b PG16: Handle DefineIndex's new parameter
PG16 adds a new parameter to DefineIndex, total_parts, that takes in the
total number of direct and indirect partitions of the relation. Updated
all the callers to pass either the actual number if it is known or -1 if
it is unknown at that point.

postgres/postgres@27f5c712
2023-08-09 04:05:57 +05:30
Lakshmi Narayanan Sreethar
3af0d282ea PG16: ExecInsertIndexTuples requires additional parameter
PG16 adds a new boolean parameter to the ExecInsertIndexTuples function
to denote if the index is a BRIN index, which is then used to determine
if the index update can be skipped. The fix also removes the
INDEX_ATTR_BITMAP_ALL enum value.

Adapt these changes by updating the compat function to accomodate the
new parameter added to the ExecInsertIndexTuples function and using an
alternative for the removed INDEX_ATTR_BITMAP_ALL enum value.

postgres/postgres@19d8e23
2023-08-09 03:04:12 +05:30
Mats Kindahl
8a2b6a03e0 Add weird user names to update test
Since we want to be able to handle update of weird user names we add
some to the update tests and create policies on them. This will create
jobs with the strange name as owner.
2023-08-08 16:22:01 +02:00
Sven Klemm
07762ea4ce Test timescaledb debian 12 packages in CI 2023-08-08 08:51:09 +02:00
Dmitry Simonenko
7aeed663b9 Feature flags for TimescaleDB features
This PR adds several GUCs which allow to enable/disable major
timescaledb features:

- enable_hypertable_create
- enable_hypertable_compression
- enable_cagg_create
- enable_policy_create
2023-08-07 10:11:01 +03:00
Markus Engel
5cf354e246 Fix quoting owners in sql scripts.
When referring to a role from a string type, it must be properly quoted
using pg_catalog.quote_ident before it can be casted to regrole.
Fixed this, especially in update scripts.
2023-08-04 16:24:32 +05:30
Dmitry Simonenko
2863daf3df Support CREATE INDEX ONLY ON main table
This PR adds support for CREATE INDEX ONLY ON clause which allows to
create index only on the main table excluding chunks.

Fix #5908
2023-08-03 15:51:57 +03:00
Lakshmi Narayanan Sreethar
52ed394d4d PG16: Remove recursion-marker values in enum AlterTableType
PG16 removed the recursion-marker values used to handle certain
subcommands during an ALTER TABLE execution and provides an alternative
flag. Removed the references to the recursion-marker values from
timescaledb code.

postgres/postgres@840ff5f4
2023-08-03 00:46:53 +05:30
Konstantina Skovola
28612ebc3c Fix crash in 1-step integer policy creation
Previously when a retention policy existed on the underlying hypertable,
we would get a segmentation fault when trying to add a Cagg refresh
policy, due to passing a bool instead of pointer to bool argument to
function `ts_jsonb_get_int64_field` in a particular code path.
Fixed by passing the expected pointer type.

Fixes #5907
2023-08-02 17:17:52 +03:00
Nikhil Sontakke
b2773aa344 Fix crash in COPY from program returning error
Reset the errcallback appropriately so that the ereport in case
of a PROGRAM returning error can work correctly.
2023-08-02 12:41:19 +05:30
Alexander Kuzmenkov
0d127f6dcc Clean up compressed batch handling in DecompressChunk node
* Remove unneeded data from batch states to use less memory
     * keep only the compressed column data because only for them we
       have to do something per row, other columns don't change
* Adjust batch memory context size so that the bulk decompression
  results fit into it.
* Determine whether we're going to use bulk decompression for each
  column at planning time, not at execution time.
* Introduce "batch queue" to unify control flow for normal and batch
  sorted merge decompression
* In batch sorted merge, compare batches on scan slot, not on projected
  slot. This avoids keeping the second slot in batches, and projection
can be performed after we find the top batch.
    * this requires some custom code to build sort infos relative to
      scan tuple, not to targetlist.
* Return a reference for the current top batch scan tuple as a result of
  DecompressChunk exec, don't copy it out. It is guaranteed to live
until the next exec, which is the usual lifetime guarantee.

This is needed to prepare for vectorized filters.
2023-08-01 10:28:19 +02:00
Alexander Kuzmenkov
d5268c36fb Fix SQLSmith workflow
The build was failing because it was picking up the wrong version of
Postgres. Remove it.
2023-07-31 14:08:18 +02:00
Mats Kindahl
ee2ddf889e Check unique indexes when enabling compression
When enabling compression on a table, there is a check of unique
and primary key *constraints*, but no check if there is just a unique
index. This means that it is possible to create a compressed table
without getting a warning that you should include the columns in the
index into the segmentby field, which can lead to suboptimal query
times.

This commit adds a check for the unique index as well and ensure that a
similar warning is printed as for a unique constraint.

Fixes #5892
2023-07-27 09:08:05 +02:00
Lakshmi Narayanan Sreethar
61c288ec5e Fix broken CI after PG12 removal
The commit cdea343cc updated the gh_matrix_builder.py script but failed
to import PG_LATEST variable into the script thus breaking the CI.
Import that variable to fix the CI tests.
2023-07-25 18:31:28 +05:30
Lakshmi Narayanan Sreethar
e5691bee11 Cleanup PG12 specific code from source and test files
Removed the PG12 specific macros and all the now, dead code. Also updated
the testcases which had workarounds in place to make them compatible
with PG12.
2023-07-25 16:00:18 +05:30
Lakshmi Narayanan Sreethar
ac33d04aa8 Remove update files for PG12
Removed the update files that were used only for PG12.
2023-07-25 16:00:18 +05:30
Lakshmi Narayanan Sreethar
c3a9f90fdd Merge PG12 specific testfiles
Merged testfiles that were split out due to their output differing only
in PG12.
2023-07-25 16:00:18 +05:30
Lakshmi Narayanan Sreethar
7936e8015b Remove PG12 specific test output files 2023-07-25 16:00:18 +05:30
Lakshmi Narayanan Sreethar
81b520d3b5 Remove support for PG12
Remove support for compiling TimescaleDB code against PG12. PG12
specific macros and testfiles will be removed in a followup patch.
2023-07-25 16:00:18 +05:30
Lakshmi Narayanan Sreethar
cdea343cc9 Remove PG12 support from github workflows 2023-07-25 16:00:18 +05:30
Mats Kindahl
906bd38573 Add job exit status and runtime to log
When a job finishes execution, either because of an error or a success,
this commit will print out the execution time of the job in the log
together with a message about what job that finished.

For continuous aggregate refreshes, the number of rows deleted from and
inserted into the materialization table will be printed.
2023-07-14 12:47:14 +02:00
Jan Nidzwetzki
36e7100013 Fix duplicates on partially compressed chunk reads
When the uncompressed part of a partially compressed chunk is read by a
non-partial path and the compressed part by a partial path, the append
node on top could process the uncompressed part multiple times because
the path was declared as a partial path and the append node assumed it
could be executed in all workers in parallel without producing
duplicates.

This PR fixes the declaration of the path.
2023-07-13 08:57:53 +02:00
Rafia Sabih
1bd527375d Rectify interval calculation
For continuous aggregates with variable bucket size, the interval
was wrongly manipulated in the process. Now it is corrected by
creating a copy of interval structure for validation purposes
and keeping the original structure untouched.

Fixes #5734
2023-07-12 23:56:04 +02:00
noctarius aka Christoph Engelbert
4c3d64aa98
Support CAGG names in chunk_detailed_size (#5839)
This patch adds support to pass continuous aggregate names to
`chunk_detailed_size` to align it to the behavior of other functions
such as `show_chunks`, `drop_chunks`, `hypertable_size`.
2023-07-12 20:22:14 +02:00
noctarius aka Christoph Engelbert
963d4eefbf
Make set_chunk_time_interval CAGGs aware (#5852)
This patch adds support to pass continuous aggregate names to the
`set_chunk_time_interval` function to align it with functions, such as
`show_chunks`, `drop_chunks`, and others.

It reuses the previously existing function to find a hypertable or
resolve a continuous aggregate to its underlying hypertable found in
chunk.c. It, however, moves the function to hypertable.c and exports it
from here. There is some discussion if this functionality should stay in
chunk.c, though, it feels wrong in that file now that it is exported.
2023-07-12 20:21:27 +02:00
noctarius aka Christoph Engelbert
88aaf23ae3
Allow Replica Identity (Alter Table) on CAGGs (#5868)
This commit is a follow up of #5515, which added support for ALTER TABLE
... REPLICA IDENTITY (FULL | INDEX) on hypertables.

This commit allows the execution against materialized hypertables to
enable update / delete operations on continuous aggregates when logical
replication in enabled for them.
2023-07-12 14:53:40 +02:00
Alexander Kuzmenkov
eaa1206b7f Improvements for bulk decompression
* Restore default batch context size to fix a performance regression on
  sorted batch merge plans.
* Support reverse direction.
* Improve gorilla decompression by computing prefix sums of tag bitmaps
  during decompression.
2023-07-06 19:52:20 +02:00
Alexander Kuzmenkov
7657efe019 Cache the libfuzzer corpus between CI runs
This might help us find something interesting. Also add deltadelta/int8
fuzzing and make other minor improvements.
2023-07-06 17:57:04 +02:00
Jan Nidzwetzki
490bc916af Warn if result of ts_set_flags_32 is not used
The ts_set_flags_32 function takes a bitmap and flags and returns an
updated bitmap. However, if the returned value is not used, the function
call has no effect. An unused result may indicate the improper use of this
function.

This patch adds the qualifier pg_nodiscard to the function which
triggers a warning if the returned value is not used.
2023-07-05 09:25:15 +02:00
Konstantina Skovola
06d20b1829 Enable altering job schedule type through alter_job
In #4664 we introduced fixed schedules for jobs. This was done by
introducing additional parameters fixed_schedule, initial_start and
timezone for our add_job and add_policy APIs.
These fields were not updatable by alter_job so it was not
possible to switch from one type of schedule to another without dropping
and recreating existing jobs and policies.
This patch adds the missing parameters to alter_job to enable switching
from one type of schedule to another.

Fixes #5681
2023-07-03 15:42:54 +03:00
Jan Nidzwetzki
b9a58dd5c4 Exclude workflow changes from being backported
The backport script for the PRs does not have the permission to backport
PRs which include workflow changes. So, these PRs are excluded from
being automatically backported.

Failed CI run:

https://github.com/timescale/timescaledb/actions/runs/5387338161/
   jobs/9780701395

> refusing to allow a GitHub App to create or update workflow
> `.github/workflows/xxx.yaml` without `workflows` permission)
2023-07-03 12:57:12 +02:00