Skip to content
dbexplore

TimescaleDB

TimescaleDB backfill and compressed chunks

For the DBA whose time-series data arrives late or gets corrected after the columnstore policy has already compressed the chunk it belongs in.

Late rows land in TimescaleDB's rowstore, and DML decompresses batches. What a bulk backfill can silently cost, and the version bugs to check first.

Reference page, revised in place. Last updated .

Treat late data as a normal part of the workload, and let late rows land where TimescaleDB already puts them. The vendor documents bulk backfills; this page is about what can still go wrong, above all how a careful one can delete aggregate history without an error. First check your version against two bugs. Under READ COMMITTED, an UPDATE or DELETE that waits for another transaction’s lock on the same row silently skips it, from 2.28.1 until the fix in 2.32.0. Separately, every scheduled job fails on PostgreSQL 18.7, 17.12, 16.16 and 15.20 unless you run 2.32.1 or one of the November patch releases for older lines.

We measured on TimescaleDB 2.32.1 with PostgreSQL 18.7, plus the row-skip test on 2.31.0 with 18.6. Everything else comes from the documentation, changelogs or the source.

Where a late row lands, and what it costs when it gets there

A columnstore policy converts a chunk to the columnstore, where rows are grouped into compressed batches of up to 1000 values per column. New rows go to the rowstore first, late ones included. A late row landing in a compressed chunk is stored beside the batches, and the release notes call that chunk partially compressed.

To update tuples, or to check constraints on insert, TimescaleDB may convert the matching batches back to the rowstore. On our unique-keyed table, a late insert with a new key scanned 11 batches, decompressed one to check the key, and moved nothing. An upsert of a single existing key moved all 1000 rows of its batch. A correction pays for every batch it touches.

A trickle of late rows needs no storage work: the policy recompresses partial chunks on its own schedule, unless writers to a unique-keyed chunk never pause. It still needs two checks. Rows older than a refresh policy’s start_offset never reach its aggregate through that policy, and rows landing where raw chunks were dropped can make a refresh delete aggregate history, the first hazard below.

Reading the state of a hypertable that takes late data

In each database that uses TimescaleDB:

SELECT current_database(),
       extname,
       extversion,
       current_setting('server_version') AS postgres_version
  FROM pg_extension
 WHERE extname = 'timescaledb';

chunk_columnstore_stats reports each chunk’s status, but it cannot show late data:

SELECT compression_status,
       count(*)                                           AS chunks,
       pg_size_pretty(sum(after_compression_total_bytes)) AS compressed_size
  FROM chunk_columnstore_stats('public.conditions')
 GROUP BY compression_status;

After our late inserts a chunk holding them still read Compressed, with its reported size unchanged. No documented view exposes the partial state. An internal function, chunk_status_text, returned {COMPRESSED,PARTIAL} for that chunk. It is undocumented and could change:

SELECT c AS chunk,
       _timescaledb_functions.chunk_status_text(c) AS status
  FROM show_chunks('public.conditions') AS c
 WHERE 'PARTIAL' = ANY (_timescaledb_functions.chunk_status_text(c));

Check whether the policy job is scheduled, and how its recent runs went. job_status misled a role without pg_read_all_stats: it read Scheduled mid-run and Paused while a paused run was alive.

SELECT j.job_id,
       j.hypertable_name,
       j.scheduled,
       s.job_status,
       s.last_run_status,
       s.last_successful_finish,
       s.total_failures
  FROM timescaledb_information.jobs j
  LEFT JOIN timescaledb_information.job_stats s USING (job_id)
 WHERE j.proc_name = 'policy_compression';

You may meet ERROR: tuple decompression limit exceeded by operation: one statement moved more tuples out of the columnstore than timescaledb.max_tuples_decompressed_per_dml_transaction allows (default 100,000).

What to look at before a bulk backfill

Three read-only queries can each give you a reason to stop; none can show that a backfill is safe. The chunks:

SELECT chunk_name, range_start, range_end, is_compressed, chunk_creation_time
  FROM timescaledb_information.chunks
 WHERE (hypertable_schema, hypertable_name) = ('public', 'conditions')
 ORDER BY 2;

A hole, or a chunk created long after its range_end, can mean raw data was dropped. The list cannot show rows removed with DELETE, a chunk recreated while its range was current, or one missing space partition, and a chunk loaded late in bulk looks like a recreated one.

The aggregates:

SELECT view_schema, view_name, hypertable_schema, hypertable_name,
       materialization_hypertable_name
  FROM timescaledb_information.continuous_aggregates;

