3703 Commits

Author SHA1 Message Date
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
Alexander Kuzmenkov
066bcbed6d Rename row-by-row fetcher to COPY fetcher
This name better reflects its characteristics, and I'm thinking about
resurrecting the old row-by-row fetcher later, because it can be useful
for parameterized queries.
2022-10-14 23:04:27 +03:00
Bharathy
38878bee16 Fix segementation fault during INSERT into compressed hypertable.
INSERT into compressed hypertable with number of open chunks greater
than ts_guc_max_open_chunks_per_insert causes segementation fault.
New row which needs to be inserted into compressed chunk has to be
compressed. Memory required as part of compressing a row is allocated
from RowCompressor::per_row_ctx memory context. Once row is compressed,
ExecInsert() is called, where memory from same context is used to
allocate and free it instead of using "Executor State". This causes
a corruption in memory.

Fixes: #4778
2022-10-13 20:48:23 +05:30
Sven Klemm
8f5698f49d Show information about OOM killer in CI
Include OOM kill event logs into error printout. Previously these
would only be visible by inspecting the postgres log and looking
for killed by signal 9.
2022-10-11 18:23:14 +02:00
Markos Fountoulakis
e33bd89727 Adjust TAP tests permissions
Starting with PG15, default permissions on the public schema is
restricted for any non-superuser non-owner. Adjust TAP tests so as to
not fail with "permission denied for schema public".

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=b073c3cc
2022-10-11 17:37:05 +03:00
Sven Klemm
cc7ea8efd1 Fix ereport call in dist_copy for PG 12.0
ereport in PG 12.0 requires extra parenthesis around the auxiliary
function calls.
2022-10-11 09:04:42 +02:00
Alexander Kuzmenkov
459c365794 Ignore clang-format-14 changes in git blame 2022-10-10 18:13:23 +03:00
Alexander Kuzmenkov
fbe4d3c1df Fix a warning with clang 14
Mark the variable as used for asserts only.
2022-10-10 18:13:23 +03:00
Alexander Kuzmenkov
7758f5959c Update .clang-format for version 14
The only configuration we're missing is the newline for braces after
case labels. The rest of the differences looks like bugs/omissions of
the version 8 that we use now.

Require clang-format-14 in cmake and use it in the CI check. We can't
support versions earlier than 14 because they have some
formatting differences that can't be configured.
2022-10-10 17:12:36 +03:00
Alexander Kuzmenkov
30596c0c47 Batch rows on access node for distributed COPY
Group the incoming rows into batches on access node before COPYing to
data nodes. This gives 2x-5x speedup on various COPY queries to
distributed hypertables.

Also fix the text format passthrough, and prefer text transfer format
for text input to be able to use this passthrough. It saves a lot of
CPU on the access node.
2022-10-10 16:30:53 +03:00
Markos Fountoulakis
7600896a66 Fix libpq disconnect for PG15
Make sure the FATAL error message before the data node disconnects
is not lost when using PG15.

