🐥
The Tech Toolbox
Visit My Website!LinkedIn Profile
  • ✍️Introduction
  • ✍️Laptop Setup Guide
  • ✍️Quotes
  • Interview Preparation
    • 🔥Topics To Cover
    • 🔥System Design
    • 🔥Google Interview
      • Data Structures
      • Algorithms
      • System Design
      • Programming Concepts
      • Behavioral
    • 🔥Documents
  • Question Answers
    • ⭐Question Set 1
    • ⭐Question Set 2
    • ⭐Question Set 3
    • ⭐Microservice Architecture
    • ⭐Company-wise
      • Publicis Sapient
        • Core Java Section
        • Solutions & Tools
        • Microservices
        • Mix Questions
      • Mastercard
      • Finicity
  • Notes
    • 🎯Java Fundamentals
      • Time & Space Complexity
      • Design Patterns
      • Collections
      • Java 8 Features
      • JVM Internals
      • Generics
      • Multithreading
    • 🎯Spring Fundamentals
      • Spring Boot
      • Spring AOP
      • Spring Cloud
      • Spring Security
      • Spring Batch
    • 🎯Database
      • Oracle SQL
        • Aggregate Functions
      • MongoDB
        • Commands
        • Aggregate Query
      • Distributed Transaction
    • 🎯Apache Kafka
      • Kafka with Spring Boot
      • Partitions
    • 🎯Redis
    • 🎯Mockito
    • 🎯Docker
      • Commands
    • 🎯Kubernetes
      • Commands
    • 🎯Prometheus
    • 🎯Build Tools
      • Gradle
      • Apache Maven
    • 🎯Architecture
      • API and Integration Strategy
  • ⚓Developer Reference
    • ❄️GCP
    • ❄️Linux
  • Structured Learning Plan
    • 🍉Java Multithreading
    • 🍉Data Structures
    • 🍉Spring AOP
    • 🍉Transaction Management
    • 🍉MongoDB
    • 🍉Design Patterns
    • 🍉System Design
Powered by GitBook
On this page
  • What is a Distributed Transaction?
  • ACID Properties of Distributed Transactions
  • Distributed Transaction Coordinator (DTC)
  • Two-Phase Commit Protocol
  • Distributed Lock Manager (DLM)
  • Conclusion

Was this helpful?

  1. Notes
  2. Database

Distributed Transaction

What is a Distributed Transaction?

A distributed transaction is a transaction that involves multiple independent transactional systems that may be geographically dispersed. It is a process where a transaction is executed across multiple nodes or machines in a network. These nodes are often referred to as participants and each participant executes a part of the transaction.

ACID Properties of Distributed Transactions

The ACID properties of a transaction are important for ensuring that transactions are executed correctly and consistently. ACID stands for:

  • Atomicity: All or nothing approach, either the entire transaction is completed or it is rolled back.

  • Consistency: The transaction brings the database from one valid state to another.

  • Isolation: Transactions execute independently of one another, and the execution of one transaction does not affect the execution of another.

  • Durability: Once a transaction is committed, the changes it made are permanent and will survive any subsequent system failures.

Distributed Transaction Coordinator (DTC)

A distributed transaction coordinator (DTC) is responsible for coordinating transactions that span multiple systems. The DTC is a component of the operating system and provides a means for different transactional systems to coordinate and participate in distributed transactions.

Two-Phase Commit Protocol

The two-phase commit protocol is a widely used protocol for coordinating distributed transactions. The protocol is used to ensure that all participants in a distributed transaction either commit or abort the transaction. The protocol consists of two phases:

  1. Prepare Phase: In this phase, the DTC sends a prepare message to all participants to verify that they are ready to commit the transaction. The participants respond with a yes or no answer. If all participants respond with yes, the transaction moves to the commit phase. If any participant responds with no, the transaction is aborted.

  2. Commit Phase: In this phase, the DTC sends a commit message to all participants to instruct them to commit the transaction. If any participant encounters an error during the commit phase, it rolls back the transaction.

Distributed Lock Manager (DLM)

A distributed lock manager (DLM) is a component of the DTC that manages locks on resources used in distributed transactions. The DLM ensures that resources are locked when they are needed and released when they are no longer needed.

Conclusion

Distributed transactions are complex and require coordination between multiple systems. The ACID properties, DTC, two-phase commit protocol, and DLM are important components of a distributed transaction system that ensures that transactions are executed correctly and consistently.

PreviousAggregate QueryNextApache Kafka

Last updated 2 years ago

Was this helpful?

🎯