You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: If 3 volume snapshots fail in a row, the instance manager stops functioning (connection pool exhausted) #6761
When 3 scheduled volume snapshots fail in a row. The super user connection pool becomes exhausted in the instance manger. This causes all endpoints except /healthz to fail. This causes a near total failure of CNPG.
Impact:
All scheduled backups start to fail (due to endpoints hanging)
You run out of WAL space
Metrics are no longer collected
Hibernate fails
cnpg status hangs
All HTTP endpoints except /healthz hang
Instance manager can no longer be updated in-place
Depending on when you catch it, the real reason for the volume snapshot failure will be buried by context cancelled: deadline exceeded (because only the first 2-3 attempts can start a backup, the other ones hang getting the cluster status).
This PR has the beginnings of a fix, but there's more to be done: jmealo#1
Is there a reason that the connection is held until the backup completes (never being released if it fails)? The Postgres docs make it sound like this is unnecessary.
Thank you for reporting this issue; this is important and needs to be fixed.
Is there a reason that the connection is held until the backup completes (never being released if it fails)? The Postgres docs make it sound like this is unnecessary.
Concurrent backups are aborted if the controlling connection is terminated.
@armru: I have a fix for the issue and the bug is easy to reproduce (takes 1-3 minutes).
Set a scheduled backup to minute or second intervals. Two volume snapshots against the same volume can't be in progress at once on most clouds. That will cause the connection exhaustion in 4x backup interval.
What needs to be fixed/addressed or documented:
CNPG allows multiple failed backups to keep connections open indefinitely
CNPG shares a single 3 connection pool for backups, status, and metrics*
CNPG allows multiple in-flight /pg/status calls to queue indefinitely for a connection*
CNPG does not pass around context to queries to allow for timeout or cancellation
CNPG does not have query or http response timeouts
CNPG requires a connection to do an in-place upgrade*
* My PR fixes these. I need to rebase it over main, most of it is on my fork.
Azure has been giving us 502s for volume snapshots. I can try to get you some backup or volume snapshots but the work is all outlined above.
@armru As you can see, no underlying volume snapshot here, because the backup connection pool is exhausted, it never gets that far. This behavior can ONLY be seen on my fork. CNPG as-is would have timed out on /pg/status not /pg/mode/backup.
@mnencia: my operator manager briefly entered a crash loop (for about a minute)... I only noticed because this release requires a reload of the cluster to clear the old stuck backups. I don't know if that's all we need to add to the release notes or if we should share queries to run against each instance to check for stuck backups? @gbartolini
In terms of release notes:
Do we think we want to provide a query and instructions on how to run it against each instance to check for the presence of stuck backups, or should folks just check for failed backups via k8s?
Simplest approach:
Should we simply suggest folks do a reload if they have any failed backups?
Reasoning:
The presence of failed backups (via k8s) is easier to check for than the stuck backups.
Activity
jmealo commentedon Feb 5, 2025
Is there a reason that the connection is held until the backup completes (never being released if it fails)? The Postgres docs make it sound like this is unnecessary.
mnencia commentedon Feb 7, 2025
Thank you for reporting this issue; this is important and needs to be fixed.
Concurrent backups are aborted if the controlling connection is terminated.
armru commentedon Feb 13, 2025
Hello @jmealo, could you please post the
cnpg.backupandvolumesnapshotresources yaml with their respectivestatusconnected to those stuck backups?jmealo commentedon Feb 13, 2025
@armru: I have a fix for the issue and the bug is easy to reproduce (takes 1-3 minutes).
Set a scheduled backup to minute or second intervals. Two volume snapshots against the same volume can't be in progress at once on most clouds. That will cause the connection exhaustion in 4x backup interval.
What needs to be fixed/addressed or documented:
*My PR fixes these. I need to rebase it over main, most of it is on my fork.Azure has been giving us 502s for volume snapshots. I can try to get you some backup or volume snapshots but the work is all outlined above.
jmealo commentedon Feb 13, 2025
@armru
cnpg.backup:@armru As you can see, no underlying volume snapshot here, because the backup connection pool is exhausted, it never gets that far.
This behavior can ONLY be seen on my fork. CNPG as-is would have timed out on
/pg/statusnot/pg/mode/backup.48 remaining items
jmealo commentedon Feb 19, 2025
@mnencia: Building now. I have this deployed in staging. I'll let three hours pass and see where we're at. (I have hourly volume snapshots)
jmealo commentedon Feb 20, 2025
@mnencia: Tests look good overnight in staging. 👍 No not ready pods. We'll deploy to production shortly.
jmealo commentedon Feb 20, 2025
@mnencia: my operator manager briefly entered a crash loop (for about a minute)... I only noticed because this release requires a reload of the cluster to clear the old stuck backups. I don't know if that's all we need to add to the release notes or if we should share queries to run against each instance to check for stuck backups? @gbartolini
In terms of release notes:
Do we think we want to provide a query and instructions on how to run it against each instance to check for the presence of stuck backups, or should folks just check for failed backups via k8s?
Simplest approach:
Should we simply suggest folks do a reload if they have any failed backups?
Reasoning:
The presence of failed backups (via k8s) is easier to check for than the stuck backups.
jmealo commentedon Feb 20, 2025
Release note draft:
https://gist.github.com/jmealo/768b27430ba0c90a3fe88c6e05363759
jmealo commentedon Feb 20, 2025
@mnencia: these timed out in as little as 40 seconds, and did not provide helpful error information.
When I describe the volumesnapshot (in the one case they were created, despite the timeout):
fix(backup,snapshot): avoid parallel actions on endpoints (#6890)
fix(backup,snapshot): avoid parallel actions on endpoints (cloudnativ…
fix(backup,snapshot): avoid parallel actions on endpoints (#6890)
fix(backup,snapshot): avoid parallel actions on endpoints (#6890)
chore(webserver,update): retrieve instance architecture using Go runt…
chore(webserver,update): retrieve instance architecture using Go runt…
chore(webserver,update): retrieve instance architecture using Go runt…
chore(webserver,update): retrieve instance architecture using Go runt…