https://github.com/postgres/postgres/commit/618c1670
2022-10-10 12:21:33 +03:00
Sven Klemm
2defb2b0b3 Improve job_crash_log test
Older versions seens to have problems when undef is passed to
poll_query_until so we change the call to pass explicit query instead.
2022-10-10 10:01:43 +02:00
Sven Klemm
efbd8a94b2 Increase timeout to wait for cluster start
By default pg_isready only waits for 3 seconds before giving up
which is occasionally not enough in the windows tests. This patch
bumps the timeout up to 30 seconds which should be plenty to have
the cluster start up under all circumstances.
2022-10-10 08:48:00 +02:00
Fabrízio de Royes Mello
e0bbd4042a Fix missing upgrade/downgrade tests DDL validation
Recently we fixed a DDL error (#4739) after upgrading to 2.8.0 version
that surprisly the CI upgrade/dowgrade tests didn't complained during
the development of the feature (#4552).

Fixed it by adding an specific query in the `post.catalog.sql` script to
make sure we'll check all the constraints of our internal tables and
catalog.
2022-10-07 16:40:30 -03:00
Jan Nidzwetzki
2f739bb328 Post-release fixes for 2.8.1
Bumping the previous version and adding tests for 2.8.1.
2022-10-07 10:10:22 +02:00
Konstantina Skovola
ea1014fa61 Fix flaky bgw_custom test 2022-10-06 17:07:48 +02:00
Sven Klemm
45a8c0b5cf Improve formatting when printing coredump information
Add a newline between query and stacktrace when printing coredump
information to make copying the query easier.
2022-10-05 23:31:01 +02:00
Sven Klemm
d602c1fe2e Fix typo in homebrew workflow 2022-10-05 23:31:01 +02:00
Sven Klemm
d2f0c4ed20 Fix update script handling of bgw_job_stat
Update scripts should not use ADD/DROP/RENAME and always rebuild
catalog tables to ensure the objects are identical between new
install, upgrade and downgrade.
2022-10-05 23:31:01 +02:00
Fabrízio de Royes Mello
a76f76f4ee Improve size utils functions and views performance
Changed queries to use LATERAL join on size functions and views instead
of CTEs and it eliminate a lot of unnecessary projections and give a
chance for the planner to push-down predicates.

Closes #4775
2022-10-05 17:40:28 -03:00
Sven Klemm
8cda0e17ec Extend the now() optimization to also apply to CURRENT_TIMESTAMP
The optimization that constifies certain now() expressions before
hypertable expansion did not apply to CURRENT_TIMESTAMP even
though it is functionally similar to now(). This patch extends the
optimization to CURRENT_TIMESTAMP.
2022-10-05 20:46:30 +02:00
Jan Nidzwetzki
12b7b9f665 Release 2.8.1
This release is a patch release. We recommend that you upgrade at the
next available opportunity.

**Bugfixes**
* #4454 Keep locks after reading job status
* #4658 Fix error when querying a compressed hypertable with compress_segmentby on an enum column
* #4671 Fix a possible error while flushing the COPY data
* #4675 Fix bad TupleTableSlot drop
* #4676 Fix a deadlock when decompressing chunks and performing SELECTs
* #4685 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
* #4694 Change parameter names of cagg_migrate procedure
* #4698 Do not use row-by-row fetcher for parameterized plans
* #4711 Remove support for procedures as custom checks
* #4712 Fix assertion failure in constify_now
* #4713 Fix Continuous Aggregate migration policies
* #4720 Fix chunk exclusion for prepared statements and dst changes
* #4726 Fix gapfill function signature
* #4737 Fix join on time column of compressed chunk
* #4738 Fix error when waiting for remote COPY to finish
* #4739 Fix continuous aggregate migrate check constraint
* #4760 Fix segfault when INNER JOINing hypertables
* #4767 Fix permission issues on index creation for CAggs

**Thanks**
* @boxhock and @cocowalla for reporting a segfault when JOINing hypertables
* @carobme for reporting constraint error during continuous aggregate migration
* @choisnetm, @dustinsorensen, @jayadevanm and @joeyberkovitz for reporting a problem with JOINs on compressed hypertables
* @daniel-k for reporting a background worker crash
* @justinpryzby for reporting an error when compressing very wide tables
* @maxtwardowski for reporting problems with chunk exclusion and space partitions
* @yuezhihan for reporting GROUP BY error when having compress_segmentby on an enum column
2022-10-05 14:40:25 +02:00
Alexander Kuzmenkov
b259191dfe Add COSTS OFF to make test more stable
For some reason the cost estimates are different on my machine.
2022-10-05 14:15:05 +03:00
Konstantina Skovola
8a5e59b097 Fix flaky bgw_custom test
The test was flaky because the scheduler was launching the scheduled
jobs, therefore their next_start field could differ depending on
whether they had finished executing.
Fixed by not selecting the next_start field in alter_job calls,
when it is not of interest.

Fixes #4719
2022-10-05 11:22:35 +02:00
Jan Nidzwetzki
33e4e554d4 Ensure that internal users don't trigger workflows
This patch adds a membership check to the 'Waiting for Engineering'
workflow. The check ensures that the workflow is only triggered by
external users. Without this check, when someone from the database
engineering team responded to an issue, the "need-more-info" flag was
removed and the issue was erroneously moved to the "waiting for
engineering" column.
2022-10-04 21:48:48 +02:00
Bharathy
f1c6fd97a3 Continue compressing other chunks after an error
When a compression_policy is executed by a background worker, the policy
should continue to execute even if compressing or decompressing one of
the chunks fails.

Fixes: #4610
2022-10-04 22:00:13 +05:30
Dmitry Simonenko
ea5038f263 Add connection cache invalidation ignore logic
Calling `ts_dist_cmd_invoke_on_data_nodes_using_search_path()` function
without an active transaction allows connection invalidation event
happen between applying `search_path` and the actual command
execution, which leads to an error.

This change introduces a way to ignore connection cache invalidations
using `remote_connection_cache_invalidation_ignore()` function.

This work is based on @nikkhils original fix and the problem research.

Fix #4022
2022-10-04 10:50:45 +03:00
Sven Klemm
fa9d07f6a8 Add link to community forum to issue template chooser 2022-10-03 17:39:48 +02:00
Sven Klemm
eac3132b67 Migrate CI summary slack bot to eng-database 2022-10-03 17:09:09 +02:00
Sven Klemm
7a6ce372e7 Adjust pgspot CI check
Change the pgspot check to use downgrade_to_version instead of
update_from_version.
We use downgrade_to_version instead of update_from_version because
when the release PR for a new version has been merged to main
but the version is not tagged yet update_from will not exist yet.
In all other situations update_from_version and downgrade_to_version
should point to the same version.
2022-10-03 16:34:32 +02:00
Rafia Sabih
f7c769c684 Allow manual index creation in CAggs
The materialised hypertable resides in the _timescaledb.internal schema
which resulted in permission error at the time of manual index creation
by non super user. To solve this, it now switches to timescaledb user
before index creation of CAgg.

Fixes #4735
2022-09-30 07:55:38 -07:00
Konstantina Skovola
9bd772de25 Add interface for troubleshooting job failures
This commit gives more visibility into job failures by making the
information regarding a job runtime error available in an extension
table (`job_errors`) that users can directly query.
This commit also adds an infromational view on top of the table for
convenience.
To prevent the `job_errors` table from growing too large,
a retention job is also set up with a default retention interval
of 1 month. The retention job is registered with a custom check
function that requires that a valid "drop_after" interval be provided
in the config field of the job.
2022-09-30 15:22:27 +02:00
Sven Klemm
1d4b9d6977 Fix join on time column of compressed chunk
Do not allow paths that are parameterized on a
compressed column to exist when creating paths
for a compressed chunk.
2022-09-29 10:36:02 +02:00
Sven Klemm
940187936c Fix segfault when INNER JOINing hypertables
This fixing a segfault when INNER JOINing 2 hypertables that are
ordered by time.
2022-09-28 17:12:45 +02:00
Sven Klemm
d833293a52 Add missing ORDER BY clause to dist_move_chunk 2022-09-28 16:22:06 +02:00
Ante Kresic
cc110a33a2 Move ANALYZE after heap scan during compression
Depending on the statistics target, running ANALYZE on a chunk before
compression can cause a lot of random IO operations for chunks that
are bigger than the number of pages ANALYZE needs to read. By moving
that operation after the heap is loaded into memory for sorting,
we increase the chance of hitting cache and reducing disk operations
necessary to execute compression jobs.
2022-09-28 14:40:52 +02:00