An aggregate whose hypertable_name is another’s materialization_hypertable_name is stacked on it.

The jobs:

SELECT job_id, proc_name, hypertable_name, scheduled,
       schedule_interval, config
  FROM timescaledb_information.jobs
 WHERE job_id >= 1000
 ORDER BY 1;

It shows retention, refresh offsets and user-defined actions by name, but not what those actions do, cron entries, or a job’s time zone, which the view has no column for.

What the vendor says to do

“Set up hypercore” warns that a backfill and a conversion on one chunk wait on each other, and says to pause the policy, backfill, convert and re-enable. “Choose a migration approach”, written for loading a migration target, adds loading oldest first, non-overlapping ranges for parallel workers, pausing retention and refresh, and disabling the columnstore during the load. On a table that already has compressed chunks, “Set up hypercore” says disabling it means converting them all back first. “About data retention with continuous aggregates” says not to let a refresh window overlap deleted raw data. “Troubleshoot hypercore” caps a large first conversion with maxchunks_to_compress.

What can still go wrong

Late rows can hide dropped raw data, and a refresh over it deletes aggregate history. We dropped three days of chunks under an hourly aggregate, loaded ten late rows into one hour and refreshed: buckets that had summarised 4,320 rows were cut to 2,530, late rows included. On a second table, an open-start refresh policy, run by hand, left 1,090. The late rows recreated a chunk, so the oldest moved from 4 back to 2 October and a check of the oldest chunk alone no longer showed the drop.

The same loss happens one level up. We dropped the hourly chunks under a daily aggregate by hand, left the raw rows alone, loaded ten late rows and refreshed both levels. Four daily buckets summarising 5,760 rows became one of 70.

A long pause can leave a gap. Rows that arrive early in one can fall outside every later refresh window. With a three-hour start_offset and ten hours of rows waiting, 60 of 540 were materialised; with a six-hour offset and a five-hour pause, 240 of 420, because some were already waiting. Both pauses were simulated with back-dated rows and the policy run by hand. A manual refresh restored all 540, on a table with no retention; over dropped raw data, that refresh is the first hazard. Resuming retention deletes whatever was loaded behind its cut-off: 24 rows loaded 60 days back under a 30-day policy were gone after one run, which we forced by hand.

Pausing a job changes it. alter_job empties a job’s time zone whenever the call does not pass one. A daily retention job with Europe/Berlin lost it when paused and stayed without it when resumed, so from the source a fixed schedule then runs on UTC and drifts an hour when clocks change. From the source, every call that omits it does this, the vendor’s own examples included. Pausing also cancels a run in flight and counts it as a failure; from the source, the scheduler terminates it after three seconds. And a policy removed and added back is a new job, live at once.

Recompression gives way to writers. With a unique key, one open writer made converting a partial chunk fail after about five seconds with aborting recompression due to concurrent DML on uncompressed data; two made it print a WARNING and report success. Both times the chunk stayed partial. Without a unique key one open writer got success and silence: committed rows moved and the chunk stayed partial.

Some corrections are refused, or not recorded. Shifting timestamps on a unique-keyed compressed chunk failed with cannot update column "time" of a compressed chunk. The documentation says an UPDATE that moves rows between chunks, upserts included, is not supported. From the changelog, not run by us, rows a MERGE updated or deleted before 2.31.0 are not recorded for aggregate refresh.

Where this advice is weakest: the decompression limit

The documentation says the limit exists because one command could otherwise run the server out of storage. On 2.32.1 it does not stop an UPDATE early. We ran one across four compressed chunks with the limit at 100,000, and the error reported 405,850 tuples decompressed: the whole statement had already been expanded, and 79 MB of WAL written, before the check fired. That WAL also goes to every replica and slot, whether or not the statement succeeds, and with autovacuum off the heap space came back only after a vacuum. An INSERT ... ON CONFLICT is checked row by row instead: ours stopped at 80 tuples against a limit of 10.

The limit still stops a legitimate correction of a bad sensor feed, and it rolls back the whole transaction when it does. Despite the _transaction in its name, it is counted per statement. Two updates of 50,400 tuples each ran in one transaction; one of 100,800 failed. Split a large correction into statements bounded by time, each in its own transaction and each under the limit. For a correction that touches most of a chunk, the convert_to_rowstore reference says to stop the jobs that move chunks, which brings in the pause hazards above, then convert the whole chunk out and back, which avoids the limit. In our runs each conversion was blocked by an open reader as well as a writer, until a 3-second lock timeout.

