1 Chapter 3. Synchronization. STEMPusan National University STEM-PNU 2 Synchronization in Distributed Systems Synchronization in a single machine Same.

Slides:



Advertisements
Similar presentations
1 Integrity Ioan Despi Transactions: transaction concept, transaction state implementation of atomicity and durability concurrent executions serializability,
Advertisements

Em Spatiotemporal Database Laboratory Pusan National University File Processing : Transaction Management 2004, Spring Pusan National University Ki-Joune.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Chapter 7 Transactions 7.1 Transaction Concept 7.2 Transaction State 7.3 Implementation of Atomicity and Durability 7.4 Concurrent Executions 7.5 Serializability.
©Silberschatz, Korth and Sudarshan15.1Database System ConceptsTransactions Transaction Concept Transaction State Implementation of Atomicity and Durability.
Synchronization Part 2 REK’s adaptation of Claypool’s adaptation ofTanenbaum’s Distributed Systems Chapter 5 and Silberschatz Chapter 17.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
Transaction Management
1 Transaction Management Database recovery Concurrency control.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
Synchronization.
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Massively Distributed Database Systems - Transaction management Spring 2014 Ki-Joune Li Pusan National University.
Transactions Sylvia Huang CS 157B. Transaction A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction.
Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.
Transaction Processing Concepts. 1. Introduction To transaction Processing 1.1 Single User VS Multi User Systems One criteria to classify Database is.
Transaction Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
1 Transactions. 2 Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15: Transactions.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
Real-Time & MultiMedia Lab Synchronization Chapter 5.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts - 6 th Edition UNIT 5 :Transactions Transaction concepts, properties of transactions, serializability.
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
Concurrency Control in Database Operating Systems.
Global State (1) a)A consistent cut b)An inconsistent cut.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Synchronization Chapter 5. Outline 1.Clock synchronization 2.Logical clocks 3.Global state 4.Election algorithms 5.Mutual exclusion 6.Distributed transactions.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
Computing & Information Sciences Kansas State University Wednesday, 05 Nov 2008CIS 560: Database System Concepts Lecture 28 of 42 Wednesday, 05 November.
Chapter 14 Transactions Yonsei University 1 st Semester, 2015 Sanghyun Park.
File Processing : Transaction Management 2015, Spring Pusan National University Ki-Joune Li.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
Synchronization Chapter 5. Table of Contents Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
15.1 Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction to transfer.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts - 6 th Edition Chapter 14: Transactions Transaction Concept Transaction State Concurrent.
1 DC8: Transactions Chapter 12 Transactions and Concurrency Control.
Advanced Database- Dr. Arasteh1 Advanced Database Bahman Arasteh ( Ph.D, Software Engineering ) Department of Software Engineering, Azad University of.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Transactions.
Software System Lab. Transactions Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various.
D ATABASE A DMINISTRATION L ECTURE N O 5 Muhammad Abrar.
Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
Advanced Database CS-426 Week 6 – Transaction. Transactions and Recovery Transactions A transaction is an action, or a series of actions, carried out.
Lecture on Synchronization Submitted by
Transactions Chapter 12 Transactions and Concurrency Control.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Transaction Management
Last Class: Canonical Problems
Database Management System
Part- A Transaction Management
Transactions.
Transaction Properties
Synchronization Chapter 5C
Mutual Exclusion What is mutual exclusion? Single processor systems
Transactions Sylvia Huang CS 157B.
Database Transactions
Chapter 14: Transactions
Synchronization outline
UNIT -IV Transaction.
Transactions, Properties of Transactions
Presentation transcript:

1 Chapter 3. Synchronization

STEMPusan National University STEM-PNU 2 Synchronization in Distributed Systems Synchronization in a single machine Same clock Shared data for synchronization Semaphore for mutual exclusion Synchronization in distributed system Difficult to handle it No same physical clock No shared data for synchronization Machine 1Machine 2 Semaphore Remote Access : Delay and Error

STEMPusan National University STEM-PNU 3 Clock In distributed systems Multiple Physical Clocks : No Centralized Clock Logical Clock rather than a Global Physical Clock

STEMPusan National University STEM-PNU 4 Global Clock and Logical Clock Global Clock TAI (Temps Atomique International) at Paris Time Server Broadcasting from Satellite Granularity Logical Clock Not absolute time but for ordering Lamport Algorithm Correction of Clock T(A, tx) < T(B, rx)

STEMPusan National University STEM-PNU 5 Logical Clock Not absolute time but for ordering Lamport Algorithm Correction of Clock C(A, tx) < C(B, rx)

STEMPusan National University STEM-PNU 6 Global Clock and Time Server Global Clock TAI (Temps Atomique International) at Paris Time Server Broadcasting from Satellite Granularity Global Clock Server Adjust local clock Cristian’s Algorithm Berkeley Algorithm Time never runs backward

STEMPusan National University STEM-PNU 7 Global State States of each local system Messages in transit Very important to determine the status of distributed system Example : Deadlock Detection Distributed Snapshot : State of distributed systems in a given time

STEMPusan National University STEM-PNU 8 Mutual Exclusion : Monitor (Coordinator) In a single system : Easy to implement by semaphore In distributed systems : No shared data for semaphore A Centralized Algorithm Simple But single point of failure

