Skip to content

fix serverless backup resume bug#644

Open
kbrwn wants to merge 1 commit intoauthzed:mainfrom
kbrwn:backup-fix
Open

fix serverless backup resume bug#644
kbrwn wants to merge 1 commit intoauthzed:mainfrom
kbrwn:backup-fix

Conversation

@kbrwn
Copy link

@kbrwn kbrwn commented Mar 17, 2026

Description

This fixes duplicate relationships during zed backup when backup streams encounter retryable transport failures.

There were two related issues:

  • ReadRelationships was still using the generic gRPC stream retry interceptor. On retry, that interceptor reopens the stream from the beginning, which can replay already-exported relationships and append duplicates to the backup.
  • The legacy/serverless backup resume marker only stored the cursor token, not the object definition it belonged to. If a backup resumed from disk after interruption, it could restart from the wrong place and replay earlier relationships.

This PR:

  • disables generic stream retries for ReadRelationships, matching the existing manual handling for bulk export/import
  • stores serverless backup progress as {resource_type, cursor} so resume can restart at the correct definition
  • returns a clear error when attempting to resume an old incomplete serverless backup created without resource type metadata, instead of silently duplicating data

Testing

Ran targeted tests locally:

go test ./internal/client -run TestDoesNotRetry -count=1 -v
go test ./internal/cmd -run 'TestTakeBackupRecoversFromRetryableErrors|TestTakeBackupResumesServerlessBackupAtSavedDefinition' -count=1 -v

Added coverage for:

  • ReadRelationships not being retried by the generic stream retry interceptor
  • serverless backup resuming from the saved definition/cursor without replaying earlier relationships
  • existing manual retry handling for backup export continuing to work

Reviewers can test by:

  • running the commands above
  • optionally reproducing with an interrupted serverless-style backup and confirming resume does not duplicate previously exported relationships

References

Customer report describing duplicate relationships after retryable backup transport failures.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 52.17391% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.44%. Comparing base (082eee0) to head (7c07dc4).

Files with missing lines Patch % Lines
internal/cmd/backup.go 48.83% 14 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   41.65%   42.44%   +0.79%     
==========================================
  Files          38       38              
  Lines        6127     6166      +39     
==========================================
+ Hits         2552     2617      +65     
+ Misses       3319     3280      -39     
- Partials      256      269      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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