1809 Commits

Author SHA1 Message Date
Sven Klemm
bb8f59a654 Disable background workers in cagg ddl tests
The continuous agg ddl test is flaky and occasionally fails with a
deadlock which might be caused by background workers running.
2019-12-12 16:19:17 +01:00
Matvey Arye
d9d1a44d2e Refactor chunk handling to separate out stub
Previously, the Chunk struct was used to represent both a full
chunk and the stub used for joins. The stub used for joins
only contained valid values for some chunk fields and not others.
After the join determined that a Chunk was complete, it filled
in the rest of the chunk field. The fact that a chunk could have
only some fields filled out and not others at different times,
made the code hard to follow and error prone.

So we separate out the stub state of the chunk into a separate
struct that doesn't contain the not-filled-out fields inside
of it.  This leverages the type system to prevent errors that
try to access invalid fields during the join phase and makes
the code easier to follow.
2019-12-06 15:04:51 -05:00
Ruslan Fomkin
e6b215b8c0 Remove duplicate allocation during planning
Removes duplicate call to setup_append_rel_array and avoids allocating
another append_rel_array with the same values during planning queries
with  hypertables.
2019-12-05 22:03:02 +01:00
Matvey Arye
08ad7b6612 Add ignore_invalidation_older_than to continuous aggs
We added a timescaledb.ignore_invalidation_older_than parameter for
continuous aggregatess. This parameter accept a time-interval (e.g. 1
month). if set, it limits the amount of time for which to process
invalidation. Thus, if
	timescaledb.ignore_invalidation_older_than = '1 month'
then any modifications for data older than 1 month from the current
timestamp at insert time will not cause updates to the continuous
aggregate. This limits the amount of work that a backfill can trigger.
This parameter must be >= 0. A value of 0 means that invalidations are
never processed.

When recording invalidations for the hypertable at insert time, we use
the maximum ignore_invalidation_older_than of any continuous agg attached
to the hypertable as a cutoff for whether to record the invalidation
at all. When materializing a particular continuous agg, we use that
aggs  ignore_invalidation_older_than cutoff. However we have to apply
that cutoff relative to the insert time not the materialization
time to make it easier for users to reason about. Therefore,
we record the insert time as part of the invalidation entry.
2019-12-04 15:47:03 -05:00
Matvey Arye
3848c95c1c Fix isolation test on older PG versions
On older point releases (e.g. 10.2) the step size in isolation
tests is smaller leading to "SQL step too long" errors. This
PR splits up the setup step to avoid this error.
2019-12-04 11:05:01 -05:00
gayyappan
4ecc96509d Fix partial select query for continuous aggregate
continuous aggregate views like
select time_bucket(), sum(col)
from ...
group by time_bucket(), grpcol;

when grpcol is missing from the select targetlist, the
partialize query's select targetlist is incorrect and the view
cannot be materialized. This PR fixes this issue.
2019-12-03 13:20:38 -05:00
Matvey Arye
513ad6de6a Fix tests errors
Fix some minor compiler warnings and errors. Move some tests that
require `timescaledb.current_timestamp_mock` from release to
debug-only.
2019-12-03 10:05:23 -05:00
Matvey Arye
09051df8cd Apply max_interval_per_job to invalidations
This change the continuous aggregate materialization logic so that
the max_interval_per_job applies to invalidation entries as well
as new ranges in the materialization. The new logic is that the
MIPJ setting limits the sum of work done by the invalidations
and new ranges. Invalidations take precedence so new ranges
are only processed if there is time left over in the MIPJ
budget after all invalidations are done.

This forces us to calculate the invalidation range during the first
transaction. We still delete and/or cut the invalidation entries
in the second transaction. This change also more neatly separates concerns:
all decisions on work to be done happens in the first txn while only
execution happens in the second. Further refactoring could make
this more clear by passing a list of InternalRanges to represent the
work. But this PR is big enough, so that's left to a future refactor.

Note: There is remaining work to be done in breaking up invalidation
entries as created during inserts to constrain the length of the entries.
But that's a separate issue to be addressed in the future.
2019-12-02 12:41:38 -05:00
Ruslan Fomkin
4ad40931f1 Notify internal Slack an Travis CRON build fail
Adds notification from Travis CI to an internal Slack channel when a
CRON build fails.
2019-12-01 07:39:47 +01:00
Sven Klemm
e82b94a658 Use function cache to check for valid bucketing functions
Refactor the continuous aggregate validation to use our function cache
to check for bucketing function. This simplifies the code and allows
adding support for other bucketing functions like date_trunc later on.
2019-11-26 17:30:30 +01:00
niksa
1e5d0d4424 Fix CMake condition
In some cases _temp variable will not be set due to pg_config not
returning any output for a specific flag. This results in an
error when doing comparison using STREQUAL and build failure.
Wrapping variable in double quotes fixes the problem.
2019-11-22 16:05:08 +01:00
Matvey Arye
2f7d69f93b Make continuous agg relative to now()
Previously, refresh_lag in continuous aggs was calculated
relative to the maximum timestamp in the table. Change the
semantics so that it is relative to now(). This is more
intuitive.

