4639 Commits

Author SHA1 Message Date
Nikhil Sontakke
20f422b26a Remove broken_tables test
This test file was created to handle repairing of hypertables that
had broken related metadata in the dimension_slice catalog tables.
Probably the test does not make sense today given that we have more
robust referential integrity in our catalog tables. Removing it now.
2024-04-08 11:04:28 +05:30
Jan Nidzwetzki
8d9b06294e Support for CAgg with origin/offset parameter
So far, we allowed only CAggs without origin or offset parameters in the
time_bucket definition. This commit adds support for the remaining
time_bucket variants.

Fixes #2265, Fixes #5453, Fixes #5828
2024-04-05 10:30:57 +02:00
Fabrízio de Royes Mello
52094a3103 Track job execution history
In #4678 we added an interface for troubleshoting job failures by
logging it in the metadata table `_timescaledb_internal.job_errors`.

With this PR we extended the existing interface to also store succeeded
executions. A new GUC named `timescaledb.enable_job_execution_logging`
was added to control this new behavior and the default value is `false`.

We renamed the metadata table to `_timescaledb_internal.bgw_job_stat_history`
and added a new view `timescaledb_information.job_history` to users that
have enough permissions can check the job execution history.
2024-04-04 10:39:28 -03:00
Mats Kindahl
034d577c96 Switch to official Slack API
The existing service does not seem to stable and does not work so
switch to using the official Spack API GitHub action instead.
2024-04-03 14:40:00 +02:00
Nikhil Sontakke
a9a033432d Fix a crash involving a view on a hypertable
The logic in chunk append path creation when a space dimension was
involved was crashing while checking for matches in the flattened out
children chunk lists. This has been fixed now.
2024-04-02 14:21:34 +05:30
Sven Klemm
2f1b27c2a3 Remove unneeded pg_locale.h include
This include will pull in header files from ICU which would result
in ICU being a build requirement for timescaledb.
2024-03-29 11:38:34 +01:00
Alexander Kuzmenkov
a3d03ea846
Vectorize text equality and LIKE (#6189)
This PR adds vectorized computation of text equality for deterministic
collations, and case-sensitive LIKE for UTF-8 database encoding.
2024-03-28 16:13:49 +00:00
Nikhil Sontakke
ea5c7f158d Fix deletes with subqueries and compression
For UPDATEs and DELETEs when a compressed chunk is involved, the code
decompresses the relevant data into the uncompressed portion of the
chunk. This happens during execution, so it's possible that if the
planner doesn't have a plan for the uncompressed chunk then we might
miss scanning out on those decompressed rows. We now check for the
possibility of a compressed chunk becoming partial during the planning
itself and tag on an APPEND plan on top of scans on the compressed and
uncompressed parts.
2024-03-28 17:37:57 +05:30
Fabrízio de Royes Mello
6b06c60ea4 Add wait_for_job_to_run to testsupport.sql
Several scheduler regression tests create the plpgsql function
`wait_for_job_to_run` with the same purpose of waiting for a given job
to execute or fail, so refactor the regression tests by adding it to the
testsupport.sql library.
2024-03-26 00:43:05 -03:00
Ante Kresic
24552be12d Fully recompress unordered compressed chunks
Recent changes switched recompression of unordered compressed
chunks to use segmentwise recompression which is designed to work
with partial chunks only. This change reverts that back to full
recompression.
2024-03-25 09:51:06 +01:00
Ante Kresic
5715029c35 Improve chunks status modification for consistency
Due to the chunk status being a bitmap, updating any of the flags
needs previous locking of the tuple to make sure nobody can update
the status from under us and cause lost updates. This change unifies
all the places were we change chunk status and makes this more explicit
so we don't run into concurrency issues due to updates.
2024-03-25 09:47:52 +01:00
Fabrízio de Royes Mello
9f39241645 Fix uploading Postgres log on Windows CI
We were not uploading the correct Postgres log to the CI artifacts, so
fixed it by setting the TEST_PG_LOG_DIRECTORY when building the
extension and using it properly when uploading the postmaster.log
artifact.
2024-03-20 17:58:48 -03:00
Jan Nidzwetzki
8beee08f43 Exclude OSM chunks from enabling autovaccum
Storage options can not be set for OSM chunks. Therefore, the need to be
excluded from resetting the autovaccum storage option.
2024-03-20 11:15:23 +01:00
Jan Nidzwetzki
c05d7306d4 Refactor parameter of invalidation_state_init
So far, the invalidation_state_init function used a loop to find the
proper CAgg bucket function. This PR refactors the parameter of the
function and passes the needed information directly.
2024-03-19 08:29:40 +01:00
Nikhil Sontakke
50cc8e3f3b Don't show osm chunk via show_chunks
Fix show_chunks to not to show the OSM chunk. In passing, also fix
a compilation error on macOS.
2024-03-19 11:22:17 +05:30
Matvey Arye
ebb2556ab3 Make compression use the defaults functions
Previously, we create functions to calculate default order by and
segment by values. This PR makes those functions be used by default
when compression is enabled. We also added GUCs to disable those
functions or to use alternative functions for the defaults calculation.
2024-03-18 12:35:27 -04:00
Ante Kresic
8a40e553de Remove stats update from incremental recompression
Compression size stats are formed during initial compression.
At that time, we know what the uncompressed stats were before
the operation and the compressed stats after. But during incremental
recompression, we are not decompressing the whole chunk thus we
cannot update those statistics. So far, we only updated compressed
stats and the tuple count. This ends up making the compression
ratio incorrect since we are not updating all the stats. Removing
any updates during incremental recompression will at least keep
the initial stats consistent which is better than partially updated
stats.
2024-03-14 11:11:15 +01:00
Alexander Kuzmenkov
ae9b83b5e8
Allow up to INT16_MAX rows per batch (#6734)
We're getting requests to make the number of rows per batch
configurable, so this PR makes some refactoring to make that easier.
E.g. it removes some large stack allocations and change width of
variables to accomodate this. It doesn't actually add an option to
change the compressed batch size yet.

The new potential upper limit is INT16_MAX rows per batch, because
dictionary compression uses signed int16 indexes. The actual target
compressed batch size is kept hardcoded at 1000 rows for now.

I also had to make some tweaks to memory management to avoid performance
regressions, but after that there are no changes in tsbench that I could
reproduce:
https://grafana.ops.savannah-dev.timescale.com/d/fasYic_4z/compare-akuzm?orgId=1&var-branch=All&var-run1=3331&var-run2=3341&var-threshold=0&var-use_historical_thresholds=true&var-threshold_expression=2.5%20%2A%20percentile_cont%280.90%29&var-exact_suite_version=false


Disable-check: force-changelog-file
2024-03-14 09:47:18 +00:00
Mats Kindahl
b28c8b30ec Build release builds with debug info
It is not possible to get anything sensible out of core dumps that do
not contain debug info, so make sure that release builds are built with
debug information by using `RelWithDebInfo`.
2024-03-14 10:03:57 +01:00
Pallavi Sontakke
95c7d480fd Remove multinode reference
From update smoke test.

Related to Issue https://github.com/timescale/eng-database/issues/565

So, we no more need update-test-patch for dev-cloud update pre-release tests.
2024-03-14 13:13:34 +05:30
Jan Nidzwetzki
95baf1e6f3 Unify dimension min handling
PR #6737 introduced a new function to determine the min value for a
given data type. This patch uses the function in a further place.
2024-03-14 08:21:10 +01:00
Jan Nidzwetzki
5ac02241c2 Move cagg_invalidation to solo tests
The cagg_invalidation test stops the background workers and performs
tests with invalidations. However, they the test was running in a
parallel group, and background workers could be activated by other
tests, leading to flaky test behavior. This PR moves the
cagg_invalidation tests to the solo tests.
2024-03-14 08:09:11 +01:00
Jan Nidzwetzki
8dcb6eed99 Populate CAgg bucket catalog table for all CAggs
This changes the behavior of the CAgg catalog tables. From now on, all
CAggs that use a time_bucket function create an entry in the catalog
table continuous_aggs_bucket_function. In addition, the duplicate
bucket_width attribute is removed from the catalog table continuous_agg.
2024-03-13 16:40:56 +01:00
Jan Nidzwetzki
8433e3b559 Exclude is_sparse_index_type in non assert builds
PR #6705 introduces the function is_sparse_index_type. However, it is
only used for assert checking. If no assets are checked, the function is
unused, and some compilers error out. This PR includes the function only
if asserts are checked.
2024-03-13 13:38:58 +01:00
Fabrízio de Royes Mello
3ec04e1a1d Make CAgg error message more clear
When creating a Continuous Aggregate we can only reference the primary
hypertable dimension column on the `time_bucket` function, so reworded a
bit the error message to be more clear.
2024-03-13 08:11:01 -03:00
Jan Nidzwetzki
8e6994b4be Log CAgg refresh details in BGW
Currently, when a CAgg is refreshed using a background worker, only the
refresh invocation is logged. However, the details of the refresh, such
as the number of individual ranges that are refreshed, are not logged.
This PR changes the log level for these details in background workers to
INFO, to ensure the information is captured.
2024-03-13 07:59:03 +01:00
Jan Nidzwetzki
06f08c5b25 Convert max materializations setting to GUC
PR #2926 introduced a session-based configuration parameter for the CAgg
refresh behavior. If more individual refreshes have to be carried out
than specified by this setting, a refresh for a larger window is
performed.

It is mentioned in the original PR that this setting should be converted
into a GUC later. This PR performs the proposed change.
2024-03-12 16:57:30 +01:00
Alexander Kuzmenkov
e30699101b
Add minmax sparse indexes when compressing columns with btree indexes (#6705)
The decision to add a minmax sparse index is made every time when the
compressed chunk is created (full decompression followed by compression)
based on the currently present indexes on the hypertable. No new chunk
compression settings are added.

No action is required on upgrade, but the feature is not enabled on
existing chunks. The minmax index will be added when the chunk is fully
decompressed and compressed.

No action is required on downgrade, we ignore the unknown metadata
columns. They will be removed when the chunk is fully decompressed and
compressed.

The potential drawback of this feature is increasing the storage
requirements for the compressed chunk table, but it is normally only a
few percent of the total compressed data size. It can be disabled with
the GUC `timescaledb.auto_sparse_indexes`.

Here's a small example of this feature in action:
https://gist.github.com/akuzm/84d4b3b609e3581768173bd21001dfbf
Note that the number of hit buffers is reduced almost 4x.
2024-03-12 10:59:38 +00:00
Sven Klemm
3bb331860d Allow DROP CONSTRAINT on compressed hypertables
Removing constraints is always safe so there is no reason to block it on
compressed hypertables. Adding constraints is still blocked for
compressed hypertables as verifying of constraints currently requires
decompressed hypertable.
2024-03-11 11:59:18 +01:00
Jan Nidzwetzki
67ad085d18 Remove autovacuum setting from compressed chunks
In old TSDB versions, we disabled autovacuum for compressed chunks to
keep the statistics. However, this restriction was removed in #5118, but
no migration was performed to reset the custom autovacuum setting for
existing chunks.
2024-03-08 15:10:21 +01:00
Mats Kindahl
20a6b0a21b Fix JSON format for message
The JSON format was not correct for the generated message, so this
commit fixes that.
2024-03-07 16:13:16 +01:00
Nikhil Sontakke
6b819de329 Fix error in show_chunks
If "created_after/before" is used with a "time" type partitioning
column then show_chunks was not showing appropriate list due to a
mismatch in the comparison of the "creation_time" metadata (which is
stored as a timestamptz) with the internally converted epoch based
input argument value. This is now fixed by not doing the unnecessary
conversion into the internal format for cases where it's not needed.

Fixes #6611
2024-03-07 19:04:00 +05:30
Mats Kindahl
a8666d0105 Fix URL reference for event
The field reference for the event URL was wrong.
2024-03-07 14:32:25 +01:00
Mats Kindahl
c07decfe94 Check for missing memory context switch back
If memory context is switched temporarily and there is no switch back,
it will cause strange errors.

This adds a Coccinelle rule that checks for a case where the memory
context is saved in a temporary variable but this variable is not used
to switch back to the original memory context.

Co-authored-by: Fabrízio de Royes Mello <fabrizio@timescale.com>
2024-03-07 13:12:46 +01:00
Mats Kindahl
e5b5e437ab Fix security issue notification
The wrong field was used when checking if the issue was opened with or
labeled as a security ussue.
2024-03-07 13:09:56 +01:00
Fabrízio de Royes Mello
898f18bfb2 Add handler functions for Datum/Bools arrays
When updating catalog tables we rely on low level functions instead of
SQL statements and in order to read/write data from/to those tables we
frequent do something like:

```CPP
Datum values[natts] = { 0 };
bool nulls[natts] = { false };
char *char_value = "foo";

if (char_value != NULL)
    values[AttrNumberGetAttrOffset(text_value_offset)] =
        PointerGetDatum(cstring_to_text(char_value);
else
    null[AttrNumberGetAttrOffset(char_value_offset)] = true;
```

So instead of using a pair of Datum and bool arrays we'll replace it by
using arrays of `NullableDatum` that contains both members and introduce
some accessor functions to encapsulate the logic to fill the proper
values, like:

```CPP
ts_datum_set_text(int index, NullableDatum *datums, text *value);
ts_datum_set_bool(int index, NullableDatum *datums, bool value);
```

We also introduce a new `ts_heap_form_tuple` that essentially to the
same as Postgres `heap_form_tuple` but using array of `NullableDatum`
instead of Datum and bool arrays.

In this first commit we added only the necessary accessor functions to
refactor the existing `create_cagg_validate_query_datum` as example.
More accessor functions to deal with other C types should be introduced
in the future.
2024-03-07 09:01:36 -03:00
Jan Nidzwetzki
30d4bc0744 Remove unused multi-node related error codes
This patch removes a few unused error codes that belong to the removed
multi-node implementation.
2024-03-06 14:56:26 +01:00
Alexander Kuzmenkov
7d6173b431
Simplification and cleanup of decompression planning (#6731)
This PR renames some things in preparation to cost changes from
https://github.com/timescale/timescaledb/pull/6550

Also simplifies path creation for partial chunks, improving some plans
(now index scans are used instead of sort).
2024-03-06 11:30:04 +00:00
Fabrízio de Royes Mello
119d54129c Use INVALID_HYPERTABLE_ID constant when necessary
Instead of checking an invalid hypertable id against an arbitrary
integer number (in this case zero) use the existing constant
INVALID_HYPERTABLE_ID.
2024-03-06 07:38:24 -03:00
Fabrízio de Royes Mello
dcb68ce230 Refactor returning time dimension MINIMUM value
Encapsulate the logic for getting the MINIMUM value of a time dimension
for a Continuous Aggregate in a single place instead of spread the logic
everywhere that can lead to wrong usage specially because there are a
difference between fixed and variable size buckets.
2024-03-06 07:37:47 -03:00
Jan Nidzwetzki
b87aada776 Remove unused enable_async_append GUC
Remove the unused timescaledb.enable_async_append GUC.
2024-03-06 11:33:08 +01:00
Alexander Kuzmenkov
8a9ba06ef9
Allow multi-commit PRs with squash auto-merge (#6733)
It's convenient to squash the cleanup commits using the GitHub
interface, but currently the PR validation prevents the squash merge
from succeeding. Fix this.
2024-03-06 09:48:37 +00:00
Fabrízio de Royes Mello
b719787aa6 Disable homebrew automatic dependency upgrades
Setting the HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 when using `brew
install` will turn off the automatic dependency upgrade when using this
command.

Reference:
https://docs.brew.sh/Manpage#install-options-formulacask-
2024-03-06 05:33:26 -03:00
Jan Nidzwetzki
c0a3369c96 Fix CAgg migration with custom settings
The CAgg migration path contained two bugs. This PR fixes both. A typo
in the column type prevented 'timestamp with time zone' buckets from
being handled properly. In addition, a custom setting of the datestyle
could create errors during the parsing of the generated timestamp
values.

Fixes: #5359
2024-03-05 14:20:08 +01:00
Jan Nidzwetzki
2858110f05 Fix NULL start value handling in CAgg refresh
The CAgg refresh job did not handle the NULL value of start_offset for a
time_bucket function with a variable width properly. This problem has
led to the creation of invalid invalidation records and 'timestamp out
of range' errors during the next refresh.

Fixes: #5474
2024-03-05 08:33:24 +01:00
Fabrízio de Royes Mello
a1cd7c45f6 Fix constify cagg_watermark using window functions
When querying a realtime Continuous Aggregate using window functions the
new planner optimization to constify the `cagg_watermark` function call
is not working because we're checking for window function usage on the
query tree but actually this is a current limitation when creating a new
Continuous Aggregate, but users can use window functions when querying
it.

Fixed it by removing the check for `query->hasWindowFuncs` to prevent
the process of constification of the `cagg_watermak` function call.

Fixes #6722
2024-03-04 07:58:55 -03:00
Sven Klemm
9f2d4e983e Remove obsolete update test files
The only relevant update test versions are v7 and v8 all previous
versions are no longeri used in any supported update path so we can
safely remove those files.
2024-03-04 09:40:10 +01:00
Sven Klemm
c87be4ab84 Remove get_chunk_colstats and get_chunk_relstats
These 2 functions were used in the multinode context and are no longer
used now.
2024-03-03 23:14:02 +01:00
Sven Klemm
5d63aea2b3 Remove debug_optimizer_flags
This was only used in multinode and is now dead code.
2024-03-03 22:30:52 +01:00
Sven Klemm
fe06eddbf2 Refactor update test
Currently the update test is quite inconvenient to run locally and also
inconvenient to debug as the different update tests all run in their own
docker container. This patch refactors the update test to no longer
require docker and make it easier to debug as it will run in the
local environment as determined by pg_config.
This patch also consolidates update/downgrade and repair test since
they do very similar things and adds support for coredump stacktraces to
the github action and removes some dead code from the update tests.
Additionally the versions to be used in the update test are now
determined from existing git tags so the post release patch no longer
needs to add newly released versions.
2024-03-03 08:29:15 +01:00