Skip to content

Conversation

Copy link

Copilot AI commented Dec 9, 2025

pg_basebackup for large databases can take hours, hitting Ansible's default 120s timeout during replica cloning.

Changes

  • New configurable timeout: Added pg_basebackup_timeout (default: 14400s / 4 hours) in roles/postgres/replica/final/defaults/main.yml
  • Async execution pattern: Modified pg_basebackup task to use async/poll: 0 with separate async_status wait loop
  • Retry logic: Calculates retries as (timeout / 10) | int with minimum of 1, polls every 10 seconds
  • Error handling: Preserves original rc != 0 or 'error' in stderr logic, adds safety checks for undefined variables

Usage

Override timeout in config.yml for very large databases:

cluster_vars:
  pg_basebackup_timeout: 28800  # 8 hours

Pattern follows existing roles/barman/first_backup/tasks/backup.yml implementation.

Original prompt

So, I want to add support for the tasks that could potentially take multiple hours to run on the remote nodes. For example, pg_basebackup of a large database when cloning to a standby. Tel


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 9, 2025 14:00
Co-authored-by: haroon-github <10290607+haroon-github@users.noreply.github.com>
Co-authored-by: haroon-github <10290607+haroon-github@users.noreply.github.com>
Co-authored-by: haroon-github <10290607+haroon-github@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for long-running tasks on remote nodes Add async/poll support for long-running pg_basebackup operations Dec 9, 2025
Copilot AI requested a review from haroon-github December 9, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants