Skip to content

surface rather than hide error handling#135

Draft
maxenglander wants to merge 1 commit into
mainfrom
maxeng-error-handling-1
Draft

surface rather than hide error handling#135
maxenglander wants to merge 1 commit into
mainfrom
maxeng-error-handling-1

Conversation

@maxenglander

@maxenglander maxenglander commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Surface rather than hide errors that are encountered throughout the sync process. Only update table cursor position after successfully flushing records to Airbyte.

This is a lot, so splitting across multiple PRs:

  1. This PR: split up sync() a bit to make subsequent refactoring a bit easier.
  2. surface errors for flushing and recording #136
  3. QueryToResults error handling #137

Once all PRs are approved, I'll merge them from the bottom up, and then merge this PR into main.

Signed-off-by: Max Englander <max@planetscale.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the sync process to expose errors more clearly and simplify error handling during the VStream processing. Key changes include:

  • Splitting up the sync() function parameters for better readability.
  • Introducing a local logf closure for consistent logging.
  • Replacing panic calls in unexpected event cases with error returns.

switch {
case ok && s.Code() == codes.DeadlineExceeded:
// No next VGTID found within deadline.
logf(LOGLEVEL_ERROR, "no new VGTID found before deadline exceeded: %v", err)

Copilot AI Apr 3, 2025

Copy link

Choose a reason for hiding this comment

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

The DeadlineExceeded condition is likely an expected scenario; consider using an informational log level instead of LOGLEVEL_ERROR.

Suggested change
logf(LOGLEVEL_ERROR, "no new VGTID found before deadline exceeded: %v", err)
logf(LOGLEVEL_INFO, "no new VGTID found before deadline exceeded: %v", err)

Copilot uses AI. Check for mistakes.
logf(LOGLEVEL_ERROR, "no new VGTID found before deadline exceeded: %v", err)
case errors.Is(err, io.EOF):
// EOF is an acceptable error indicating VStream is finished.
logf(LOGLEVEL_ERROR, "encountered EOF, possibly indicating end of VStream")

Copilot AI Apr 3, 2025

Copy link

Choose a reason for hiding this comment

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

EOF is typically an acceptable signal indicating the end of the stream; consider logging it at an informational level rather than as an error.

Suggested change
logf(LOGLEVEL_ERROR, "encountered EOF, possibly indicating end of VStream")
logf(LOGLEVEL_INFO, "encountered EOF, possibly indicating end of VStream")

Copilot uses AI. Check for mistakes.

@nickvanw nickvanw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I skipped some of the parts that are copy/pasted, but this looks good to me at first read

isFullSync := syncMode == "full"
vtgateReq := buildVStreamRequest(tabletType, s.Name, tc.Shard, tc.Keyspace, tc.Position, tc.LastKnownPk)
p.Logger.Log(LOGLEVEL_INFO, fmt.Sprintf("%sRequesting VStream with %+v", preamble, vtgateReq))
logf(LOGLEVEL_INFO, "Requesting VStream with %+v", vtgateReq)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logging change is a very welcome change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants