3967 Commits

Author SHA1 Message Date
Fabrízio de Royes Mello
cc9c3b3431 Post-release 2.10.3
Adjust the upgrade/downgrade scripts and add the tests.
2023-04-28 10:05:11 -03:00
Nikhil Sontakke
ed8ca318c0 Quote username identifier appropriately
Need to use quote_ident() on the user roles. Otherwise the
extension scripts will fail.

Co-authored-by: Mats Kindahl <mats@timescale.com>
2023-04-28 16:53:43 +05:30
Bharathy
2ce4bbc432 Enable continuous_aggs tests on all PG version. 2023-04-28 07:40:59 +05:30
Zoltan Haindrich
1d092560f4 Fix on-insert decompression after schema changes
On compressed hypertables 3 schema levels are in use simultaneously
 * main - hypertable level
 * chunk - inheritance level
 * compressed chunk

In the build_scankeys method all of them appear - as slot have their
fields represented as a for a row of the main hypertable.

Accessing the slot by the attribut numbers of the chunks may lead to
indexing mismatches if there are differences between the schemes.

Fixes: #5577
2023-04-27 16:33:36 +02:00
Mats Kindahl
be28794384 Enable run_job() for telemetry job
Since telemetry job has a special code path to be able to be used both
from Apache code and from TSL code, trying to execute the telemetry job
with run_job() will fail.

This code will allow run_job() to be used with the telemetry job to
trigger a send of telemetry data. You have to belong to the group that
owns the telemetry job (or be the owner of the telemetry job) to be
able to use it.

Closes #5605
2023-04-27 16:00:03 +02:00
Fabrízio de Royes Mello
d5a286174d Changelog for 2.10.3 2023-04-26 20:11:57 -03:00
Fabrízio de Royes Mello
8a95d1b9ee Add missing matrix in ignored 32bits regression workflow 2023-04-26 19:47:47 -03:00
Fabrízio de Royes Mello
e140cc702c Add missing matrix in ignored regression workflow 2023-04-26 17:43:40 -03:00
Fabrízio de Royes Mello
002b6e879a Fix CI ignored regression workflows
We defined some paths to ignore regression test workflows when, for
example, we change the CHANGELOG.md and others. But in fact it was not
happening because we didn't define a proper name in the fake regression
workflow that fake to the CI that some required status passed.

Fixed it defining a proper regression name like we do for the regular
regression workflow.
2023-04-26 15:58:33 -03:00
Fabrízio de Royes Mello
3c8d7cef77 Fix cagg_repair for the old CAgg format
In commit 4a6650d1 we fixed the cagg_repair running for broken
Continuous Aggregates with JOINs but we accidentally removed the
code path for running against the old format (finalized=false)
leading us to a dead code pointed out by CoverityScan:
https://scan4.scan.coverity.com/reports.htm#v54116/p12995/fileInstanceId=131706317&defectInstanceId=14569420&mergedDefectId=384044

Fixed it by restoring the old code path for running the cagg_repair
for Continuous Aggregates in the old format (finalized=false).
2023-04-26 14:29:58 -03:00
Mats Kindahl
d3730a4f6a Add permission checks to run_job()
There were no permission checks when calling run_job(), so it was
possible to execute any job regardless of who owned it. This commit
adds such checks.
2023-04-26 11:56:56 +02:00
Fabrízio de Royes Mello
4a6650d170 Fix broken CAgg with JOIN repair function
The internal `cagg_rebuild_view_definition` function was trying to cast
a pointer to `RangeTblRef` but it actually is a `RangeTblEntry`.