Requires an integer_now function applied to hypertables
with integer-based time dimensions.
2019-11-21 14:17:37 -05:00
Sven Klemm
1ec16869f8 Release 1.5.1
This maintenance release contains bugfixes since the 1.5.0 release. We deem it low
priority for upgrading.

In particular the fixes contained in this maintenance release address potential
segfaults and no other security vulnerabilities. The bugfixes are related to bloom
indexes and updates from previous versions.

**Bugfixes**
* #1523 Fix bad SQL updates from previous updates
* #1526 Fix hypertable model
* #1530 Set active snapshots in multi-xact index create

**Thanks**
* @84660320 for reporting an issue with bloom indexes
2019-11-12 12:42:43 +01:00
Matvey Arye
122856c1bd Fix update scripts for type functions
Type functions have to be CREATE OR REPLACED on every update
since they need to point to the correct .so. Thus,
split the type definitions into a pre, functions,
and post part and rerun the functions part on both
pre_install and on every update.
2019-11-11 17:10:13 -05:00
Matvey Arye
707bb9d584 Add compression to update tests
Add a test using cmpressed tables to our extension update
test suite.
2019-11-11 17:10:13 -05:00
Matvey Arye
713ceb2a23 Set active snapshots in multi-xact index create
Set active snapshots when creating txns during index
create with timescaledb.transaction_per_chunk. This
is needed for some index types like `bloom`.

Tests not added since we don't want dependencies on contrib modules
like bloom.

Fixes #1521.
2019-11-11 07:47:33 -05:00
Matvey Arye
85d35af140 Fix shared tests on OSX
Fix the test runner to work with the OSX version of tests.
2019-11-07 20:29:19 -05:00
Matvey Arye
2cf66fdf44 Fix hypertable model handling
The hypertable model now has NULL fields but was still using
GETSTRUCT. This is unsafe. Switch to using the proper model
access methods.
2019-11-07 20:29:19 -05:00
gayyappan
3e5e0de164 Add constraint aware tests for compression
1. This commit introduces changes to existing plans due
to the addition of new chunks to metrics_ordered_idx.
2. Add tests for constraint aware appends on compressed
tables.
2019-11-07 15:52:21 -05:00
Matvey Arye
99f862198e Fix update logic from 1.4.2 to 1.5.0
The update logic from 1.4.2 to 1.5.0 had an error where
the _timescaledb_catalog.hypertable table was altered in such
a way that the table was not re-written. This causes
bugs in catalog processing code. A CLUSTER rewrites the
table. We also backpatch this change to the 1.4.2--1.5.0
script to help anyone building from source.

Also fixes a similar error on  _timescaledb_catalog.metadata
introduced in the 1.3.2--1.4.0 update.
2019-11-07 12:12:54 -05:00
Matvey Arye
e575cc2b88 Add tests for updates of catalog tables
PG11 added an optimization where columns that were added by
an ALTER TABLE that had a DEFAULT value did not cause a table
re-write. Instead, those columns are filled with the default
value on read.

But, this mechanism does not apply to catalog tables and does
not work with our catalog scanning code. This tests makes
sure we never have such alters in our updates.
2019-11-07 12:12:54 -05:00
Matvey Arye
d34731a4e3 Add update test on PG11
Change travis to to run update tests on PG11.
2019-11-07 12:12:54 -05:00
Sven Klemm
6fe5ef3957 Move prepared statement queries to shared tests
This patch moves the prepared statement test to the shared tests so
they can be run on compressed hypertables as well.
2019-11-07 15:56:20 +01:00
Sven Klemm
41209fd629 Add 1.5.0 to update test scripts 2019-11-07 15:56:20 +01:00
Sven Klemm
04041b06c7 Ignore bgw_db_scheduler failure in 32 bit test
Ignore results of bgw_db_scheduler test because it is not reliable.
2019-11-07 15:56:20 +01:00
Sven Klemm
156da6cf75 Refactor transparent decompression sort pushdown
The construct used for pushing down produces a warning on certain
older compiler, so while it was correct this patch changes it to
get rid of the warning and to prevent introducing an imbalance later.
2019-11-07 15:56:20 +01:00
Mats Kindahl
b2918e58fe Fix permission issue in test_sanitizer
The `test_sanitizer.sh` test failed because source code was being
copied from the host to the container as user `postgres` and this user
did not have read permissions on the mounted directory. This is fixed
by copying the files as `root` and then changing the owner to
`postgres`.

