Databases. Laboratorio de sistemas distribuidos. Universidad Politécnica de Madrid (UPM)

Similar documents
CSE 544 Principles of Database Management Systems. Alvin Cheung Fall 2015 Lecture 14 Distributed Transactions

Transactions. Transactions. Distributed Software Systems. A client s banking transaction. Bank Operations. Operations in Coordinator interface

Data Modeling and Databases Ch 14: Data Replication. Gustavo Alonso, Ce Zhang Systems Group Department of Computer Science ETH Zürich

Transactions. ACID Properties of Transactions. Atomicity - all or nothing property - Fully performed or not at all

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh

CSE 344 MARCH 25 TH ISOLATION

CSE 530A ACID. Washington University Fall 2013

Distributed Transaction Management

CSE 344 MARCH 5 TH TRANSACTIONS

EE324 INTRO. TO DISTRIBUTED SYSTEMS LECTURE 13 TRANSACTIONS

Chapter 22. Transaction Management

CSE 444: Database Internals. Lecture 25 Replication

Example: Transfer Euro 50 from A to B

Introduction to Data Management CSE 344

SQL: Transactions. Introduction to Databases CompSci 316 Fall 2017

Large-Scale Key-Value Stores Eventual Consistency Marco Serafini

Distributed Transactions

Problems Caused by Failures

Motivating Example. Motivating Example. Transaction ROLLBACK. Transactions. CSE 444: Database Internals

Concurrency Control 9-1

Topics in Reliable Distributed Systems

Transactions. A Banking Example

Introduction to Database Systems CSE 444

Distributed Data Management Transactions

Transaction Management. Pearson Education Limited 1995, 2005

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein. Copyright 2003 Philip A. Bernstein. Outline

SQL: Transactions. Announcements (October 2) Transactions. CPS 116 Introduction to Database Systems. Project milestone #1 due in 1½ weeks

A transaction is a sequence of one or more processing steps. It refers to database objects such as tables, views, joins and so forth.

CSE 444: Database Internals. Section 9: 2-Phase Commit and Replication

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein Sameh Elnikety. Copyright 2012 Philip A. Bernstein

On the Study of Different Approaches to Database Replication in the Cloud

Overview of Transaction Management

Pessimistic v.s. Optimistic. Outline. Timestamps. Timestamps. Timestamps. CSE 444: Database Internals. Main invariant:

Introduction to Data Management CSE 344

CSE 444: Database Internals. Lectures 13 Transaction Schedules

TRANSACTION PROPERTIES

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

A Framework for Transactional Consistency Models with Atomic Visibility

Distributed Transaction Processing in the Escada Protocol

Final Review #2. Monday, May 4, 2015

Chapter 11 - Data Replication Middleware

Lecture X: Transactions

Transaction Processing: Concurrency Control ACID. Transaction in SQL. CPS 216 Advanced Database Systems. (Implicit beginning of transaction)

Databases - Transactions

Performance and Forgiveness. June 23, 2008 Margo Seltzer Harvard University School of Engineering and Applied Sciences

Announcements. Motivating Example. Transaction ROLLBACK. Motivating Example. CSE 444: Database Internals. Lab 2 extended until Monday

Chapter 7 (Cont.) Transaction Management and Concurrency Control

Introduction to Data Management CSE 344

Transaction Management & Concurrency Control. CS 377: Database Systems

CONCURRENCY CONTROL, TRANSACTIONS, LOCKING, AND RECOVERY

Weak Levels of Consistency

bobpusateri.com heraflux.com linkedin.com/in/bobpusateri. Solutions Architect

Security Mechanisms I. Key Slide. Key Slide. Security Mechanisms III. Security Mechanisms II

Transaction Management: Concurrency Control, part 2

Locking for B+ Trees. Transaction Management: Concurrency Control, part 2. Locking for B+ Trees (contd.) Locking vs. Latching

CSE 486/586 Distributed Systems

Information Systems (Informationssysteme)

Database System Concepts

Transactions. Kathleen Durant PhD Northeastern University CS3200 Lesson 9

Optimistic Concurrency Control. April 18, 2018

Transaction Concept. Two main issues to deal with:

Consistency in Distributed Systems

COURSE 1. Database Management Systems

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 13 Managing Transactions and Concurrency

