Skip to content

Commit

Permalink
Move lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Aug 20, 2024
1 parent f6d2465 commit 8f141f7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions processes/consumer/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func Flush(ctx context.Context, inMemDB *models.DatabaseData, dest destination.B
return
}

_tableData.Lock()
defer _tableData.Unlock()
err = retry.WithRetries(retryCfg, func(_ int, _ error) error {
return flush(ctx, dest, metricsClient, args.Reason, _tableName, _tableData)
})
Expand All @@ -91,9 +93,6 @@ func Flush(ctx context.Context, inMemDB *models.DatabaseData, dest destination.B
}

func flush(ctx context.Context, dest destination.Baseline, metricsClient base.Client, reason string, _tableName string, _tableData *models.TableData) error {
// Lock the tables when executing merge / append.
_tableData.Lock()
defer _tableData.Unlock()
if _tableData.Empty() {
return nil
}
Expand Down

0 comments on commit 8f141f7

Please sign in to comment.