3558 Commits

Author SHA1 Message Date
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
Ante Kresic
9c819882f3 Increase memory usage for compression jobs
When compressing larger chunks, compression sort tends to use
temporary files since memory limits (`work_mem`) are usually
pretty small to fit all the data into memory. On the other hand,
using `maintenance_work_mem` makes more sense since its generally
safer to use a larger value without impacting general resource usage.
2022-09-28 14:40:52 +02:00
Mats Kindahl
c0e193dd81 Keep locks after reading job status
When reading the job status table `bgw_job_stat` and after that
updating it, locks where released after the read, allowing a competing
session to update the job status and trigger a concurrent update error
either in a session doing the update or in the scheduler. Since the
scheduler does not recover after aborting with an error, this caused
the background worker subsystem to stop and not start new jobs.

This commit fixes this by upgrading `RowExclusiveLock` to
`ShareRowExclusiveLock` to ensure that not two sessions tries to update
the row at the same time, remove an initial speculative lock
that are taken when a job status row can be added, and also keeps the
lock until the end of the transaction to prevent other sessions to
update. Since these updating transactions are short, it should not
cause other threads to block long.

Fixes #4293
2022-09-28 10:41:06 +02:00
Bharathy
f6dd55a191 Hypertable FK reference to partitioned table
Consider a hypertable which has a foreign key constraint on a
referenced table, which is a parititioned table. In such case, foreign
key constraint is duplicated for each of the partitioned table. When
we insert into a hypertable, we end up checking the foreign key
constraint multiple times, which obviously leads to foreign key
constraint violation. Instead we only check foreign key constraint of
the parent table of the partitioned table.

Fixes #4684
2022-09-27 21:09:05 +05:30
Mats Kindahl
244b3e637c Move perltidyrc to root
To allow perltidy to be used from editors and IDEs, the perltidyrc file
is moved from `scripts/perltidyrc` to `.perltidyrc`. This will allow
editors and IDEs to quickly find the style file in the root of the
repository, where `perltidy` normally searches for the style file.

The workflow is then updated to use the new location, and the two
options `--backup-file-extension` and `--backup-and-modify-in-place`
are moved to the workflow file to allow editors and IDEs to use
whatever method they find useful to process the file.
2022-09-26 17:27:16 +02:00
Alexander Kuzmenkov
6011c1446e Fix error when waiting for remote COPY to finish
Pass proper flags to WaitLatchOrSocket, and fix the swapped up
arguments.
2022-09-23 13:46:03 +03:00
Markos Fountoulakis
9d0d159ac1 Port perl tests to support PG15
Port the timescaledb perl tests and the corresponding infrastructure to
support the new perl namespace introduced in PG15.

https://github.com/postgres/postgres/commit/b3b4d8e6
2022-09-23 11:40:48 +03:00
Fabrízio de Royes Mello
893faf8a6b Fix Continuous Aggregate migration policies
After migrate a Continuous Aggregate from the old format to the new
using `cagg_migrate` procedure we end up with the following problems:
* Refresh policy is not copied from the OLD to the NEW cagg;
* Compression setting is not copied from the OLD to the NEW cagg.

Fixed it by properly copying the refresh policy and setting the
`timescaledb.compress=true` flag to the new CAGG.

Fix #4710
2022-09-22 17:38:21 -03:00
Sven Klemm
2529ae3f68 Fix chunk exclusion for prepared statements and dst changes
The constify code constifying TIMESTAMPTZ expressions when doing
chunk exclusion did not account for daylight saving time switches
leading to different calculation outcomes when timezone changes.
This patch adds a 4 hour safety buffer to any such calculations.
2022-09-22 18:16:20 +02:00
Fabrízio de Royes Mello
217f514657 Fix continuous aggregate migrate check constraint
Instances upgraded to 2.8.0 will end up with a wrong check constraint
in catalog table `continuous_aggregate_migrate_plan_step`.

Fixed it by removing and adding the constraint with the correct checks.

