本节包含一些关于自托管 TimescaleDB 常见问题故障排除的想法。有关适用于所有 Timescale 产品的通用故障排除建议,请参阅使用 Timescale部分。

"<TYPE_OF_BACKGROUND_JOB>": failed to start a background worker

如果后台工作进程配置不正确,您可能会在日志中看到此错误消息。

要修复此错误,请确保正确设置了 max_worker_processesmax_parallel_workerstimescaledb.max_background_workerstimescaledb.max_background_workers 应等于数据库数量加上并发后台工作进程数量。max_worker_processes 应等于 timescaledb.max_background_workersmax_parallel_workers 的总和。

有关更多信息,请参阅工作进程配置文档

Log error: could not access file "timescaledb"

如果您的 PostgreSQL 日志中有此错误阻止其启动,您应该仔细检查 TimescaleDB 文件是否已安装到正确的位置。我们的安装方法使用 pg_config 来获取 PostgreSQL 的位置。但是,如果您在同一台机器上安装了多个版本的 PostgreSQL,则 pg_config 指向的位置可能不是您期望的版本。要检查 TimescaleDB 使用的版本

$ pg_config --version
PostgreSQL 12.3

如果那是正确的版本,请仔细检查安装路径是否是您期望的路径。例如,对于通过 Homebrew 在 macOS 上安装的 PostgreSQL 11.0,它应该是 /usr/local/Cellar/postgresql/11.0/bin

$ pg_config --bindir
/usr/local/Cellar/postgresql/11.0/bin

如果这些步骤中的任何一个步骤的版本不是您期望的版本,您需要 (a) 卸载不正确的 PostgreSQL 版本(如果可以)或 (b) 更新您的 PATH 环境变量,将 pg_config 的正确路径放在首位,即通过前置完整路径

export PATH = /usr/local/Cellar/postgresql/11.0/bin:$PATH

然后,重新安装 TimescaleDB,它应该会找到正确的安装路径。

pg_restore: creating EXTENSION "timescaledb"
pg_restore: creating COMMENT "EXTENSION timescaledb"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 6239; 0 0 COMMENT EXTENSION timescaledb
pg_restore: error: could not execute query: ERROR: must be owner of extension timescaledb

pg_restore 函数复制您的模式时,它会尝试应用 TimescaleDB 扩展。这可能会导致权限错误。如果您已经安装了 TimescaleDB 扩展,您可以安全地忽略此错误。

pg_dump: warning: there are circular foreign-key constraints on this table:
pg_dump: hypertable
pg_dump: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.
pg_dump: Consider using a full dump instead of a --data-only dump to avoid this problem.
pg_dump: NOTICE: hypertable data are in the chunks, no data will be copied
DETAIL: Data for hypertables are stored in the chunks of a hypertable so COPY TO of a hypertable will not copy any data.
HINT: Use "COPY (SELECT * FROM <hypertable>) TO ..." to copy all data in hypertable, or copy each chunk individually.
WARNING: skipping "<TABLE OR INDEX>" --- only superuser can analyze it

如果您在迁移过程中看到这些错误,您可以安全地忽略它们。迁移仍然会成功发生。

pg_dump: NOTICE: hypertable data are in the chunks, no data will be copied
DETAIL: Data for hypertables are stored in the chunks of a hypertable so COPY TO of a hypertable will not copy any data.
HINT: Use "COPY (SELECT * FROM <hypertable>) TO ..." to copy all data in hypertable, or copy each chunk individually.

当运行 pg_dump 时,您可能会看到上述错误。您可以安全地忽略这些错误。您的超表数据仍然会被准确复制。

pg_dump: error: query failed: ERROR: permission denied for table job_errors
pg_dump: detail: Query was: LOCK TABLE _timescaledb_internal.job_errors IN ACCESS SHARE MODE

pg_dump 工具尝试获取 job_errors 表上的锁时,如果用户没有所需的 SELECT 权限,则会导致此错误。

要解决此问题,请使用超级用户帐户授予需要 pg_dump 工具的用户必要的权限。使用以下命令向 <TEST_USER> 授予权限

GRANT SELECT ON TABLE _timescaledb_internal.job_errors TO <TEST_USER>;

