benbjohnson/litestream · error

read existing lease: %w

Error message

read existing lease: %w

What it means

Leaser.AcquireLease's initial readLease failed with an error other than not-exist. S3 GetObject on the lease key errored — credentials, bucket access, or connectivity — so the current lease state could not be inspected before acquiring.

Source

Thrown at s3/leaser.go:93

func (l *Leaser) SetClient(client S3API) {
	l.s3 = client
}

func (l *Leaser) Type() string {
	return LeaserType
}

func (l *Leaser) lockKey() string {
	if l.Path == "" {
		return DefaultLeasePath
	}
	return l.Path + "/" + DefaultLeasePath
}

func (l *Leaser) AcquireLease(ctx context.Context) (*litestream.Lease, error) {
	existing, etag, err := l.readLease(ctx)
	if err != nil && !errors.Is(err, os.ErrNotExist) {
		return nil, fmt.Errorf("read existing lease: %w", err)
	}

	if existing != nil && !existing.IsExpired() {
		return nil, &litestream.LeaseExistsError{
			Owner:     existing.Owner,
			ExpiresAt: existing.ExpiresAt,
		}
	}

	var generation int64 = 1
	if existing != nil {
		generation = existing.Generation + 1
	}

	newLease := &litestream.Lease{
		Generation: generation,
		ExpiresAt:  time.Now().Add(l.TTL),
		Owner:      l.Owner,

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Verify S3 credentials can GetObject on the lease key
  2. Check bucket name and connectivity
  3. Retry lease acquisition once the backend is healthy
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at s3/leaser.go:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/ef1b24aaab10e6ce. Report an issue: GitHub.