2106 Commits

Author SHA1 Message Date
Sven Klemm
ae0f17705b Improve behaviour of test runner when being run in parallel
The test runner used to use a lockfile to decide whether
initial cluster setup has to be done. Unfortunately
checking for existance and creating the lockfile are 2 distinct
operations leading to race conditions. This patch changes the
runner to use a directory instead because with a directory
the operation is atomic.
2020-06-22 18:14:29 +02:00
Sven Klemm
a959281e48 Replace Travis badge with GitHub badge
Since most of our regression tests run on GitHub actions now this
patch replaces the build status badge from Travis with a GitHub
actions one.
2020-06-22 18:14:29 +02:00
David Kohn
66544c7564 Reset restoring gucs rather than explicitly setting 'off'
Setting the `timescaledb.restoring` guc explicitly to 'off'
for the db meant that the setting got exported in `pg_dumpall`
and some other cases where that setting would then conflict
with the setting set by the pre_restore function causing it to
be overridden and causing errors on restore. This changes to
`RESET` so that instead it will take the system default and not
be dumped separately as an override.
2020-06-22 11:43:27 -04:00
Dmitry Simonenko
04bcc949c1 Add checks for read-only transactions
This change ensures that API functions and DDL operations
which modify data respects read-only transaction state
set by default_transaction_read_only option.
2020-06-22 17:03:04 +03:00
Sven Klemm
ab293976f2 Make TSL_MODULE_PATHNAME available in testsupport.sql
This patch makes TSL_MODULE_PATHNAME available when executing
testsupport.sql in the regression test runner. This fixes an
error that happened in the test runner that was suppressed
because it happens before the actual test run.
2020-06-22 12:08:17 +02:00
Sven Klemm
157764c70e Remove dynamic version checks from SQL tests
The sql tests still had version checks and would run EXPLAIN
with different parameters depending on postgres version. Since
all supported postgres versions now support all the parameters
we use we can safely remove the version check.
2020-06-22 12:08:17 +02:00
gayyappan
b93b30b0c2 Add counts to compression statistics
Store information related to compressed and uncompressed row
counts after compressing a chunk. This is saved in
compression_chunk_size table.
2020-06-19 15:58:04 -04:00
Sven Klemm
5aaa07b9ee Fix flaky reorder_vs_insert isolation test
This patch makes the lock_timeout values for the 2 sessions distinct
so they will always fire in the same order leading to reproducable
results.
2020-06-19 19:40:02 +02:00
Sven Klemm
5b7f2fec18 Disable CI fail-fast for code style and i386 test
When fail-fast is true a single failing job will cancel
the entire workflow which is not desirable for scheduled runs
and the code style tests. This patch changes fail-fast
to false for the code style tests and the scheduled i386 tests.
It also changes the different code style check steps to always
run.
2020-06-19 19:40:02 +02:00
Sven Klemm
5659cb7515 Remove postgres 10 test files
Remove files that got introduced by rebase error or were missed
during removal of PG9.6 and PG10 support.
2020-06-19 19:40:02 +02:00
Sven Klemm
6d84751ebb Remove handling for pre PG10 version format
The telemetry code still had code to handle the version format used
by postgres before PG10 which is dead code now since PG11 is the
minimum version. This patch removes that code path.
2020-06-19 19:40:02 +02:00
Sven Klemm
b810dd3780 Add MacOS regression tests 2020-06-19 00:05:37 +02:00
Sven Klemm
5b8de4710e Fix compression_ddl isolation test
The compression_ddl test had a permutation that depended on the
PGISOLATIONTIMEOUT to cancel the test leading to unreasonably long
running and flaky test. This patch changes the test to set
lock_timeout instead to cancel the blocking much earlier.
2020-06-19 00:05:37 +02:00
Sven Klemm
4a6bdb7f1b Increase lock_timeout for isolation tests
In slower environments the isolation tests are extremely flaky
because lock_timeout is only 50ms this patch changes lock_timeout
to 500ms for the isolation tests leading to much more reliable tests
in those environments.
2020-06-19 00:05:37 +02:00
Sven Klemm
32ed2c02d5 Adjust export prefix check for MacOS 2020-06-19 00:05:37 +02:00
Erik Nordström
596515eb0f Fix ANALYZE on replicated distributed hypertable
With replicated chunks, the function to import column stats would
experience errors when updating `pg_statistics`, since it tried to
write identical stats from several replica chunks.