Fixed it by using the already existing `direct_query` data struct to
check if there are JOINs in the CAgg to be repaired.
2023-04-25 15:20:48 -03:00
Ante Kresic
910663d0be Reduce decompression during UPDATE/DELETE
When updating or deleting tuples from a compressed chunk, we first
need to decompress the matching tuples then proceed with the operation.
This optimization reduces the amount of data decompressed by using
compressed metadata to decompress only the affected segments.
2023-04-25 15:49:59 +02:00
Lakshmi Narayanan Sreethar
3bf58dac02 Update windows package link in github action 2023-04-25 11:29:37 +05:30
Bharathy
44dc042bb3 Fixed transparent decompress chunk test which seem to be flaky. 2023-04-24 19:58:02 +05:30
Jan Nidzwetzki
2f194e6109 Make compression metadata column names reusable
Move the creation of metadata column names for min/max values to
separate functions to make the code reusable.
2023-04-24 13:42:00 +02:00
Jan Nidzwetzki
c54d8bd946 Add missing order by to compression_ddl tests
Some queries in compression_ddl had no order by. Therefore the output
order was not defined, which led to flaky tests.
2023-04-21 15:54:25 +02:00
Ante Kresic
583c36e91e Refactor compression code to reduce duplication 2023-04-20 22:27:34 +02:00
Sven Klemm
744b44cc52 Fix parameterization in DecompressChunk path generation
All children of an append path are required to have the same parameterization
so we have to reparameterize when the selected path does not have the right
parameterization.
2023-04-20 17:20:04 +02:00
Ante Kresic
23b3f8d7a6 Block unique idx creation on compressed hypertable
This block was removed by accident, in order to support this we
need to ensure the uniqueness in the compressed data which is
something we should do in the future thus removing this block.
2023-04-20 16:22:03 +02:00
Alexander Kuzmenkov
12f3131f9e Post-release 2.10.2
Adjust the upgrade/downgrade scripts and add the tests.
2023-04-20 17:55:18 +04:00
Zoltan Haindrich
a0df8c8e6d Fix on-insert decompression for unique constraints
Inserting multiple rows into a compressed chunk could have bypassed
constraint check in case the table had segment_by columns.

Decompression is narrowed to only consider candidates by the actual
segment_by value.
Because of caching - decompression was skipped for follow-up rows of
the same Chunk.

Fixes #5553
2023-04-20 13:47:47 +02:00
Ante Kresic
a49fdbcffb Reduce decompression during constraint checking
When inserting into a compressed chunk with constraints present,
we need to decompress relevant tuples in order to do speculative
inserting. Usually we used segment by column values to limit the
amount of compressed segments to decompress. This change expands
on that by also using segment metadata to further filter
compressed rows that need to be decompressed.
2023-04-20 12:17:12 +02:00
Alexander Kuzmenkov
28d9db1af9 Changelog for 2.10.2
## 2.10.2 (2023-04-20)

**Bugfixes**
* #5410 Fix file trailer handling in the COPY fetcher
* #5446 Add checks for malloc failure in libpq calls
* #5233 Out of on_proc_exit slots on guc license change
* #5428 Use consistent snapshots when scanning metadata
* #5499 Do not segfault on large histogram() parameters
* #5470 Ensure superuser perms during copy/move chunk
* #5500 Fix when no FROM clause in continuous aggregate definition
* #5433 Fix join rte in CAggs with joins
* #5556 Fix duplicated entries on timescaledb_experimental.policies view
* #5462 Fix segfault after column drop on compressed table
* #5543 Copy scheduled_jobs list before sorting it
* #5497 Allow named time_bucket arguments in Cagg definition
* #5544 Fix refresh from beginning of Continuous Aggregate with variable time bucket
* #5558 Use regrole for job owner
* #5542 Enable indexscan on uncompressed part of partially compressed chunks

**Thanks**
* @nikolaps for reporting an issue with the COPY fetcher
* @S-imo-n for reporting the issue on Background Worker Scheduler crash
* @geezhu for reporting issue on segfault in historgram()
* @mwahlhuetter for reporting the issue with joins in CAggs
* @mwahlhuetter for reporting issue with duplicated entries on timescaledb_experimental.policies view
* @H25E for reporting error refreshing from beginning of a Continuous Aggregate with variable time bucket
2023-04-20 09:54:39 +04:00
Konstantina Skovola
5633960f8b Enable indexscan on uncompressed part of partially compressed chunks
This was previously disabled as no data resided on the
uncompressed chunk once it was compressed, but this is not
the case anymore with partially compressed chunks, so we
enable indexscan for the uncompressed chunk again.

Fixes #5432

