765 Commits

Author SHA1 Message Date
Mats Kindahl
e7daf74d40 Release 2.2.1
This maintenance release contains bugfixes since the 2.2.0 release. We
deem it high priority for upgrading.

This release extends Skip Scan to multinode by enabling the pushdown
of `DISTINCT` to data nodes. It also fixes a number of bugs in the
implementation of Skip Scan, in distributed hypertables, in creation
of indexes, in compression, and in policies.

**Features**
* #3113 Pushdown "SELECT DISTINCT" in multi-node to allow use of Skip
  Scan

**Bugfixes**
* #3101 Use commit date in `get_git_commit()`
* #3102 Fix `REINDEX TABLE` for distributed hypertables
* #3104 Fix use after free in `add_reorder_policy`
* #3106 Fix use after free in `chunk_api_get_chunk_stats`
* #3109 Copy recreated object permissions on update
* #3111 Fix `CMAKE_BUILD_TYPE` check
* #3112 Use `%u` to format Oid instead of `%d`
* #3118 Fix use after free in cache
* #3123 Fix crash while using `REINDEX TABLE CONCURRENTLY`
* #3135 Fix SkipScan path generation in `DISTINCT` queries
  with expressions
* #3146 Fix SkipScan for IndexPaths without pathkeys
* #3147 Skip ChunkAppend if AppendPath has no children
* #3148 Make `SELECT DISTINCT` handle non-var targetlists
* #3151 Fix `fdw_relinfo_get` assertion failure on `DELETE`
* #3155 Inherit `CFLAGS` from PostgreSQL
* #3169 Fix incorrect type cast in compression policy
* #3183 Fix segfault in calculate_chunk_interval
* #3185 Fix wrong datatype in integer based retention policy

**Thanks**
* @Dead2, @dv8472 and @einsibjarni for reporting an issue with
  multinode queries and views
* @hperez75 for reporting an issue with Skip Scan
* @nathanloisel for reporting an issue with compression on hypertables
  with integer-based timestamps
* @xin-hedera for fixing an issue with compression on hypertables with
  integer-based timestamps
2021-05-05 08:50:39 +02:00
gayyappan
e0bff859e3 Add chunk_status column to catalog chunk table
Add a new column chunk_status to _timescaledb_catalog.chunk.
2021-04-26 16:26:47 -04:00
Mats Kindahl
aeb107659b Copy recreated object permissions on update
Tables, indexes, and sequences that are recreated as part of an update
does not propagate permissions to the recreated object. This commit
fixes that by saving away the permissions in `pg_class` temporarily and
then copying them back into the `pg_class` table.

If internal objects are created or re-created, they get the wrong
initial privileges, which result in privileges not being dumped when
using `pg_dump`. Save away the privileges before starting the update
and restore them afterwards to make sure that the privileges are
maintained over the update.

For new objects, we use the initial privileges of the `chunk` metadata
table, which should always have correct initial privileges.

Fixes #3078
2021-04-26 08:36:57 +02:00
Ruslan Fomkin
b1143de795 Release 2.2.0
This release adds major new features since the 2.1.1 release.
We deem it moderate priority for upgrading.

This release adds the Skip Scan optimization, which significantly
improves the performance of queries with DISTINCT ON. This
optimization is not yet available for queries on distributed
hypertables.

This release also adds a function to create a distributed
restore point, which allows performing a consistent restore of a
multi-node cluster from a backup.

The bug fixes in this release address issues with size and stats
functions, high memory usage in distributed inserts, slow distributed
ORDER BY queries, indexes involving INCLUDE, and single chunk query
planning.

**PostgreSQL 11 deprecation announcement**

Timescale is working hard on our next exciting features. To make that
possible, we require functionality that is unfortunately absent on
PostgreSQL 11. For this reason, we will continue supporting PostgreSQL
11 until mid-June 2021. Sooner to that time, we will announce the
specific version of TimescaleDB in which PostgreSQL 11 support will
not be included going forward.

**Major Features**
* #2843 Add distributed restore point functionality
* #3000 SkipScan to speed up SELECT DISTINCT

**Bugfixes**
* #2989 Refactor and harden size and stats functions
* #3058 Reduce memory usage for distributed inserts
* #3067 Fix extremely slow multi-node order by queries
* #3082 Fix chunk index column name mapping
* #3083 Keep Append pathkeys in ChunkAppend

**Thanks**
* @BowenGG for reporting an issue with indexes with INCLUDE
* @fvannee for reporting an issue with ChunkAppend pathkeys
* @pedrokost and @RobAtticus for reporting an issue with size
  functions on empty hypertables
* @phemmer and @ryanbooz for reporting issues with slow
  multi-node order by queries