This change fixes this issue by filtering duplicate stats rows
received from data nodes.

In the future, this could be improved by only requesting stats from
"primary" chunks on each data node, thus avoiding duplicates without
having to filter the result. However, this would complicate the
function interface as it would require sending a list of chunks
instead of just getting the stats for all chunks in a hypertable.
2020-06-18 12:38:18 +02:00
Erik Nordström
72d9def619 Fix output in show_connection_cache function
The "invalidation" column was accidentally set as the "processing"
column in `show_connection_cache`. This made the output of these
columns show the wrong values. This change fixes this issue.
2020-06-17 15:02:53 +02:00
Ruslan Fomkin
195bba114d Remove flakiness of cagg materializaion test
Replaces now() with mocked timestamp value in
continuous_aggs_materialize test, so the test doesn't produce
unexpected result when now() is close to a chunk border.
2020-06-17 12:42:21 +02:00
Ruslan Fomkin
175edfa669 Force installing PostgreSQL in GH Actions on Windows
PostgreSQL 12 is preinstalled, while 11 is not. To unify different
paths of PG 11 and 12 binaries, this commit implements workaround by
forcing installation of PostgreSQL 12, so it is in the same path as
PostgreSQL 11.
2020-06-17 11:21:07 +02:00
Mats Kindahl
5d188267e4 Fix crash with create_distributed_hypertable
Function `ts_hypertable_create_from_info` will error if the hypertable
already exists unless the if-not-exists flag is not set.  If we reach
this point, either if-not-exists-flag was set or the hypertable did not
exist and was created above.

In `ts_hypertable_create_from_info`, a call to
`ts_dimension_info_validate` with `space_dim_info` will be made if (and
only if) the table did not exist. The function does not only validate
the dimension, it also set `dimension_id` field.

 If the table already existed, `created` will be false and the
`dimension_id` will be set to the invalid OID, which means that
`ts_hypertable_check_partitioning` will crash since it it expect a
proper OID to be passed.

This commit fixes that by checking if the hypertable exists prior to
calling `ts_hypertable_create_from_info` in
`ts_hypertable_create_internal` and aborting with an error if the
hypertable already exists.

Fixes #1987
2020-06-17 08:38:31 +02:00
Mats Kindahl
a089843ffd Make table mandatory for drop_chunks
The `drop_chunks` function is refactored to make table name mandatory
for the function. As a result, the function was also refactored to
accept the `regclass` type instead of table name plus schema name and
the parameters were reordered to match the order for `show_chunks`.

The commit also refactor the code to pass the hypertable structure
between internal functions rather than the hypertable relid and moving
error checks to the PostgreSQL function.  This allow the internal
functions to avoid some lookups and use the information in the
structure directly and also give errors earlier instead of first
dropping chunks and then error and roll back the transaction.
2020-06-17 06:56:50 +02:00
Sven Klemm
0bff7dcac3 Run linux regression tests as GitHub action
Since we want to run additional test configurations when triggered
by a push to prerelease_test or by cron but github actions don't
allow a dynamic matrix via yaml configuration we generate the matrix
with a python script. While we could always have the full matrix
and have if checks on every step that would make the actual checks
harder to browse because the workflow will have lots of entries and
only by navigating into the individual jobs would t sit be visible
if a job was actually run.
Additionally we set fail-fast to true for pull requests and false
for other event types.
2020-06-15 00:56:33 +02:00
Sven Klemm
ca9b37d9de Improve i386 slack failure message
Change i386 slack notification to set border color to red and
to include last commit message.
2020-06-15 00:56:33 +02:00
Sven Klemm
129aa47987 Adjust export prefix check to work with clang
This patch changes the export prefix check to ignore symbols
present in clang builds.
2020-06-15 00:56:33 +02:00
Erik Nordström
7d132b3a37 Improve error handling in async library
The async library for remote connections has multiple ways to deal
with errors. For instance, errors can both be thrown internally and be
returned as port of an `AsyncResult`. In other cases, it is possible
to pass in an "elevel" to avoid throwing errors, but this only works
for some functions and not for all errors.

