[GH-ISSUE #165] Backups to Hetzner S3 fail with 504 Timeout and hang indefinitely (blocking Autovacuum) #134

Open
opened 2026-02-26 21:34:34 +03:00 by kerem · 1 comment
Owner

Originally created by @maltesa on GitHub (Dec 28, 2025).
Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/165

Describe the bug

I am using pgbackweb to back up a PostgreSQL 15 database to Hetzner S3 Object Storage. The backup process fails during the upload phase with 504 Gateway Timeout and 400 Bad Request errors.

The db connection is not closed after these errors. It remains active, holding an open transaction slot on the PostgreSQL database. This prevented our Postgres Autovacuum from cleaning up dead tuples until we restarted pgbackweb manually.

To Reproduce

  1. Configure a backup destination using Hetzner S3 (Region: nbg1, Endpoint: https://nbg1.your-objectstorage.com).
  2. Run a backup for a larger database (our backup size is > 5GB)
  3. The upload fails with S3 timeout errors (likely due to chunks being too large for the connection/gateway).
  4. Check pg_stat_activity on the database; the COPY ... TO stdout query remains active indefinitely (we observed one running for 17 days).

Expected behavior

If the S3 upload fails, pgbackweb should:

  1. Retry a reasonable number of times.
  2. If retries fail, close the database connection.

This bugfix/issue-91-idle-connections seems like a fix for the connection issue. However, recently still all our backups fail with the logs below.

Logs

failed to upload file to S3: upload multipart failed, upload id: <ID>, cause: operation error S3: UploadPart, exceeded maximum number of attempts, 3, https response error StatusCode: 504, RequestID: N/A, HostID: N/A, api error GatewayTimeout: The server did not respond in time.

failed to upload file to S3: upload multipart failed, upload id: <ID>, cause: operation error S3: UploadPart, https response error StatusCode: 400, RequestID: , HostID: , api error BadRequest: Bad Request
Originally created by @maltesa on GitHub (Dec 28, 2025). Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/165 ### Describe the bug I am using `pgbackweb` to back up a PostgreSQL 15 database to Hetzner S3 Object Storage. The backup process fails during the upload phase with `504 Gateway Timeout` and `400 Bad Request` errors. The db connection is not closed after these errors. It remains active, holding an open transaction slot on the PostgreSQL database. This prevented our Postgres Autovacuum from cleaning up dead tuples until we restarted pgbackweb manually. ### To Reproduce 1. Configure a backup destination using Hetzner S3 (Region: `nbg1`, Endpoint: `https://nbg1.your-objectstorage.com`). 2. Run a backup for a larger database (our backup size is > 5GB) 3. The upload fails with S3 timeout errors (likely due to chunks being too large for the connection/gateway). 4. Check `pg_stat_activity` on the database; the `COPY ... TO stdout` query remains active indefinitely (we observed one running for 17 days). ### Expected behavior If the S3 upload fails, `pgbackweb` should: 1. Retry a reasonable number of times. 2. If retries fail, close the database connection. This [bugfix/issue-91-idle-connections](https://github.com/possebon/pgbackweb/compare/bugfix/issue-91-idle-connections) seems like a fix for the connection issue. However, recently still all our backups fail with the logs below. ### Logs ```text failed to upload file to S3: upload multipart failed, upload id: <ID>, cause: operation error S3: UploadPart, exceeded maximum number of attempts, 3, https response error StatusCode: 504, RequestID: N/A, HostID: N/A, api error GatewayTimeout: The server did not respond in time. failed to upload file to S3: upload multipart failed, upload id: <ID>, cause: operation error S3: UploadPart, https response error StatusCode: 400, RequestID: , HostID: , api error BadRequest: Bad Request ```
Author
Owner

@coderabbitai[bot] commented on GitHub (Dec 28, 2025):

📝 CodeRabbit Plan Mode

Generate an implementation plan and prompts that you can use with your favorite coding agent.

  • Create Plan
Examples

🔗 Similar Issues

Possible Duplicates

Related Issues

👤 Suggested Assignees

🧪 Issue enrichment is currently in open beta.

You can configure auto-planning by selecting labels in the issue_enrichment configuration.

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

💬 Have feedback or questions? Drop into our discord!

<!-- gh-comment-id:3694760988 --> @coderabbitai[bot] commented on GitHub (Dec 28, 2025): <!-- This is an auto-generated issue plan by CodeRabbit --> ### 📝 CodeRabbit Plan Mode Generate an implementation plan and prompts that you can use with your favorite coding agent. - [ ] <!-- {"checkboxId": "8d4f2b9c-3e1a-4f7c-a9b2-d5e8f1c4a7b9"} --> Create Plan <details> <summary>Examples</summary> - [Example 1](https://github.com/coderabbitai/git-worktree-runner/issues/29#issuecomment-3589134556) - [Example 2](https://github.com/coderabbitai/git-worktree-runner/issues/12#issuecomment-3606665167) </details> --- <details> <summary><b>🔗 Similar Issues</b></summary> **Possible Duplicates** - https://github.com/eduardolat/pgbackweb/issues/91 **Related Issues** - https://github.com/eduardolat/pgbackweb/issues/140 - https://github.com/eduardolat/pgbackweb/issues/111 </details> <details> <summary><b>👤 Suggested Assignees</b></summary> - [reynaldots](https://github.com/reynaldots) - [TristisOris](https://github.com/TristisOris) - [kamasylvia](https://github.com/kamasylvia) </details> --- <details> <summary> 🧪 Issue enrichment is currently in open beta.</summary> You can configure auto-planning by selecting labels in the issue_enrichment configuration. To disable automatic issue enrichment, add the following to your `.coderabbit.yaml`: ```yaml issue_enrichment: auto_enrich: enabled: false ``` </details> 💬 Have feedback or questions? Drop into our [discord](https://discord.gg/coderabbit)!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pgbackweb#134
No description provided.