* @stephane-moreau for reporting an issue with high memory usage during
  single-transaction inserts on a distributed hypertable.
2021-04-13 09:41:03 +02:00
Ruslan Fomkin
2cba4b1d81 Release 2.1.1
This maintenance release contains bugfixes since the 2.1.0 release. We
deem it high priority for upgrading.

The bug fixes in this release address issues with CREATE INDEX and
UPSERT for hypertables, custom jobs, and gapfill queries.

This release marks TimescaleDB as a trusted extension in PG13, so that
superuser privileges are not required anymore to install the extension.

**Minor features**
* #2998 Mark timescaledb as trusted extension

**Bugfixes**
* #2948 Fix off by 4 error in histogram deserialize
* #2974 Fix index creation for hypertables with dropped columns
* #2990 Fix segfault in job_config_check for cagg
* #2987 Fix crash due to txns in emit_log_hook_callback
* #3042 Commit end transaction for CREATE INDEX
* #3053 Fix gapfill/hashagg planner interaction
* #3059 Fix UPSERT on hypertables with columns with defaults

**Thanks**
* @eloyekunle and @kitwestneat for reporting an issue with UPSERT
* @jocrau for reporting an issue with index creation
* @kev009 for fixing a compilation issue
* @majozv and @pehlert for reporting an issue with time_bucket_gapfill
2021-03-29 20:08:50 +02:00
Erik Nordström
931da9a656 Refactor and harden size and stats functions
Fix a number of issues with size and stats functions:

* Return `0` size instead of `NULL` in several functions when
  hypertables have no chunks (e.g., `hypertable_size`,
  `hypertable_detailed_size`).
* Return `NULL` when functions are called on non-hypertables instead
  of simply failing with generic error `query returned no rows`.
* Include size of "root" hypertable, which can have non-zero size
  indexes and other objects even if the root table holds no data.
* Make `hypertable_detailed_size` include one additional row for
  storage size of objects on the access node. While the access node
  stores no data, the empty hypertable may still take up some disk
  space.
* Improve test coverage for all size utility functions. In particular,
  add tests on regular tables as well as empty and compressed
  hypertables.
* Several size utility functions that were defined as `PL/pgSQL`
  functions have been converted to simple `SQL` functions since they
  ran only a single SQL query.

The `dist_util` test is moved to the solo test group because,
otherwise, it gives different size output when run in parallel vs. in
isolation.

Fixes #2871
2021-03-23 16:23:56 +01:00
Dmitry Simonenko
6a1c81b63e Add distributed restore point functionality
This change adds create_distributed_restore_point() function
which allows to create recovery restore point across data
nodes.

Fix #2846
2021-02-25 15:39:50 +03:00
Sven Klemm
06593a1c24 Release 2.1.0
This release adds major new features since the 2.0.2 release.
We deem it moderate priority for upgrading.

This release adds the long-awaited support for PostgreSQL 13 to TimescaleDB.
The minimum required PostgreSQL 13 version is 13.2 due to a security vulnerability
affecting TimescaleDB functionality present in earlier versions of PostgreSQL 13.

This release also relaxes some restrictions for compressed hypertables;
namely, TimescaleDB now supports adding columns to compressed hypertables
and renaming columns of compressed hypertables.

**Major Features**
* #2779 Add support for PostgreSQL 13

**Minor features**
* #2736 Support adding columns to hypertables with compression enabled
* #2909 Support renaming columns of hypertables with compression enabled
2021-02-22 12:04:22 +01:00
Erik Nordström
9ddf375fd5 Release 2.0.2
This maintenance release contains bugfixes since the 2.0.1 release. We
deem it high priority for upgrading.

The bug fixes in this release address issues with joins, the status of
background jobs, and disabling compression. It also includes
enhancements to continuous aggregates, including improved validation
of policies and optimizations for faster refreshes when there are a
lot of invalidations.

**Minor features**
* #2926 Optimize cagg refresh for small invalidations

**Bugfixes**
* #2850 Set status for backend in background jobs
* #2883 Fix join qual propagation for nested joins
* #2884 Add GUC to control join qual propagation
* #2885 Fix compressed chunk check when disabling compression
* #2908 Fix changing column type of clustered hypertables
* #2942 Validate continuous aggregate policy

**Thanks**
* @zeeshanshabbir93 for reporting the issue with full outer joins
* @Antiarchitect for reporting the issue with slow refreshes of
* @diego-hermida for reporting the issue about being unable to disable
  compression
* @mtin for reporting the issue about wrong job status
2021-02-19 16:39:42 +01:00
Ruslan Fomkin
6d679a14d0 Release 1.7.5
This maintenance release contains bugfixes since the 1.7.4 release.
Most of these fixes were backported from the 2.0.0 and 2.0.1 releases.
We deem it high priority for upgrading for users on TimescaleDB 1.7.4
or previous versions.

