Clear last position on replica sync error

This commit is contained in:
Ben Johnson
2021-01-16 07:45:08 -07:00
parent cbc2dce6dc
commit 25fec29e1a
3 changed files with 26 additions and 7 deletions

View File

@@ -678,6 +678,16 @@ func (r *Replica) findBucketRegion(ctx context.Context, bucket string) (string,
}
func (r *Replica) Sync(ctx context.Context) (err error) {
// Clear last position if if an error occurs during sync.
defer func() {
if err != nil {
r.mu.Lock()
r.pos = litestream.Pos{}
r.mu.Unlock()
}
}()
// Connect to S3, if necessary.
if err := r.Init(ctx); err != nil {
return err
}