Mobile and Heterogeneous databases Distributed Database System Transaction Management. A.R. Hurson Computer Science Missouri Science & Technology

CSE 344 MARCH 21 ST TRANSACTIONS

SCALABLE CONSISTENCY AND TRANSACTION MODELS

Transactions with Replicated Data. Distributed Software Systems

Introduction to Database Systems CSE 444

Database Systems CSE 414

Introduction to Data Management CSE 344

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Transactions Processing (i)

CS 245: Database System Principles

T ransaction Management 4/23/2018 1

Announcements. Transaction. Motivating Example. Motivating Example. Transactions. CSE 444: Database Internals

Database Recovery. Dr. Bassam Hammo

Distributed Systems. Day 13: Distributed Transaction. To Be or Not to Be Distributed.. Transactions

Database Management Systems

Distributed Data Analytics Transactions

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428. Fall 2012

Transactions and Isolation

OPTIMISTIC AND MULTIVERSION CONCURRENCY CONTROL

Some Examples of Conflicts. Transactional Concurrency Control. Serializable Schedules. Transactions: ACID Properties. Isolation and Serializability

Database Systems CSE 414

A New Approach to Developing and Implementing Eager Database Replication Protocols

Synchronization. Chapter 5

In This Lecture. Transactions and Recovery. Transactions. Transactions. Isolation and Durability. Atomicity and Consistency. Transactions Recovery

Database Replication: A Tutorial

Implementing Isolation

Database System Concepts

Geographically Distributed Transactional Applications

Database Management Systems CSEP 544. Lecture 9: Transactions and Recovery

Concurrency Control & Recovery

Database Tuning and Physical Design: Execution of Transactions

Overview. Introduction to Transaction Management ACID. Transactions

Intro to Transaction Management

Transcription:

Databases Laboratorio de sistemas distribuidos Universidad Politécnica de Madrid (UPM) http://lsd.ls.fi.upm.es/lsd/lsd.htm Nuevas tendencias en sistemas distribuidos 2

Summary Transactions. Isolation. Concurrency control. Isolation levels. Database replication. Nuevas tendencias en sistemas distribuidos 3

Motivation What happens if the two programs are executed concurrently? 1 a=read(a) if a >= 100 then Write(A,a-100) b=read(b) Write(B,b+100) end if 3 4 2 a=read(a) if a >= 100 then Write(A,a-100) b=read(b) Write(B,b+100) end if Nuevas tendencias en sistemas distribuidos 4

Introduction Transactions provide ACID properties: Atomicity: All (commit) or nothing (abort). Consistency: Program correctness. Isolation: serializability, equivalent to a serial execution. Durability: once a transaction commits its effects remain despite of failures. Nuevas tendencias en sistemas distribuidos 5

Introduction Isolation is provided by concurrency control protocols -> e.g., locking Atomicity and durability are provided by recovery protocols Correctness criteria: different isolation levels. Nuevas tendencias en sistemas distribuidos 6

Concurrency control If there is no concurrency control two problems may happen: lost updates and inconsistent retrievals (dirty reads). a lost update occurs when two transactions both read the old value of a variable and use it to calculate a new value. inconsistent retrievals occur when a retrieval transaction observes values that are involved in an ongoing updating transaction. Nuevas tendencias en sistemas distribuidos 7

Concurrency control: Lost updates a.deposit(200) bal= a.getbalance() (1) a.deposit(300) bal= a.getbalance() (2) a.setbalance(bal+200) (3) a.setbalance(bal+300) (4) bal 500 (1) a 500 (0) 700 (3) 800 (4) bal 500 (2) 8 Nuevas tendencias en sistemas distribuidos

Concurrency control: inconsistent retrievals bank.transfer(a, b, 100) a.withdraw(100) (1) b.deposit(100) (4) branch.getbalance() bal= a.getbalance() (2) bal = bal +b.getbalance() (3) a 500 (0) 400 (1) b 300 (0) 400 (4) bal 400 (2) 700 (3) 9 Nuevas tendencias en sistemas distribuidos

Serial equivalence A serial equivalence interleaving is one in which the combined effect is the same effect as if the transactions have been executed sequentially in some order. the same effect means: the read operations return the same values The variables have the same values at the end For two transactions to be serially equivalent, it is necessary and sufficient that all pairs of conflicting operations of the two transactions be executed in the same order at all of the objects they both access. Two operations conflict if they access the same item and at least one of the operations is a write operation. Nuevas tendencias en 10 sistemas distribuidos