PostgreSQL pg_dump 命令不允许您在备份时指定要使用的扩展版本。如果您安装了更新的版本,这可能会造成问题。例如,如果您使用旧版本的 TimescaleDB 创建备份,并且当您恢复它时,它使用了当前版本,而没有给您首先升级的机会。

当您从备份恢复时,可以通过确保新的 PostgreSQL 实例在执行恢复之前具有与原始数据库相同的扩展版本来解决此问题。数据恢复后,您可以升级 TimescaleDB 的版本。

org.postgresql.util.PSQLException: ERROR: invalid INSERT on the root table of hypertable "_hyper_1_10_chunk.

当运行 pg_restore 时,您可能会看到上述错误。从逻辑转储加载时,请确保在加载转储之前将 timescaledb.restoring 设置为 true。

ERROR: extension "timescaledb_toolkit" has no update path from version "1.2" to version "1.3"

在某些情况下,当您创建 TimescaleDB Toolkit 扩展,或使用 ALTER EXTENSION timescaledb_toolkit UPDATE 命令升级它时,可能会失败并出现上述错误。

如果可用扩展列表不包含您尝试升级到的版本,则会发生这种情况,如果软件包最初安装不正确,也可能发生这种情况。要纠正此问题,请安装升级包,重启 PostgreSQL,验证版本,然后再次尝试更新。

  1. 如果您正在从软件包安装 Toolkit,请检查您的软件包管理器的本地存储库列表。确保 TimescaleDB 存储库可用并包含 Toolkit。有关添加 TimescaleDB 存储库的说明,请参阅安装指南

  2. 使用 apt updateyum update 更新您的本地存储库列表。

  3. 重启您的 PostgreSQL 服务。

  4. 检查正确版本的 Toolkit 是否在您的可用扩展中

    SELECT * FROM pg_available_extensions
    WHERE name = 'timescaledb_toolkit';

    结果应如下所示

    -[ RECORD 1 ]-----+--------------------------------------------------------------------------------------
    name | timescaledb_toolkit
    default_version | 1.6.0
    installed_version | 1.6.0
    comment | Library of analytical hyperfunctions, time-series pipelining, and other SQL utilities
  5. 重试 CREATE EXTENSIONALTER EXTENSION

ERROR: could not access file "timescaledb-<VERSION>": No such file or directory

如果错误在更新 TimescaleDB 版本后立即发生,并且提到的文件来自之前的版本,则可能是由于更新过程不完整。在更大的 PostgreSQL 服务器实例中,每个安装了 TimescaleDB 的数据库都需要使用 SQL 命令 ALTER EXTENSION timescaledb UPDATE; 进行更新,同时连接到该数据库。否则,数据库会查找先前版本的 timescaledb 文件。

有关更多信息,请参阅我们的更新文档

ERROR: extension "timescaledb" cannot be updated after the old version has already been loaded

当您使用 ALTER EXTENSION timescaledb UPDATE 命令进行升级时,可能会出现此错误。

如果您在启动使用 psql 的新会话后没有将 ALTER EXTENSION timescaledb UPDATE 命令作为第一个命令运行,或者您在使用制表符补全运行命令时使用了制表符补全,则会发生这种情况。制表符补全会在后台触发元数据查询,这会阻止 alter extension 成为第一个命令。

要纠正此问题,请像这样执行 ALTER EXTENSION 命令

``sql psql -X -c 'ALTER EXTENSION timescaledb UPDATE;'

export const _frontmatter = {"title":"Upgrading fails with an error saying \"old version has already been loaded\"","section":"troubleshooting","products":["self_hosted"],"topics":["upgrades"],"errors":[{"language":"sql","message":"ERROR: extension \"timescaledb\" cannot be updated after the old version has already been loaded"}],"keywords":["upgrades"],"tags":["upgrade"]}
ERROR: extension "timescaledb_toolkit" has no update path from version "1.2" to version "1.3"

在某些情况下,当您使用 ALTER EXTENSION timescaledb UPDATE 命令进行升级时,可能会失败并出现上述错误。

如果可用扩展列表不包含您尝试升级到的版本,则会发生这种情况,如果软件包最初安装不正确,也可能发生这种情况。要纠正此问题,请安装升级包,重启 PostgreSQL,验证版本,然后再次尝试升级。

关键词

在此页面上发现问题?报告问题 或 在 GitHub 上编辑此页