Retry on 423 error "snapshot is in transition"

This commit is contained in:
Alexey Masterov
2025-07-16 13:21:32 +02:00
parent f222256225
commit 018f95115a
2 changed files with 6 additions and 1 deletions

View File

@@ -66,6 +66,7 @@ class NeonAPI:
elif resp.status_code == 423 and resp.json()["message"] in {
"endpoint is in some transitive state, could not suspend",
"project already has running conflicting operations, scheduling of new ones is prohibited",
"snapshot is in transition"
}:
retry = True
self.retries4xx += 1

View File

@@ -463,7 +463,7 @@ class NeonProject:
Two optional arguments: lsn and timestamp are mutually exclusive
they instruct to create a snapshot with the specific lns or timestamp
"""
return NeonSnapshot(
snapshot = NeonSnapshot(
self,
self.neon_api.create_snapshot(
self.id,
@@ -473,6 +473,8 @@ class NeonProject:
self.gen_snapshot_name(),
),
)
self.wait()
return snapshot
def delete_snapshot(self, snapshot_id: str) -> None:
"""
@@ -480,6 +482,7 @@ class NeonProject:
"""
self.neon_api.delete_snapshot(self.id, snapshot_id)
self.snapshots.pop(snapshot_id)
self.wait()
def restore_snapshot(self, snapshot_id: str) -> NeonBranch | None:
"""
@@ -496,6 +499,7 @@ class NeonProject:
self.generate_branch_name(),
)
target_branch.start_benchmark()
self.wait()
return target_branch