Serial equivalence Example: T: x = read(i); write(i, 10); write(j, 20); U: y = read(j); write(j, 30); z = read (i); serial equivalence requires that either T accesses i before U and T accesses j before U. or U accesses i before T and U accesses j before T. Concurrency control protocols: pessimistic (locking) and optimistic ones (backward and forward validation). Nuevas tendencias en 11 sistemas distribuidos

ANSI isolation levels ANSI isolation levels: Read uncommitted. Read committed. Repetable read. Serializable. Nuevas tendencias en 12 sistemas distribuidos

ANSI Isolation levels ANSI isolation levels are defined based on the anomalies they avoid. The anomalies are : Dirty read: T1 updates an item. T2 reads that item. T1 aborts. T2 has read an update that never happened. Non-repeatable read: T1 reads an item. T2 updates the same item and commits. T1 reads the same item again and it has changed its value. Phantom: T1 retrieves the set of items that satisfy a predicate. T2 inserts new data that satisfy that predicate and commits. T1 repeats the retrieval with the same predicate and there are new items in the result. Nuevas tendencias en 13 sistemas distribuidos

ANSI Isolation levels Isoltation Level /Anomalies Read uncommitted Read committed Repeatable read Dirty Write Dirty Read Nonrepeatable Read Phantom No Yes Yes Yes No No Yes Yes No No No Yes Serializable No No No No 14 Nuevas tendencias en sistemas distribuidos

Snapshot Isolation This isolation criteria avoids all ANSI anomalies. Oracle was the first company to implement it. This isolation level is defined for mul tiversion DBs. A transaction reads the most recent committed data at the time the transaction start. The only conflicts are write-write conflicts. Two concurrent transactions conflict if they update the same item. Either the first committer wins or the first transaction that updates the item. Nuevas tendencias en 15 sistemas distribuidos

Database Replication Goal: increase data availability (fault-tolerance) and efficiency. Read operations can be done in any replica. Local data access. Correctness criteria: one-copy correctness (serializability or SI). The effect of executing a set of transactions on a replicated database is equivalent to the execution of the same set of transactions over a non-replicated database. All copies must be updated and kept consistent. Nuevas tendencias en 16 sistemas distribuidos

Database replication Updates are propagated in the context of the original transaction - > Eager replication (synchronous replication). No inconsistencies. Increased latency. Updates are propagated in a different transaction -> Lazy replication (Asynchronous replication). Updates can be executed at any replica -> Update everywhere. Updates can be executed only at a given replica -> primary copy. Queries can be executed at any replica. Used by commercial DBs. When updates are propagated to other replicasreplicas Where updates are executed Primary Nuevas tendencias en 17 sistemas distribuidos Any replica In the original transaction Eager primary copy Eager update everywhere In a different transaction Lazy primary copy Lazy update everywhere

Database replication Updates can be done at all the replicas at the same time or locally and at commit time the other replicas are updated (deferred updates). Deferred updates need less messages. All updates can be sent in a single message (commit prepare) Aborts are less expensive (only one replica needs to undo the updates). Late detection of conflicts (if it implements update everywhere). Nuevas tendencias en 18 sistemas distribuidos

Database Replication If there are network partitions inconsistencies may happen. Quorum consensus or majority quorum: only one partition can continue proccessing. Each replica is assigned a weight. All replicas are aware of the weights of each replica. A quorum is a set of nodes whose weights sum more than half of the total weight. Only a quorum component will proccess transactions. A read quorum (RT) (writewt) is a set of replicas that satisfy 2.WT > sum all weights WT+RT > sum all weights. Nuevas tendencias en 19 sistemas distribuidos

Database Replication One read operation always overlaps with a write operation. Two write operations always overlap. Each data item has a version number. Read operations return the most recent version number. Read operations cannot be executed locally. Write operations are executed on a write quorum. The most update version in the quorum is incremented and a new version is created in all the replicas in the quorum with that version number. A high number of replicas is needed to tolerate failures. One failure, three replicas. Two failures, five replicas... Nuevas tendencias en 20 sistemas distribuidos