3638 Commits

Author SHA1 Message Date
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
Konstantina Skovola
fabb01fdaf Add telemetry for fixed schedule jobs
Previous commit #4664 introduced the ability to execute
background jobs on a fixed schedule.
This commit updates our telemetry data to include the number
of jobs scheduled to execute on a fixed schedule vs the number
registered to execute on a drifting schedule.
2022-10-24 00:01:52 +03:00
Fabrízio de Royes Mello
06f2e57c50 Fix ereport call in job schedule for PG 12.0
Since PG 12.3 the `ereport` syntax changed and the commit 54ed0d
introduced and `ereport` call that works just using newer PG versions.

Changed the `ereport` call a PG 12.0 compatible syntax.

CI failure: https://github.com/timescale/timescaledb/actions/runs/3292571583/jobs/5428090238

Related PRs: #4733, #4809
2022-10-22 12:08:40 -03:00
Alexander Kuzmenkov
39c9921947 Fix flaky copy_memory_usage tests
The changes from e555eea lead to flakiness. They are a leftover of
earlier version and probably not needed anymore.

The original version is also still flaky on Windows, so use linear
regression to tell if the memory usage is increasing.

Verified to still fail on 2.7.x
2022-10-21 21:20:40 +04:00
Alexander Kuzmenkov
25628e037a Use non-refcounted tupdesc for multi-insert buffers
We don't need reference counting there, and it spends a lot of CPU in
ResourceOwner.

This slightly improves COPY performance on some data sets.
2022-10-21 16:39:58 +04:00
Mats Kindahl
84b2fef6ef Fix GitHub output action
To avoid untrusted logged data to use `set-state` and `set-output`
workflow commands without the intention of the workflow author GitHub
have introduced a new set of environment files to manage state and
output.

This commit changes the existing uses of `set-output` to use the new
environment files instead.

See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-21 11:10:09 +02:00
Erik Nordström
4b05402580 Add health check function
A new health check function _timescaledb_internal.health() returns the
health and status of the database instance, including any configured
data nodes (in case the instance is an access node).

Since the function returns also the health of the data nodes, it tries
hard to avoid throwing errors. An error will fail the whole function
and therefore not return any node statuses, although some of the nodes
might be healthy.

The health check on the data nodes is a recursive (remote) call to the
same function on those nodes. Unfortunately, the check will fail with
an error if a connection cannot be established to a node (or an error
occurs on the connection), which means the whole function call will
fail. This will be addressed in a future change by returning the error
in the function result instead.
2022-10-21 10:34:16 +02:00
Jan Nidzwetzki
23c01c44e5 Remove an unused function in the copy code
Since e555eea9dbc05f4c09cf0d7e23b814054a459d19 the function
TSCopyMultiInsertInfoIsEmpty is no longer used. This patch removes the
unused code from src/copy.c.
2022-10-21 10:02:34 +02:00
Jan Nidzwetzki
e555eea9db Fix performance regressions in the copy code
In 8375b9aa536a619a5ac2644e0dae3c25880a4ead, a patch was added to handle
chunks closes during an ongoing copy operation. However, this patch
introduces a performance regression. All MultiInsertBuffers are deleted
after they are flushed. In this PR, the performance regression is fixed.
The most commonly used MultiInsertBuffers survive flushing.

The 51259b31c4c62b87228b059af0bbf28caa143eb3 commit changes the way the
per-tuple context is used. Since this commit, more objects are stored in
this context. The size of the context was used to set the tuple size to
PG < 14. The extra objects in the context lead to wrong (very large)
results and flushes almost after every tuple read.

The cache synchronization introduced in
296601b1d7aba7f23aea3d47c617e2d6df81de3e is reverted. With the current
implementation, `MAX_PARTITION_BUFFERS` survive the flash. If
`timescaledb.max_open_chunks_per_insert` is lower than
`MAX_PARTITION_BUFFERS` , a buffer flush would be performed after each
tuple read.
2022-10-21 09:02:03 +02:00
Erik Nordström
40a6c4cf87 Fix unused sort in dimension partition lookup
Dimension partition lookups use binary search to find the partition to
place a chunk in. However, in the code, an array of partitions might
not be sorted because the sort happened on a copy of the array instead
of the main array. This change fixes the issue to ensure the array is
sorted and binary search works properly.
2022-10-20 18:36:49 +02:00
Alexander Kuzmenkov
f862212c8c Add clang-tidy warning readability-inconsistent-declaration-parameter-name
Mostly cosmetic stuff. Matched to definition automatically with
--fix-notes.
2022-10-20 19:42:11 +04:00
Alexander Kuzmenkov
73c3d02ed2 Enable clang-tidy warning readability-misleading-indentation 2022-10-20 16:53:50 +04:00
Alexander Kuzmenkov
05ba1cf22f Add clang-tidy warning readability-suspicious-call-argument
Helps find accidentally swapped arguments, like in the recent
epoll_ctl() error.
2022-10-20 16:53:50 +04:00
Mats Kindahl
276d3a331d Add macro to assert or error
For some unexpected conditions, we have a check and an error that is
generated. Since this always generate an error, it is more difficult to
find the bug if the error is generated rather than an assert fired
generating a core dump. Similarly, some asserts can occur in production
builds and will lead to strange situations triggering a crash. For
those cases we should instead generate an error.

