Skip to content

sync -- log tweaks #2008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions x/sync/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ func (m *Manager) Start(ctx context.Context) error {
return ErrAlreadyStarted
}

m.config.Log.Info("starting sync", zap.Stringer("target root", m.config.TargetRoot))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will help for debugging/showing stuff to user


// Add work item to fetch the entire key range.
// Note that this will be the first work item to be processed.
m.unprocessedWork.Insert(newWorkItem(ids.Empty, maybe.Nothing[[]byte](), maybe.Nothing[[]byte](), lowPriority))
Expand Down Expand Up @@ -539,14 +541,15 @@ func (m *Manager) Wait(ctx context.Context) error {

root, err := m.config.DB.GetMerkleRoot(ctx)
if err != nil {
m.config.Log.Info("completed with error", zap.Error(err))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the caller should worry about logging this

return err
}

if targetRootID := m.getTargetRoot(); targetRootID != root {
// This should never happen.
return fmt.Errorf("%w: expected %s, got %s", ErrFinishedWithUnexpectedRoot, targetRootID, root)
}
m.config.Log.Info("completed", zap.String("new root", root.String()))

m.config.Log.Info("completed", zap.Stringer("root", root))
return nil
}

Expand All @@ -568,6 +571,7 @@ func (m *Manager) UpdateSyncTarget(syncTargetRoot ids.ID) error {
return nil
}

m.config.Log.Debug("updated sync target", zap.Stringer("target", syncTargetRoot))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for debugging

m.config.TargetRoot = syncTargetRoot

// move all completed ranges into the work heap with high priority
Expand Down Expand Up @@ -600,7 +604,7 @@ func (m *Manager) setError(err error) {
m.errLock.Lock()
defer m.errLock.Unlock()

m.config.Log.Error("syncing failed", zap.Error(err))
m.config.Log.Error("sync errored", zap.Error(err))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syncing --> sync for parallelism

m.fatalError = err
// Call in goroutine because we might be holding [m.workLock]
// which [m.Close] will try to acquire.
Expand Down Expand Up @@ -662,7 +666,7 @@ func (m *Manager) completeWorkItem(ctx context.Context, work *workItem, largestH
}

// completed the range [work.start, lastKey], log and record in the completed work heap
m.config.Log.Info("completed range",
m.config.Log.Debug("completed range",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the user doesn't need to see all these, so made it debug

zap.Stringer("start", work.start),
zap.Stringer("end", largestHandledKey),
zap.Stringer("rootID", rootID),
Expand Down