#10711·timescaledb

[Bug]: Query cancel during TSL load sticks the backend on the Apache continuous-aggregate stub (0A000) even when timescaledb.license is timescale

Author: nikolaigutCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbugv2.30.1

What type of bug is this?

Unexpected error

What subsystems and features are affected?

Continuous aggregate, Data ingestion

What happened?

A hypertable with five continuous aggregates accepts upserts on a fresh backend (timescaledb.license = timescale, tsl_loaded() = true).

If the first statement on a backend is cancelled while TimescaleDB has loaded timescaledb-.so but not yet timescaledb-tsl-.so, that same backend then rejects every upsert:

SQLSTATE 0A000 ERROR: functionality not supported under the current "timescale" license.

SHOW timescaledb.license is still timescale. _timescaledb_functions.tsl_loaded() is false. /proc//maps contains timescaledb-.so and does not contain timescaledb-tsl-.so. SELECT on that connection still works. A new connection loads the TSL library and the same upsert succeeds.

Expected: the upsert succeeds. The license error should not be raised when timescaledb.license is already timescale.

Seen in production with PgBouncer in transaction mode: the server connection is kept and reused after the cancelled first statement, so later upserts on that connection keep failing.

TimescaleDB version affected

2.30.1 (also reproduced with 2.25.2)

PostgreSQL version used

18.6 (also reproduced with 16.14)

What operating system did you use?

Ubuntu 24.04 x64

What installation method did you use?

Deb/Apt

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

bash
SQLSTATE 57014
ERROR:  canceling statement due to user request

SHOW timescaledb.license;
 timescale

SELECT _timescaledb_functions.tsl_loaded();
 f

INSERT INTO measurements (time, device_id, value)
VALUES ('2026-09-29 13:00:00+00', 7, 3.5)
ON CONFLICT (device_id, time)
DO UPDATE SET value = EXCLUDED.value;

SQLSTATE 0A000
ERROR:  functionality not supported under the current "timescale" license. Learn more at https://tsdb.co/pdbir1r3
HINT:  To access all features and the best time-series experience, try out Timescale Cloud.

How can we reproduce the bug?

bash
1. Install PostgreSQL 18.6 and TimescaleDB 2.30.1 from the apt packages. Set shared_preload_libraries = 'timescaledb'. timescaledb.license stays at the default timescale.

2. Create a database and run:

CREATE EXTENSION timescaledb;

CREATE TABLE measurements (
  time timestamptz NOT NULL,
  device_id integer NOT NULL,
  value double precision NOT NULL,
  PRIMARY KEY (device_id, time)
);
SELECT create_hypertable('measurements', 'time');

CREATE MATERIALIZED VIEW measurements_1min WITH (timescaledb.continuous) AS
SELECT time_bucket(INTERVAL '1 minute', time) AS bucket, device_id, avg(value) AS value
FROM measurements GROUP BY 1, 2 WITH NO DATA;

3. Create four more continuous aggregates the same way, with intervals 5 minutes, 15 minutes, 1 hour, and 1 day.

4. Open a new session and run:

INSERT INTO measurements (time, device_id, value)
VALUES ('2026-09-29 13:00:00+00', 7, 3.5)
ON CONFLICT (device_id, time)
DO UPDATE SET value = EXCLUDED.value;

SELECT _timescaledb_functions.tsl_loaded();

The upsert succeeds and tsl_loaded() is true. Both timescaledb-2.30.1.so and timescaledb-tsl-2.30.1.so are mapped in that backend.

5. Open another new session. Do not run a query yet. Note the backend pid.

6. On the first statement of that session, cancel it after load_enabled has been set inside ts_license_enable_module_loading and before set_config_option reaches dlopen of timescaledb-tsl-2.30.1.so. That point is the instruction at ts_license_enable_module_loading+66. InterruptHoldoffCount is 0 there. The statement ends with:

SQLSTATE 57014
ERROR:  canceling statement due to user request

7. On that same connection, run:

SHOW timescaledb.license;
SELECT _timescaledb_functions.tsl_loaded();

and repeat the upsert from step 4.

SHOW returns timescale. tsl_loaded() is false. /proc/<pid>/maps contains timescaledb-2.30.1.so and does not contain timescaledb-tsl-2.30.1.so. The upsert fails with:

SQLSTATE 0A000
ERROR:  functionality not supported under the current "timescale" license.

8. Open a third session and run the same upsert. It succeeds.