Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .changeset/fuzzy-items-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@powersync/service-module-mysql': patch
'@powersync/service-core': patch
'@powersync/service-image': patch
---

[MySQL] Fix errors being hidden by ROLLBACK failure
12 changes: 10 additions & 2 deletions modules/module-mysql/src/replication/BinLogStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class BinLogStream {
await this.snapshotTable(connection.connection, batch, result.table);
await promiseConnection.query('COMMIT');
} catch (e) {
await promiseConnection.query('ROLLBACK');
await tryRollback(promiseConnection);
throw e;
}
} finally {
Expand Down Expand Up @@ -292,7 +292,7 @@ AND table_type = 'BASE TABLE';`,
logger.info(`Initial replication done`);
await promiseConnection.query('COMMIT');
} catch (e) {
await promiseConnection.query('ROLLBACK');
await tryRollback(promiseConnection);
throw e;
} finally {
connection.release();
Expand Down Expand Up @@ -653,3 +653,11 @@ AND table_type = 'BASE TABLE';`,
}
}
}

async function tryRollback(promiseConnection: mysqlPromise.Connection) {
try {
await promiseConnection.query('ROLLBACK');
} catch (e) {
logger.error('Failed to rollback transaction', e);
}
}