Quiz 2 Review 6.814 / 6.830 F2014.

Slides:



Advertisements
Similar presentations
What is Concurrent Process (CP)? Multiple users access databases and use computer systems Multiple users access databases and use computer systems simultaneously.
Advertisements

More About Transaction Management Chapter 10. Contents Transactions that Read Uncommitted Data View Serializability Resolving Deadlocks Distributed Databases.
Crash Recovery John Ortiz. Lecture 22Crash Recovery2 Review: The ACID properties  Atomicity: All actions in the transaction happen, or none happens 
1 CSIS 7102 Spring 2004 Lecture 9: Recovery (approaches) Dr. King-Ip Lin.
1 Integrity Ioan Despi Transactions: transaction concept, transaction state implementation of atomicity and durability concurrent executions serializability,
IDA / ADIT Lecture 10: Database recovery Jose M. Peña
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Topic 6.3: Transactions and Concurrency Control Hari Uday.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
COS 461 Fall 1997 Transaction Processing u normal systems lose their state when they crash u many applications need better behavior u today’s topic: how.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Jan. 2014Dr. Yangjun Chen ACS Database recovery techniques (Ch. 21, 3 rd ed. – Ch. 19, 4 th and 5 th ed. – Ch. 23, 6 th ed.)
Chapter 19 Database Recovery Techniques Copyright © 2004 Pearson Education, Inc.
ICS 421 Spring 2010 Distributed Transactions Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/16/20101Lipyeow.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Recovery 10/18/05. Implementing atomicity Note, when a transaction commits, the portion of the system implementing durability ensures the transaction’s.
CS 582 / CMPE 481 Distributed Systems
Recovery Fall 2006McFadyen Concepts Failures are either: catastrophic to recover one restores the database using a past copy, followed by redoing.
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 23 Database Recovery Techniques.
Chapter 19 Database Recovery Techniques. Slide Chapter 19 Outline Databases Recovery 1. Purpose of Database Recovery 2. Types of Failure 3. Transaction.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
Google Bigtable A Distributed Storage System for Structured Data Hadi Salimi, Distributed Systems Laboratory, School of Computer Engineering, Iran University.
Database Management Systems I Alex Coman, Winter 2006
1 ICS 214B: Transaction Processing and Distributed Data Management Distributed Database Systems.
Distributed Commit. Example Consider a chain of stores and suppose a manager – wants to query all the stores, – find the inventory of toothbrushes at.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
Distributed Databases
Distributed Deadlocks and Transaction Recovery.
Quiz 2 Review.
Distributed Transactions March 15, Transactions What is a Distributed Transaction?  A transaction that involves more than one server  Network.
Data Concurrency Control And Data Recovery
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.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
C-Store: Concurrency Control and Recovery Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY Jun. 5, 2009.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Chapter 16 Recovery Yonsei University 1 st Semester, 2015 Sanghyun Park.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
Databases Illuminated
 Distributed file systems having transaction facility need to support distributed transaction service.  A distributed transaction service is an extension.
XA Transactions.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
1 Chapter 6 Database Recovery Techniques Adapted from the slides of “Fundamentals of Database Systems” (Elmasri et al., 2003)
Recovery technique. Recovery concept Recovery from transactions failure mean data restored to the most recent consistent state just before the time of.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Topics in Distributed Databases Database System Implementation CSE 507 Some slides adapted from Navathe et. Al and Silberchatz et. Al.
Bigtable A Distributed Storage System for Structured Data.
CS 540 Database Management Systems NoSQL & NewSQL Some slides due to Magda Balazinska 1.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.

Database recovery techniques
Database Recovery Techniques
Database Recovery Techniques
DURABILITY OF TRANSACTIONS AND CRASH RECOVERY
Transaction Management
Two phase commit.
Database Recovery Techniques
Outline Announcements Fault Tolerance.
Chapter 10 Transaction Management and Concurrency Control
Quiz 2 Review Slides.
Database Recovery 1 Purpose of Database Recovery
Transactions in Distributed Systems
Presentation transcript:

Quiz 2 Review 6.814 / 6.830 F2014

