2643 Commits

Author SHA1 Message Date
Erik Nordström
0c27dfaa78 Ignore PostgreSQL's timetz test
PostgreSQL's `timetz` test fails outside of daylight savings. The
test is ignored until fixed in PostgreSQL (likely to happen in
12.5).
2020-11-03 11:39:03 +01:00
gayyappan
8b8b318fe0 Add test for continuous agg policies
Add mock timestamp support for subtract_from_now.
Use mock timestamp to execute cont. agg policies for
date and timestamp based tables.
2020-11-02 11:29:22 -05:00
Mats Kindahl
2cf3af1eb6 Fix dist_hypertable test for parallel execution
Change database names to be unique over the test suite by adding the
test database name in front of the created database names in the test.
This will allow the test to be executed in parallel with other tests
since it will not have conflicting databases in the same cluster.

Previously, there were a few directories created for tablespaces, but
this commit changes that to create one directory for each test where
the tablespace can be put. This is done by using a directory prefix for
each tablespace and each test should then create a subdirectory under
that prefix for the tablespace. The commit keeps variables for the old
tablespace paths around so that old tests work while transitioning to
the new system.
2020-10-21 15:28:58 +02:00
Mats Kindahl
e9cb14985e Read function name dynamically
The function name is hard-coded in some cases in the C function, so
this commit instead define and use a macro that will extract the
function name from the `fcinfo` structure. This prevents mismatches
between the hard-coded names and the actual function name.

Closes #2579
2020-10-21 15:03:32 +02:00
Sven Klemm
7c7b4f995c Fix distributed_exec create statement 2020-10-21 01:30:01 +02:00
Sven Klemm
374c405db3 Add 2.0.0-rc2 to update tests 2020-10-21 01:30:01 +02:00
Brian Rowe
525e821055 Add missing increment for PG11 decompression
There is a bug in some versions of PG11 where ANALYZE was not
calling CommandCounterIncrement.  This is causing us to fail to
update pg_class statistics during compression for those versions.
To work around this, this change adds an explicit
CommandCounterIncrement call after ExecVacuum in PG11.

Fixes #2581
2020-10-20 11:54:35 -07:00
Sven Klemm
709ed0d4d0 Release 2.0.0-rc2
This release candidate contains bugfixes since the previous release candidate.

**Minor Features**
* #2520 Support non-transactional distibuted_exec

**Bugfixes**
* #2307 Overflow handling for refresh policy with integer time
* #2503 Remove error for correct bootstrap of data node
* #2507 Fix validation logic when adding a new data node
* #2510 Fix outer join qual propagation
* #2514 Lock dimension slices when creating new chunk
* #2515 Add if_attached argument to detach_data_node()
* #2517 Fix member access within misaligned address in chunk_update_colstats
* #2525 Fix index creation on hypertables with dropped columns
* #2543 Pass correct status to lock_job
* #2544 Assume custom time type range is same as bigint
* #2563 Fix DecompressChunk path generation
* #2564 Improve continuous aggregate datatype handling
* #2568 Change use of ssl_dir GUC
* #2571 Make errors and messages conform to style guide
* #2577 Exclude compressed chunks from ANALYZE/VACUUM
2020-10-20 18:41:36 +02:00
Brian Rowe
8a11b022bc Exclude compressed chunks from ANALYZE/VACUUM
This change makes sure that ANALYZE and VACUUM commands run without
any relations will not clear the stats on compressed chunks that
were saved at compression time.  It also will skip any distributed
tables.

Fixes #2576
2020-10-20 09:18:39 -07:00
Erik Nordström
3cf9c857c4 Make errors and messages conform to style guide
Errors and messages are overhauled to conform to the official
PostgreSQL style guide. In particular, the following things from the
guide has been given special attention:

* Correct capitalization of first letter: capitalize only for hints,
  and detail messages.
* Correct handling of periods at the end of messages (should be elided
  for primary message, but not detail and hint messages).
* The primary message should be short, factual, and avoid reference to
  implementation details such as specific function names.

Some messages have also been reworded for clarity and to better
conform with the last bullet above (short primary message). In other
cases, messages have been updated to fix references to, e.g., function
parameters that used the wrong parameter name.

