Skip to content

执行数据#

¥Execution data

根据你的执行设置和执行量,你的 n8n 数据库可能会不断增长并耗尽存储空间。

¥Depending on your executions settings and volume, your n8n database can grow in size and run out of storage.

为避免此错误,n8n 建议你不要保存不必要的数据,并启用旧执行数据的清理功能。

¥To avoid this, n8n recommends that you don't save unnecessary data, and enable pruning of old executions data.

为此,请配置相应的 环境变量

¥To do this, configure the corresponding environment variables.

减少保存的数据#

¥Reduce saved data

Configuration at workflow level

你还可以使用 工作流设置 在单个工作流的基础上配置这些设置。

¥You can also configure these settings on an individual workflow basis using the workflow settings.

你可以选择 n8n 保存哪些执行数据。例如,你可以仅保存生成 Error 的执行结果。

¥You can select which executions data n8n saves. For example, you can save only executions that result in an Error.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# npm
# Save executions ending in errors
export EXECUTIONS_DATA_SAVE_ON_ERROR=all

# Don't save successful executions
export EXECUTIONS_DATA_SAVE_ON_SUCCESS=none

# Don't save node progress for each execution
export EXECUTIONS_DATA_SAVE_ON_PROGRESS=false

# Don't save manually launched executions
export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
1
2
3
4
5
6
7
8
9
# Docker
docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e EXECUTIONS_DATA_SAVE_ON_ERROR=all \
 -e EXECUTIONS_DATA_SAVE_ON_SUCCESS=none \
 -e EXECUTIONS_DATA_SAVE_ON_PROGRESS=true \
 -e EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false \
 docker.n8n.io/n8nio/n8n
1
2
3
4
5
6
7
# Docker Compose
n8n:
    environment:
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false

启用执行修剪#

¥Enable executions pruning

执行修剪会定期删除已完成的执行及其执行数据和二进制数据。n8n 默认启用数据修剪。出于性能考虑,修剪操作会先标记要删除的目标,然后再将其永久移除。

¥Executions pruning deletes finished executions along with their execution data and binary data on a regular schedule. n8n enables pruning by default. For performance reasons, pruning first marks targets for deletion, and then later permanently removes them.

当满足以下任一条件时,n8n 会终止执行:

¥n8n prunes executions when either of the following condition occur:

  • 年龄:执行已完成超过 EXECUTIONS_DATA_MAX_AGE 小时(默认值:336 小时 -> 14 天)。

¥Age: The execution finished more than EXECUTIONS_DATA_MAX_AGE hours ago (default: 336 hours -> 14 days).

  • 计数:执行总数超过 EXECUTIONS_DATA_PRUNE_MAX_COUNT(默认值:10,000)。发生这种情况时,n8n 会按时间顺序(从旧到新)删除执行记录。

¥Count: The total number of executions exceeds EXECUTIONS_DATA_PRUNE_MAX_COUNT (default: 10,000). When this occurs, n8n deletes executions from oldest to newest.

请注意:

¥Keep in mind:

  • 状态为 newrunningwaiting 的执行不符合修剪条件。

¥Executions with the new, running, or waiting status aren't eligible for pruning.

  • 带注释的执行(例如,带有标签或评分的执行)永远不会被剪枝。

¥Annotated executions (for example, executions with tags or ratings) are never pruned.

  • 数据清理遵循 EXECUTIONS_DATA_HARD_DELETE_BUFFER 小时的安全缓冲期(默认值:1 小时),以确保用户在构建或调试工作流时,最新数据仍然可用。

¥Pruning honors a safety buffer period of EXECUTIONS_DATA_HARD_DELETE_BUFFER hours (default: 1h), to ensure recent data remains available while the user is building or debugging a workflow.

1
2
3
4
5
6
7
8
# Enable executions pruning
export EXECUTIONS_DATA_PRUNE=true

# How old (hours) a finished execution must be to qualify for soft-deletion
export EXECUTIONS_DATA_MAX_AGE=168

# Max number of finished executions to keep. May not strictly prune back down to the exact max count. Set to `0` for unlimited.
export EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000
1
2
3
4
5
6
7
# Docker
docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e EXECUTIONS_DATA_PRUNE=true \
 -e EXECUTIONS_DATA_MAX_AGE=168 \
 docker.n8n.io/n8nio/n8n
1
2
3
4
5
6
# Docker Compose
n8n:
    environment:
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=168
      - EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000

SQLite

如果你使用默认的 SQLite 数据库运行 n8n,则任何已清理数据的磁盘空间不会自动释放,而是会被重新用于后续执行的数据。要释放此空间,请配置 DB_SQLITE_VACUUM_ON_STARTUP 环境变量 或手动运行 VACUUM 操作。

¥If you run n8n using the default SQLite database, the disk space of any pruned data isn't automatically freed up but rather reused for future executions data. To free up this space configure the DB_SQLITE_VACUUM_ON_STARTUP environment variable or manually run the VACUUM operation.

Binary data pruning

Binary data pruning operates on the active binary data mode. For example, if your instance stored data in S3, and you later switched to filesystem mode, n8n only prunes binary data in the filesystem. This may change in future.