Backend & APIs
Designing a database transaction boundary: group changes that must succeed together
A transaction boundary defines which database changes form one success-or-failure unit. Put the minimum set of changes needed to preserve a business invariant in one transaction, and commit when they can be finalized together. A boundary that is too narrow can save only part of a change; one that is too wide holds locks and connections longer and delays other work.