3676 Commits

Author SHA1 Message Date
Alexander Kuzmenkov
1b65297ff7 Fix memory leak with INSERT into compressed hypertable
We used to allocate some temporary data in the ExecutorContext.
2022-11-16 13:58:52 +04:00
Alexander Kuzmenkov
7e4ebd131f Escape the quotes in gdb command 2022-11-15 21:49:39 +04:00
Alexander Kuzmenkov
676d1fb1f1 Fix const null clauses in runtime chunk exclusion
The code we inherited from postgres expects that if we have a const null
or false clause, it's going to be the single one, but that's not true
for runtime chunk exclusion because we don't try to fold such
restrictinfos after evaluating the mutable functions. Fix it to also
work for multiple restrictinfos.
2022-11-15 21:49:39 +04:00
Mats Kindahl
f3a3da7804 Take advisory lock for job tuple
Job ids are locked using an advisory lock rather than a row lock on the
jobs table, but this lock is not taken in the job API functions
(`alter_job`, `delete_job`, etc.), which appears to cause a race
condition resulting in addition of multiple rows with the same job id.

This commit adds an advisory `RowExclusiveLock` on the job id while
altering it to match the advisory locks taken while performing other
modifications.

Closes #4863
2022-11-15 17:58:49 +01:00
Ante Kresic
51e5f31918 Update compress chunk interval on compressed data
Compress chunk interval is set using an ALTER TABLE statement.
This change makes it so you can update the compress chunk interval
while keeping the rest of the compression settings intact.
Updating it will only affect chunks that are compressed and rolled
up after the change.
2022-11-15 15:31:16 +01:00
Sven Klemm
8b6eb9024f Check for interrupts in gapfill main loop
Add CHECK_FOR_INTERRUPTS() macro to gapfill main loop.
2022-11-15 15:02:46 +01:00
Sven Klemm
87756bcff9 Bump postgres versions used in CI
Use PG 12.13, 13.9 and 14.6 in our CI
2022-11-15 13:48:10 +01:00
Sven Klemm
2f237e6e57 Add Enterprise Linux 9 packages to RPM package test 2022-11-15 12:13:55 +01:00
Lakshmi Narayanan Sreethar
33531212b2 Disable dist_move_chunk test in PG15
The dist_move_chunk causes the CI to hang when compiled and run with
PG15 as explained in #4972.

Also fixed schema permission issues in data_node and dist_param tests.
2022-11-15 14:10:45 +05:30
Bharathy
8afdddc2da Deprecate continuous aggregates with old format
This patch will report a warning when upgrading to new timescaledb extension,
if their exists any caggs with partial aggregates only on release builds.
Also restrict users from creating cagss with old format on timescaledb with
PG15.
2022-11-15 08:38:03 +05:30
Mats Kindahl
b085833fda Print errors in release builds for jobs
Old assertions checking integrety of metadata for jobs will print error
message in release builds instead of continuing executing with bad
metadata.
2022-11-14 16:54:13 +01:00
Alexander Kuzmenkov
121631c70f Support parameterized data node scans in joins
This allows us to perform a nested loop join of a small outer local
table to an inner distributed hypertable, without downloading the
entire hypertable to the access node.
2022-11-14 18:57:15 +04:00
Alexander Kuzmenkov
9964ba8ba6 Remove accidental debug output
Was added in # 4890
2022-11-14 18:57:15 +04:00
Alexander Kuzmenkov
0d30155b26 Upload test results into a database
This will help us find the flaky tests or the rare failures.
2022-11-14 17:35:50 +04:00
Alexander Kuzmenkov
0360812e3c Simplify llvm configuration for linux/macos builds
Set it only in the matrixbuilder.
2022-11-14 17:35:50 +04:00
Alexander Kuzmenkov
feb09c54e9 Rebuild cached PG daily and on config changes
Otherwise it's easy to break these builds and not notice it until much
later.
2022-11-14 17:35:50 +04:00
Mats Kindahl
141e114ccb Fix race in bgw_db_scheduler_fixed
When deleting a job in the test, the job does not necessarily terminate
immediately, so wait for a log entries from the job before checking the
jobs table.

Fixed #4859
2022-11-14 13:23:23 +01:00
Markos Fountoulakis
e2b7c76c9c Disable MERGE when using hypertables
Fixes #4930

Co-authored-by: Lakshmi Narayanan Sreethar <lakshmi@timescale.com>
2022-11-14 13:57:17 +02:00
Fabrízio de Royes Mello
9e276c58ee Revert "Upload test results into the database"
This reverts commit 252cefb509153fadcb32741a27ec3fa977487049 because it
broke our CI globally.
2022-11-11 15:25:01 -03:00
Fabrízio de Royes Mello
6ae192631e Fix CAgg migration with timestamp without timezone
It was a leftover from the original implementation where we didn't add
tests for time dimension using `timestamp without timezone`.

Fixed it by dealing with this datatype and added regression tests.

