Skip to content

fix(export): paginate large database dumps in bounded chunks with breathing intervals and R2 support (#59) - #319

Open
hornsandhalos619 wants to merge 1 commit into
outerbase:mainfrom
hornsandhalos619:fix/large-database-dumps-issue-59
Open

hornsandhalos619 wants to merge 1 commit into
outerbase:mainfrom
hornsandhalos619:fix/large-database-dumps-issue-59

Conversation

@hornsandhalos619

Copy link
Copy Markdown

Summary

Fixes large database export OOMs and Durable Object lockups in /export/dump and table exports by paginating table rows in bounded LIMIT ... OFFSET ... batches, encoding chunks directly into Uint8Array buffers, yielding cooperative breathing intervals when continuous execution exceeds the active window, and supporting optional R2 bucket offload (dump_YYYYMMDD-HHMMSS.sql) + completion webhook callback.

Changes

  • src/export/index.ts: Added paginateTableData async generator with bounded batchSize (default 500) and cooperative breathingIntervalMs pauses after maxActiveWindowMs.
  • src/export/dump.ts: Updated dumpDatabaseRoute to paginate large tables in chunks, encode batches to Uint8Array, support optional r2Bucket.put('dump_YYYYMMDD-HHMMSS.sql', ...) and callbackUrl notification, and format NULL/boolean/number/escaped string SQL literals cleanly.
  • src/export/dump.test.ts & src/export/dump.node.test.ts: Added unit tests covering multi-batch pagination, breathing intervals, R2 bucket persistence, and SQL literal formatting.

Closes #59
/claim #59

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.

Database dumps do not work on large databases

1 participant