In particular the fixes contained in this maintenance release address
issues in continuous aggregates, compression, JOINs with hypertables,
and when upgrading from previous versions.

**Bugfixes**
* #2502 Replace check function when updating
* #2558 Repair dimension slice table on update
* #2619 Fix segfault in decompress_chunk for chunks with dropped
  columns
* #2664 Fix support for complex aggregate expression
* #2800 Lock dimension slices when creating new chunk
* #2860 Fix projection in ChunkAppend nodes
* #2865 Apply volatile function quals at decompresschunk
* #2851 Fix nested loop joins that involve compressed chunks
* #2868 Fix corruption in gapfill plan
* #2883 Fix join qual propagation for nested joins
* #2885 Fix compressed chunk check when disabling compression
* #2920 Fix repair in update scripts

**Thanks**
* @akamensky for reporting several issues including segfaults after
  version update
* @alex88 for reporting an issue with joined hypertables
* @dhodyn for reporting an issue when joining compressed chunks
* @diego-hermida for reporting an issue with disabling compression
* @Netskeh for reporting bug on time_bucket problem in continuous
  aggregates
* @WarriorOfWire for reporting the bug with gapfill queries not being
  able to find pathkey item to sort
* @zeeshanshabbir93 for reporting an issue with joins
2021-02-12 16:07:11 +01:00
Sven Klemm
e3c6725ad1 Fix compressed chunk check when disabling compression
The check for existence of compressed chunks when disabling
compression would not ignore dropped chunks making it impossible
to disable compression on hypertables with continuous aggregates
that had dropped chunks.
This patch ignores dropped chunks in this check and also sets
compressed_chunk_id to NULL in the metadata for deleted chunks.
2021-02-02 14:33:53 +01:00
Sven Klemm
636c8bbdae Release 2.0.1
This maintenance release contains bugfixes since the 2.0.0 release. We deem it
high priority for upgrading.

In particular the fixes contained in this maintenance release address issues
in continuous aggregates, compression, JOINs with hypertables and when
upgrading from previous versions.

**Bugfixes**
* #2772 Always validate existing database and extension
* #2780 Fix config enum entries for remote data fetcher
* #2806 Add check for dropped chunk on update
* #2828 Improve cagg watermark caching
* #2842 Do not mark job as started when setting next_start field
* #2845 Fix continuous aggregate privileges during upgrade
* #2851 Fix nested loop joins that involve compressed chunks
* #2860 Fix projection in ChunkAppend nodes
* #2861 Remove compression stat update from update script
* #2865 Apply volatile function quals at decompresschunk node
* #2866 Avoid partitionwise planning of partialize_agg
* #2868 Fix corruption in gapfill plan
* #2874 Fix partitionwise agg crash due to uninitialized memory

**Thanks**
* @alex88 for reporting an issue with joined hypertables
* @brian-from-quantrocket for reporting an issue with extension update and dropped chunks
* @dhodyn for reporting an issue when joining compressed chunks
* @markatosi for reporting a segfault with partitionwise aggregates enabled
* @PhilippJust for reporting an issue with add_job and initial_start
* @sgorsh for reporting an issue when using pgAdmin on windows
* @WarriorOfWire for reporting the bug with gapfill queries not being
  able to find pathkey item to sort
2021-01-28 17:28:05 +01:00
Mats Kindahl
c71632542c Fix repair in update scripts
The commit fixes two bugs in the repair scripts that could
prevent an update in rare circumstances.

For the 1.7.1--1.7.2 repair script: if there were several missing
dimension slices in different hypertables with the same column name,
the repair script would be confused on what constraint had what type
and generate an error.

For the 2.0.0-rc1--2.0.0-rc2 repair script: if a partition constraint
was broken, it would generate an error rather than repairing the
dimension slices because BIGINT_MIN would be cast to a double float and
then an attempt would be made to cast it back to bigint, causing an
overflow error.

This commit also creates an update repair test that breaks a few tables
for pre-2.0 versions to ensure that the repair script actually fixes
them.  The integrity check for the update tests already contain a check
that dimension slices are valid, so there is no need to add a test for
that.

This commit adds an extra dimension in the workflow to test updates
with repair and run that separately. It also changes the update test
scripts to by default run without repair tests and add the additional
option `-r` for running repair tests in addition to the normal tests.

