Skip to content

Commit

Permalink
source-mongodb: always emit an updated checkpoint after `updateResour…
Browse files Browse the repository at this point in the history
…ceStates`

`updateResourceStates` may remove bindings from the checkpoint, and these removals won't be reflected
in persisted merge patches in future document checkpoints. Because of this, we should always emit a
full update to the state checkpoint in `Pull` after `updateResourceStates` has run to persist any
changes in the state due to bindings being removed.
  • Loading branch information
williamhbaker committed Jan 24, 2024
1 parent a862cea commit 5abec15
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions source-mongodb/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ func (d *driver) Pull(open *pc.Request_Open, stream *boilerplate.PullOutput) err
}
}

migrated, err := migrateState(&prevState, open.Capture.Bindings)
if err != nil {
if _, err := migrateState(&prevState, open.Capture.Bindings); err != nil {
return fmt.Errorf("migrating binding states: %w", err)
}

prevState, err = updateResourceStates(prevState, bindings)
prevState, err := updateResourceStates(prevState, bindings)
if err != nil {
return fmt.Errorf("error initializing resource states: %w", err)
}
Expand Down Expand Up @@ -94,10 +93,10 @@ func (d *driver) Pull(open *pc.Request_Open, stream *boilerplate.PullOutput) err
return err
}

if migrated {
if err := c.outputCheckpoint(&prevState, false); err != nil {
return err
}
// Persist the checkpoint in full, which may have been updated in updateResourceStates to remove
// bindings.
if err := c.outputCheckpoint(&prevState, false); err != nil {
return err
}

if !prevState.isBackfillComplete(bindings) {
Expand Down

0 comments on commit 5abec15

Please sign in to comment.