1
0
mirror of https://github.com/timescale/timescaledb.git synced 2025-05-23 14:39:15 +08:00

4522 Commits

Author SHA1 Message Date
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
Sven Klemm
5b0a89bc62 Improve SkipScan unsupported node type error message
Improve the error message when we encounter unexpected node types by
printing the node name instead of the node id.
2024-02-05 11:13:15 +01:00
Nikhil
0791871e7e
Fix overflowing integer expression. ()
Fix potentially overflowing expression. Reported by Coverity.

Disable-check: force-changelog-file
2024-02-05 15:29:50 +05:30
Sven Klemm
cddb4e9578 Change internal default for decompress_chunk
The default for the function definition of decompress_chunk was already
changed in a previous patch. This patch also adjusts the internal
default, but since there was no way this could have been called it does
not affect the user-facing API.
2024-02-04 16:39:50 +01:00
Sven Klemm
435658524c Fix recompression ignoring partial compressed chunks
The recompression policy only recompresses unordered chunks which
will be rarely created but does not deal with partial chunks which
are the result of DML operations into compressed chunks.
2024-02-04 16:39:50 +01:00
Sven Klemm
9e737bc528 Fix wrong usage of PERFORM in update test script
PERFORM can only be used in PLpgSQL context and not SQL context.
2024-02-02 13:27:15 +01:00
Mats Kindahl
3296084aa5 Fix upload name on windows
Upload artifact name was using a matrix field that did not exist,
causing a duplicate upload artifact name.
2024-02-01 15:54:06 +01:00
Mats Kindahl
2650447019 Fix upload names for ABI tests
The names were not unique so two different jobs could have the same
name for the upload artifact.
2024-02-01 15:54:06 +01:00
Mats Kindahl
a292b2021d Update cache and download actions to node20 2024-02-01 15:54:06 +01:00
Mats Kindahl
248891131e Use checkout v3 for centos7
Also fix a version tag
2024-02-01 15:54:06 +01:00
Fabrízio de Royes Mello
b093749b45 Properly set job failure on compression policies
In  we changed the behavior of compression policies to continue
compressing chunks even if a failure happens in one of them.

The problem is if a failure happens in one or all the chunks the job is
marked as successful, and this is wrong because a failure happens so if
an exception occurs when compressing chunks we'll raise an exception at
the end of the procedure in order to mark the job as failed.
2024-02-01 10:59:47 -03:00
Alexander Kuzmenkov
d7239f30bd Fix UBSan failure in bulk text decompression
Fix missing alignment handling, and also buffer size problems. We were
not properly reporting the failures in the compression_algo tests, so
didn't notice these problems. Add part of tests from "vector text
predicates" PR to improve coverage.
2024-02-01 14:25:08 +01:00
Jan Nidzwetzki
7474eee3b4 Remove double initialization of time_bucket origin
The variable origin in ts_timestamptz_bucket was initialized two times.
This commit removes one of the initializations.
2024-02-01 14:18:58 +01:00
Sven Klemm
4a00434e9d Bump pgspot to 0.7.0
Use pgspot 0.7.0 in our CI which updates the parser used by pgspot to
the PG16 parser.
2024-02-01 11:24:26 +01:00
Nikhil Sontakke
2b8f98c616 Support approximate hypertable size
If a lot of chunks are involved then the current pl/pgsql function
to compute the size of each chunk via a nested loop is pretty slow.
Additionally, the current functionality makes a system call to get the
file size on disk for each chunk everytime this function is called.
That again slows things down. We now have an approximate function which
is implemented in C to avoid the issues in the pl/pgsql function.
Additionally, this function also uses per backend caching using the
smgr layer to compute the approximate size cheaply. The PG cache
invalidation clears off the cached size for a chunk when DML happens
into it. That size cache is thus able to get the latest size in a
matter of minutes. Also, due to the backend caching, any long running
session will only fetch latest data for new or modified chunks and can
use the cached data (which is calculated afresh the first time around)
effectively for older chunks.
2024-02-01 13:25:41 +05:30
Nikhil Sontakke
d86346fd48 Fix openssl issues on MacOSX on CI
Issues due to OpenSSL 3.2 seem to be resolved via components
installing 3.1.x. So, remove our temporary changes.