Fixes #2824
2021-01-28 15:04:30 +01:00
Erik Nordström
86f8e30ae0 Fix continuous aggregate privileges during update
Copy ACL privileges (grants) from the query view (user-facing object)
to the internal objects (e.g., materialized hypertable, direct view,
and partial view) when updating the extension to the new version. A
previous change added such propagation of privileges when executing
`GRANT` statements, but didn't apply it retrospectively to the
internal objects of existing continuous aggregates.

Having the right permissions on internal objects is also necessary for
the watermark function used by real-time aggregation since it queries
the materialized hypertable directly.

The update script copies the ACL information from the user-facing view
of every continuous aggregate to its internal objects (including the
materialized hypertable and its chunks). This is done by direct insert
into `pg_class` instead of executing a `GRANT` statement in the update
script, since the latter will record the grant/ACL as an init
privilege (i.e., the system believes the GRANT is for an extension
object). The init privilege will prevent this ACL from being included
in future dump files, since `pg_dump` only includes non-init
privileges as it believes such privileges will be recreated with the
extension.

Fixes #2825
2021-01-27 13:57:34 +01:00
Mats Kindahl
126f1c815f Remove compression stat update from update script
Updating the compression stats can potentially be a very big task
locking many tables, so we remove it from the update script. We also
remove the check from the update test.

Fixes #2859
2021-01-26 10:36:54 +01:00
Mats Kindahl
51745b3553 Add check for dropped chunk on update
If `drop_chunks` has been executed on a hypertable that has a
continuous aggregate defined, the chunks will be removed and marked as
dropped in `_timescaledb_catalog.chunk` but the lines will not be
removed. This will cause problems for the update script since it is
missing a check to only process chunks that are not dropped and will
try to cast the chunk name into a `REGCLASS` for a table that does not
exist.

This commit fixes this by adding a check that the chunk is not dropped
and also fixes the update test to not count dropped chunks when
comparing with the chunk index since the chunk index does not count
dropped chunks.

Fixes #2791
2021-01-13 13:34:36 +01:00
Ruslan Fomkin
5fc3f45185 Release 2.0.0
With this release, we are officially moving TimescaleDB 2.0 to GA,
concluding several release candidates.

TimescaleDB 2.0 adds the much-anticipated support for distributed
hypertables (multi-node TimescaleDB), as well as new features and
enhancements to core functionality to give users better clarity and
more control and flexibility over their data.

Multi-node architecture:  In particular, with TimescaleDB 2.0, users
can now create distributed hypertables across multiple instances of
TimescaleDB, configured so that one instance serves as an access node
and multiple others as data nodes. All queries for a distributed
hypertable are issued to the access node, but inserted data and queries
are pushed down across data nodes for greater scale and performance.

Multi-node TimescaleDB can be self managed or, for easier operation,
launched within Timescale's fully-managed cloud services.

This release also adds:

* Support for user-defined actions, allowing users to define,
  customize, and schedule automated tasks, which can be run by the
  built-in jobs scheduling framework now exposed to users.
* Significant changes to continuous aggregates, which now separate the
  view creation from the policy.  Users can now refresh individual
  regions of the continuous aggregate materialized view, or schedule
  automated refreshing via  policy.
* Redesigned informational views, including new (and more general)
  views for information about hypertable's dimensions and chunks,
  policies and user-defined actions, as well as support for multi-node
  TimescaleDB.
* Moving all formerly enterprise features into our Community Edition,
  and updating Timescale License, which now provides additional (more
  permissive) rights to users and developers.

Some of the changes above (e.g., continuous aggregates, updated
informational views) do introduce breaking changes to APIs and are not
backwards compatible. While the update scripts in TimescaleDB 2.0 will
upgrade databases running TimescaleDB 1.x automatically, some of these
API and feature changes may require changes to clients and/or upstream
scripts that rely on the previous APIs.  Before upgrading, we recommend
reviewing upgrade documentation at docs.timescale.com for more details.

**Major Features**

TimescaleDB 2.0 moves the following major features to GA:
* #1923 Add support for distributed hypertables
* #2006 Add support for user-defined actions
* #2125 #2221 Improve Continuous Aggregate API
* #2084 #2089 #2098 #2417 Redesign informational views
* #2435 Move enterprise features to community
* #2437 Update Timescale License

**Previous Release Candidates**

* #2702 Release Candidate 4 (December 2, 2020)
* #2637 Release Candidate 3 (November 12, 2020)
* #2554 Release Candidate 2 (October 20, 2020)
* #2478 Release Candidate 1 (October 1, 2020)

**Minor Features**

Since the last release candidate 4, there are several minor
improvements:
* #2746 Optimize locking for create chunk API
* #2705 Block tableoid access on distributed hypertable
* #2730 Do not allow unique index on compressed hypertables
* #2764 Bootstrap data nodes with versioned extension

**Bugfixes**

