3750 Commits

Author SHA1 Message Date
Sven Klemm
93667df7d8 Release 2.9.1
This release contains bug fixes since the 2.9.0 release.
This release is high priority for upgrade. We strongly recommend that you
upgrade as soon as possible.

**Bugfixes**
* #5072 Fix CAgg on CAgg bucket size validation
* #5101 Fix enabling compression on caggs with renamed columns
* #5106 Fix building against PG15 on Windows
* #5117 Fix postgres server restart on background worker exit
* #5121 Fix privileges for job_errors in update script
2022-12-23 14:38:45 +01:00
Konstantina Skovola
0a3615fc70 Fix privileges for job_errors table in update script 2022-12-23 14:05:19 +02:00
Konstantina Skovola
cdf8676689 Fix postgres server restart on background worker exit
Fixed by removing the croak signal handler that was introduced
to enable the silent exit of the telemetry job.
2022-12-23 11:50:59 +02:00
Sven Klemm
ca609696d6 Fix Windows package test 2022-12-22 15:40:39 +01:00
Sven Klemm
b1314e63f2 Fix RPM package test for PG15 on centos 7
Installing PG15 on Centos 7 requires the EPEL repository to satisfy
the dependencies.
2022-12-22 13:30:06 +01:00
Sven Klemm
4527f51e7c Refactor INSERT into compressed chunks
This patch changes INSERTs into compressed chunks to no longer
be immediately compressed but stored in the uncompressed chunk
instead and later merged with the compressed chunk by a separate
job.

This greatly simplifies the INSERT-codepath as we no longer have
to rewrite the target of INSERTs and on-the-fly compress leading
to a roughly 2x improvement on INSERT rate into compressed chunk.
Additionally this improves TRIGGER-support for INSERTs into
compressed chunks.

This is a necessary refactoring to allow UPSERT/UPDATE/DELETE on
compressed chunks in follow-patches.
2022-12-21 12:53:29 +01:00
Sven Klemm
bd20afccbb Add test for PG15 windows package 2022-12-21 10:44:07 +01:00
Sven Klemm
1d51672336 Skip package downgrade test for PG15
Since we currently only have 1 released version that supports PG15
we cannot test downgrade with PG15.
2022-12-20 20:19:15 +01:00
Lakshmi Narayanan Sreethar
a4806827dc Enable PG15 in various CI checks
This commit enables PG15 in the following workflows:
 - Regression Linux
 - ABI test
 - Memory tests
 - Coverity
 - SQLSmith
 - Additional cron tests

Co-authored-by: Bharathy Satish <bharathy@timescale.com>
2022-12-20 23:39:47 +05:30
Fabrízio de Royes Mello
024b1e1f30 Fix CAgg on CAgg bucket size validation
The bucket size of a Continuous Aggregate should be greater or equal to
the parent Continuous Aggregate because there are many cases where you
actually want to roll up on another dimension.
2022-12-20 14:03:45 -03:00
Bharathy
c5e496a554 Fix column ordering in compressed table index.
When defining compression segment by parameter using multiple columns,
the parameter ordering is not respected for index creation.

This patch fixes the issue by maintaining the same order in which user
has defined columns in segment by clause.

Fixes #5104
2022-12-20 21:11:35 +05:30
Sven Klemm
7d1b74a8c6 Use rand() instead of random()
Use rand() instead of random() cause the latter is not available
on Windows and postgres stopped backporting it with PG15.
Ideally we switch to the crypto functions added in PG15 but that
requires a bit more work and this is the minimal change required
to get it to build against PG15 on Windows.
2022-12-20 15:12:24 +01:00
Sven Klemm
b74f563a33 Run regression tests on pg15 windows 2022-12-20 15:12:24 +01:00
Sven Klemm
08bb21f7e6 2.9.0 Post-release adjustments
Add 2.9.0 to update test scripts and adjust downgrade scripts for
2.9.0. Additionally adjust CHANGELOG to sync with the actual release
CHANGELOG and add PG15 to CI.
2022-12-19 19:10:24 +01:00
Alexander Kuzmenkov
27310470be Allow AsyncAppend under IncrementalSort
We forgot to add a case for it.
2022-12-19 21:16:14 +04:00
Sven Klemm
c0e9bb4a30 Fix enabling compression on caggs with renamed columns
On caggs with realtime aggregation changing the column name does
not update all the column aliases inside the view metadata.
This patch changes the code that creates the compression
configuration for caggs to get the column name from the materialization
hypertable instead of the view internals.

