Skip to content

Conversation

@rkistner
Copy link
Contributor

Previously, replication could fail with an unhelpful error like this:

Replication error Can't add new command when connection is in closed state

This error was raised during ROLLBACK, hiding the actual underlying issue.

This now logs the rollback error, then continues throwing the original error.

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2025

🦋 Changeset detected

Latest commit: d1bd8ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@powersync/service-module-mysql Patch
@powersync/service-core Patch
@powersync/service-image Patch
@powersync/service-core-tests Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner marked this pull request as ready for review March 13, 2025 14:37
@rkistner rkistner requested a review from Copilot March 13, 2025 14:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request aims to reveal the underlying error during replication when a rollback fails by logging the rollback error instead of letting it mask the original error.

  • Updates the changeset file to include version patch releases for multiple modules.
  • Replaces inline rollback queries with a new tryRollback function to log rollback errors and then rethrow the original error.
  • Adds the tryRollback function to handle rollback failures gracefully.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.changeset/fuzzy-items-look.md Updates changeset for new patch releases with the appropriate header.
modules/module-mysql/src/replication/BinLogStream.ts Replaces direct rollback calls with tryRollback and adds tryRollback function for improved logging of rollback errors.
Comments suppressed due to low confidence (1)

modules/module-mysql/src/replication/BinLogStream.ts:657

  • [nitpick] Consider renaming 'tryRollback' to a more descriptive name (e.g., 'attemptRollbackWithLogging') to clarify its specific behavior and intent.
async function tryRollback(promiseConnection: mysqlPromise.Connection) {

@rkistner rkistner merged commit 8601d6c into main Mar 17, 2025
21 checks passed
@rkistner rkistner deleted the fix-mysql-error-hidden branch March 17, 2025 07:58
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.

2 participants