Since the last release candidate 4, there are several bugfixes:
* #2719 Support disabling compression on distributed hypertables
* #2742 Fix compression status in chunks view for distributed chunks
* #2751 Fix crash and cancel when adding data node
* #2763 Fix check constraint on hypertable metadata table

**Thanks**

Thanks to all contributors for the TimescaleDB 2.0 release:
* @airton-neto for reporting a bug in executing some queries with UNION
* @nshah14285 for reporting an issue with propagating privileges
* @kalman5 for reporting an issue with renaming constraints
* @LbaNeXte for reporting a bug in decompression for queries with
  subqueries
* @semtexzv for reporting an issue with continuous aggregates on
  int-based hypertables
* @mr-ns for reporting an issue with privileges for creating chunks
* @cloud-rocket for reporting an issue with setting an owner on
  continuous aggregate
* @jocrau for reporting a bug during creating an index with transaction
  per chunk
* @fvannee for reporting an issue with custom time types
* @ArtificialPB for reporting a bug in executing queries with
  conditional ordering on compressed hypertable
* @dutchgecko for reporting an issue with continuous aggregate datatype
  handling
* @lambdaq for suggesting to improve error message in continuous
  aggregate creation
* @francesco11112 for reporting memory issue on COPY
* @Netskeh for reporting bug on time_bucket problem in continuous
  aggregates
* @mr-ns for reporting the issue with CTEs on distributed hypertables
* @akamensky for reporting an issue with recursive cache invalidation
* @ryanbooz for reporting slow queries with real-time aggregation on
  continuous aggregates
* @cevian for reporting an issue with disabling compression on
  distributed hypertables
2020-12-21 17:06:58 +01:00
Erik Nordström
40367d2dbf Fix check constraint on hypertable metadata table
The `replication_factor` is set to `-1` on hypertables that are
created on data nodes as part of a larger distributed
hypertable. However, the check constraint on the hypertable metadata
table doesn't allow such values, causing update scripts to fail when
this check constraint is recreated as part of updating to version
`2.0.0-rc4`.

The reason it is possible to insert violating rows is because check
constraints aren't validated when inserting data using PostgreSQL's
internal catalog functions (in C). Therefore, the violating row can
exist until one tries to update a data node to `2.0.0-rc4`, at which
point the update script tries to recreate the `hypertable` metadata
table due to other changes that were made to the table.

This change fixes the check constraint to account for `-1` as a valid
value, and also changes the update scripts to account for the new
check constraint so that updates to the latest version will no longer
fail.
2020-12-21 12:31:43 +01:00
Ruslan Fomkin
2500172a80 Revert "Release 2.0.0"
This reverts the 2.0.0 release commit, since new commits need to be
merged before the release.
2020-12-21 10:35:09 +01:00
Ruslan Fomkin
07175eb888 Release 2.0.0
With this release, we are officially moving TimescaleDB 2.0 to GA,
concluding several release candidates.

TimescaleDB 2.0 adds the much-anticipated support for distributed
hypertables (multi-node TimescaleDB), as well as new features and
enhancements to core functionality to give users better clarity and
more control and flexibility over their data.

Multi-node architecture:  In particular, with TimescaleDB 2.0, users
can now create distributed hypertables across multiple instances of
TimescaleDB, configured so that one instance serves as an access node
and multiple others as data nodes. All queries for a distributed
hypertable are issued to the access node, but inserted data and queries
are pushed down across data nodes for greater scale and performance.

Multi-node TimescaleDB can be self managed or, for easier operation,
launched within Timescale's fully-managed cloud services.

This release also adds:

* Support for user-defined actions, allowing users to define,
  customize, and schedule automated tasks, which can be run by the
  built-in jobs scheduling framework now exposed to users.
* Significant changes to continuous aggregates, which now separate the
  view creation from the policy.  Users can now refresh individual
  regions of the continuous aggregate materialized view, or schedule
  automated refreshing via  policy.
* Redesigned informational views, including new (and more general)
  views for information about hypertable's dimensions and chunks,
  policies and user-defined actions, as well as support for multi-node
  TimescaleDB.
* Moving all formerly enterprise features into our Community Edition,
  and updating Timescale License, which now provides additional (more
  permissive) rights to users and developers.

Some of the changes above (e.g., continuous aggregates, updated
informational views) do introduce breaking changes to APIs and are not
backwards compatible. While the update scripts in TimescaleDB 2.0 will
upgrade databases running TimescaleDB 1.x automatically, some of these
API and feature changes may require changes to clients and/or upstream
scripts that rely on the previous APIs.  Before upgrading, we recommend
reviewing upgrade documentation at docs.timescale.com for more details.

**Major Features**