The commit also removes `wait_for_pg` since PostgreSQL server status is
not relevant for the tests since they start their own temporary
instance.

The commit also switches to use here-is documents for the execution for
readability purposes.
2019-11-07 08:54:32 +01:00
Sven Klemm
0ca9e30198 Run 32 bit tests on i386 instead of ARM emulation
The main reason to run ARM tests was not to identify issues with
ARM but to identify 32 bit issues e.g. int64 as pointer instead
type by value. Those issues don't need ARM emulation but can be
tested with i386 which is much faster.
2019-11-06 11:17:58 +01:00
Sven Klemm
5427bccf01 Remove byte sizes from chunk_adaptive test
The byte sizes for tables/indexes differ between 32 bit and 64 bit
so this patch removes them from the test output.
2019-11-06 11:17:58 +01:00
Sven Klemm
c6350aaaea Move decompress_chunk to nodes/decompress_chunk
Code for all custom nodes should live under the nodes directory
to make different parts of the code easier to distinguish.
2019-11-06 10:43:36 +01:00
gayyappan
874b4512b2 Fix test failure with custom type
Fix tests that fail like so:
test=# CREATE CAST (customtype AS bigint)
test-# WITHOUT FUNCTION AS ASSIGNMENT;
ERROR:  source and target data types are not physically compatible
2019-11-05 13:48:18 -05:00
Erik Nordström
1e75c27c16 Fix build flags for Apple builds
A previous change made `UNIX` and `APPLE` build flags mutually
exclusive instead of complementary. This broke builds on, e.g., Mac OS
X.

The changes in this commit will make builds work on Mac OS X again.
2019-11-04 11:24:37 +01:00
Mats Kindahl
90cab8e61c Use Postgres linker flags when linking
When linking the extensions as shared libraries, the linker flags from
`pg_config` is not used. This means that if `PG_PATH` is provided and
refer to a locally compiled Postgres installation, shared libraries
from that installation will not be used. Instead any default-installed
version of Postgres will be used.

This commit adds `PG_LDFLAGS` to `CMAKE_SHARED_LINKER_FLAGS` and
`CMAKE_MODULE_LINKER_FLAGS`.

To handle that Windows set some fields to "not recorded" when they are
not available, it introduces a CMake function `get_pg_config` that will
replace it with `<var>-NOTFOUND` so that it is treated as undefined by
CMake.
2019-11-01 08:55:54 +01:00
Joshua Lockerman
d6b1c52d71 Set CMAKE_C_STANDARD on TSL
We should have this since we set it on the rest of the DB.
2019-10-31 14:40:16 -04:00
Sven Klemm
7b2519eb44 Release 1.5.0
This release adds major new features and bugfixes since the 1.4.2 release.
We deem it moderate priority for upgrading.

This release adds compression as a major new feature.
Multiple type-specific compression options are available in this release
(including DeltaDelta with run-length-encoding for integers and
timestamps; Gorilla compression for floats; dictionary-based compression
for any data type, but specifically for low-cardinality datasets;
and other LZ-based techniques). Individual columns can be compressed with
type-specific compression algorithms as Postgres' native row-based format
are rolled up into columnar-like arrays on a per chunk basis.
The query planner then handles transparent decompression for compressed
chunks at execution time.

This release also adds support for basic data tiering by supporting
the migration of chunks between tablespaces, as well as support for
parallel query coordination to the ChunkAppend node.
Previously ChunkAppend would rely on parallel coordination in the
underlying scans for parallel plans.
2019-10-31 17:13:41 +01:00
Matvey Arye
825645b2f5 Fix bug with histogram function in parallel
Histogram's combine function threw a segfault if both state1
and state2 were NULL. I could only reproduce this case in
PG 10. Add a tests that hits this with PG 10.4

Fixes #1490
2019-10-30 12:13:41 -04:00
Matvey Arye
db23139b3c Fix error for exported_uuid in pg_restore
When restoring a database, people would encounter errors if
the restore happened after telemetry has run. This is because
a 'exported_uuid' field would then exist and people would encounter
a "duplicate key value" when the restore tried to overwrite it.

We fix this by moving this metadata to a different key
in pre_restore and trying to move it back in post_restore.
If the restore create an exported_uuid, that restored
value is used and the moved version is simply deleted

We also remove the error redirection in restore so that errors
will show up in tests in the future.