We also disable uploading of test stats till the next minor release
of PG on macOS.
2024-02-01 13:02:14 +05:30
Sven Klemm
1502bad832 Change boolean default value for compress_chunk and decompress_chunk
This patch changes those functions to no longer error by default when
the chunk is not the expected state, instead a warning is raised.
This is in preparation for changing compress_chunk to forward to
the appropriate operation depending on the chunk state.
2024-01-31 20:55:55 +01:00
Erik Nordström
101acb149a Fix compressed chunk not found during upserts
When inserting into a compressed chunk with an ON CONFLICT clause, and
there is a concurrent recompression of the chunk, an error can occur
due to a failed lookup of the compressed chunk.

The error happens because the chunk information is re-read from an
outdated cache holding a compressed chunk ID that no longer exists
after the chunk was recompressed (recompression effectively removes
the compressed chunk and creates it again).

Fix this issue by ensuring that the insert path only uses up-to-date
chunk metadata read _after_ the lock on the chunk was taken.
2024-01-31 17:07:26 +01:00
Erik Nordström
09be6df8a9 Reproduce "chunk not found" error during upserts
Add an isolation test that reproduces a "chunk not found" error that
happen during upserts on compressed chunks.
2024-01-31 17:07:26 +01:00
Mats Kindahl
ac12c43c64 Switch to node20 for github actions
See https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-01-31 16:09:33 +01:00
Alexander Kuzmenkov
bf20e5f970 Bulk decompression of text columns
Implement bulk decompression for text columns. This will allow us to use
them in the vectorized computation pipeline.
2024-01-31 14:03:01 +01:00
Alejandro Do Nascimento Mora
85b27b4f34 Fix create_hypertable referenced by fk succeeds
Foreign keys pointing to hypertables are not supported. Creating a
hypertable from a table referenced by foreign key succeeds, but it
leaves the referencing (child) table in a broken state, failing on every
insert with a `violates foreign key constraint` error.

To prevent this scenario, if a foreign key reference to the table exists
before converting it to a hypertable, the following error will be
raised:

```
cannot have FOREIGN KEY contraints to hypertable "<table_name>"
HINT: Remove all FOREIGN KEY constraints to table "<table_name>"
  before making it a hypertable.
```

Fixes 
2024-01-30 15:01:12 -03:00
Sven Klemm
8875c7a897 Refactor tsl_get_compressed_chunk_index_for_recompression
Refactor the compression to code to move the column map code
in a separate function and change tsl_get_compressed_chunk_index_for_recompression
to not initialize RowCompressor anymore.
2024-01-30 15:26:31 +01:00
Alexander Kuzmenkov
47e28a8ff9 Vectorize boolean operators
Implement vectorized computation of AND, OR and NOT operators in WHERE
clause.
2024-01-29 19:41:31 +01:00
Jan Nidzwetzki
b63fbad33d Add plan-time chunk exclusion for real-time CAggs
The watermark function for CAggs is declared as STABLE since the value
of the function changes after every CAgg refresh. The function
volatility prevents the planner from replacing the function invocation
with a constant value and executing plan time chunk exclusion. This
leads to high planning times on hypertables with many chunks.

This PR replaces the function invocation with a constant value to allow
plan time exclusion of chunks. We perform the replacement at plan time
instead of changing the function volatility to IMMUTABLE, because we
want to control the constification. Only queries that access the
underlying hypertable in a query (i.e., no queries like SELECT
cagg_watermark(...) without any FROM condition) are rewritten. This is
done to make sure that the query is properly invalidated when the
underlying table changes (e.g., the watermark is updated) and the query
is replanned on the subsequent execution.