TimescaleDB 2.0 moves the following major features to GA:
* #1923 Add support for distributed hypertables
* #2006 Add support for user-defined actions
* #2125 #2221 Improve Continuous Aggregate API
* #2084 #2089 #2098 #2417 Redesign informational views
* #2435 Move enterprise features to community
* #2437 Update Timescale License

**Previous Release Candidates**

* #2702 Release Candidate 4 (December 2, 2020)
* #2637 Release Candidate 3 (November 12, 2020)
* #2554 Release Candidate 2 (October 20, 2020)
* #2478 Release Candidate 1 (October 1, 2020)

**Minor Features**

Since the last release candidate 4, it includes several minor
improvements:
* #2746 Optimize locking for create chunk API
* #2705 Block tableoid access on distributed hypertable
* #2730 Do not allow unique index on compressed hypertables

**Bugfixes**

Since the last release candidate 4, it includes several bugfixes:
* #2719 Support disabling compression on distributed hypertables
* #2742 Fix compression status in chunks view for distributed chunks
* #2751 Fix crash and cancel when adding data node

**Thanks**

Thanks to all contributors for the TimescaleDB 2.0 release:
* @airton-neto for reporting a bug in executing some queries with UNION
* @nshah14285 for reporting an issue with propagating privileges
* @kalman5 for reporting an issue with renaming constraints
* @LbaNeXte for reporting a bug in decompression for queries with
  subqueries
* @semtexzv for reporting an issue with continuous aggregates on
  int-based hypertables
* @mr-ns for reporting an issue with privileges for creating chunks
* @cloud-rocket for reporting an issue with setting an owner on
  continuous aggregate
* @jocrau for reporting a bug during creating an index with transaction
  per chunk
* @fvannee for reporting an issue with custom time types
* @ArtificialPB for reporting a bug in executing queries with
  conditional ordering on compressed hypertable
* @dutchgecko for reporting an issue with continuous aggregate datatype
  handling
* @lambdaq for suggesting to improve error message in continuous
  aggregate creation
* @francesco11112 for reporting memory issue on COPY
* @Netskeh for reporting bug on time_bucket problem in continuous
  aggregates
* @mr-ns for reporting the issue with CTEs on distributed hypertables
* @akamensky for reporting an issue with recursive cache invalidation
* @ryanbooz for reporting slow queries with real-time aggregation on
  continuous aggregates
* @cevian for reporting an issue with disabling compression on
  distributed hypertables
2020-12-18 21:15:25 +01:00
gayyappan
bbac35b094 Fix compression status in chunks view for distributed chunks
The compression status of individual chunks for distributed tables is
unknown on the access node. Fix the view so that is_compressed is NULL
 instead of false for distributed chunks.
2020-12-16 10:51:31 -05:00
Mats Kindahl
e945ac762c Release 2.0.0-rc4
This release candidate contains bugfixes since the previous release
candidate, as well as additional minor features. It improves
validation of configuration changes for background jobs, adds support
for gapfill on distributed tables, contains improvements to the memory
handling for large COPY, and contains improvements to compression for
distributed hypertables.

**Minor Features**
* #2689 Check configuration in alter_job and add_job
* #2696 Support gapfill on distributed hypertable
* #2468 Show more information in get_git_commit
* #2678 Include user actions into job stats view
* #2664 Fix support for complex aggregate expression
* #2672 Add hypertable to continuous aggregates view
* #2662 Save compression metadata settings on access node
* #2707 Introduce additional db for data node bootstrapping

**Bugfixes**
* #2688 Fix crash for concurrent drop and compress chunk
* #2666 Fix timeout handling in async library
* #2683 Fix crash in add_job when given NULL interval
* #2698 Improve memory handling for remote COPY
* #2555 Set metadata for chunks compressed before 2.0
2020-12-03 09:31:30 +01:00
Sven Klemm
7fe74d4f07 Add test for statistics on compressed chunks
Add a test for updating statistics on chunks compressed before
statistics where kept. This patch also sets metadata for previously
compressed chunks so running ANALYZE on them will set the correct
tuplecount.
2020-12-02 19:11:33 +01:00
gayyappan
7c76fd4d09 Save compression settings on access node for distributed hypertables
1. Add compression_state column for hypertable catalog
by renaming compressed column for the hypertable catalog
table. compression_state is a tri-state column.
This column indicates if the hypertable has
compression enabled (value = 1) or if it is an internal
compression table (value = 2).

2. Save compression settings on access node when compression
is turned on for a distributed hypertable
For a distributed hypertable, that has compression enabled,
compression_state is set. We don't create any internal tables
on the access node.