This commit introduces a macro `Ensure` that will result in an assert
in debug builds, but an error message in release build. This macro
should only be used for conditions that should not occur during normal
runtime, but which can happen is odd corner-cases in release builds and
therefore warrants an error message.

It also replaces some existing checks with such errors to demonstrate
usage.
2022-10-20 13:35:09 +02:00
Nikhil Sontakke
f55aaf06dd Add hook for ssl options
External components like timescaledb_cloudutils might want to add
additional options or do additional ssl related processing. They can
do so by implementing a hook and then assigning it to a timescaledb
variable to allow timescale to invoke it as appropriate.
2022-10-20 13:26:33 +05:30
Bharathy
d218715d5c Fix tests which fail on PG15
When TimescaleDB 2.9.0 compiled against PG15, many tests fail due to
permissions on default public schema not getting propagated to data
nodes, although connected user has required GRANTS on access nodes.
This patch fixes failing tests by explicitly granting required permissions
for connected user or role after data nodes are added.
2022-10-19 17:57:54 +05:30
Alexander Kuzmenkov
080011d767 Speed up the dist_copy tests
In some cases we can use less chunks, less data, and not truncate
tables.
2022-10-19 15:53:19 +04:00
Fabrízio de Royes Mello
702ac53c0a Bump codecov github action version
Leftover from previous commit 8950ab where we bumped some github action
versions to run on Node16 instead of Node12 (in deprecation).
2022-10-19 03:02:58 -03:00
Konstantina Skovola
54ed0d5c05 Introduce fixed schedules for background jobs
Currently, the next start of a scheduled background job is
calculated by adding the `schedule_interval` to its finish
time. This does not allow scheduling jobs to execute at fixed
times, as the next execution is "shifted" by the job duration.

This commit introduces the option to execute a job on a fixed
schedule instead. Users are expected to provide an initial_start
parameter on which subsequent job executions are aligned. The next
start is calculated by computing the next time_bucket of the finish
time with initial_start origin.
An `initial_start` parameter is added to the compression, retention,
reorder and continuous aggregate `add_policy` signatures. By passing
that upon policy creation users indicate the policy will execute on
a fixed schedule, or drifting schedule if `initial_start` is not
provided.
To allow users to pick a drifting schedule when registering a UDA,
an additional parameter `fixed_schedule` is added to `add_job`
to allow users to specify the old behavior by setting it to false.

Additionally, an optional TEXT parameter, `timezone`, is added to both
add_job and add_policy signatures, to address the 1-hour shift in
execution time caused by DST switches. As internally the next start of
a fixed schedule job is calculated using time_bucket, the timezone
parameter allows using timezone-aware buckets to calculate
the next start.
2022-10-18 18:46:57 +03:00
Fabrízio de Royes Mello
8950abe0ee Bump github action versions
All github actions that run on Node12 are deprecated so bumped github
action versions to run on Node16.

https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-10-18 11:20:39 -03:00
Fabrízio de Royes Mello
043bd55c0b Miss segmentby compression option in CAGGs
Timescale 2.7 released a new version of Continuous Aggregate (#4269)
that store the final aggregation state instead of the byte array of
the partial aggregate state, offering multiple opportunities of
optimizations as well a more compact form.

This new version also removes the unecessary `chunk_id` column from the
materialization hypertable and consequently the re-aggregation in the
user view. It means the user view that query the materialization
hypertable don't have a GROUP BY clause anymore that was problematic
for query performance.

Before 2.7 when users turn compression ON we infer compression options
`segmentby` and `orderby` based on the GROUP BY clause and time bucket
respectively. With the new version without a GROUP BY clause in the user
view the inferetion for the 'segmentby' compression option stopped to
work.

Fixed it by changing the code to the compression on the new version of
Continuous Aggregate (aka finals form) behave the same as the old
version.

Fix #4816
2022-10-17 16:50:02 -03:00
Alexander Kuzmenkov
bde337e92d Fix the flaky pg_dump test
It was frequently failing on Windows. Sort by what is actually printed.
2022-10-17 21:17:48 +03:00
Bharathy
0e32656b54 Support for PG15.
As part of this patch, added and fixed some of the regress checks which
fail on PG15.
2022-10-17 21:43:44 +05:30
Markos Fountoulakis
d5c25e8914 Adjust partition pruning to support PG15
PostgreSQL 15 introduced a Bitmapset for tracking non-pruned partitions
for performance purposes. Adjust our code for expanding hypertable
chunks to support this.

https://github.com/postgres/postgres/commit/475dbd0b718
2022-10-17 17:39:43 +03:00