feat(api): implement heartbeat mechanism for database migration lock

- Added a heartbeat function to renew the Redis lock during database migrations, preventing long blockages from crashed processes.
- Updated the upgrade_db command to utilize the new locking mechanism with a configurable TTL.
- Removed the deprecated MIGRATION_LOCK_TTL from DeploymentConfig and related files.
- Enhanced unit tests to cover the new lock renewal behavior and error handling during migrations.

(cherry picked from commit a3331c622435f9f215b95f6b0261f43ae56a9d9c)
This commit is contained in:
L1nSn0w
2026-02-13 12:48:10 +08:00
parent 9acdfbde2f
commit afdd5b6c86
5 changed files with 115 additions and 19 deletions

View File

@ -1,4 +1,4 @@
from pydantic import Field, PositiveInt
from pydantic import Field
from pydantic_settings import BaseSettings
@ -33,7 +33,3 @@ class DeploymentConfig(BaseSettings):
default="PRODUCTION",
)
MIGRATION_LOCK_TTL: PositiveInt = Field(
description="Redis lock TTL for startup DB migration (seconds). Increase for large/slow databases.",
default=3600,
)