Closes #2364
2020-10-20 16:49:32 +02:00
Sven Klemm
dc913ef0d4 Fix DecompressChunk path generation
The non-parallel pathes generated by DecompressChunk were
incorrectly marked as parallel_safe even when the child scan
was not parallel aware. Leading to incorrect query results
when those pathes were used in a parallel plan.
Additionaly DecompressChunk code didnt set total_table_pages on
PlannerInfo leading to an assertion failure in BitmapHeapscan
path creation.
2020-10-19 22:10:12 +02:00
Sven Klemm
6cd688c366 Fix use-after-free in finalize
Fix use-after-free in fa_perquery_state_init
2020-10-19 20:05:17 +02:00
Mats Kindahl
253ceeb880 Change use of ssl_dir GUC
By default, user certificates are placed in the directory
`timescaledb/certs` relative to the data directory. This location can,
however, be changed by setting `timescaledb.ssl_dir` to another value.
If `timescaledb.ssl_dir` is set, user certificates will be
`timescaledb/certs` relative to this location.

This commit changes the usage of `timescaledb.ssl_dir` to point to the
actual directory for the user SSL certificates and keys rather than the
subdirectory `timescaledb/certs` under that directory.

The default location of the user certificates and keys are unchanged.

Closes #2568
2020-10-19 17:50:28 +02:00
Matvey Arye
4050f97dcf Add Promscale extension to telemetry
This tracks the extension usage.
2020-10-19 11:05:50 -04:00
Brian Rowe
5acf3343b5 Ensure reltuples are preserved during compression
This change captures the reltuples and relpages (and relallvisible)
statistics from the pg_class table for chunks immediately before
truncating them during the compression code path.  It then restores
the values after truncating, as there is no way to keep postgresql
from clearing these values during this operation.  It also properly
uses these values properly during planning, working around some
postgresql code which substitutes in arbitrary sizing for tables
which don't see to hold data.

Fixes #2524
2020-10-19 07:21:38 -07:00
Sven Klemm
295817f18e Improve cagg datatype handling
This patch improves datatype handling when the aggregate function
argument type is a pseudotype.
2020-10-19 12:01:43 +02:00
Mats Kindahl
03f2fbcf32 Repair dimension slice table on update
In #2514 a a race condition between inserts and `drop_chunks` is fixed
and this commit will repair the dimension slices table by
re-constructing missing dimension slices from the corresponding
constraint expressions.

Closes #1986
2020-10-19 11:41:11 +02:00
Sven Klemm
9963ecd181 Use postgres builtin hton functions
Switch to postgres builtin functions for converting from host to
network byte order since those are better optimized.

510b8cbff1
2020-10-19 10:05:56 +02:00
Sven Klemm
8cfaeb820e Use AttrNumberGetAttrOffset to convert AttrNumber
Change code to use AttrNumberGetAttrOffset to convert AttrNumber
into AttrOffset instead of manual subtraction.
2020-10-17 20:14:49 +02:00
Sven Klemm
5642ccaa1d Fix index creation on hypertables with dropped columns
Fix creating expression indexes on hypertables with dropped columns.
2020-10-17 20:14:49 +02:00
Brian Rowe
3f23cb64e8 Suspend retention policies with caggs conflicts
When upgrading from 1.7, it's possible to have retention policies
which overlap with continuous aggregates.  These make use of the
cascade_to_materializations parameter to avoid invalidating the
aggregate.

In 2.0 there is no equivalent behavior to prevent the retention from
disrupting the aggregate.  So during the 2.0 upgrade, check for any
running retention policies that are dropping chunks still used by a
continuous aggregate and suspend them (scheduled=>false).  This will
also print a notice informing the user of what happened and how to
resume the retention policy if that's what they truly want.

Fixes #2530
2020-10-16 14:27:03 -07:00
Sven Klemm
94af62f813 Adjust package test to 2.0 package name change 2020-10-16 21:54:27 +02:00
gayyappan
ff560a903c Fix outer join qual propagation
time_bucket_annotate_walker passes an incorrect status
for outer join to the function that checks quals eligibility
for propagation.

Fixes #2500
2020-10-16 08:55:30 -04:00
Erik Nordström
2cc2df23bd Lock dimension slices when creating new chunk
This change makes two changes to address issues with processes doing
concurrent inserts and `drop_chunks` calls:

- When a new chunk is created, any dimension slices that existed prior
  to creating the new chunk are locked to prevent them from being
  dropped before the chunk-creating process commits.

- When a chunk is being dropped, concurrent inserts into the chunk
  that is being dropped will try to lock the dimension slices of the
  chunk. In case the locking fails (due to the slices being
  concurrently deleted), the insert process will treat the chunk as
  not existing and will instead recreate it. Previously, the chunk
  slices (and thus chunk) would be found, but the insert would fail
  when committing since the chunk was concurrently deleted.

A prior commit (PR #2150) partially solved a related problem, but
didn't lock all the slices of a chunk. That commit also threw an error
when a lock on a slice could not be taken due to the slice being
deleted by another transaction. This is now changed to treat that case
as a missing slice instead, causing it to be recreated.

Fixes #1986
2020-10-15 21:56:10 +02:00
Erik Nordström
5564ad8c6c Handle negative values in saturating sub and add
The functions for saturating addition and subtraction of time values
assumed positive intervals as input. This change generalizes the code
to also handle negative intervals being added or subtracted.
2020-10-15 18:58:01 +02:00
Erik Nordström
ce6387aa90 Allow only integer intervals for custom time types
Fix a check for a compatible chunk time interval type when creating a
hypertable with a custom time type.

Previously, the check allowed `Interval` type intervals for any
dimension type that is not an integer type, including custom time
types. The check is now changed so that it only accepts an `Interval`
for timestamp and date type dimensions.

A number of related error messages are also cleaned up so that they
are more consistent and conform to the error style guide.
2020-10-15 18:58:01 +02:00
Erik Nordström
c4a91e5ae8 Assume custom time type range is same as bigint
The database must know the valid time range of a custom time type,
similar to how it knows the time ranges of officially supported time
types. However, the only way to "know" the valid time range of a
custom time type is to assume it is the same as the one of a supported
time type.

A previous commit tried to make such assumptions by finding an
appropriate cast from the custom time type to a supported time
type. However, this fails in case there are multiple casts available
that each could return a different type and range.

This change restricts the choice of valid time ranges to only that of
the bigint time type.

Fixes #2523
2020-10-15 18:58:01 +02:00
Sven Klemm
e33a72a607 Fix flaky remote_txn test
The error message about closed connections varies between
platforms/environments leading to flaky tests. This patch
changes expected test output to sqlstate only in tests
affected by this.
2020-10-15 05:01:15 +02:00
Sven Klemm
b1c28c9c7c Remove unreferenced steps from isolation tests
Some isolation tests had steps that were not referenced in
any of the permutations so this patch removes those.
2020-10-15 04:03:48 +02:00
Mats Kindahl
0e507affc1 Remove modification time from invalidation log
The `modification_time` column is hard to maintain with any level of
consistency over merges and splits of invalidation ranges so this
commit removes it from the invalidation log entries for both
hypertables and continuous aggregates. If the modification time is
needed in the future, we need to re-introduce it in a manner that can
maintain it over both merges and splits.

THe function `ts_get_now_internal` is also removed since it is not used
any more.

Part of #2521
2020-10-14 17:36:51 +02:00
gayyappan
cf34f7d2ce Pass correct status to lock_job
lock_job is passed incorrect Status as argument.
The lock is incorrectly interpreted as a session
lock when a transaction lock is desired.
2020-10-14 09:43:30 -04:00
Sven Klemm
e79c0648cf Fix member access within misaligned address in chunk_update_colstats
The array argument passed to array_length is treated as AnyArrayType
which is a union of ArrayType and ExpandedArrayHeader, which lead to
member access within misaligned address when used on the argument
passed to array_length by chunk_update_colstats which is ArrayType.
2020-10-13 21:05:23 +02:00
Sven Klemm
4b4db04c1e Clean up update tests
Refactor update test files and remove obsolete test files.
2020-10-13 18:06:28 +02:00
Sven Klemm
336d8f9c47 Check function linkage in update test
This patch adds a check that all c functions link to the correct
library after an update.
2020-10-13 18:06:28 +02:00
Mats Kindahl
7b8203fc53 Update test dist_ddl to execute in parallel
Change database names to be unique over the test suite by adding the
test database name in front of the created database names in the test.
This will allow the test to be executed in parallel with other tests
since it will not have conflicting databases in the same cluster.
2020-10-13 16:44:31 +02:00
Sven Klemm
ccfca446f2 Fix timescaledb_fdw function handling in update script
This patch splits the timescaledb_fdw sql file into two parts to
separate the idempotent parts from the non-idempotent ones so
the function definitions can be included in the regular update
script.
2020-10-13 14:59:27 +02:00
Sven Klemm
87f78b4844 Move distributed insert tests to shared test
Change the distributed insert test to shared test so it can run in
parallel and doesn't require dedicated distributed setup.
2020-10-13 14:22:17 +02:00
Sven Klemm
d22799e21c Use unique datanode name in read_only test 2020-10-13 14:22:17 +02:00
Sven Klemm
d8048f2a33 Use environment files for github actions
GitHub deprecates use of set-env in workflows so switch to using
environment files.

https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
2020-10-13 12:18:05 +02:00
Ruslan Fomkin
85095b6eef Cleanup public API
Removes unlrelated column schedule_interval from
timescaledb_information.continuous_aggregates view and simplifies it.
Renames argument cagg in refresh_continuous_aggregate into
continuous_aggregate as in add_continuous_aggregate_policy.

Part of #2521
2020-10-13 09:41:12 +02:00
Mats Kindahl
85428bc383 Support non-transactional distibuted_exec
Before this commit, executions of `distributed_exec` was always
transactional and this could not be disabled. This cause problems when
executing statements that cannot be executed inside a transaction, such
as `CREATE DATABASE`.

With this commit, we introduce a parameter `transactional` to
`distributed_exec` that allow non-transactional executions on data
nodes. The parameter defaults to `TRUE`.  Generates an error if
`distributed_exec` is non-transactional and inside a transaction.

It also changes `distributed_exec` to be a procedure, which better
matches it's usage (it returns `VOID`).

Closes #1660
2020-10-13 08:36:06 +02:00
Sven Klemm
967a10afcb Fix flaky update test
Disable background workers during update tests to prevent deadlocks
in continuous aggregates on 1.7.x
2020-10-12 16:15:29 +02:00
Sven Klemm
03deb65b0f Fix update test diff display
The latest update test refactoring renamed some of the output files
to better state their origin but not all places in the github
workflow were adjusted to handle the new names.
2020-10-12 16:15:29 +02:00
Dmitry Simonenko
ebc4fd9b9e Add if_attached argument to detach_data_node()
This change makes detach_data_node() function consistent with
other data node management functions by adding missing
if_attach argument.

The function will not show an error in case if data node is not
attached and if_attached is set to true.

Issue: #2506
2020-10-08 20:53:14 +03:00
Mats Kindahl
8ddaef66ea Remove error for correct bootstrap of data node
If the database exists on the data node when executing `add_data_node`
it will generate an error in the data node log, which can cause
problems since there is an error indication in the log but there are no
failing operations.

This commit fixes this by first validating the database and only if it
does not exist, create the database.

Closes #2503
2020-10-08 09:03:15 +02:00
niksa
65f31122ee Fix validation logic when adding a new data node
We stop enforcing an extension owner to be the same as a user adding a
data node since that's not strictly necessary. In multi-node setups
it is common that a data node is pre bootstrapped and an extension owner
is already set. This will prevent getting an error when a non
extension owner tries to add a data node.
2020-10-07 21:11:30 +02:00
gayyappan
2347ebd123 Overflow handling for refresh policy with integer time
When we compute the start and end intervals for the
refresh job execution, there is a potential to
run into overflow with integer computations. In such cases,
clamp the start/end boundaries to the MIN and MAX for that
datatype ( i.e. PG_INT64_MIN or PG_INT64_MAX for int64,
PG_INT16_MIN or PG_INT16_MAX for int16 and so on).
2020-10-06 10:26:53 -04:00
Dmitry Simonenko
3f2297b173 Block reorder policy for distributed hypertables 2020-10-06 15:46:38 +03:00
Sven Klemm
641eb4e86b Ignore details of telemetry job in update test
Since handling of telemetry differs between timescaledb versions
when telemetry is disabled via environment variable we ignore the
scheduled flag in the post update diff.
2020-10-06 01:50:53 +02:00
Sven Klemm
c3b9ca9e49 Fix compression_settings view definition 2020-10-06 01:50:53 +02:00