Fixes #5100
2022-12-19 10:46:37 +01:00
Fabrízio de Royes Mello
317f8f1a99 Refactor CAggs on CAggs regression tests
When CAggs on CAggs was introduced in commit 3749953 the regression
tests was splited into 6 (six) different test suites.

Simplyfied it grouping tests and reduced to just 2 (two) different test
suites. It save resources and time because each suite test spawn it own
Postgres instance.
2022-12-17 17:19:43 -03:00
Fabrízio de Royes Mello
854b677749 Fix broken postgres install on Windows CI
The last minor versions for PG14 (14.6) and PG15 (15.1) were unlisted by
chocolatey maintainers due to some issues.

Fixed it by hardcoding the 14.5 until the packages become available
again.
2022-12-17 12:10:27 -03:00
Fabrízio de Royes Mello
4694c7d798 Refactor CAgg migrate regression tests
When CAggs migration was introduced in commit e34218ce the regression
tests was splited into 6 (six) different test suites.

Simplyfied it grouping tests and reduced to just 2 (two) different test
suites. It save resources and time because each suite test spawn it own
Postgres instance.
2022-12-16 14:39:44 -03:00
Mats Kindahl
e5843dddd3 Link development and design documentation
The tree contains a lot of design and architecture documents, but they
are not linked together, so this commits adds a few additional README
and build a basic structure for the documentation.
2022-12-15 21:35:36 +01:00
shhnwz
601b37daa8 Index support for compress chunk
It allows to override tuplesort with indexscan
if compression setting keys matches with Index keys.
Moreover this feature has Enable/Disable Toggle.
To Disable from the client use the following command,
SET timescaledb.enable_compression_indexscan = 'OFF'
2022-12-15 20:26:00 +05:30
Ante Kresic
cbf51803dd Fix index att number calculation
Attribute offset was used by mistake where attribute number was
needed causing wrong values to be fetched when scanning
compressed chunk index.
2022-12-15 11:23:10 +01:00
Ante Kresic
3f9e3379a9 Allow BitmapHeapScans on non-parameterized paths
Planner can decide to use BitmapHeapScans exclusively when
scanning compressed chunks. Since we filter out such scans
due to previously reported issues, this can lead to no
query plan devised when querying compressed chunks. This
change allows Bitmap scans on compressed chunks only when
it is not parameterized.

Fixes #5090
2022-12-15 11:23:10 +01:00
Lakshmi Narayanan Sreethar
3b3846b0ff Fix assertion failure in cursor_fetcher_rewind
The cursor_fetcher_rewind method assumes that the data node cursor is
rewind either after eof or when there is an associated request. But the
rewind can also occur once the server has generated required number of
rows by joining the relation being scanned with another regular
relation. In this case, the fetch would not have reached eof and there
will be no associated requests as the rows would have been already
loaded into the cursor causing the assertion in cursor_fetcher_rewind
to fail. Fixed that by removing the Assert and updating
cursor_fetcher_rewind to discard the response only if there is an
associated request.

Fixes #5053
2022-12-14 21:00:53 +05:30
Jan Nidzwetzki
940626b1d4 Fix Git permission issue during CI build
The new permissions checks to fix CVE-2022-29187 in Git caused some
issues in our CI pipeline. This patch adds the checkout directory to
Git's "safe.directory" setting.
2022-12-14 16:05:22 +01:00
Mats Kindahl
558688c86f Reset baserel cache on invalid hypertable cache
When popping the hypertable cache stack, it might happen that the
hypertable cache was invalidated between the push and the pop. In that
case, the baserel cache can contain invalid entries pointing to the now
popped hypertable cache, so we reset the baserel cache.

Fixes #4795
2022-12-13 19:42:38 +01:00
Matvey Arye
df16815009 Fix memory leak for compression with merge chunks
The RelationInitIndexAccessInfo call leaks cache memory and
seems to be unnecessary.
2022-12-13 08:22:49 +01:00
Ildar Musin
13ac2fc63a Add a GUC variable to enable/disable OSM for
SELECTs
2022-12-12 19:08:56 +01:00
Bharathy
dd65a6b436 Fix segfault after second ANALYZE
Issue occurs in extended query protocol mode only where every
query goes through PREPARE and EXECUTE phase. First time ANALYZE
is executed, a list of relations to be vaccumed is extracted and
saved in a list. This list is referenced in parsetree node. Once
execution of ANALYZE is complete, this list is cleaned up, however
reference to the same is not cleaned up in parsetree node. When
second time ANALYZE is executed, segfault happens as we access an
invalid memory location.

