Skip to content

Commit

Permalink
MySQL: Removed duplicate snapshot query stream invocation (#175)
Browse files Browse the repository at this point in the history
Removed duplicate snapshot query stream invocation
Added abort controller check during MySQL initial snapshot
  • Loading branch information
Rentacookie authored Jan 9, 2025
1 parent 715fc26 commit 318f9f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-plums-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/service-module-mysql': patch
---

Resolved excessive memory consumption during MySQL initial replication.
8 changes: 6 additions & 2 deletions modules/module-mysql/src/replication/BinLogStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,16 @@ AND table_type = 'BASE TABLE';`,
columns = toColumnDescriptors(fields);
});

for await (let row of query.stream()) {
for await (let row of stream) {
if (this.stopped) {
throw new Error('Abort signal received - initial replication interrupted.');
}

if (columns == null) {
throw new Error(`No 'fields' event emitted`);
}
const record = common.toSQLiteRow(row, columns!);

const record = common.toSQLiteRow(row, columns!);
await batch.save({
tag: storage.SaveOperationTag.INSERT,
sourceTable: table,
Expand Down

0 comments on commit 318f9f9

Please sign in to comment.