Skip to content

Commit

Permalink
materialize-mongodb: don't send a batch if there were 0 documents
Browse files Browse the repository at this point in the history
When setting a `notBefore` configuration there will be transactions with 0
stored documents. This adds a condition to prevent a panic trying to send a
batch in Store when there aren't any documents to store.
  • Loading branch information
williamhbaker committed Nov 21, 2024
1 parent 3dc9bf8 commit a2f8522
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions materialize-mongodb/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ func (t *transactor) Store(it *m.StoreIterator) (m.StartCommitFunc, error) {
}

// Drain the last batch.
if err := sendBatch(); err != nil {
return nil, err
if len(batch) > 0 {
if err := sendBatch(); err != nil {
return nil, err
}
}

close(sendBatches)
Expand Down

0 comments on commit a2f8522

Please sign in to comment.