Fix #4727
2022-09-22 11:33:29 -03:00
Jan Nidzwetzki
4cb38350c6 Change project management GH action
In af8e3c6b12035dd45bc7bf61e9420489cfa56eaa, an GitHub action to assign
issues to a project column has been introduced. However, this action
does not work with organization-wide projects. This patch replaces the
used project management action with a more recent one.
2022-09-22 15:45:35 +02:00
Jan Nidzwetzki
de30d190e4 Fix a deadlock in chunk decompression and SELECTs
This patch fixes a deadlock between chunk decompression and SELECT
queries executed in parallel. The change in
a608d7db614c930213dee8d6a5e9d26a0259da61 requests an AccessExclusiveLock
for the decompressed chunk instead of the compressed chunk, resulting in
deadlocks.

In addition, an isolation test has been added to test that SELECT
queries on a chunk that is currently decompressed can be executed.

Fixes #4605
2022-09-22 14:37:14 +02:00
Jan Nidzwetzki
5600fc06d6 Updated the text of the stalebot
This PR improves the text of the stalebot and makes it clearer who is
addressed by the message.
2022-09-21 12:10:18 +02:00
Sven Klemm
7508d66639 Fix gapfill function signature
Very recent compilers will warn about function pointers with empty
argument list. While currently in C func() means a function with
an unspecified argument list the next version of the C standard will
change this to mean func(void).
2022-09-21 11:31:51 +02:00
Jan Nidzwetzki
db66a194b2 Fix an ereport syntax error when using PG 12.0
Since PG 12.3, the syntax of the ereport() function has changed
slightly. The change 97a603fe5c5ba25aa6e4e596fd7da7a401051d7b introduces
an ereport() call that only works using newer PG versions. This PR
changes the ereport() call to a PG 12.0 compatible syntax.
2022-09-20 15:45:20 +02:00
Jan Nidzwetzki
b451f0c521 Update the name of the automation token
We now have an organization-wide token for automation. This patch
changes the name in existing Github actions accordingly.
2022-09-19 16:07:01 +02:00
Jan Nidzwetzki
a4d9c9fd69 Fix CI coredump information print
The patch #4714 introduces the extraction of the running query from a
coredump by calling gdb with two commands. These commands are separated
by a newline character. This character may not always be correctly
converted to a new line before being processed by gdb, resulting in the
following error:

Invalid character '\' in expression.

This PR ensures the proper handling of the newline character.
2022-09-19 14:45:32 +02:00
Mats Kindahl
af8e3c6b12 Update procedural.yml
Fix the 'Waiting for Engineering' job. Issues that contain the label
'need-more-info' that receive an issue_comment are automatically
moved to the 'Waiting for Engineering' column on the bug board and
the 'need-more-info' is removed.
2022-09-19 11:15:14 +02:00
Konstantina Skovola
97a603fe5c Remove support for procedures as custom checks
Procedures doing their own transaction handling could lead to errors
or even crashes.

Fixes #4703
2022-09-19 08:39:23 +02:00
Markos Fountoulakis
042735f1f5 Fix vacuum_set_xid_limits_compat() macro
Fix an error in the PG15 portion of the vacuum_set_xid_limits_compat()
preprocessor macro.
2022-09-17 13:25:39 +03:00
Bharathy
d00a55772c error compressing wide table
Consider a compressed hypertable has many columns (like more than 600 columns).
In call to compress_chunk(), the compressed tuple size exceeds, 8K which causes
error as "row is too big: size 10856, maximum size 8160."

This patch estimates the tuple size of compressed hypertable and reports a
warning when compression is enabled on hypertable. Thus user gets aware of
this warning before calling compress_chunk().