There is no dry run for sizing those statements. EXPLAIN ANALYZE executes the statement, so a trial you roll back still does the work: ours, at 50,400 tuples, wrote 25 MB of WAL and left the chunk’s heap 5 MB larger until a vacuum. A SELECT count(*) over the same predicate avoids that but is only a lower bound: a one-hour correction across ten devices matched 600 rows and decompressed 10,000.

Why the version comes first

TimescaleDB 2.32.0, released in November 2026, fixed concurrent UPDATE and DELETE on hypertables silently skipping rows under READ COMMITTED. The release thanks a contributor “for reporting the concurrent UPDATE/DELETE regression and bisecting it to 2.28.1”. In the bug report, two sessions update one row, and the one waiting for the lock reports UPDATE 0 once the first commits, dropping its change. We ran that test once per case on 2.31.0 and 2.32.1, on images that also differ in PostgreSQL minor.

Row the two sessions meet on 2.31.0, PostgreSQL 18.6 2.32.1, PostgreSQL 18.7
Plain hypertable, waiting UPDATE UPDATE 0, change lost UPDATE 1
Plain hypertable, waiting DELETE DELETE 0, row still there DELETE 1
Row inside a compressed batch, waiting UPDATE UPDATE 1, applied UPDATE 1, applied
Same row afterwards, in the rowstore part of a partial chunk UPDATE 0, change lost UPDATE 1, applied

In these runs the writes were lost in the rowstore, which is where late data sits. The reporter’s workaround was to lock the row first with SELECT ... FOR UPDATE. It only reaches rows still in the rowstore: on a compressed row, 2.32.1 answered locking compressed tuples is not supported, and the same error is in the affected releases’ source. On an affected release, stop every other writer to the range for the length of the correction.

Treat every release from 2.28.1 through 2.31.2 as affected. The November patches on the older lines list a single fix, for the scheduler, and do not touch the file the row-skip fix changes. No policy setting touches this bug, which needs only two writers on the same row: a correction that runs while the application updates the same recent rows, or one split across parallel sessions whose ranges overlap.

The scheduler fix is in 2.32.1, 2.31.2, 2.30.3, 2.29.3, 2.28.5 and 2.27.3, and the vendor’s APT repository carries all six. On 23 November only 2.32.1 had a GitHub release page or a timescale/timescaledb Docker image. On an affected combination the jobs fail before any backfill starts. Upgrade TimescaleDB before PostgreSQL. Our guide to pg_upgrade and extensions makes the same point for major upgrades.

Other silent DML faults on compressed data were fixed this year. The table lists those a backfill is most likely to meet, by the release that carries the fix; it is not a full list.

Release Row skip Scheduler on the newest minors Compressed-DML fixes it lacks
2.32.1 Fixed, and run here Fixed None listed here
2.32.0 Fixed Fails None listed here
2.31.2 Present, by diff Fixed None listed here
2.30.3 Present, by diff Fixed Collation in insert conflicts and MERGE invalidation (2.31.0)
2.28.5, 2.29.3 Present, by diff Fixed Those two, plus ON CONFLICT with more than one unique key and NULL conflicts with a single-column bloom (2.30.1)
2.28.0 Absent, per the reporter Fails All of the above, plus constant-false DELETE (2.28.1), NULL arrays and collation in batch filtering (2.28.3)
2.27.3 Absent, by diff from 2.27.2 Fixed All of the above, plus the unique-column guard (2.28.0)

On 2.28.1 or later, the target is 2.32.1. On 2.27.x or earlier, 2.27.3 fixes the scheduler and avoids the row skip and 2.32.0’s changes, at the price of the fixes it lacks. On 2.28.0 the target is also 2.32.1, unless you hold the PostgreSQL minor and go without its security fixes. 2.29.0 removed support for PostgreSQL 15: there, 2.27.3 and 2.28.5 fix the scheduler, but the row-skip fix needs 16 or later, so on 2.28.1 or later stop other writers to the range while you correct it, or do the major upgrade.

2.32.0 ships loader changes that need a PostgreSQL restart, runs the scheduler as the database owner, and requires ownership of the chunk itself for chunk operations, so a backfill script may now be refused where a chunk’s owner has drifted. Rehearse the whole backfill on a restored copy running the new version, under the role that will run it. On an affected release, the row count each statement reports is the only sign that a concurrent correction went wrong.

Put every Postgres you run on autopilot.

We onboard teams in small batches. Tell us about your fleet and we will reach out when a seat opens. One email, no drip campaign.