Skip to content

Comments

Remove unnecessary transactions#950

Merged
brandur merged 1 commit intomasterfrom
brandur-reduce-transactions
Jun 21, 2025
Merged

Remove unnecessary transactions#950
brandur merged 1 commit intomasterfrom
brandur-reduce-transactions

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Jun 8, 2025

Here, remove unnecessary transactions around job completion. We
specifically start a transaction for completion only to run exactly one
operation against it, then commit it again. This is undesirable because:

  • Each individual operation is already transaction. So if the completion
    operation fails, it's rolled back even without being in a transaction.

  • For drivers that need to start a subtransaction for completion, this
    ends ups up nesting two transactions for no reason. e.g. The SQLite
    driver needs to run more than one DB operation during completion to
    ensure everything's atomic. It doesn't know whether it's in a
    transaction already, so it ends up opening a transaction despite
    already being in a transaction. This isn't that big of a deal, but
    it's unnecessary.

@brandur brandur force-pushed the brandur-reduce-transactions branch from 7b6bc0e to 53c2ef9 Compare June 8, 2025 11:20
Copy link
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

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

I think the PR description and changelog are maybe slightly out of date based on how this was changed, but in general this looks good. We'll just need a matching tweak on the Pro side, as well as a warning about needing to upgrade the two in lockstep yet again.

These were the original APIs added to the Pilot interface and this change brings everything in line with how the others work now: always providing a full executor so the pilot can decided if/when transactions are appropriate.

@brandur brandur force-pushed the brandur-reduce-transactions branch 4 times, most recently from 8d7979d to bb58da2 Compare June 14, 2025 13:03
@brandur
Copy link
Contributor Author

brandur commented Jun 14, 2025

I think the PR description and changelog are maybe slightly out of date based on how this was changed, but in general this looks good. We'll just need a matching tweak on the Pro side, as well as a warning about needing to upgrade the two in lockstep yet again.

Updated the changelog and added a note on version compatibility.

Here, remove unnecessary transactions around job completion. We
specifically start a transaction for completion only to run exactly one
operation against it, then commit it again. This is undesirable because:

* Each individual operation is already transaction. So if the completion
  operation fails, it's rolled back even without being in a transaction.

* For drivers that need to start a subtransaction for completion, this
  ends ups up nesting two transactions for no reason. e.g. The SQLite
  driver needs to run more than one DB operation during completion to
  ensure everything's atomic. It doesn't know whether it's in a
  transaction already, so it ends up opening a transaction despite
  already being in a transaction. This isn't that big of a deal, but
  it's unnecessary.
@brandur brandur force-pushed the brandur-reduce-transactions branch from bb58da2 to c919eec Compare June 21, 2025 08:03
@brandur brandur merged commit 33c1d25 into master Jun 21, 2025
10 checks passed
@brandur brandur deleted the brandur-reduce-transactions branch June 21, 2025 08:07
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