Fixes #2660
2020-12-02 10:42:57 -05:00
Mats Kindahl
1e7f961055 Show more information in get_git_commit
The command `get_git_commit` shows quite a little information and
especially if mistakes are made it is hard to verify what the binary is
actually based on.

This commit extends the function to provide some more information:
specifically the SHA of the HEAD regardless of whether there is a tag
on it or not and the time for the HEAD commit.

```
postgres=# select * from _timescaledb_internal.get_git_commit();
        commit_tag        | commit_hash |      commit_time
--------------------------+-------------+------------------------
 1.7.4-10-g09b0b778-dirty | 09b0b778    | 2020-09-13 17:50:38+02
(1 row)
```

If git is not installed, the function `get_git_commit` will return an
error indicating that no git information is available. If some of the
fields are available, they will be emitted and the remaining fields
will be NULL.

Fixes #2457
2020-11-26 21:43:13 +01:00
Ruslan Fomkin
79b7f4b14d Include user actions into job stats view
timescale_information.job_stats view was missing information about
jobs running user actions, since they don't have associated
hypertables. This commit fixes that the view includes user jobs in
addition to the predefined policies, which were already covered as all
of them reference a hypertable.
2020-11-24 15:39:10 +01:00
Erik Nordström
c1abf3b5c1 Add hypertable to continuous aggregates view
Add the hypertable's schema and name to the continuous aggregates view
in the information schema, since these fields where missing.

The new fields use the same names and order in the view to be
consistent with other information views that reference the hypertable.

Fixes #2653
2020-11-23 16:17:33 +01:00
Erik Nordström
54f943b8f9 Release 2.0.0-rc3
This release candidate contains bugfixes since the previous release
candidate, as well as additional minor features including support for
"user-mapping" authentication between access/data nodes and an
experimental API for refreshing continuous aggregates on individual
chunks.

**Minor Features**
* #2627 Add optional user mappings support
* #2635 Add API to refresh continuous aggregate on chunk

**Bugfixes**
* #2560 Fix SCHEMA DROP CASCADE with continuous aggregates
* #2593 Set explicitly all lock parameters in alter_job
* #2604 Fix chunk creation on hypertables with foreign key constraints
* #2610 Support analyze of internal compression table
* #2612 Optimize internal cagg_watermark function
* #2613 Refresh correct partial during refresh on drop
* #2617 Fix validation of available extensions on data node
* #2619 Fix segfault in decompress_chunk for chunks with dropped columns
* #2620 Fix DROP CASCADE for continuous aggregate
* #2625 Fix subquery errors when using AsyncAppend
* #2626 Fix incorrect total_table_pages setting for compressed scan
* #2628 Stop recursion in cache invalidation
2020-11-12 13:10:43 +01:00
Ruslan Fomkin
791b0a4db7 Add API to refresh continuous aggregate on chunk
Function refresh_continuous_aggregate, which takes a continuous
aggregate and a chunk, is added. It refreshes the continuous aggregate
on the given chunk if there are invalidations. The function can be
used in a transaction, e.g., together with following drop_chunks. This
allows users to create a user defined action to refresh and drop
chunks. Therefore, the refresh on drop is removed from drop_chunks.
2020-11-12 08:33:35 +01:00
Erik Nordström
47d26b422e Allow optional password when adding data node
Add an optional password parameter to `add_data_node` so that users
that don't have a password in a `passfile` on the access node can add
data nodes using password authentication. Together with user mappings,
this allows full multinode configuration without relying on passwords
or certificates provided in external/on-disk files.

While wasswords can be provided in the database via a user mapping
object, such a mapping is created on a per-server basis and requires
the foreign server to exist prior to creating the mapping. When adding
a data node, however, bootstrapping and/or validation of the data node
happens at the same time as the server object is created, which means
no user mapping can be created prior to adding the data
node. Therefore, the password must be provided as an argument to add
data node instead of via a user mapping.

Fortunately, using a function parameter might be preferred to a user
mapping since the (plaintext) password won't be stored in the
database. A user mapping for the user that created the data node can
optionally be added after the data node has been added. But it might
be desirable to only create user mappings for unprivileged users that
will mostly interact only with specific distributed hypertables.
2020-11-10 13:48:21 +01:00
Tyler Fontaine
1bccedf3f8 Limit Index Tablespace Lookup To p and u Constraints
This resolves an issue when using both constraints with index
tablespaces AND constraints that have no indexes on a single hypertable.

chunk_constraint_add_table_constraint() was attempting to add
`USING INDEX TABLESPACE` to all constraints when a given hypertable had
any constraint configured to use a tablespace, resulting in a SYNTAX
error and blocking the creation of new chunks.

