Skip to content

Fix export transactions#659

Merged
tdroxler merged 2 commits into
masterfrom
fix-export-transactions
Apr 7, 2026
Merged

Fix export transactions#659
tdroxler merged 2 commits into
masterfrom
fix-export-transactions

Conversation

@tdroxler

Copy link
Copy Markdown
Member

Previously, if a transaction export started but the user canceled it (or the connection dropped), the backend would just keep churning away in the background. This resulted in a ton of zombie DB calls and wasted CPU.

We saw this hit us in prod: EB was a bit slow, Nginx timed out the download, and the user (rightfully) clicked retry multiple times. This created a "stack" of simultaneous exports for the same request, which blew up our RAM.

Changes:

  • We now listen for the Vert.x closeHandler. If the connection drops, we trigger a cancelToken.
  • The internal export process is now reactive to this token and will kill the DB stream immediately.
  • I changed the batchSize from 1 to 100. Previously, we were doing a DB round-trip for every single transaction, which was super inefficient (because I thought we wouldn't preserve transactions order with batch, which I was wrong). Now we fetch and process in chunks of 100, which significantly reduces the IO overhead and helps the stream keep up with Nginx timeouts.

Testing:

I simulated the prod failure by setting a 1s Nginx timeout and forcing a 2s delay between batches in EB. The internal process now correctly catches the disconnect and stops immediately.

Before that commit, if you were starting an export of transactions, but
stop in the middle, the process was still continuing in EB.
Producing unnecessary calls to DB.

The request could be stopped by nginx because of a timeout and then the
user might then want to re-request, leading to double work in EB.
It was hardcoded to 1 previously because I thought it would break the
transactions order if we we batching our transactions, but actually not,
the order is preserved (by time).

So it ease the load of the DB (batching request, instead of 1 by 1 query
for each transaction).
@tdroxler tdroxler requested a review from h0ngcha0 March 25, 2026 14:58

@h0ngcha0 h0ngcha0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@tdroxler tdroxler merged commit 3d62b3f into master Apr 7, 2026
2 checks passed
@tdroxler tdroxler deleted the fix-export-transactions branch April 7, 2026 07:03
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