Fixes #4956
2022-11-11 15:25:01 -03:00
Alexander Kuzmenkov
252cefb509 Upload test results into the database
This will help us find the flaky tests or the rare failures.
2022-11-11 20:02:29 +04:00
Erik Nordström
f13214891c Add function to alter data nodes
Add a new function, `alter_data_node()`, which can be used to change
the data node's configuration originally set up via `add_data_node()`
on the access node.

The new functions introduces a new option "available" that allows
configuring the availability of the data node. Setting
`available=>false` means that the node should no longer be used for
reads and writes. Only read "failover" is implemented as part of this
change, however.

To fail over reads, the alter data node function finds all the chunks
for which the unavailable data node is the "primary" query target and
"fails over" to a chunk replica on another data node instead. If some
chunks do not have a replica to fail over to, a warning will be
raised.

When a data node is available again, the function can be used to
switch back to using the data node for queries.

Closes #2104
2022-11-11 13:59:42 +01:00
Sven Klemm
fe6731cead Fix compress_segmentby in isolation tests
compress_segmentby should never be on a column with random() values
as that will result in very inefficient compression as the batches
will only have 1 tuple each.
2022-11-10 17:38:57 +01:00
Jan Nidzwetzki
4f9eef3211 Print correct variables in downgrade test script
The downgrade script has printed a message in which the same variable is
used for the upgrade and the downgrade version. This patch corrects the
output and uses the correct variables.
2022-11-10 15:31:20 +01:00
Alexander Kuzmenkov
6ad28248f3 Change the flaky check to use output files
This is simpler, accounts for both sql and isolation tests, changes in
included files, and versioned tests.
2022-11-10 13:46:20 +04:00
Sven Klemm
e4ba2bcf56 Remove debian 9 from packages tests.
Debian 9 is EOL since July 2022 so we won't build packages for it
anymore and can remove it from CI.
2022-11-09 17:10:05 +01:00
Mats Kindahl
1f80715308 Check for trailing whitespace
As a result of editing, trailing whitespace is often resulting and
since some editors automatically remove trailing whitespace this
creates diffs with more changed lines than necessary.

Add a check that files do not have trailing whitespace and fail if
there are.
2022-11-09 08:54:58 +01:00
Sven Klemm
9744b4f3bc Remove BitmapScan support in DecompressChunk
We don't want to support BitmapScans below DecompressChunk
as this adds additional complexity to support and there
is little benefit in doing so.
This fixes a bug that can happen when we have a parameterized
BitmapScan that is parameterized on a compressed column and
will lead to an execution failure with an error regarding
incorrect attribute types in the expression.
2022-11-08 23:29:29 +01:00
Fabrízio de Royes Mello
bfef3173bc Refactor CAgg migration code to use job API
The current implementation update the jobs table directly and to make it
consistent with other parts of the code we changed it to use the
`alter_job` API instead to enable and disable the jobs during the
migration. This refactoring is related to #4863.
2022-11-08 17:41:01 -03:00
Bharathy
2a64450651 Add new tests to gitignore list
Since new tests specific to PG15 were added, these tests which generated .sql files needs to be added to .gitnore
2022-11-07 22:14:39 +05:30
Bharathy
3a9688cc97 Extra Result node on top of CustomScan on PG15
On PG15 CustomScan by default is not projection capable, thus wraps this
node in Result node. THis change in PG15 causes tests result files which
have EXPLAIN output to fail. This patch fixes the plan outputs.

Fixes #4833
2022-11-07 21:20:08 +05:30
Mats Kindahl
b95576550c Add printout for multiple jobs with same job_id
We have a rare condition where a debug build asserts on more than one
job with the same job id. Since it is hard to create a reproduction,
this commit adds a printout for those conditions and print out all the
jobs with that job id in the postgres log.

Part of #4863
2022-11-07 14:17:38 +01:00
Sven Klemm
3059290bea Add new chunk state CHUNK_STATUS_COMPRESSED_PARTIAL
A chunk is in this state when it is compressed but also has
uncompressed data in the uncompressed chunk. Individual tuples
can only ever exist in either area. This is preparation patch
to add support for uncompressed staging area for DML operations.
2022-11-07 13:32:37 +01:00
Sven Klemm
5b0bff384b Improve InvalidOid coccinelle check
The initial version of the check did not include a detailed message
about the code failure in the CI output and did not check for
expressions with operands in wrong order.
2022-11-07 11:55:39 +01:00
Sven Klemm
f289ef8828 Remove unused function ts_chunk_is_uncompressed_or_unordered 2022-11-07 11:03:34 +01:00
Bharathy
12745c8806 Fix error: variable not found in subplan target list on PG15
On PG15 new flag CUSTOMPATH_SUPPORT_PROJECTION is introduced. This flag
tells if a planner node is projection capable or not. CustomScan created
in TimescaleDB by default is not projection capable, this causes CustomScan
node to be wrapped around Result node. Update query on a hypertable has
a logic which is based on assumption that "ModifyTable" plan nodes lefttree
should be CustomScan node. With PG15 this assumption is broken which causes
"ERROR:  variable not found in subplan target list".

