Skip to content

Commit

Permalink
Removed InlineVerifier state tracker for now
Browse files Browse the repository at this point in the history
This commit can be reverted in a later PR.
  • Loading branch information
shuhaowu committed Jul 23, 2019
1 parent 4f17d4d commit 3caa901
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
1 change: 0 additions & 1 deletion ferry.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ func (f *Ferry) Start() error {
// is terminated with some rows copied but no binlog events are written.
// This guarentees that we are able to restart from a valid location.
f.StateTracker.UpdateLastWrittenBinlogPosition(pos)
f.StateTracker.UpdateLastStoredBinlogPositionForInlineVerifier(pos)

return nil
}
Expand Down
45 changes: 11 additions & 34 deletions state_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,13 @@ type SerializableState struct {
GhostferryVersion string
LastKnownTableSchemaCache TableSchemaCache

LastSuccessfulPrimaryKeys map[string]uint64
CompletedTables map[string]bool
LastWrittenBinlogPosition mysql.Position
LastStoredBinlogPositionForInlineVerifier mysql.Position
LastSuccessfulPrimaryKeys map[string]uint64
CompletedTables map[string]bool
LastWrittenBinlogPosition mysql.Position
}

func (s *SerializableState) MinBinlogPosition() mysql.Position {
nilPosition := mysql.Position{}
if s.LastWrittenBinlogPosition == nilPosition {
return s.LastStoredBinlogPositionForInlineVerifier
}

if s.LastStoredBinlogPositionForInlineVerifier == nilPosition {
return s.LastWrittenBinlogPosition
}

if s.LastWrittenBinlogPosition.Compare(s.LastStoredBinlogPositionForInlineVerifier) >= 0 {
return s.LastStoredBinlogPositionForInlineVerifier
} else {
return s.LastWrittenBinlogPosition
}
return s.LastWrittenBinlogPosition
}

// For tracking the speed of the copy
Expand All @@ -81,8 +67,7 @@ type StateTracker struct {
BinlogRWMutex *sync.RWMutex
CopyRWMutex *sync.RWMutex

lastWrittenBinlogPosition mysql.Position
lastStoredBinlogPositionForInlineVerifier mysql.Position
lastWrittenBinlogPosition mysql.Position

lastSuccessfulPrimaryKeys map[string]uint64
completedTables map[string]bool
Expand All @@ -108,7 +93,6 @@ func NewStateTrackerFromSerializedState(speedLogCount int, serializedState *Seri
s.lastSuccessfulPrimaryKeys = serializedState.LastSuccessfulPrimaryKeys
s.completedTables = serializedState.CompletedTables
s.lastWrittenBinlogPosition = serializedState.LastWrittenBinlogPosition
s.lastStoredBinlogPositionForInlineVerifier = serializedState.LastStoredBinlogPositionForInlineVerifier
return s
}

Expand All @@ -119,13 +103,6 @@ func (s *StateTracker) UpdateLastWrittenBinlogPosition(pos mysql.Position) {
s.lastWrittenBinlogPosition = pos
}

func (s *StateTracker) UpdateLastStoredBinlogPositionForInlineVerifier(pos mysql.Position) {
s.BinlogRWMutex.Lock()
defer s.BinlogRWMutex.Unlock()

s.lastStoredBinlogPositionForInlineVerifier = pos
}

func (s *StateTracker) UpdateLastSuccessfulPK(table string, pk uint64) {
s.CopyRWMutex.Lock()
defer s.CopyRWMutex.Unlock()
Expand Down Expand Up @@ -216,12 +193,12 @@ func (s *StateTracker) Serialize(lastKnownTableSchemaCache TableSchemaCache) *Se
defer s.CopyRWMutex.RUnlock()

state := &SerializableState{
GhostferryVersion: VersionString,
LastKnownTableSchemaCache: lastKnownTableSchemaCache,
LastSuccessfulPrimaryKeys: make(map[string]uint64),
CompletedTables: make(map[string]bool),
LastWrittenBinlogPosition: s.lastWrittenBinlogPosition,
LastStoredBinlogPositionForInlineVerifier: s.lastStoredBinlogPositionForInlineVerifier,
GhostferryVersion: VersionString,
LastKnownTableSchemaCache: lastKnownTableSchemaCache,
LastSuccessfulPrimaryKeys: make(map[string]uint64),
CompletedTables: make(map[string]bool),
LastWrittenBinlogPosition: s.lastWrittenBinlogPosition,
// TODO: LastVerifiedBinlogPosition
// TODO: BinlogVerifySerializedStore
}

Expand Down
1 change: 0 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,5 @@ def assert_basic_fields_exist_in_dumped_state(dumped_state)
refute dumped_state["LastSuccessfulPrimaryKeys"].nil?
refute dumped_state["CompletedTables"].nil?
refute dumped_state["LastWrittenBinlogPosition"].nil?
refute dumped_state["LastStoredBinlogPositionForInlineVerifier"].nil?
end
end

0 comments on commit 3caa901

Please sign in to comment.