Fixes #4398
2022-09-17 11:24:23 +05:30
Sven Klemm
ffd9dfb7eb Fix assertion failure in constify_now
The code added to support VIEWs did not account for the fact that
varno could be from a different nesting level and therefore not
be present in the current range table.
2022-09-16 17:40:03 +02:00
Sven Klemm
85d0e16a98 Fix flaky pg_dump test
Use DROP DATABASE WITH(FORCE) to drop the database in pg_dump test
since occasionally there would still be connections to the database
leading to test failures. Unfortunately PG12 does not support that
syntax so we have to drop without that option on PG12.
2022-09-16 15:01:31 +02:00
Sven Klemm
1cb3edddc1 Fix bgw_db_scheduler regresscheck configuration
Recent refactoring changed bgw_db_scheduler to also be run on
non-Debug builds. Adjust the configuration so it is only included
for debug builds.
2022-09-16 13:05:48 +02:00
Sven Klemm
3e1ce8c34a Include running query in CI coredump information
Pretty print the active query during a coredump when printing the
stacktrace for a coredump.
2022-09-16 13:05:48 +02:00
Nikhil Sontakke
7aadf1332f Fix some clang compile warnings
Local compilation of timescaledb fails on MaCOSx with clang version
11.0.0. Fixes for a couple of warnings.
2022-09-16 14:29:57 +05:30
Alexander Kuzmenkov
fee27484ce Do not use row-by-row fetcher for parameterized plans
We have to prepare the data node statement in this case, and COPY
queries don't work with prepared statements.
2022-09-15 22:59:06 +03:00
Sven Klemm
424f6f7648 Remove database port from test output
Don't include the used database ports into test output as this
will lead to failing tests when running against a local instance
or against a preconfigured cloud instance.
2022-09-15 07:56:12 +02:00
Sven Klemm
1642750e47 Remove multiple PG configurations from regresscheck-t
Using multiple different configurations in a single target will
not work when running against a local instance or when running
against a preconfigured cloud instance. With recent adjustments
to the test cleanup this should not be needed anymore and if we
really need different configuration we should make it a separate
target to make it compatible with instances configured outside
of pg_regress.
2022-09-15 07:56:12 +02:00
Sven Klemm
cea1a21c01 Improve SKIPS handling in regression tests
This patch changes the regression test schedule generation to only
completely rebuild the schedule when TESTS is specified. In all
other cases the existing schedule is amended. This means any
parallelity present in the cmake generated schedule will be kept.
2022-09-14 20:15:43 +02:00
Sven Klemm
063bfcfef9 Fix pgspot update script check
Previously the pgspot call used in CI did not properly check the
update script. Unsafe function creations for functions with changed
signatures could go undetected in the update script.
2022-09-14 16:22:41 +02:00
Konstantina Skovola
3b3681858d Remove test case causing bgw_custom crash
Patch #4425 introduced regression test failures, namely, a crash
in function `ts_bgw_job_update_by_id`. The failures are due to the
COMMIT statement in the custom check procedure. This patch removes
that particular test case from bgw_custom.
2022-09-14 16:24:28 +03:00
Sven Klemm
0144c75b3f Remove flaky test from bgw_db_scheduler
The out of background worker test in bgw_db_scheduler is flaky and
fails very often, especially in the 32bit environment and on windows.
This patch removes that specific test from bgw_db_scheduler. If we
want to test this specific part of the scheduler this should be
better rewritten in an isolation test.
2022-09-14 14:44:23 +02:00
Mats Kindahl
88e2f24ea3 Add automation for waiting on author
If an issue is labeled with `needs-more-info` it is automatically
considered as waiting for author and we should move it to the column
for that.
2022-09-14 09:29:42 +02:00
Fabrízio de Royes Mello
02ad4f6b76 Change parameter names of cagg_migrate procedure
Removed the underline character prefix '_' from the parameter names of
the procedure `cagg_migrate`. The new signature is:

