eval {
- # Clean up after previous transaction.
- # This is a no-op if there is no open transaction.
- $e->xact_rollback if $commit;
+ # Clean up after previous transaction and disconnect from
+ # cstore drone. Forcing a disconnect helps prevent memory
+ # exhaustion when processing huge batches of transactions.
+ # Note the disconnect is forced here instead of during
+ # $e->xact_commit to ensure a disconnect happens with every
+ # transaction regardless of whether a billing was created.
+ $e->rollback if $commit;
$logger->info(sprintf("Processing $ctype %d...", $c->id));