Skip to content

Add Carbonite.delete_transaction_if_empty/2#144

Merged
maltoe merged 1 commit intomainfrom
delete-transaction-if-empty
Sep 10, 2025
Merged

Add Carbonite.delete_transaction_if_empty/2#144
maltoe merged 1 commit intomainfrom
delete-transaction-if-empty

Conversation

@maltoe
Copy link
Collaborator

@maltoe maltoe commented Sep 10, 2025

This patch adds a new Carbonite.delete_transaction_if_empty/2 function that deletes the ongoing transaction if no changes have been recorded.

I'm a bit torn on this one, as advertising this as the "go to solution" to avoid orphaned transactions is probably uncalled for. For example, my employer has an operation in their codebase that 99% of the time does nothing, but in 1% of runs it requires a transaction; and the operation runs frequently enough for it to matter, so adding a pointless INSERT + DELETE combo is likely not ideal. However, in other cases I've found this trade-off to be less clear, as "skip the entire transaction" often hurts code clarity more (e.g. as it requires pulling up conditionals from lower layers).

@maltoe maltoe requested a review from agatheblues September 10, 2025 09:08
@maltoe maltoe merged commit efd5736 into main Sep 10, 2025
10 checks passed
@maltoe maltoe deleted the delete-transaction-if-empty branch September 10, 2025 10:45
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