This change tries to make error handling more consistent by avoiding
throwing errors while waiting for results, instead returning any error
as `AsyncResponseError`. This makes error handling more predictible
and the caller has to explicitly check if the returned response is an
error or valid result without having to try-catch any errors.

A number of issues with potentially leaking PQresult:s have also been
fixed.
2020-06-13 12:05:41 +02:00
Erik Nordström
47a4d931f3 Remove need to pin connection cache
Since the connection cache is no longer replaced on a transaction
rollback, it is not necessary to pin the connection cache (this wasn't
done correctly in some places in any case, e.g.,
`data_node_get_connection`).
2020-06-13 12:05:41 +02:00
Erik Nordström
9d533f31c2 Improve connection handling during transactions
This change refactors how connections are handled during remote
transactions. In particular, the connection cache now stays consistent
during transactions, even during rollbacks. Previously, the connection
cache was replaced on every rollback, even if the rollback was
intentional (i.e, not due to an error). This made it hard to debug
connections since the cache became completely empty.

Connections could also be left in the cache in a bad state after
failed transactions. This has been fixed by moving connection checks
to the cache and tying transaction state changes to each
connection. This ensures that such checks are done in one canonical
place instead of being spread out throughout the code.

Given how tightly coupled a remote transaction is with its connection,
it might make sense to remove the separate remote transaction store
and instead put this information in each connection. This is left to a
future change, however.

In addition to the above changes, this commit includes:

* Showing transaction depth and invalidation in the transaction store
* Invalidation on individual connections instead of replacing the
  whole cache
* Closing of connections to a local database that is being dropped to
  prevent "in use" errors.
* Ability to add callbacks to async requests that are executed when a
  response is received. This is used by remote transactions to mark
  connections as having successfully completed a transaction. Thus, on
  errors, it is easy to detect connections that are in bad states.
* Error checks on each connection instead of having global error
  tracking for each remote transaction. This change removes the global
  error state for distributed transactions.
2020-06-13 12:05:41 +02:00
Erik Nordström
31d5254c2e Add internal function to show connection cache
The connection cache for remote transactions can now be examined using
a function that shows all connections in the cache. This allows easier
debugging and validation both in tests and on live systems.

In particular, we'd like to know that connections are in good state
post commit or rollback and that we don't leave bad connections in the
cache.

The remote transaction test (`remote_txn`) has been updated to show
the connection cache as remote transactions are
executed. Unfortunately, the whole cache is replaced on every
(sub-)transaction rollback, which makes it hard to debug the
connection state of a particular remote transaction. Further, some
connections are left in the cache in a bad state after, e.g.,
connection loss.

These issues will be fixed with an upcoming change.
2020-06-13 12:05:41 +02:00
Mats Kindahl
0fdfcdb9d3 Fix bit array left shift count
If `bits_used` is not exactly 64, a shift will be attempted, even when
`bits_used > 64`. According to the standard "[...] if the value of the
right operand is negative or is greater or equal to the number of bits
in the promoted left operand, the behavior is undefined."

Hence we change the code to return `PG_UINT64_MAX` if a request to
shift more bits than the number of bits in the type is requested,
otherwise we perform the shift.
2020-06-12 07:51:32 +02:00
Mats Kindahl
ead588f971 Check for disabled telemetry earlier
If telemetry is disabled, it is checked inside the `ts_telemetry_main`
function, which starts to execute after a background worker has been
scheduled to execute the function. This means that any errors occurring
when starting the job will trigger errors and generate lines in the
log.

This commit moves the check to before a background worker is scheduled
for executing the job and allow the telemetry job to trivially succeed
without actually invoking the worker, hence no errors will be
generated for the telemetry job if it is disabled.

Also, the privacy test result changes and it is updated to check that
the telemetry job cannot leak information regardless of whether
telemetry is on or off.

Fixes #1934 #1788
2020-06-10 20:45:57 +02:00
Sven Klemm
c0f66a4e1f Move code style checks to github action
Move code formatting, license and git commit hook checks to
GitHub action.
2020-06-10 19:29:46 +02:00
Sven Klemm
835ec5af10 Change export prefix check to work with gcov
This patch adjusts the export prefix check to exclude some symbols
present when using older toolchain and also includes gcov symbols
so export prefix check can be used on coverage enabled builds.
2020-06-10 15:09:31 +02:00
Sven Klemm
db617bf1d6 Fix typos in comments and documentation 2020-06-10 15:09:31 +02:00
Sven Klemm
6e3fa54a7c Add slack notification to i386 tests
This patch adds a slack notification on failed i386 tests.
Unfortunately most slack actions don't work with the 32bit
image so our options for better styling/costumisation are
somewhat limited.
2020-06-10 15:09:31 +02:00
Dmitry Simonenko
f3b7907778 Cleanup remote_txn on data node delete
Remove any 2PC transaction records associated with the data node
from _timescaledb_catalog.remote_txn on delete_data_node() call.
2020-06-10 15:34:40 +03:00
Sven Klemm
5bbab82eca Initialize variables complained about by older compilers
GCC 7.5 warns that invalidation_range in continuous aggregate
materialization may be used uninitialized.
Older clang versons warn that res in calculate_next_start_on_failure
may be used uninitialized.
This patch changes the code to always initialize those two variables.
2020-06-09 08:53:07 +02:00
Mats Kindahl
d3ed288d2a Do not use NOTICE in CMake files
The `NOTICE` level for `message` doesn't exist in CMake 3.11, which is
our minimum supported version, so removing it.
2020-06-08 14:44:54 +02:00
Sven Klemm
182f6f14fd Release 2.0.0-beta5
This release adds new functionality on distributed hypertables,
including (but not limited to) basic LIMIT pushdown, manual chunk
compression, table access methods storage options,  SERIAL columns,
and altering of the replication factor.
This release only supports PG11 and PG12. Thus, PG9.6 and PG10
are no longer supported.

Note that the 2.0 major release will introduce breaking changes
to user functions and APIs. In particular, this beta removes the
cascade parameter from drop_chunks and changes the names of
certain GUC parameters. Expect additional breaking changes to be
introduced up until the 2.0 release.

**For beta releases**, upgrading from an earlier version of the
extension (including previous beta releases) is not supported.

**Features**

* #1877 Add support for fast pruning of inlined functions
* #1922 Cleanup GUC names
* #1923 Add repartition option on detach/delete_data_node
* #1923 Allow ALTER TABLE SET on distributed hypertable
* #1923 Allow SERIAL columns for distributed hypertables
* #1923 Basic LIMIT push down support
* #1923 Implement altering replication factor
* #1923 Support compression on distributed hypertables
* #1923 Support storage options for distributed hypertables
* #1941 Change default prefix for distributed tables
* #1943 Support table access methods for distributed hypertables
* #1952 Remove cascade option from drop_chunks
* #1955 Remove support for PG9.6 and PG10

**Bugfixes**
* #1915 Check for database in extension_current_state
* #1918 Unify chunk index creation
* #1923 Fix insert batch size calculation for prepared statements
* #1923 Fix port conversion issue in add_data_node
* #1932 Change compression locking order
* #1938 Fix gapfill locf treat_null_as_missing

**Thanks**
* @dmitri191 for reporting an issue with failing background workers
* @fvannee for optimizing pruning of inlined functions
* @nbouscal for reporting an issue with compression jobs locking referenced tables
* @nicolai6120 for reporting an issue with locf and treat_null_as_missing
* @nomanor for reporting an issue with expression index with table references
2.0.0-beta5
2020-06-06 23:24:16 +02:00
Mats Kindahl
d08e19931c Include internal dependencies in delete of chunks
If a hypertable is created with an index on it and a continuous
aggregate is further defined on the hypertable, it will create an
internal dependency between the chunks of the hypertable and the chunks
of the continuous aggregate.

