📓
ainzzorl's wiki
  • Intro
  • Pet Projects
    • Good Code
    • LangFlipFlop
    • Soccer Adjectives
    • Word Highlighter
    • News Digest
    • Algorithms in Kotlin
    • rustorcli
  • Tech
    • Tech Articles
    • Algorithms
      • Distributed Hash Table (DHT)
      • RSA
      • Seam Carving
      • Fibonacci Heaps
      • Suffix trees, suffix arrays, etc.
    • Technologies
      • Threads vs Events
      • TLS
      • GPU
      • Web Sockets
      • OSI Model
    • Open Source
      • Homebrew
      • Standard Notes
      • LiChess
    • Bash
    • Raft
    • Quantum Computing
    • GFS
    • MapReduce
    • ZooKeeper
  • Courses
    • MIT 6.824: Distributed Systems
      • Primary-Backup Replication
      • Object Storage on CRAQ
      • Aurora
      • Cache Consistency: Frangipani
      • Takeways
      • Distributed Transactions
      • Midterm
      • Spanner
      • FaRM
      • Spark
      • Cache Consistency: Memcached at Facebook
    • Page 2
    • MIT 6.854/18.415: Advanced Algorithms + Stanford CS168: The Modern Algorithmic Toolbox
  • Math
    • Fourier Transform
    • Probabilities & Statistics
  • Places
    • Moscow
  • Books
    • Page 1
    • Page 1
    • Page 1
    • Page 1
    • Page 1
    • Tobol Mnogo Zvannyh - Ivanov
    • The Twelve Chairs/12 стульев - Ilf, Petrov
    • Beauty is a Wound - Eka Kurniawan
    • The Queen of Spades/Пиковая Дама - Pushkin
    • The Sirens of Titan - Kurt Vonnegut
    • Обитель - Захар Прилепин
    • The Faithful Executioner - Joel Harrington
    • City of Lies: Love, Sex, Death, and the Search for Truth in Tehran - Ramita Navai
    • June/Июль - Dmitry Bykov/Дмитрий Быков
    • East of Eden - John Steinbeck
    • Como Agua Para Chocolate/Like Water for Chocolate - Laura Esquivel Valdés
    • The Kukotski Enigma/Казус Кукоцкого - Lyudmila Ulitskaya/Людмила Улицкая
    • Ancillary Justice - Ann Leckie
    • Career of Evil - JK Rowling
    • The Signal and the Noise - Nate Silver
    • Don't Sleep, There are Snakes - Daniel Everett
    • Оправдание Острова - Eugene Vodolazkin
    • A Place Called Winter - Patrick Gale
    • 1491: New Revelations of the Americas Before Columbus - Charles C. Mann
    • Трудно Отпускает Антарктида - Vladimir Sanin
    • Klara and the Sun - Kazuo Ishiguro
    • The History of My Contemporary/История Моего Современника - Vladimir Korolenko
    • Life at the Speed of Light - Craig Venter
    • Misery - Stephen King
    • And Then There Were None - Agatha Christie
    • A Kim Jong-Il Production - Paul Fischer
  • Cooking
    • Marinated Mushrooms
    • Pea Soup
    • Fried Potato
    • Chimichurri
    • Komendantsky Sauce
    • Spicy mushroom marinara
    • Bruschetta
    • Solyanka with Mushrooms
    • Tofu Scramble
    • Bean Spaghetti
    • Salsa
    • Baked Mushrooms
    • Lentil Soup
    • Веганство в Москве
  • Misc Research
    • Recycling
    • Sailing Upwind
    • Viruses
  • Misc Reading
    • Harry Potter - Rowling Writing
  • Fitness
  • Languages
    • Spanish
    • Language Classification
  • Juggling
  • Life Advice
Powered by GitBook
On this page

Was this helpful?

  1. Courses
  2. MIT 6.824: Distributed Systems

Distributed Transactions

  • Concurrency control.

  • Atomic commit.

ACID: Atomic, Consistent, Isolated (serializable), Durable.

Serializable: exists serial order of execution of the transactions that yields same result.

Concurrency control:

  1. Pessimistic.

  2. Optimistic, OCC.

If conflicts are frequent - pessimistic is good. If they are rare - optimistic is good.

Two-phase locking:

  1. Acquire lock before using record.

  2. Hold lock until after it commits or aborts. It's bad for concurrency, but required for performance.

Distributed transactions:

  • Transaction participants.

  • Transaction coordinator (TC).

  • Each message is tagged with transaction id.

  • First send prepare message to participants. Make sure participants can do it.

  • If they all reply yes, send Commit message. Participants reply.

  • Participants unlock when they see either Commit or Abort.

What if a participant crashed after replying to PREPARE but crashed? When recovering, it must still be prepared to commit. So the participant must make state and locks durable on disk before replying to Prepare.

What if a participant crashed after making change but before returning to COMMIT?

What if TC crashes? Before sending COMMIT messages, it must write it to its durable log. If it doesn't receive replies from any Prepare's, it must abort.

If a participant is waiting for Commit but hasn't received it for some time, it's not entitled to abort the transaction unilaterally. It must keep waiting.

Blocking and locking is a fundamental property of 2-phase commits. But it's not a good property. It makes it slow.

The decision is made by a single entity - TC.

Sort of looks similar to Raft, but it's entirely different. It solves very different problem.

Raft: High availability by replicating data. Can operate even though some servers are unreachable. In 2PC, you need to wait for all participants. Raft - everyone is doing the same, 2PC - everyone doing different. Raft is all about availability, 2PC - not highly available at all. 2PC is correct with failures, but not available with failures.

You can use Raft to replicate each part, coordinate cross-shard communication with 2PC. This can be highly available and correct.

PreviousTakewaysNextMidterm

Last updated 3 years ago

Was this helpful?