Co-authored-by: Ante Kresic <ante.kresic@gmail.com>
2023-04-18 17:29:08 +03:00
shhnwz
ca472ebb0d Fixed transparent decompress chunk
Transparent decompress chunk was added into to ignore list due to
the side effect of #5118. This issue is to fix the flaky nature of
the test.
2023-04-18 14:12:22 +05:30
Mats Kindahl
9a64385f34 Use regrole for job owner
Instead of using a user name to register the owner of a job, we use
regrole. This allows renames to work properly since the underlying OID
does not change when the owner name changes.

We add a check when calling `DROP ROLE` that there is no job with that
owner and generate an error if there is.
2023-04-18 08:57:52 +02:00
Alexander Kuzmenkov
20db884bd7 Increase remote tuple and startup costs
Our cost model should be self-consistent, and the relative values for
the remote tuple and startup costs should reflect their real cost,
relative to costs of other operations like CPU tuple cost.

For example, now remote costs are set even lower than the parallel tuple
and startup cost. Contrary to that, their real world cost is going to be
an order of magnitude higher or more, because parallel tuples are sent
through shared memory, and remote tuples are sent over the network.

Increasing these costs leads to query plan improvements, e.g. we start
to favor the GROUP BY pushdown in some cases.
2023-04-17 22:22:08 +04:00
Fabrízio de Royes Mello
b16bf3b100 Fix post repair tests
Commit 3f9cb3c2 introduced new repair tests for broken Continuous
Aggregates with JOIN clause but in the post.repair.sql we not properly
calling the post.repair.cagg_joins.sql because a wrong usage of psql
`if` statement.
2023-04-17 14:47:06 -03:00
Alexander Kuzmenkov
d32224a914 Add labels to backported PRs
Makes it easier to check what was done when looking at the release
milestone.
2023-04-17 13:26:57 +04:00
Sven Klemm
90e54def8a Improve interpolate error message on datatype mismatch
Include information about the expected and the returned datatype
in the error details of interpolate.
2023-04-15 09:38:42 +02:00
Fabrízio de Royes Mello
a3d778f7a0 Add CI check for missing gitignore entries
Whenever we create a template sql file (*.sql.in) we should add the
respective .gitignore entry for the generated test files.

So added a CI check to check for missing gitignore entries for generated
test files.
2023-04-14 12:46:20 -03:00
Lakshmi Narayanan Sreethar
a383c8dd4f Copy scheduled_jobs list before sorting it
The start_scheduled_jobs function mistakenly sorts the scheduled_jobs
list in-place. As a result, when the ts_update_scheduled_jobs_list
function compares the updated list of scheduled jobs with the existing
scheduled jobs list, it is comparing a list that is sorted by job_id to
one that is sorted by next_start time. Fix that by properly copying the
scheduled_jobs list into a new list and use that for sorting.

Fixes #5537
2023-04-14 15:59:57 +05:30
Lakshmi Narayanan Sreethar
b10139ba48 Update bgw_custom testcase
Added a few cleanup steps and updated a test logic to make the testcase
runs more stable.
2023-04-14 15:59:57 +05:30
Maheedhar PV
b136bb554b Run dist_move_chunk as a solo test in PG15.2
Running the test dist_move_chunk in parallel can
cause a timeouts(deadlock) in other tests running
in parallel on PG15.2. Force the test to run solo.
2023-04-14 14:26:50 +05:30
Maheedhar PV
ca240c33ca Build failure on windows
The cmake call to "find_package(OpenSSL)" on windows may set the
variable OPENSSL_LIBRARIES to a non-standard list which might include
non path items such as "debug", "optimized". These non-standard
elements in the list would cause the link failure with error
"LNK1104".

Fix:
Check and retain only valid paths in OPENSSL_LIBRARIES list.

closes#407
2023-04-13 17:10:43 +05:30
Ante Kresic
464d20fb41 Propagate vacuum/analyze to compressed chunks
With recent changes, we enabled analyze on uncompressed chunk tables
for compressed chunks. This change includes analyzing the compressed
chunks table when analyzing the hypertable and its chunks,
enabling us to remove the generating stats when compressing chunks.
2023-04-13 12:15:32 +02:00
Rafia Sabih
3f9cb3c27a Pass join related structs to the cagg rte
In case of joins in the continuous aggregates, pass the required
structs to the new rte created. These values are required by the
planner to finally query the materialized view.