Fixes: , 
Co-authored-by: Fabrizio de Royes Mello <fabriziomello@gmail.com>
2024-01-29 15:13:34 +01:00
Ante Kresic
285fd7c7e8 Limit tuple decompression during DML operations
This change introduces a GUC to limit the amount of tuples
that can be decompressed during an INSERT, UPDATE, or
DELETE on a compressed hypertable. Its used to prevent
running out of disk space if you try to decompress
a lot of data by accident.
2024-01-29 14:40:33 +01:00
Jan Nidzwetzki
d878b9ee29 Fix pathtarget adjustment for MergeAppend paths
The chunk-wise aggregation pushdown code creates a copy of the existing
paths; it copies the existing paths to create new ones with pushed-down
aggregates. However, the copy_merge_append_path function behaves
differently than other copy functions (e.g., copy_append_path); it
resets the pathtarget on the copy. This leads to a wrong pathlist and
crashes. This PR fixes the wrong pathtarget by setting it after the path
is copied.
2024-01-29 12:57:54 +01:00
Sven Klemm
50c757c6f1 Adjust .gitignore for transparent_decompression test files 2024-01-29 12:57:43 +01:00
Sven Klemm
83ff9662dc Verify compression configuration on compression rollup
Add a check to verify compression settings for chunks to be rolled
up are identical.
2024-01-25 16:43:47 +01:00
Sven Klemm
4934941f75 Remove restrictions for changing compression settings
This patch removes the restrictions preventing changing compression
settings when compressed chunks exist. Compression settings can now
be changed at any time and will not affect existing compressed chunks
but any subsequent compress_chunk will apply the changed settings.
A decompress_chunk/compress_chunk cycle will also compress the chunk
with the new settings.
2024-01-25 16:13:15 +01:00
Nikhil Sontakke
c715d96aa4 Don't dump unnecessary extension tables
Logging and caching related tables from the timescaledb extension
should not be dumped using pg_dump. Our scripts specify a few such
unwanted tables. Apart from being unnecessary, the "job_errors" had
some restricted permissions causing additional problems in pg_dump.

We now don't include such tables for dumping.

Fixes 
2024-01-25 12:01:11 +05:30
Konstantina Skovola
929ad41fa7 Fix now() plantime constification with BETWEEN
Previously when using BETWEEN ... AND additional constraints in a
WHERE clause, the BETWEEN was not handled correctly because it was
wrapped in a BoolExpr node, which prevented plantime exclusion.
The flattening of such expressions happens in `eval_const_expressions`
which gets called after our constify_now code.
This commit fixes the handling of this case to allow chunk exclusion to
take place at planning time.
Also, makes sure we use our mock timestamp in all places in tests.
Previously we were using a mix of current_timestamp_mock and now(),
which was returning unexpected/incorrect results.
2024-01-24 18:25:39 +02:00
Alexander Kuzmenkov
92e9009960 Vectorize more arithmetic functions
We didn't account for some permutations of types like comparing int4 to
int2.
2024-01-24 14:22:37 +01:00
Konstantina Skovola
942f1fb399 Fix OSM build failure
The commit  removed some restricted chunk operations, enabling
adding constraints to OSM chunks directly. This operation is blocked
on OSM chunks. The present commit ensures that adding a constraint
directly on an OSM chunk is blocked.
2024-01-23 17:07:47 +02:00
Ante Kresic
80f1b23738 Reduce index lock in segmentwise recompression
Segmentwise recompression grabbed an AccessExclusiveLock on
the compressed chunk index. This would block all read operations
on the chunk which involved said index. Reducing the lock to
ExclusiveLock would allow reads, removing blocks from other
ongoing operations.
2024-01-23 15:08:57 +01:00
Sven Klemm
0b23bab466 Include _timescaledb_catalog.metadata in dumps
This patch changes the dump configuration for
_timescaledb_catalog.metadata to include all entries. To allow loading
logical dumps with this configuration an insert trigger is added that
turns uniqueness conflicts into updates to not block the restore.
2024-01-23 12:53:48 +01:00
Jan Nidzwetzki
4cb7bacd17 Change GitHub token for changelog check
Since , the changelog script tries to access the
secrets.ORG_AUTOMATION_TOKEN. However, accessing secrets is not possible
for PRs. This PR changes the token to the default access token, which
is available in PRs and provides read access to the issue API.
2024-01-23 11:15:52 +01:00
Alexander Kuzmenkov
d7018953c1 Fix joins with compressed chunks
We couldn't use parameterized index scan by segmentby column on
compressed chunk, effectively making joins on segmentby unusable. We
missed this when bulk-updating test references for PG16. The underlying
reason is the incorrect creation of equivalence members for segmentby
columns of compressed chunk tables. This commit fixes it.
2024-01-23 10:18:05 +01:00
Sven Klemm
acd69d4cd2 Support all time_bucket variants in plan time chunk exclusion
Since the optional time_bucket arguments like offset, origin and
timezone shift the output by at most bucket width we can optimize
these similar to how we optimize the other time_bucket constraints.

Fixes 
2024-01-22 16:23:23 +01:00
Fabrízio de Royes Mello
a44a19b095 Remove some multinode leftovers from CAggs 2024-01-22 12:14:17 -03:00