Fixed the issue by restoring the actual value in parsetree node
once ANALYZE completes its execution.

Fixes #4857
2022-12-12 17:34:41 +05:30
Jan Nidzwetzki
d92739099b Reduce test group size in sanitizer runs
When the sanitizer is active, the tests require a lot of memory. If they
are run in large parallel groups, out-of-memory situations can occur.
This patch reduces the size of parallel groups to 5 when the sanitizer
is active.
2022-12-09 08:26:47 +01:00
Alexander Kuzmenkov
a01e483bf3 More gdb output in CI
Print locals and arguments.
2022-12-09 08:05:05 +04:00
Jan Nidzwetzki
c76dfa0acb Improve Sanitizer checks
This patch contains two changes to the Sanitizer checks:

(1) All logfiles of the Sanitizer will be uploaded to the
    CI database.

(2) The Sanitizer checks are executed on every PR.
2022-12-08 10:55:17 +01:00
Jan Nidzwetzki
323d41b53b Ensure dist_hypertable is executed as solo test
The `dist_hypertable` test needs a lot of memory, especially when the
sanitizer is enabled. This patch runs this test as a `SOLO_TEST`. This
ensures that PostgreSQL does not run into an out-of-memory situation.
2022-12-08 08:57:14 +01:00
Jan Nidzwetzki
5fd9170b0a Correct sanitizer log directory
So far, we have treated the 'log_path' setting of the sanitizer like a
file. In fact, this value is used as a prefix for the created log file.
Since we expected the exact file name when uploading the sanitizer
output, this file was not found and we lost the messages of the
sanitizer. This PR changes the behavior. We now treat the setting as a
prefix and upload all files created in a new sanitizer output folder.
2022-12-07 21:17:44 +01:00
Bharathy
bfed42c2d3 Fix remote_txn on PG15
In remote_txn, testcases which kill remote processes on data nodes,
tend to rollback transactions and as part of the process, WARNINGS/ERROR
are reported to client. Client however reports WARNINGS/ERROR in different
order intermittently. This is an issue specific to psql utility. Placing
psql in gdb and trying to diagnise the problem does not reproduce the issue.

This patch fixes the tests by not reporting WARNINGS.

Fixes #4837
2022-12-06 12:07:49 +05:30
Erik Nordström
fd42fe76fa Read until EOF in COPY fetcher
Ensure the COPY fetcher implementation reads data until EOF with
`PQgetCopyData()`. Also ensure the malloc'ed copy data is freed with
`PQfreemem()` if an error is thrown in the processing loop.

Previously, the COPY fetcher didn't read until EOF, and instead
assumed EOF when the COPY file trailer is received. Since EOF wasn't
reached, it required terminating the COPY with an extra call to the
(deprecated) `PQendcopy()` function.

Still, there are cases when a COPY needs to be prematurely terminated,
for example, when querying with a LIMIT clause. Therefore, distinguish
between "normal" end (when receiving EOF) and forceful end (cancel the
ongoing query).
2022-12-05 18:28:35 +01:00
Sachin
cd4509c2a3 Release 2.9.0
This release adds major new features since the 2.8.1 release.
We deem it moderate priority for upgrading.

This release includes these noteworthy features:
* Hierarchical Continuous Aggregates (aka Continuous Aggregate on top of another Continuous Aggregate)
* Improve `time_bucket_gapfill` function allowing specifying timezone to bucket
* Use `alter_data_node()` to change the data node configuration. This function introduces the option to configure the availability of the data node.

This release also includes several bug fixes.