cagg_migrate(
    IN cagg regclass,
    IN override boolean DEFAULT false,
    IN drop_old boolean DEFAULT false
)
2022-09-13 17:22:27 -03:00
Fabrízio de Royes Mello
6ecefff93e Add CAGG migration permission tests
Timescale 2.8 released a migration path from the old format of
Continuous Aggregate to the new format (#4552).

Unfortunately it lacks of proper tests when a non-superuser execute the
migration. For a non-superuser execute the migration properly it
requires SELECT/INSERT/UPDATE permissions in some catalog objects:
* _timescaledb_catalog.continuous_agg_migrate_plan
* _timescaledb_catalog.continuous_agg_migrate_plan_step
* _timescaledb_catalog.continuous_agg_migrate_plan_step_step_id_seq

Improved the regression tests to cover the lack of permissions in the
catalog objects for non-superusers.
2022-09-12 17:04:59 -03:00
Sven Klemm
d2baef3ef3 Fix planner chunk exclusion for VIEWs
Allow planner chunk exclusion in subqueries. When we decicde on
whether a query may benefit from constifying now and encounter a
subquery peek into the subquery and check if the constraint
references a hypertable partitioning column.

Fixes #4524
2022-09-12 17:29:14 +02:00
Bharathy
b869f91e25 Show warnings during create_hypertable().
The schema of base table on which hypertables are created, should define
columns with proper data types. As per postgres best practices Wiki
(https://wiki.postgresql.org/wiki/Don't_Do_This), one should not define
columns with CHAR, VARCHAR, VARCHAR(N), instead use TEXT data type.
Similarly instead of using timestamp, one should use timestamptz.
This patch reports a WARNING to end user when creating hypertables,
if underlying parent table, has columns of above mentioned data types.

Fixes #4335
2022-09-12 18:47:47 +05:30
Alexander Kuzmenkov
4e47302c2c Speed up chunk search by restriction clauses
We don't have to look up the dimension slices for dimensions for which
we don't have restrictions.

Also sort chunks by ids before looking up the metadata, because this
gives more favorable table access patterns (closer to sequential).

This fixes a planning time regression introduced in 2.7.
2022-09-12 13:44:18 +03:00
Sven Klemm
a26a5974dc Improve space constraint exclusion datatype handling
This patch adjusts the operator logic for valid space dimension
constraints to no longer look for an exact match on both sides
of the operator but instead allow mismatched datatypes.

Previously a constraint like `col = value` would require `col`
and `value` to have matching datatype with this change `col` and
`value` can be different datatype as long as they have equality
operator in btree family.

Mismatching datatype can happen commonly when using int8 columns
and comparing them with integer literals. Integer literals default
to int4 so the datatypes would not match unless special care has
been taken in writing the constraints and therefore the optimization
would never apply in those cases.
2022-09-11 10:57:54 +02:00
Sven Klemm
f27e627341 Fix chunk exclusion for space partitions in SELECT FOR UPDATE queries
Since we do not use our own hypertable expansion for SELECT FOR UPDATE
queries we need to make sure to add the extra information necessary to
get hashed space partitions with the native postgres inheritance
expansion working.
2022-09-11 10:57:54 +02:00
Sven Klemm
6de979518d Fix compression_chunk_size primary key
The primary key for compression_chunk_size was defined as chunk_id,
compressed_chunk_id but other places assumed chunk_id is actually
unique and would error when it was not. Since it makes no sense
to have multiple entries per chunk since that reference would be
to a no longer existing chunk the primary key is changed to chunk_id
only with this patch.
2022-09-08 22:28:20 +02:00
Alexander Kuzmenkov
8e4dcddad6 Make the copy_memory_usage test less flaky
Increase the failure threshold.
2022-09-08 22:13:18 +03:00
Sven Klemm
d65cad94e3 Reorganize gapfill header files
Combine gapfill header files to only have gapfill.h and
gapfill_internal.h and make C files globally unique.
2022-09-07 16:37:53 +02:00
Sven Klemm
b34b91f18b Add timezone support to time_bucket_gapfill
This patch adds a new time_bucket_gapfill function that
allows bucketing in a specific timezone.

You can gapfill with explicit timezone like so:
`SELECT time_bucket_gapfill('1 day', time, 'Europe/Berlin') ...`

Unfortunately this introduces an ambiguity with some previous
call variations when an untyped start/finish argument was passed
to the function. Some queries might need to be adjusted and either
explicitly name the positional argument or resolve the type ambiguity
by casting to the intended type.
2022-09-07 16:37:53 +02:00
Markos Fountoulakis
698084c0e1 Fix bad TupleTableSlot drop
PostgreSQL 15 exposed a use after free bug that went undetected in
previous versions.
2022-09-06 17:08:11 +03:00