4561 Commits

Author SHA1 Message Date
Sven Klemm
d0e07a404f Release 2.14.2
This release contains bug fixes since the 2.14.1 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #6655 Fix segfault in cagg_validate_query
* #6660 Fix refresh on empty CAgg with variable bucket
* #6670 Don't try to compress osm chunks

**Thanks**
* @kav23alex for reporting a segfault in cagg_validate_query
2024-02-20 07:39:51 +01:00
Alexander Kuzmenkov
e978619b06
Use data inheritance from VirtualTupleTableSlot in compressed batch (#6615)
This simplifies passing the columnar data out of the DecompressChunk to
Vectorized Aggregation node which we plan to implement. Also this should
improve memory locality and bring us closer to the architecture used in
TAM for ArrowTupleSlot.
2024-02-19 16:18:45 +00:00
Jan Nidzwetzki
677809d4be Replace memcpy on NameData with namestrcpy
This PR replaces memcpy calls on NameData with namestrcpy. In addition,
a Coccinelle rule is introduced to detect these problems automatically.
2024-02-19 11:14:41 +01:00
Sven Klemm
57e67507fb Grant write permissions to pr handling workflow
The job assigning PR needs write permissions and the pull requests to
function.
2024-02-18 21:28:24 +01:00
Sven Klemm
23b2665d42 Don't try to compress osm chunks
This patch filters out the osm chunk in the compression policy and
adds some additional checks so we dont run compress_chunk on osm
chunks.
2024-02-18 20:00:56 +01:00
Jan Nidzwetzki
7d6332e83a Fix passed parameter to system catalog
The PR #6624 introduces a catalog access to get the Oid of a relation.
However, C strings were passed to the catalog cache and NameStr are
needed since namehashfast() is called internally. This PR fixes the
problem. Found by sanitizer.
2024-02-17 08:40:47 +01:00
Jan Nidzwetzki
1f217ed1be Fix refresh on empty CAgg with variable bucket
So far, we have not handled CAggs with variable buckets correctly. The
CAgg refresh on a hypertable without any data lead to the error message
"timestamp out of range". This patch fixes the problem by declaring
empty CAggs as up-to-date.
2024-02-16 18:28:37 +01:00
Jan Nidzwetzki
b01c8e7377 Unify handling of CAgg bucket_origin
So far, bucket_origin was defined as a Timestamp but used as a
TimestampTz in many places. This commit changes this and unifies the
usage of the variable.
2024-02-16 18:28:21 +01:00
Jan Nidzwetzki
ab7a09e876 Make CAgg time_bucket catalog table more generic
The catalog table continuous_aggs_bucket_function is currently only used
for variable bucket sizes. Information about the fixed-size buckets is
stored in the table continuous_agg only. This causes some problems
(e.g., we have redundant fields for the bucket_size, fixes size buckets
with offsets are not supported, ...).

This commit is the first in a row of commits that refactor the catalog
for the CAgg time_bucket function. The goals are:

* Remove the CAgg redundant attributes in the catalog
* Create an entry in continuous_aggs_bucket_function for all CAggs
  that use time_bucket

This first commit refactors the continuous_aggs_bucket_function table
and prepares it for more generic use. Not all attributes are used yet,
but these will change in follow-up PRs.
2024-02-16 15:39:49 +01:00
Fabrízio de Royes Mello
ba21904041 Fix typo in coccinele script
Forgot to fix some typo raised by Mats before merge #6661.
2024-02-16 11:14:30 -03:00
Fabrízio de Royes Mello
5a359ac660 Remove metadata when dropping chunk
Historically we preserve chunk metadata because the old format of the
Continuous Aggregate has the `chunk_id` column in the materialization
hypertable so in order to don't have chunk ids left over there we just
mark it as dropped when dropping chunks.

In #4269 we introduced a new Continuous Aggregate format that don't
store the `chunk_id` in the materialization hypertable anymore so it's
safe to also remove the metadata when dropping chunk and all associated
Continuous Aggregates are in the new format.

Also added a post-update SQL script to cleanup unnecessary dropped chunk
metadata in our catalog.

Closes #6570
2024-02-16 10:45:04 -03:00
Fabrízio de Royes Mello
89af50d886 Add coccinele checking for AttrNumberGetAttrOffset
Postgres has `AttrNumberGetAttrOffset()` macro to proper access Datum
array members, so added a new coccinele static analysis to check for
missing macro usage.

Example:
`datum[attrno - 1]` should be `datum[AttrNumberGetAttrOffset(attrno)]`

Reference:
* https://github.com/postgres/postgres/blob/master/src/include/access/attnum.h)
2024-02-16 09:19:00 -03:00
Sven Klemm
aa4dac195d Add windows package test for pg16 2024-02-15 09:34:45 +01:00
Jan Nidzwetzki
95bf4349d0 Fix misleading watermark threshold error message
This commit fixes a misleading error message when we get more than one
invalidation threshold message for a continuous aggregate.
2024-02-15 09:16:15 +01:00
Sven Klemm
8d8f158302 2.14.1 post release
Adjust update tests to include new version.
2024-02-15 06:15:59 +01:00
Sven Klemm
7ab0566ff1 Fix segfault in cagg_validate_query
When the input to pg_parse_query does not contain anything to parse
it will return NIL. This patch adds a check for NIL to prevent the
segfault that would otherwise happen later in the code.

Fixes: #6625
2024-02-15 06:04:30 +01:00
Jan Nidzwetzki
265ec175fa Update GitHub actions to Node.js 20
This commit updates the following workflows that used Node.js 16 to a
newer version that uses Node.js 20:

* actions/cache
* codecov/codecov-action
* Vampire/setup-wsl
2024-02-14 22:19:59 +01:00
Sven Klemm
59f50f2daa Release 2.14.1
This release contains bug fixes since the 2.14.0 release.
We recommend that you upgrade at the next available opportunity.

**Features**
* #6630 Add views for per chunk compression settings

**Bugfixes**
* #6636 Fixes extension update of compressed hypertables with dropped columns
* #6637 Reset sequence numbers on non-rollup compression
* #6639 Disable default indexscan for compression
* #6651 Fix DecompressChunk path generation with per chunk settings

**Thanks**
* @anajavi for reporting an issue with extension update of compressed hypertables
2024-02-14 17:19:04 +01:00
Alexander Kuzmenkov
e44e0ad10e
Avoid excessive reallocation in row compressors (#6638)
Memory operations can add up to tens of percents of the total
compression CPU load. To reduce the need for them, reserve for the
expected array sizes when initializing the compressor.
2024-02-14 16:02:16 +00:00
Sven Klemm
87430168b5 Fix downgrade script to make backports easier
While the downgrade script doesnt combine multiple version into a single
script since we only create the script for the previous version, fixing
this will make backporting in the release branch easier.
2024-02-14 14:45:06 +01:00
Sven Klemm
fc0e41cc13 Fix DecompressChunk path generation with per chunk settings
Adjust DecompressChunk path generation to use the per chunk settings
and not the hypertable settings when building compression info.
This patch also fixes the missing chunk configuration generation
in the update script which was masked by this bug.
2024-02-14 14:18:04 +01:00
Fabrízio de Royes Mello
a4bd6f171b Remove multinode related GUC
Leftover GUC `ts_guc_max_insert_batch_size` from multinode removal.
2024-02-13 12:07:23 -03:00
Mats Kindahl
1dc3efe17f Use "unlikely" with Ensure
Since conditions used with `Ensure` are not expected to fire except in
rare circumstances, we should always treat this as unlikely.
2024-02-13 15:32:11 +01:00
Ante Kresic
cc2642484e Reset sequence numbers on non-rollup compression
In a previous commit, a performance regression was introduced
which needlessly scanned indexes to get sequence numbers when
it was not necessary. This change resets sequence numbers when
we know that we are not rolling up chunks during compression.
2024-02-13 12:30:35 +01:00
Jan Nidzwetzki
1fb62b5b86 Remove function mattablecolumninfo_addinternal
This commit removes the unused
function mattablecolumninfo_addinternal.
2024-02-13 11:02:22 +01:00
Jan Nidzwetzki
90d6121c29 Remove function ts_number_of_continuous_aggs
This commit removes the unused function ts_number_of_continuous_aggs.
2024-02-13 10:56:23 +01:00
Fabrízio de Royes Mello
916e14e9f6 Bump PG versions used in CI
Use newly released 13.14, 14.11, 15.6 and 16.2 in CI.
2024-02-13 10:25:25 +01:00
Sven Klemm
ea6d826c12 Add compression settings informational view
This patch adds 2 new views hypertable_compression_settings and
chunk_compression_settings to query the per chunk compression
settings.
2024-02-13 07:33:37 +01:00
Sven Klemm
fa5c0a9b22 Fix update script for tables with dropped columns 2024-02-12 20:58:20 +01:00
Jan Nidzwetzki
550ba17539 Add existence check to CAgg catalog find function
The function ts_continuous_agg_find_by_mat_hypertable_id is used to read
the data about a CAgg from the catalog. If the CAgg for a given
mat_hypertable_id is not found, the function returns NULL. Therefore,
most code paths performed a NULL check and did some error handling
afterward.  This PR moves the duplicated error handling into the
function.
2024-02-12 20:04:37 +01:00
Nikhil Sontakke
4f912f77ca Disable default indexscan for compression
The current code would always prefer indexscan over tuplesort while
doing scans of the rows from the chunk that was being compressed.
The thinking was that we'd avoid doing a sort via the indexscan.
The theory looked good on paper, but from various cloud customer
reports we have seen that the random access of the heap pages via the
indexscan was typically more expensive than doing the tuplesort. So we
disable the default indexscan till we get better usecases warranting
enabling it again for all scenarios. Specific use cases can enable the
timescaledb.enable_compression_indexscan manually if desired.
2024-02-12 22:09:21 +05:30
Alexander Kuzmenkov
2265c18baf
Report the PG version and path before complaining it's incorrect (#6634)
Helps to investigate errors where a wrong PG version gets picked.
2024-02-12 10:45:46 +00:00
Sven Klemm
00f2f01b1c Remove unused function get_vacuum_options
The last caller for this was removed as part of multinode removal.
2024-02-12 10:27:41 +01:00
Ante Kresic
ba3ccc46db Post-release fixes for 2.14.0
Bumping the previous version and adding tests for 2.14.0.
2024-02-12 09:32:40 +01:00
Alexander Kuzmenkov
d93aa5c8c1
Log internal program errors to CI database (#6598)
SQLSmith finds many internal program errors (`elog`, code `XX000`).
Normally these errors shouldn't be triggered by user actions and
indicate a bug in the program (like `variable not found in subplan
targetlist`). We don't have a capacity to fix all of them currently,
especially since some of them seem to be the upstream ones. This commit
adds logging for these errors so that we at least can study the current
situation.
2024-02-09 13:28:54 +01:00
Sven Klemm
96aa7e0fb9 Fix rpm package test workflow
Variables cannot be used to specify the action version. Looks like
we have to wait for an upstream fix to make a node image available
that is compatible with centos7.
2024-02-09 09:35:17 +01:00
Sven Klemm
e734433a7a Adjust pg_dump_unprivileged test to only run on versions with fixed pg_dump
pg_dump_unprivileged.sql was fixed by an upstream change to pg_dump in 13.14, 14.11, 15.6, and 16.2
2024-02-09 08:55:19 +01:00
Jan Nidzwetzki
1765c82c50 Remove distributed CAgg leftovers
Version 2.14.0 removes the multi-node code. However, there were a few
leftovers for the handling of distributed CAggs. This commit cleans up
the CAgg code and removes the no longer needed functions:

invalidation_cagg_log_add_entry(integer,bigint,bigint);
invalidation_hyper_log_add_entry(integer,bigint,bigint);
materialization_invalidation_log_delete(integer);
invalidation_process_cagg_log(integer,integer,regtype,bigint,
     bigint,integer[],bigint[],bigint[]);
invalidation_process_cagg_log(integer,integer,regtype,bigint,
     bigint,integer[],bigint[],bigint[],text[]);
invalidation_process_hypertable_log(integer,integer,regtype,
     integer[],bigint[],bigint[]);
invalidation_process_hypertable_log(integer,integer,regtype,
     integer[],bigint[],bigint[],text[]);
hypertable_invalidation_log_delete(integer);
2024-02-08 16:02:19 +01:00
Ante Kresic
505b427a04 Release 2.14.0
This release contains performance improvements and bug fixes since
the 2.13.1 release. We recommend that you upgrade at the next
available opportunity.

In addition, it includes these noteworthy features:

* Ability to change compression settings on existing compressed hypertables at any time.
New compression settings take effect on any new chunks that are compressed after the change.
* Reduced locking requirements during chunk recompression
* Limiting tuple decompression during DML operations to avoid decompressing a lot of tuples and causing storage issues (100k limit, configurable)
* Helper functions for determining compression settings

**For this release only**, you will need to restart the database before running `ALTER EXTENSION`

**Multi-node support removal announcement**
Following the deprecation announcement for Multi-node in TimescaleDB 2.13,
Multi-node is no longer supported starting with TimescaleDB 2.14.

TimescaleDB 2.13 is the last version that includes multi-node support. Learn more about it [here](docs/MultiNodeDeprecation.md).

If you want to migrate from multi-node TimescaleDB to single-node TimescaleDB, read the
[migration documentation](https://docs.timescale.com/migrate/latest/multi-node-to-timescale-service/).

**Deprecation notice: recompress_chunk procedure**
TimescaleDB 2.14 is the last version that will include the recompress_chunk procedure. Its
functionality will be replaced by the compress_chunk function, which, starting on TimescaleDB 2.14,
works on both uncompressed and partially compressed chunks.
The compress_chunk function should be used going forward to fully compress all types of chunks or even recompress
old fully compressed chunks using new compression settings (through the newly introduced recompress optional parameter).

**Features**
* #6325 Add plan-time chunk exclusion for real-time CAggs
* #6360 Remove support for creating Continuous Aggregates with old format
* #6386 Add functions for determining compression defaults
* #6410 Remove multinode public API
* #6440 Allow SQLValueFunction pushdown into compressed scan
* #6463 Support approximate hypertable size
* #6513 Make compression settings per chunk
* #6529 Remove reindex_relation from recompression
* #6531 Fix if_not_exists behavior for CAgg policy with NULL offsets
* #6545 Remove restrictions for changing compression settings
* #6566 Limit tuple decompression during DML operations
* #6579 Change compress_chunk and decompress_chunk to idempotent version by default
* #6608 Add LWLock for OSM usage in loader
* #6609 Deprecate recompress_chunk
* #6609 Add optional recompress argument to compress_chunk

**Bugfixes**
* #6541 Inefficient join plans on compressed hypertables.
* #6491 Enable now() plantime constification with BETWEEN
* #6494 Fix create_hypertable referenced by fk succeeds
* #6498 Suboptimal query plans when using time_bucket with query parameters
* #6507 time_bucket_gapfill with timezones doesn't handle daylight savings
* #6509 Make extension state available through function
* #6512 Log extension state changes
* #6522 Disallow triggers on CAggs
* #6523 Reduce locking level on compressed chunk index during segmentwise recompression
* #6531 Fix if_not_exists behavior for CAgg policy with NULL offsets
* #6571 Fix pathtarget adjustment for MergeAppend paths in aggregation pushdown code
* #6575 Fix compressed chunk not found during upserts
* #6592 Fix recompression policy ignoring partially compressed chunks
* #6610 Ensure qsort comparison function is transitive

**Thanks**
* @coney21 and @GStechschulte for reporting the problem with inefficient join plans on compressed hypertables.
* @HollowMan6 for reporting triggers not working on materialized views of
CAggs
* @jbx1 for reporting suboptimal query plans when using time_bucket with query parameters
* @JerkoNikolic for reporting the issue with gapfill and DST
* @pdipesh02 for working on removing the old Continuous Aggregate format
* @raymalt and @martinhale for reporting very slow query plans on realtime CAggs queries
2024-02-08 13:57:06 +01:00
Sven Klemm
e2d55cd9e8 Make transparent_decompress_chunk test less flaky
Change more queries to run EXPLAIN without ANALYZE to make the test less
flaky due to different parallelization.
2024-02-08 12:37:03 +01:00
gayyappan
8c34a207d9 Add LWLock for OSM usage in loader
Modify the loader to add a LWLock for OSM code.
Update the loader API version to 4.
2024-02-07 09:21:15 -05:00
Sven Klemm
101e4c57ef Add recompress optional argument to compress_chunk
This patch deprecates the recompress_chunk procedure as all that
functionality is covered by compress_chunk now. This patch also adds a
new optional boolean argument to compress_chunk to force applying
changed compression settings to existing compressed chunks.
2024-02-07 12:19:13 +01:00
Erik Nordström
c5fd41cd6b Add PG source dir to system includes
Add a CMake option to add the PostgreSQL source directory as a system
include for the build system. This will ensure that the PG source
include directory will end up in a generated `compile_commands.json`,
which can be used by language servers (e.g., clangd) to navigate from
the TimescaleDB source directly to the PostgreSQL source.
2024-02-07 11:02:58 +01:00
Sven Klemm
ac50cbaf45 Don't disable downgrade test on PG16
Since we now have multiple versions packaged for PG16 we can enable
the downgrade test in our apt and rpm package test.
2024-02-07 09:38:21 +01:00
Mats Kindahl
9e67552c7d Ensure qsort comparison function is transitive
If the comparison function for qsort is non-transitive, there is a risk
of out-of-bounds access. Subtraction of integers can lead to overflows,
so instead use a real comparison function.
2024-02-06 12:40:58 +01:00
Alexander Kuzmenkov
6c0009af48 Fix coverity false positive
Change the variable from single uint64 to array to prevent the error.
2024-02-06 05:15:12 +01:00
Fabrízio de Royes Mello
9e797dcdd0 Fix coverityscan logically dead code
https://scan4.scan.coverity.com/#/project-view/54116/12995?selectedIssue=414714
2024-02-06 01:09:14 -03:00
Nikhil Sontakke
28d3a5f1ee Report progress in compression related APIs
Log progress of the compression/decompression APIs into the postgresql
log file. In case of issues in the field, we really do not have much
idea about which stage the compression function is stuck at. Hopefully
we will have a better idea now with these log messages in place. We
want to keep things simple and enable logging of the progress by
default for these APIs. We can re-look if the users complaint about the
chattiness later.
2024-02-06 09:38:01 +05:30
Sven Klemm
4118dcaeab Change compress_chunk to recompress partial and unordered chunks when needed
This patch changes compress_chunk to recompress partial or unordered
chunks so the result of compress_chunk will always be a fully compressed
chunk.
2024-02-05 14:23:52 +01:00
Alexander Kuzmenkov
525b045839 Fix handling of expressions evaluated to Const in OR
We had this handling for top-level AND, but not for deeper boolean
expressions. Make it general.

Also fix a Coverity warning.
2024-02-05 12:19:44 +01:00