Key Concepts: Transactions ACID Serializability Serial equivalence (testing via conflict graph) Conflict vs view serializability Two-phase locking (strict/rigorous) Deadlocks & Deadlock detection (waits-for graph) Optimistic concurrency control Three conditions under which commits allowed Serial vs Parallel Validation Granularity of locking (intention locks) Phantoms

Recovery Goal: losers undone, winners redone Write ahead logging Log all writes, plus xaction start / end STEAL/FORCE ARIES: 3 passes ANALYSIS: determine where to start replay from REDO: “repeat history” UNDO: remove effects of losers “physiological logging” dirty page table (DPT) / transaction table (XT) cheap checkpoints: just flush DPT/XT dirty pages flushed (not logged) CLRs for recovering during crashes in recovery

Parallel / Distributed Databases Shared memory vs shared nothing Goal: linear speed up (not always possible) Horizontal partitioning Hash/range/round robin Parallel query processing Filter / projection applied locally Joins Proper partitioning: done locally Improper partitioning: requires repartitioning, or replication of one table on all nodes Group BYs “Pre-aggregation” – compute partial aggregates locally (SUMs, COUNTs, etc), and then merge

Distributed Transactions Goal: preserve atomicity across multiple machines Two-phase commit protocol Additional logging; some records forced, some not Workers “PREPARE” xactions; once prepared a worker must wait for coordinator to determine outcome of a xaction Coordinator commits transactions that it and all workers vote “YES” for Commit point is when coordinator logs xaction outcome Presumed abort / presumed commit variants

Replication Key strategy for preserving high-availability Keep multiple copies of each data item Single master vs multi-master Asynchronous vs synchronous

Readings: Dynamo Dynamo & Eventual Consistency CAP theorem & ACID vs BASE Uses consistent hashing & replication Multiple versions of each data item Vector clocks to track changes Configurable numbers of replicas/readers/writers (N/R/W) to tune consistency guarantees Eventual consistency: all replicas eventually agree on state of an tiem

BigTable Wide area distributed storage system Single-record atomicity 3D table: keys, column groups, columns Append-only storage Writes buffered in memory, persistent via WAL Minor compactions: periodically flush memory to tablets, stored on GFS Major compactions: merge tablets B+Tree like structure in metadata tablets Chubby lock service to find root tablet; master Master allocates key space to workers, updates metadata

Spark A better MapReduce “Data Flow” language allowing users to compose pipelines of filters, maps, joins, aggregates, etc Resilient Distributed Datasets (RDDs) Cached in memory for performance between iterations / operations Made recoverably by persistent logging of lineage Also periodic checkpoints

BigTable Sample Question Consider an example table storing bank accounts in Google’s BigTable system: The bank programmer implements the deposit function as follows: function deposit(account, amount): currentBalance = bigtable.get(account) currentBalance += amount bigtable.put(account, currentBalance) The user executes deposit(“sam”, $500). The program crashes somewhere during execution. What are the possible states of the “sam” row in the table?

Answer The row could either have “sam” = $9000 or “sam” = $9500, depending on if the program crashed before or after it wrote the result.

BigTable #2 The user executes deposit(“sam”, $500). The program completes. Immediately after the program completes, the power goes out in the BigTable data center, and all the machines reboot. When BigTable recovers, what are the possible states of the “sam” row in the table?

Answer The row can only have the value $9500, since BigTable does not inform a client that a write has been completed until it logs the update to disk on multiple physical machines. Thus, when BigTable recovers it will find the write in the log.

BigTable #3 Now consider the following pair of functions:

Big Table #3 (continued) Given the table above, a program executes transfer(“evan”, “adam”, 200). While that function is executing, another program executes totalAssets(). What return values from totalAssets() are possible? For the purposes of this question, assume there is only one version of each value, and that the values in BigTable are stored and processed in the order given above (i.e., “adam”, “evan”, “sam”). Provide a short explanation for your answer.