Fixes #4834
2022-11-07 14:20:10 +05:30
Fabrízio de Royes Mello
6c73b61b99 Fix orphan jobs after CAgg migration
When using `override => true` the migration procedure rename the
current cagg using the suffix `_old` and rename the new created with
suffix `_new` to the original name.

The problem is the `copy polices` step was executed after the
`override` step and then we didn't found the new cagg name because it
was renamed to the the original name leading the policy orphan (without
connection with the materialization hypertable).

Fixed it by reordering the steps executin the `copy policies` before
the `override` step. Also made some ajustments to properly copy all
`bgw_job` columns even if this catalog table was changed.

Fixes #4885
2022-11-05 12:45:24 -03:00
Alexander Kuzmenkov
1847f64a2f Fix sanitizer builds with -Wclobbered
They use GCC 10 which has some other set of false positives.
2022-11-04 15:30:27 +04:00
Konstantina Skovola
c54cf3ea56 Add job execution statistics to telemetry
This patch adds two new fields to the telemetry report,
`stats_by_job_type` and `errors_by_sqlerrcode`. Both report results
grouped by job type (different types of policies or
user defined action).
The patch also adds a new field to the `bgw_job_stats` table,
`total_duration_errors` to separate the duration of the failed runs
from the duration of successful ones.
2022-11-04 11:06:01 +02:00
Fabrízio de Royes Mello
f1535660b0 Honor usage of OidIsValid() macro
Postgres source code define the macro `OidIsValid()` to check if the Oid
is valid or not (comparing against the `InvalidOid` type). See
`src/include/c.h` in Postgres source three.

Changed all direct comparisons against `InvalidOid` for the `OidIsValid`
call and add a coccinelle check to make sure the future changes will use
it correctly.
2022-11-03 16:10:50 -03:00
Fabrízio de Royes Mello
7dd45cf348 Fix failure resuming a CAgg migration
Trying to resume a failed Continuous Aggregate raise an exception that
the migration plan already exists, but this is wrong and the expected
behaviour should be resume the migration and continue from the last
failed step.
2022-11-03 14:18:53 -03:00
Alexander Kuzmenkov
08791cad43 Disable llvm on macos
I accidentally re-enabled it when adding the flaky check.
2022-11-03 18:41:48 +04:00
Ante Kresic
2475c1b92f Roll up uncompressed chunks into compressed ones
This change introduces a new option to the compression procedure which
decouples the uncompressed chunk interval from the compressed chunk
interval. It does this by allowing multiple uncompressed chunks into one
compressed chunk as part of the compression procedure. The main use-case
is to allow much smaller uncompressed chunks than compressed ones. This
has several advantages:
- Reduce the size of btrees on uncompressed data (thus allowing faster
inserts because those indexes are memory-resident).
- Decrease disk-space usage for uncompressed data.
- Reduce number of chunks over historical data.

From a UX point of view, we simple add a compression with clause option
`compress_chunk_time_interval`. The user should set that according to
their needs for constraint exclusion over historical data. Ideally, it
should be a multiple of the uncompressed chunk interval and so we throw
a warning if it is not.
2022-11-02 15:14:18 +01:00
Sutou Kouhei
8d1755bd78 Fix a typo in process_compressed_data_out() 2022-11-02 13:49:47 +01:00
Bharathy
c06b647680 pg_dump on PG15 does not log messages with log level set to PG_LOG_INFO.
Version 15 pg_dump program does not log any messages with log level <
PG_LOG_WARNING to stdout. Whereas this check is not present in version
14, thus we see corresponding tests fail with missing log information.
This patch fixes by supressing those log information, so that the tests
pass on all versions of postgresql.

Fixes #4832
2022-11-01 20:13:17 +05:30
Alexander Kuzmenkov
840f144e09 Enable and fix -Wclobbered
The one in job_stat.c could probably lead to errors.
2022-11-01 18:01:26 +04:00
Alexander Kuzmenkov
1cc8c15cad Do not clobber the baserel cache on UDF error
The baserel cache should only be allocated and freed by the top-level
query.
2022-11-01 18:01:26 +04:00
Sven Klemm
20cdd9ca3e Fix bgw_db_scheduler_fixed flakyness
Depending on date boundaries the number of chunks produced for the
cagg hypertable was not constant resulting on flaky tests on certain
days.
2022-11-01 14:01:38 +01:00
Sven Klemm
3d30f07bf4 Swap lookup order for clang-format
Look for the binary with exact version before looking for the
generic name to prevent failure when clang-format is lower then
required version but clang-format-14 exists.
2022-11-01 14:01:38 +01:00
Alexander Kuzmenkov
d51fefb744 Add the Flaky Check
It runs new or changed tests multiple times to find flakiness.
2022-10-31 18:51:32 +04:00