**Features**
* #4476 Batch rows on access node for distributed COPY
* #4567 Exponentially backoff when out of background workers
* #4650 Show warnings when not following best practices
* #4664 Introduce fixed schedules for background jobs
* #4668 Hierarchical Continuous Aggregates
* #4670 Add timezone support to time_bucket_gapfill
* #4678 Add interface for troubleshooting job failures
* #4718 Add ability to merge chunks while compressing
* #4786 Extend the now() optimization to also apply to CURRENT_TIMESTAMP
* #4820 Support parameterized data node scans in joins
* #4830 Add function to change configuration of a data nodes
* #4966 Handle DML activity when datanode is not available
* #4971 Add function to drop stale chunks on a datanode

**Bugfixes**
* #4663 Don't error when compression metadata is missing
* #4673 Fix now() constification for VIEWs
* #4681 Fix compression_chunk_size primary key
* #4696 Report warning when enabling compression on hypertable
* #4745 Fix FK constraint violation error while insert into hypertable which references partitioned table
* #4756 Improve compression job IO performance
* #4770 Continue compressing other chunks after an error
* #4794 Fix degraded performance seen on timescaledb_internal.hypertable_local_size() function
* #4807 Fix segmentation fault during INSERT into compressed hypertable
* #4822 Fix missing segmentby compression option in CAGGs
* #4823 Fix a crash that could occur when using nested user-defined functions with hypertables
* #4840 Fix performance regressions in the copy code
* #4860 Block multi-statement DDL command in one query
* #4898 Fix cagg migration failure when trying to resume
* #4904 Remove BitmapScan support in DecompressChunk
* #4906 Fix a performance regression in the query planner by speeding up frozen chunk state checks
* #4910 Fix a typo in process_compressed_data_out
* #4918 Cagg migration orphans cagg policy
* #4941 Restrict usage of the old format (pre 2.7) of continuous aggregates in PostgreSQL 15.
* #4955 Fix cagg migration for hypertables using timestamp without timezone
* #4968 Check for interrupts in gapfill main loop
* #4988 Fix cagg migration crash when refreshing the newly created cagg

**Thanks**
* @jflambert for reporting a crash with nested user-defined functions.
* @jvanns for reporting hypertable FK reference to vanilla PostgreSQL partitioned table doesn't seem to work
* @kou for fixing a typo in process_compressed_data_out
* @xvaara for helping reproduce a bug with bitmap scans in transparent decompression
* @byazici for reporting a problem with segmentby on compressed caggs
* @tobiasdirksen for requesting Continuous aggregate on top of another continuous aggregate
* @xima for reporting a bug in Cagg migration
2022-12-05 19:33:45 +05:30
Sachin
29f35da905 Fix Github CI failures
Not specifying alpine version causes libssl version
to change, which in turn cause error in downgrade tests
as well as ABI tests.
This commit also fixes shellcheck failures.
Some failing windows tests are addd to ignore list.

Co-authored-by: Lakshmi Narayanan Sreethar <lakshmi@timescale.com>
Co-authored-by: Alexander Kuzmenkov <akuzmenkov@timescale.com>
Signed-off-by: Sachin <sachin@timescale.com>
2022-12-05 18:15:21 +05:30
Sven Klemm
1a806e2fde Check for presence of RelationGetSmgr
RelationGetSmgr was backported by upstream to the STABLE branches
but is not yet available in any released version so we cannot use
pg version to determine presence of RelationGetSmgr.
2022-11-30 02:57:19 +01:00
Mats Kindahl
09c0ba7136 Do not spam log with telemetry problems
The telemetry process runs on a regular basis and usually does not make
a lot of noise, but in a few particular cases, it writes entries to the
log unnecessarily.

If the telemetry server cannot be contacted, it will print a warning in
the log that the server cannot be contacted. Since it is nothing wrong
with the system and the telemetry process will try to re-connect at a
later time, it is unnecessary to print as a warning.

If the telemetry response is malformed, a warning is printed. This is
also unnecessary since there is nothing wrong with the system, there is
nothing the user can do about it, and this warning can be largely
ignored.

If the hard-coded telemetry scheme is incorrect, a warning will be
printed. This should not normally happen, and if it happens on a
running server, there is nothing that can be done to eliminate the
error message and the message is unnecessary.

When the telemetry job exits, a standard termination message is
printed in the log. Although harmless, it is mostly confusing and
provide no value to the user.

If the telemetry process is attempting to connect, or is connected, to
the telemetry server, the telemetry server will wait until the
connection gets a timeout before shutting down. This is unnecessary
since there is no critical problem in aborting the connection and doing
a direct shutdown.