STEMPusan National University STEM-PNU 9 Mutual Exclusion : Distributed Algorithm No central coordinator Rule : When a system receive a request Not in CS or Not to enter : OK to requester In CS : No reply To enter : compare Timestamp and one with lower TS wins

STEMPusan National University STEM-PNU 10 Mutual Exclusion : Token Ring One with token can enter CS If a system wants to enter CS : wait Token and process it Otherwise, pass token to the next Token Wait until it gets the token

STEMPusan National University STEM-PNU 11 Mutual Exclusion : Comparison # of messages per request delay per request Problem Monitor32Crash of monitor Distributed Algorithm 2(n-1) n points of Crash Token Ring0 to n-1 Token lost

STEMPusan National University STEM-PNU 12 Election : Bully Algorithm When it is found that a coordinator is required

STEMPusan National University STEM-PNU 13 Election : Ring Algorithm When it is found that the coordinator has crashed, Circulate message with priority

STEMPusan National University STEM-PNU 14 Distributed Transaction Transaction Example : Flight Reservation Consistent State Consistent State Set of operations BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi; END_TRANSACTION (a) BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi full => ABORT_TRANSACTION (b)

STEMPusan National University STEM-PNU 15 ACID Properties : Atomicity and Consistency Atomicity. All or Nothing Not Partially Done Example : Failure in Flight Reservation Consistency. Execution of a transaction preserves the consistency of the database. State 1 State 2 All Nothing State 2’ Partially Done Consistent

STEMPusan National University STEM-PNU 16 Transaction States Active Partially Committed FailedAborted Committed the initial state; the transaction stays in this state while it is executing after the discovery that normal execution can no longer proceed. after the transaction has been rolled back and the database restored to its state prior to the start of the transaction. - restart the transaction or - kill the transaction ALL NOTHING

STEMPusan National University STEM-PNU 17 ACID Properties : Isolation and Durability Isolation. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions. Durability. After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures. DB Transaction 1 Transaction 2 No Effect

STEMPusan National University STEM-PNU 18 Example Transaction : Transfer $50 from account A to account B: 1.read(A) 2.A := A – 50 3.write(A) 4.read(B) 5.B := B write(B) Consistency requirement the sum of A and B is unchanged after the transaction. Atomicity requirement Durability Isolation

STEMPusan National University STEM-PNU 19 Example : Concurrent Execution Two Transactions T 1 : transfer $50 from A to B, T 2 transfer 10% of the balance from A to B Serial ScheduleConcurrent Schedule

STEMPusan National University STEM-PNU 20 Serializability What happens after these transactions ? Serial Schedule : Always Correct T1  T2 and T2  T1 Concurrent Schedule Serializable if Result (T1||T2) = Result(T1  T2) or Result(T2  T1)

STEMPusan National University STEM-PNU 21 Transaction : Atomicity Failure during transaction Abort the partial execution How to discard incomplete transaction Deferred updates Immediate updates Safe transaction Decrease failure probability Rollback Recovery Return to initial state Without minimum cost

STEMPusan National University STEM-PNU 22 Safe Transaction Decrease the possibility of failure Two Phase Commit Wedding Ceremony Protocol 1 st Phase : send ready message 2 nd Phase : execute only when OK messages are received from all

STEMPusan National University STEM-PNU 23 Log History of operations Used for rollback (Transaction#, Pre-state, Post-state) (Trans#, DataItem, OldValue, NewValue) Transaction operation1 operation3 operation2 System log

STEMPusan National University STEM-PNU 24 Deferred Updates Reflect Logs after Commit Shadowing If the transaction fails, then discard logs Transaction operation1 operationn... System Begin Commit Write or update operations log

STEMPusan National University STEM-PNU 25 (T1, begin) (T1, A, 20, 30) (T2, begin) (T1, B, 30, 40) (T2, B, 40, 50) (T1, commit) (T3, begin) (T2, C, 100, 50) (T2, commit) (T3, D, 10, 20) Delete them OK Deferred Updates : Recovery Log File Fail Here 1. Transaction with commit: OK 2. Transaction with begin but without commit : Delete log records

STEMPusan National University STEM-PNU 26 Transaction Begin Commit Immediate Updates Execute operation immediately If the transaction fails, undo operations operation1 operation3 operation2 System log

STEMPusan National University STEM-PNU 27 Which one is better ?

STEMPusan National University STEM-PNU 28 Transaction : Serializability Serialization Exchange non-conflict operation Conflict operation : Result(T1.Op,T2.Op) ≠ Result(T2.Op,T1.Op) Time-stamping Two Phase Locking r(a)w(a)r(b)w(b) r(a)w(a)r(b)w(b) Trans 1 Trans 2 Time

STEMPusan National University STEM-PNU 29 Time Stamping If conflict occurs, then abort For read(T,x), ts(T) < ts WR (x), then abort T For write(T,x), ts(T) < ts WR (x) or ts(T) < ts RD (x), then abort T

STEMPusan National University STEM-PNU 30 Two Phase Locking 2PL Strict 2PL

STEMPusan National University STEM-PNU 31 Implementation of Concurrency Control in Distributed Systems Three Managers TM (Transaction Manager) : Ensure the Atomicity Scheduler : Main Responsibility for Concurrency Control DM (Data Manager) : Simple Read/Write In a single machine In distributed systems