3661 Commits

Author SHA1 Message Date
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
gayyappan
e08e0a59db Add hook for chunk creation
After data is tiered using OSM, we cannot insert data into the same
range. Need a callback that can be invoked by timescaledb to check
for range overlaps before creating a new chunk
2022-10-28 12:43:31 -04:00
Alexander Kuzmenkov
5b2d9d5a10 Enable -Wnewline-eof
It enforces the newline at end of file, which is required by the C
standard.
2022-10-28 20:16:30 +04:00
gayyappan
c48b1231a8 Allow foreign tables in hypetable modify path
OSM chunks are foreign tables. Modify assert to allow
updates/deletes on hypertables with foreign table chunks.
2022-10-28 11:05:09 -04:00
Jan Nidzwetzki
dfbf030af7 Remove no-activity label on issue activity
So far, only the "need-more-info" label was removed when there was
activity on an issue. This PR ensures that the "no-activity" label is
also removed.
2022-10-28 16:03:07 +02:00
Alexander Kuzmenkov
85f5efdc8f Fix -Wsign-compare with PG 15
It changed the type of Var.varno from Index to int. I'm starting to
wonder if it was a good idea to enable this warning, but maybe we can
give it the last try.
2022-10-28 17:10:13 +04:00
Alexander Kuzmenkov
d8e892a658 Save postgres logs on Windows in CI
We don't save them currently.
2022-10-27 19:38:26 +04:00
Fabrízio de Royes Mello
8d1e165d7f Refactor Continuous Aggregate catalog code
Get rid of `GETSTRUCT` to fill the form data and use `heap_deform_tuple`
instead. This is necessary specially when you have variable lenght
fields and/or fields that accept NULL values. This refactoring will be
specially usefull in a following PR for Nested Continuous Aggregates
where we'll add a new metadata to the catalog that can accept NULL
values.

Also refactor the rename view and schema code paths improving the
readability and maintainability.
2022-10-27 11:25:20 -03:00
Alexander Kuzmenkov
9b157d5438 Don't use docker for clang-format
It's not something we normally do for the developer tools.
2022-10-27 16:06:58 +04:00
Alexander Kuzmenkov
313845a882 Enable -Wextra
Our code mostly has warnings about comparison with different
signedness.
2022-10-27 16:06:58 +04:00
Alexander Kuzmenkov
864da20cee Build on Ubuntu 22.04
It has newer GCC which should detect more warnings.
2022-10-26 23:32:05 +04:00
Fabrízio de Royes Mello
2e7d7ee960 Remove useless message from tsl_cagg_try_repair
The PR #3899 introduced a new function named `tsl_cagg_try_repair` to
try to fix buggy Continuous Aggregates that lead to segfault on a select
query. It added an INFO message when skipping the check for Continuous
Aggregate that don't have partials and it's annoying during the
upgrade/downgrade the extension specially if you have many Continuous
Aggregate.

Remove this message because it's completely useless.
2022-10-26 14:23:26 -03:00
Alexander Kuzmenkov
da9af2c05d Do not cache the classify_relation result
It depends on the context, not only on the relation id. The same chunk
can be expanded both as a child of hypertable and as an independent
table.
2022-10-26 17:05:39 +04:00
Dmitry Simonenko
498b8af261 Block multi-statement DDL command in one query
Ensure that queries involving several distributed DDL commands
in one query string are blocked.

Fix #4818
2022-10-26 14:07:29 +03:00
Sven Klemm
cef8c462db Fix postgres version assert in telemetry
The telemetry code that reads the postgres version was not updated
when support for older postgres version was dropped so we introduce
a new macro PG_MAJOR_MIN which is the oldest pg major version we
support.
2022-10-25 14:26:48 +02:00
Jan Nidzwetzki
f05545883b Add a Coccinelle test for PG 12.3+ ereport syntax
This PR adds a Coccinelle test for ereport(..) calls that use the PG
12.3+ syntax
(postgres/postgres@a867154516). We had
some of these calls in the past, which we had to fix afterward (
see #4733, #4809, #4871). This Coccinelle patch detects such calls and
reports them in the CI run.
2022-10-24 13:41:30 +02:00