Fixes #5433
2023-04-13 04:57:33 +02:00
Fabrízio de Royes Mello
09565acae4 Fix timescaledb_experimental.policies duplicates
Commit 16fdb6ca5e introduced `timescaledb_experimental.policies` view
to expose the Continuous Aggregate policies but the current JOINS over
our catalog are not accurate.

Fixed it by properly JOIN the underlying catalog tables to expose the
correct information without duplicates about the Continuous Aggregate
policies.

Fixes #5492
2023-04-12 15:28:29 -03:00
Fabrízio de Royes Mello
f6c8468ee6 Fix timestamp out of range refreshing CAgg
When refreshing from the beginning (window_start=NULL) of a
Continuous Aggregate with variable time bucket we were getting a
`timestamp out of range` error.

Fixed it by setting `-Infinity` when passing `window_start=NULL` when
refreshing a Continuous Aggregate with variable time bucket.

Fixes #5474, #5534
2023-04-12 14:50:04 -03:00
Mats Kindahl
3cc8a4ca34 Fix error message for continuous aggregates
Several error messages for continuous aggregates are not following the
error message style guidelines at
https://www.postgresql.org/docs/current/error-style-guide.html

In particular, they do not write the hints and detailed messages as
full sentences.
2023-04-12 18:34:56 +02:00
Sven Klemm
f0623a8c38 Skip Ordered Append when only 1 child node is present
This is mostly a cosmetic change. When only 1 child is present there
is no need for ordered append. In this situation we might still
benefit from a ChunkAppend node here due to runtime chunk exclusion
when we have non-immutable constraints, so we still add the ChunkAppend
node in that situation even with only 1 child.
2023-04-12 13:19:16 +02:00
Sven Klemm
0595ff0888 Move type support functions into _timescaledb_functions schema 2023-04-12 12:48:34 +02:00
Sven Klemm
2d7eb18f24 Drop unused SQL functions
This patch drops the following internal SQL functions which were
unused:
  _timescaledb_internal.is_main_table(regclass);
  _timescaledb_internal.is_main_table(text, text);
  _timescaledb_internal.hypertable_from_main_table(regclass);
  _timescaledb_internal.main_table_from_hypertable(integer);
  _timescaledb_internal.time_literal_sql(bigint, regtype);
2023-04-12 11:00:18 +02:00
Ante Kresic
84b6783a19 Fix chunk status when inserting into chunks
While executing compression operations in parallel with
inserting into chunks (both operations which can potentially
change the chunk status), we could get into situations where
the chunk status would end up inconsistent. This change re-reads
the chunk status after locking the chunk to make sure it can
decompress data when handling ON CONFLICT inserts correctly.
2023-04-12 10:50:44 +02:00
Ante Kresic
54074f1fd4 Add more compression DML isolation tests
Verify that insertion into compressed chunks does not block
each other if the chunks is already partially compressed. Also
check that using the RETURNING clause works the same.
2023-04-11 17:30:08 +02:00
Ante Kresic
dc5bf3b32e Test compression DML with physical layout changes
These tests try to verify that changing physical layout
of chunks (either compressed or uncompressed) should
yield consistent results. They also verify index mapping
on compressed chunks is handled correctly.
2023-04-11 17:30:08 +02:00
Fabrízio de Royes Mello
9a466ca185 Silence WARNING after extension update
Commit 8afdddc2da added the first step for deprecating the old format
of Continuous Aggregate but just for PostgreSQL 15 and later versions.

During the extension update we emit a message about the deprecation but
this has being emited even if the user is using PostgreSQL versions
before 15.

Fixed it by emiting the WARNING just when PostgreSQL version is greater
or equal to 15.
2023-04-11 09:01:52 -03:00
Sven Klemm
04f43335de Move aggregate support function into _timescaledb_functions
This patch moves the support functions for histogram, first and last
into the _timescaledb_functions schema. Since we alter the schema
of the existing functions in upgrade scripts and do not change the
aggregates this should work completely transparently for any user
objects using those aggregates.
2023-04-11 13:11:07 +02:00
Konstantina Skovola
3814a3f351 Properly format license error hint
Commit 57fde383b3dddd0b52263218e65a0135981c2d34 changed the
messaging but did not format the error hint correctly.
This patch fixes the error hint.

Fixes #5490
2023-04-10 14:06:39 +03:00