Answer $9,900 is possible if totalAssets either reads all the balances before or after the transfer modifies any of them. $9,700 is possible if totalAssets reads “adam” before the $200 is added, but reads “evan” after $200 is deducted. It might seem like $10,100 is possible, by reading “adam” after adding $200, and reading “evan” before the subtract. However, this is not possible. The transfer function performs the subtract, then the add. The scan in totalAssets reads the rows in order. Thus, if it sees the modified version of “adam” it will see the modified version of “evan.” However, it would not be a good idea to write an application that depends on this behavour, as it depends on the order of the keys and the operations in the code, which could easily change.

Logging You have a database with logging and recovery as described in the ARIES paper. Your database uses strict two-phase locking. Your database has just two items in it, X with starting value 10, and Y with starting value 100. You start three transactions at the same time, with transaction IDs (TIDs) TA, TB, and TC: TA TB TC BEGIN TRANSACTION X=X+1 Y=Y*3 END Y=Y*2 X=X+5 X = X * 10

Logging (con’t) These three transactions are the only activity in the system. The system crashes due to a power failure soon after you start the transactions. You are not sure whether or not any of them completed. You look at the disk while the system is down and see that, in the heap file, Y has the value 200. You restart the system and let the database recovery procedure complete. You query the database for the value of X, and it returns the value 110.

Logging (con’t) Write down a log, as it would have appeared on the disk while the system was down, that is compatible with the above story. You need only include Update (U), Commit (C), and Abort (A) records. Specify the TID (TA, TB, or TC) and record type for each record, and for Updates, the item being written (X or Y) and the new value being written.

Solution The buffer manager writes Y to disk after TB sets Y=200, and before TB aborts, which it is allowed to do under a STEAL policy. The buffer manager does not write Y to disk after TA commits, which it is allowed to do under a NO-FORCE policy. One reason TB might abort is that it deadlocks with TA.

Distributed Query Planning Problem You have a database with two tables with the following schema: T1 : (A int PRIMARY KEY, B int, C varchar) T2 : (D int REFERENCES T1.A, E varchar) You are running the following query: SELECT T1.A,COUNT(*) FROM T1,T2 AND T1.A = T2.D AND T1.B > n GROUP BY T1.A The database has the following configuration:

Question Suppose you run the query on a single node. Assuming there are no indices, and the tables are not sorted, indicate what join algorithm (of the algorithms we have studied in class) would be most efficient, and estimate the time to process the query, ignoring disk seeks and CPU costs.

Answer

Question Now suppose you switch to a cluster of 5 machines. If the above query is the only query running in the system, describe a partitioning for the tables and join algorithm that will provide the best performance, and estimate the total processing time (again, ignoring disk seeks and CPU cost). You may assume about the same number of T2.D values join with each T1.A value. You can assume the coordinator can receive an aggregate 50 MB/sec over the network from the five workers transmitting simultaneously at 10 MB/sec.

Answer

Two-phase Commit Consider the following diagram of 2PC:

Questions Suppose that the force-write at (1) were an unforced log write. Describe, in one or two sentences, what could go wrong. Suppose that the force-write at (2) did not happen. Describe, in one or two sentences, what could go wrong. Suppose that the force-write at (3) were an unforced log write. Describe, in one or two sentences, what could go wrong. Suppose that the unforced write at (4) did not happen. Describe, in one or two sentences, what could go wrong.

Answers If the worker crashes after sending its vote without writing the log record to disk (which contains the information that it is prepared and voted yes), it will abort the transaction on recovery (since it will assume it crashed before preparing.) This is a problem because the coordinator will assume that it can commit because the worker sent a yes vote. The coordinator may send out a commit message to a subset of the workers and then crash. When it recovers, it will abort the transaction (because it has no commit record for it). When workers poll for the state of the transaction, the coordinator will reply ’abort’, which is inconsistent with the fact that the coordinator has already told some workers to commit. The worker may send the acknowledgment and then crash; since the commit record is not forced, on recovery it will ask the coordinator for the status of the transaction. In the meantime, the coordinator may have heard an from all sites and written the end record and forgotten about the transaction; hence, the coordinator will tell the worker to ’abort’, which is incorrect because all other sites committed the transaction. If the coordinator crashes and there is no end record in the log, the coordinator will resend commit messages to all of this workers. This is not a problem, as they will have already committed and will hence do nothing and simply send an ack; hence, this only leads to wasted communication when the coordinator crashes.