From 52c81e65a9894e04260ab6ae2c30bb1db55ee414 Mon Sep 17 00:00:00 2001 From: Leszek Zalewski Date: Thu, 12 Dec 2024 10:20:36 +0100 Subject: [PATCH] Initialize TargetPaginationKeys in constructor --- data_iterator.go | 9 ++++----- ferry.go | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data_iterator.go b/data_iterator.go index 6b8b3597..5621a24e 100644 --- a/data_iterator.go +++ b/data_iterator.go @@ -20,7 +20,7 @@ type DataIterator struct { StateTracker *StateTracker TableSorter DataIteratorSorter - targetPaginationKeys *sync.Map + TargetPaginationKeys *sync.Map batchListeners []func(*RowBatch) error doneListeners []func() error logger *logrus.Entry @@ -33,7 +33,6 @@ type TableMaxPaginationKey struct { func (d *DataIterator) Run(tables []*TableSchema) { d.logger = logrus.WithField("tag", "data_iterator") - d.targetPaginationKeys = &sync.Map{} // If a state tracker is not provided, then the caller doesn't care about // tracking state. However, some methods are still useful so we initialize @@ -59,7 +58,7 @@ func (d *DataIterator) Run(tables []*TableSchema) { // We don't need to reiterate those tables as it has already been done. delete(tablesWithData, table) } else { - d.targetPaginationKeys.Store(tableName, maxPaginationKey) + d.TargetPaginationKeys.Store(tableName, maxPaginationKey) } } @@ -79,9 +78,9 @@ func (d *DataIterator) Run(tables []*TableSchema) { logger := d.logger.WithField("table", table.String()) - targetPaginationKeyInterface, found := d.targetPaginationKeys.Load(table.String()) + targetPaginationKeyInterface, found := d.TargetPaginationKeys.Load(table.String()) if !found { - err := fmt.Errorf("%s not found in targetPaginationKeys, this is likely a programmer error", table.String()) + err := fmt.Errorf("%s not found in TargetPaginationKeys, this is likely a programmer error", table.String()) logger.WithError(err).Error("this is definitely a bug") d.ErrorHandler.Fatal("data_iterator", err) return diff --git a/ferry.go b/ferry.go index c933443e..3718931b 100644 --- a/ferry.go +++ b/ferry.go @@ -111,6 +111,7 @@ func (f *Ferry) NewDataIterator() *DataIterator { ReadRetries: f.Config.DBReadRetries, }, StateTracker: f.StateTracker, + TargetPaginationKeys: &sync.Map{}, } if f.CopyFilter != nil { @@ -993,7 +994,7 @@ func (f *Ferry) Progress() *Progress { s.Tables = make(map[string]TableProgress) targetPaginationKeys := make(map[string]uint64) - f.DataIterator.targetPaginationKeys.Range(func(k, v interface{}) bool { + f.DataIterator.TargetPaginationKeys.Range(func(k, v interface{}) bool { targetPaginationKeys[k.(string)] = v.(uint64) return true })