Why can't a regular database transaction guarantee consistency for a business action that spans three separate microservices?
A regular database transaction only has authority over one database connection, and commits or rolls back changes within that single database. When a business action like a loan approval needs Loans to create a record, Accounts to deposit funds, and Customer to update a credit profile, those are three separate databases with three separate transaction boundaries, and no single COMMIT or ROLLBACK statement can span all three at once. If Loans successfully commits its part and Accounts then fails, there is no automatic mechanism to undo what Loans already did — the system is left in a partially completed state unless something was explicitly built to detect and correct it. This is exactly the gap that patterns like the saga pattern are designed to close.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response