Optimistic vs Pessimistic Locking and Transactions

What are transactions and why do we need them? The classic, relational database systems, such as MySQL, Postgres come with ACID (Atomicity, Consistency, Isolation, Durability). We start a transaction, execute our database changes and commit. If a single action fails, the transaction will be rolled back and no change is applied. Only if every change…