Fixes #1409.
2019-10-30 11:40:24 -04:00
Matvey Arye
0cf0e11923 Fix telemetry for ARM32
Fix telemetry logic for ARM32.
2019-10-30 08:20:53 -04:00
Matvey Arye
d2db84fd98 Fix windows compilation
Some minor fixes for compilation in Windows.
2019-10-29 19:02:58 -04:00
Matvey Arye
5241053c4a Fixes to test setup
Several fixes:
  - Change incorrect variable name in CmakeLists that prevented tests
    from running.
  - Add a PG 10.10 test to codecov
  - Remove unused CODECOV_FLAGS in travis.yml
2019-10-29 19:02:58 -04:00
Matvey Arye
1e9bc6895b Add telemetry fields to track compression
The following fields are added:
-num_compressed_hypertables
-compressed_KIND_size
-uncompressed_KIND_size

Where KIND = heap, index, toast.

`num_hypertables` field does NOT count the internal hypertables
used for compressed data.

We also removed internal continuous aggs tables from the
`num_hypertables` count.
2019-10-29 19:02:58 -04:00
Joshua Lockerman
48ef701fa9 Set toast_tuple_target to 128B when able
We want compressed data to be stored out-of-line whenever possible so
that the headers are colocated and scans on the metadata and segmentbys
are cheap. This commit lowers toast_tuple_target to 128 bytes, so that
more tables will have this occur; using the default size, very often a
non-trivial portion of the data ends up in the main table, and only
very few rows are stored in a page.
2019-10-29 19:02:58 -04:00
Joshua Lockerman
e9e7c5f38e Add missing tests discovered by Codecov 3
Tests for continuous aggregates over compressed data, which also tests
selecting tableoids from compressed tables.
2019-10-29 19:02:58 -04:00
Matvey Arye
7ae97088f3 Fix ordered append test for PG <10.4
Prior to PG 10.4, the costing for hashaggs was different (see
PG commit `1007b0`). We fix the tests not to change between the
old and new versions by disabling hashagg. We were not testing
for that anyway.
2019-10-29 19:02:58 -04:00
Joshua Lockerman
efb131dd6f Add missing tests discovered by Codecov 2
This commit adds tests for DATE, TIMESTAMP, and FLOAT compression and
decompression, NULL compression and decompression in dictionaries and
fixes a bug where the database would refuse to decompress DATEs. This
commit also removes the fallback allowing any binary compatible 8-byte
types to be compressed by our integer compressors as I believe I found
a bug in said fallback last time I reviewed it, and cannot recall what
the bug was. These can be re-added later, with appropriate tests.
2019-10-29 19:02:58 -04:00
Matvey Arye
3070a89f01 Fix tests after concurrent merge
The merges of some recent PRs occurred concurrently and did not update
the test output. This fixes that issue.
2019-10-29 19:02:58 -04:00
Matvey Arye
aaa45df369 Fix varoattno when creating ec for segment by.
We reset the varoattno when creating the equivalence
member for segment by columns. varoattno is used for
finding equivalence members (em) when searching for pathkeys
(although, strangely not for indexclauses). Without this change
the code for finding matching ems differs in the case where attnos
have changed and where they haven't.

Fixing this, allows the planner to plan more different types of paths
for several tests, Because of the way the cost fuzzer in
`compare_path_costs_fuzzily` interacts with disabling seqscans,
some choices the planner makes have changed (pretty much the cost
is dominated by the penalty of the seqscan and so it picks the
first available path). We've  changed some enable_seqscan clauses
to get around this and have the planner show what we want in tests.

Also delete transparent_decompression-9.6.out since compression is
disabled on 9.6.
2019-10-29 19:02:58 -04:00
Matvey Arye
c39091e740 Fix pre_release tests
2 fixes:
- The no-ssl telemetry tests should always run in debug tests
- Run explain on a query instead of the query because this query
  runs out of memory in our underpowered arm tests and the bug
  we are looking is in the planner anyway.
2019-10-29 19:02:58 -04:00
Sven Klemm
819414df02 Add test infrastructure with shared tables
This PR adds test infrastructure for running tests with shared tables.
This allows having hypertables with specific configurations usable for
all tests. Since these tests also don't require creating a new database
for each test case some of the overhead of the normal tests is removed.
While this will lead to much faster query tests some tests will still
require their own database to test things, but most queres could be moved
to this infrastructure to improve test coverage and speed them up.
2019-10-29 19:02:58 -04:00
Sven Klemm
e2df62c81c Fix transparent decompression interaction with first/last
Queries with the first/last optimization on compressed chunks
would not properly decompress data but instead access the uncompressed
chunk. This patch fixes the behaviour and also unifies the check
whether a hypertable has compression.
2019-10-29 19:02:58 -04:00