This commit turns those warnings into notices and installs a signal
handler so that the telemetry job exits silently and abort any
outstanding connections.

Fixes #4028
2022-11-29 12:18:00 +01:00
Sven Klemm
558da2c5c6 Use RelationGetSmgr instead of rd_smgr
rd_smgr should not be accessed directly but RelationGetSmgr should
be used instead. Accessing it directly can lead to segfaults when
parallel relcache flushes are happening.

f10f0ae420
2022-11-28 13:50:35 +01:00
Sven Klemm
2d0087a0e7 Fix segfault in cagg creation
When trying to create cagg on top of any relation that is a neither
a hypertable nor a continuous aggregate the command would segfault.
This patch changes the code to handle this case gracefully and error
out when trying to create a cagg on top of a relation that is not
supported. Found by coverity.
2022-11-28 12:19:20 +01:00
Fabrízio de Royes Mello
35c9120498 Add Hierarchical Continuous Aggregates validations
Commit 3749953e introduce Hierarchical Continuous Aggregates (aka
Continuous Aggregate on top of another Continuous Aggregate) but it
lacks of some basic validations.

Validations added during the creation of a Hierarchical Continuous
Aggregate:

* Forbid create a continuous aggregate with fixed-width bucket on top of
  a continuous aggregate with variable-width bucket.

* Forbid incompatible bucket widths:
  - should not be equal;
  - bucket width of the new continuous aggregate should be greater than
    the source continuous aggregate;
  - bucket width of the new continuous aggregate should be multiple of
    the source continuous aggregate.
2022-11-25 19:55:24 -03:00
Sven Klemm
83b13cf6f7 Use packaged postgres for sqlsmith and coverity CI
The sqlsmith and coverity workflows used the cache postgres build
but could not produce a build by themselves and therefore relied
on other workflows to produce the cached binaries. This patch
changes those workflows to use normal postgres packages instead
of custom built postgres to remove that dependency.
2022-11-25 21:37:49 +01:00
Sven Klemm
3b94b996f2 Use custom node to block frozen chunk modifications
This patch changes the code that blocks frozen chunk
modifications to no longer use triggers but to use custom
node instead. Frozen chunks is a timescaledb internal object
and should therefore not be protected by TRIGGER which is
external and creates several hazards. TRIGGERs created to
protect internal state contend with user-created triggers.
The trigger created to protect frozen chunks does not work
well with our restoring GUC which we use when restoring
logical dumps. Thirdly triggers are not functional for any
internal operations but are only working in code paths that
explicitly added trigger support.
2022-11-25 19:56:48 +01:00
Mats Kindahl
ce778faa11 Updating scheduled run
Updating scheduled run to avoid original creator from being notified.
2022-11-25 19:13:37 +01:00
Konstantina Skovola
4a30e5969b Fix flaky bgw_db_scheduler_fixed test
Apply date_trunc to last_successful_finish.

Commit 20cdd9ca3ed0c2d62779c4fc61d278a489b4460a mostly fixed
the flakiness, but date_trunc was not
applied to the last_successful_finish
so we still got some flaky runs.
2022-11-25 15:48:29 +02:00
Nikhil Sontakke
c92e29ba3a Fix DML HA in multi-node
If a datanode goes down for whatever reason then DML activity to
chunks residing on (or targeted to) that DN will start erroring out.
We now handle this by marking the target chunk as "stale" for this
DN by changing the metadata on the access node. This allows us to
continue to do DML to replicas of the same chunk data on other DNs
in the setup. This obviously will only work for chunks which have
"replication_factor" > 1. Note that for chunks which do not have
undergo any change will continue to carry the appropriate DN related
metadata on the AN.

This means that such "stale" chunks will become underreplicated and
need to be re-balanced by using the copy_chunk functionality by a micro
service or some such process.

Fixes #4846
2022-11-25 17:42:26 +05:30
Dmitry Simonenko
26e3be1452 Test dist caggs with an unavailable data node
Add additional test cases to ensure caggs functionality on distributed
hypertable during data node being unavailable.

Fix #4978
2022-11-24 19:15:40 +02:00
Dmitry Simonenko
826dcd2721 Ensure nodes availability using dist restore point
Make sure that a data node list does not have unavailable data nodes
when using create_distributed_restore_point() API.

Fix #4979
2022-11-24 16:08:06 +02:00