Timescale Cloud:性能、扩展、企业级

自托管产品

MST

本节包含一些用于解决自托管 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 函数在复制您的 schema 时会尝试应用 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 命令作为第一个命令运行,或者在运行命令时使用了 Tab 键自动补全,则会发生此情况。Tab 键自动补全会在后台触发元数据查询,从而阻止 alter extension 成为第一个命令。

要解决此问题,请像这样执行 ALTER EXTENSION 命令

psql -X -c 'ALTER EXTENSION timescaledb UPDATE;'
ERROR: extension "timescaledb_toolkit" has no update path from version "1.2" to version "1.3"

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

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

ERROR: could not load library "C:/Program Files/PostgreSQL/16/lib/timescaledb-2.14.2.dll": The specified module could not be found.

如果您看到一条消息说 PostgreSQL 无法加载 TimescaleDB 库 timescaledb-<version>.dll,请启动一个新的 psql 会话连接到您的自托管实例,并将创建 timescaledb 扩展作为第一个命令

psql -X -d "postgres://<user>:<password>@<source_host>:<source_port>/<db_name>" -c "CREATE EXTENSION IF NOT EXISTS timescaledb;"

关键词

此页面有疑问?报告问题 或 编辑此页面 在 GitHub 上。