When dropping chunks with `cascade_to_materialization` set to `FALSE`,
this will generate an error since the delete is not cascaded to the
internal dependencies.

This commit fixes this by collecting the internal dependencies and
using `performMultipleDelete` rather than `performDelete` to delete
several objects as one operation.

Fixes #1889
2020-06-05 14:41:52 +02:00
Sven Klemm
c39989bca9 Remove check for PG 10 in update script generation
Since PG 9.6 is no longer supported version not less
than 10 is always true now and this check can be removed and
remote_txn.sql can always be added.
2020-06-05 13:34:43 +02:00
Sven Klemm
eef1e16ef5 Enable linter only for clang compiler
Enabling clang-tidy on builds not using clang compiler will not
compile due to incompatible compiler flags, so this patch
changes the current behaviour to only enable clang-tidy when
using clang compiler. You can still overwrite the behaviour
by passing -DLINTER=ON when not using clang.
2020-06-05 13:34:43 +02:00
Sven Klemm
36d43503c1 Change update script generation to not use scratch files
This patch changes the update script generation to not use
scratch files and removes the sql fragments to set and unset
the post_update_stage from CMakeLists.txt and puts them into
dedicated files.
2020-06-04 15:05:31 +02:00
Ruslan Fomkin
487c0e0703 Use correct null device on Windows
Fixes null device on Windows to work in both CMD and PowerShell.
2020-06-04 11:21:03 +02:00
Floris van Nee
5c6940d734 Add support for fast pruning of inlined functions
Inlineable functions used to be slow to plan, because the query
preprocessing function could not find the relations inside the
functions, as they haven't been inlined yet at that point.
This commit adds a separate check in the get_relation_info_hook
to optimize pruning of hypertables.
2020-06-04 09:20:58 +02:00
Sven Klemm
b5915f5eab Skip dist_hypertable and dist_query in release builds
The dist_hypertable and dist_query tests need timestamp mock
functionality which is only available in debug builds.
2020-06-04 08:56:31 +02:00
Stephen Polcyn
afb6c1a78b Update CHANGELOG.md
Updates CHANGELOG with changes from PR "Change compression locking order"(#1932).
2020-06-03 21:28:00 -04:00
Sven Klemm
315a680c72 Fix gapfill locf treat_null_as_missing
When using time_bucket_gapfill with the treat_null_as_missing
option we did not properly set the number of valid values when
generating our own virtual tuples leading to "cannot extract
attribute from empty tuple slot" when the number of values got
reset. This patch changes the gapfill code to always set
the number of valid values when generating virtual tuples.
2020-06-03 17:39:42 +02:00
Sven Klemm
c90397fd6a Remove support for PG9.6 and PG10
This patch removes code support for PG9.6 and PG10. In addition to
removing PG96 and PG10 macros the following changes are done:

remove HAVE_INT64_TIMESTAMP since this is always true on PG10+
remove PG_VERSION_SUPPORTS_MULTINODE
2020-06-02 23:48:35 +02:00
Sven Klemm
663463771b Use EXECUTE FUNCTION instead of EXECUTE PROCEDURE
Replace EXECUTE PROCEDURE with EXECUTE FUNCTION because the former
is deprecated in PG11+. Unfortunately some test output will still
have EXECUTE PROCEDURE because pg_get_triggerdef in PG11 still
generates a definition with EXECUTE PROCEDURE.
2020-06-02 17:33:05 +02:00
Mats Kindahl
92b6c03e43 Remove cascade option from drop_chunks
This commit removes the `cascade` option from the function
`drop_chunks` and `add_drop_chunk_policy`, which will now never cascade
drops to dependent objects.  The tests are fixed accordingly and
verbosity turned up to ensure that the dependent objects are printed in
the error details.
2020-06-02 16:08:51 +02:00