The solution here is to limit index tablespace lookups to only the
constraint types which use indexes: primary key and unique so that only
those constraits will have `USING INDEX TABLESPACE` prepended when
necessary.
2020-11-04 08:39:44 -06:00
Sven Klemm
7c7b4f995c Fix distributed_exec create statement 2020-10-21 01:30:01 +02: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
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
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
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
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
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
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
Sven Klemm
c3b9ca9e49 Fix compression_settings view definition 2020-10-06 01:50:53 +02:00
Sven Klemm
46f7914e19 Release 2.0.0-rc1
This release adds major new features and bugfixes since the 1.7.4 release.
We deem it moderate priority for upgrading.

This release adds the long-awaited support for distributed hypertables to
TimescaleDB. With 2.0, users can create distributed hypertables across
multiple instances of TimescaleDB, configured so that one instance serves
as an access node and multiple others as data nodes. All queries for a
distributed hypertable are issued to the access node, but inserted data
and queries are pushed down across data nodes for greater scale and
performance.

This release also adds support for user-defined actions allowing users to
define actions that are run by the TimescaleDB automation framework.

In addition to these major new features, the 2.0 branch introduces _breaking_ changes
to APIs and existing features, such as continuous aggregates. These changes are not
backwards compatible and might require changes to clients and/or scripts that rely on
the previous APIs. Please review our updated documentation and do proper testing to
ensure compatibility with your existing applications.

The noticeable breaking changes in APIs are:
- Redefined functions for policies
- A continuous aggregate is now created with `CREATE MATERIALIZED VIEW`
  instead of `CREATE VIEW` and automated refreshing requires adding a policy
  via `add_continuous_aggregate_policy`
- Redesign of informational views, including new (and more general) views for
  information about policies and user-defined actions

This release candidate is upgradable, so if you are on a previous release (e.g., 1.7.4)
you can upgrade to the release candidate and later expect to be able to upgrade to the
final 2.0 release. However, please carefully consider your compatibility requirements
_before_ upgrading.

**Major Features**
* #1923 Add support for distributed hypertables
* #2006 Add support for user-defined actions
* #2435 Move enterprise features to community
* #2437 Update Timescale License

**Minor Features**
* #2011 Constify TIMESTAMPTZ OP INTERVAL in constraints
* #2105 Support moving compressed chunks

**Bugfixes**
* #1843 Improve handling of "dropped" chunks
* #1886 Change ChunkAppend leader to use worker subplan
* #2116 Propagate privileges from hypertables to chunks
* #2263 Fix timestamp overflow in time_bucket optimization
* #2270 Fix handling of non-reference counted TupleDescs in gapfill
* #2325 Fix rename constraint/rename index
* #2370 Fix detection of hypertables in subqueries
* #2376 Fix caggs width expression handling on int based hypertables
* #2416 Check insert privileges to create chunk
* #2428 Allow owner change of continuous aggregate
* #2436 Propagate grants in continuous aggregates
2020-10-05 22:00:16 +02:00
Sven Klemm
3f5872ec61 Run pg_format on SQL files 2020-10-05 21:33:42 +02:00
Sven Klemm
dbd707b17e Fix datanode sql function script
This patch merge data_node and remote_txn sql scripts and fixes
the CREATE FUNCTION statement to use CREATE OR REPLACE FUNCTION.
2020-10-05 19:35:51 +02:00
Brian Rowe
2dc15ee345 Show unscheduled jobs as paused in job_stats
This change updates the timescaledb_information.job_stats view to
check whether a job is currently scheduled in the bgw_config table.
If it is not, the `job_status` field will show `Paused` and the
`next_start` field will be NULL.

Fixes #2488
2020-10-05 10:14:56 -07:00
Sven Klemm
a1cf324063 Fix timescaledb_fdw sql script
Since CREATE FOREIGN DATA WRAPPER is not idempotent it must not be
grouped with the normal sql scripts but has to be in the pre_install
group.
2020-10-05 18:42:32 +02:00
Erik Nordström
4623db14ad Use consistent column names in views
Make all views that reference hypertables use `hypertable_schema` and
`hypertable_name`.
2020-10-05 15:18:47 +02:00
Mats Kindahl
c029a7be02 Remove use of REGCLASS in views
Removing usage of `REGCLASS` from view `continuous_aggregates` and
splitting it into schema and name.
2020-10-05 14:07:22 +02:00
Erik Nordström
7a406fa690 Make data nodes view consistent with other views
Rename the data_node view to data_nodes to be consistent with other
views that all use the plural form.
2020-10-05 12:24:54 +02:00
gayyappan
5a5cbe1a93 Rename column in job_stats view
Rename next_scheduled_run to next_start so that
jobs and job_stats views have the same column names
2020-10-02 13:36:47 -04:00