Skip to content

TimescaleDB: cannot drop not-null constraint from a time-partitioned column (SQLSTATE TS101) #1949

@m00nwtchr

Description

@m00nwtchr

I get the above-mentioned error when trying to use timescaledb as the target for the query log. It doesn't appear if I make a fresh database and then point blocky at it, but then after the DB is initialised and blocky is restarted it pops up again.

postgres version: 18.1
timescaledb version: 2.23.1

[2025-11-30 23:16:47]  INFO _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[2025-11-30 23:16:47]  INFO _/                                                              _/
[2025-11-30 23:16:47]  INFO _/                                                              _/
[2025-11-30 23:16:47]  INFO _/       _/        _/                      _/                   _/
[2025-11-30 23:16:47]  INFO _/      _/_/_/    _/    _/_/      _/_/_/  _/  _/    _/    _/    _/
[2025-11-30 23:16:47]  INFO _/     _/    _/  _/  _/    _/  _/        _/_/      _/    _/     _/
[2025-11-30 23:16:47]  INFO _/    _/    _/  _/  _/    _/  _/        _/  _/    _/    _/      _/
[2025-11-30 23:16:47]  INFO _/   _/_/_/    _/    _/_/      _/_/_/  _/    _/    _/_/_/       _/
[2025-11-30 23:16:47]  INFO _/                                                    _/        _/
[2025-11-30 23:16:47]  INFO _/                                               _/_/           _/
[2025-11-30 23:16:47]  INFO _/                                                              _/
[2025-11-30 23:16:47]  INFO _/                                                              _/
[2025-11-30 23:16:47]  INFO _/  Version: v0.28.1            Build time: 20251113-204100     _/
[2025-11-30 23:16:47]  INFO _/                                                              _/
[2025-11-30 23:16:47]  INFO _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[2025-11-30 23:16:47]  INFO list_cache: import succeeded count=3389 source=https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/doh.txt
[2025-11-30 23:16:51]  INFO list_cache: import succeeded count=167717 source=https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.txt
[2025-11-30 23:16:56]  INFO list_cache: import succeeded count=552210 source=https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif.txt
[2025-11-30 23:16:56]  INFO list_cache: group import finished group=hagezi total_count=723316
[2025-11-30 23:16:57]  INFO /go/querylog/database_writer.go:95 ERROR: cannot drop not-null constraint from a time-partitioned column (SQLSTATE TS101)
[0.285ms[] [rows:0] ALTER TABLE "log_entries" ALTER COLUMN "request_ts" DROP NOT NULL
[2025-11-30 23:16:57]  WARN query_logging: Error occurred on query writer creation, retry attempt 1/3: failed to create query log writer (type: timescale): can't perform auto migration: failed to auto-migrate database schema for querylog: ERROR: cannot drop not-null constraint from a time-partitioned column (SQLSTATE TS101)
[2025-11-30 23:16:59]  INFO /go/querylog/database_writer.go:95 ERROR: cannot drop not-null constraint from a time-partitioned column (SQLSTATE TS101)
[0.282ms[] [rows:0] ALTER TABLE "log_entries" ALTER COLUMN "request_ts" DROP NOT NULL
[2025-11-30 23:16:59]  WARN query_logging: Error occurred on query writer creation, retry attempt 2/3: failed to create query log writer (type: timescale): can't perform auto migration: failed to auto-migrate database schema for querylog: ERROR: cannot drop not-null constraint from a time-partitioned column (SQLSTATE TS101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions