18
The Concurrent Candy Question Bowl The 2 nd Database Tour

The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Embed Size (px)

Citation preview

Page 1: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

The Concurrent Candy Question Bowl

The 2nd Database Tour

Page 2: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Rules• Reverse Jeopardy: The answers are the answers • You have to answer as a group • Correct answers give candy points, wrong answers subtract candy

points. And yes, you might own me candy at the end ;) • Every question has a certain number of seconds (indicated at the

lower bar). After X seconds a bell indicates that the time is over • Groups willing to answer the question have to raise their hand • Among groups with hands raised the moderator picks a group. • At the discretion of the moderator, the answer is deemed correct

or wrong. If correct, the group can choose the next question. If wrong, candy is subtracted and another group can answer • Some questions are “all hands”, indicated by the all hands symbol.

All hands solutions have to be done on the white/black board and all groups with correct answers get candy points. • If every member of your group at least answered one question,

your group gets a Jelly Bean bonus

Reset

Page 3: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Distributed DBMS Recovery Concurrency

Control

Analytic Frameworks/

Streaming

2 Candy 2 Candy 2 Candy

3 Candy 3 Candy

4 Candy 4 Candy 4 Candy

5 Candy 5 Candy 5 Candy 5 Candy

Page 4: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Distributed Database Systems

Page 5: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

1.1

1 CandyBack

Under what type of workload would H-Store’s transaction processing technique not work?

Page 6: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

1.3 3 Candy Back

If a system ensures Atomicity, Durability, and Isolation, is it by definition not also Consistent? Explain by means of an example why/why not?

Page 7: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

1.4

4 Candy Back

So far you used a Primary/Backup replication scheme for your distributed transactional database with 2-phase locking. However, it is slow as the replication adds additional latency.

Somebody in your team had the genius idea two use 2-phase commit to directly update the primary and replicas, making it essentially an Active-Active replication scheme. Moreover, s/he argues that you can simply use the majority of responses, which will increase availability.

Name at least one problem in his argumentation.

C Coordinator

Partition 1

Partition 1

Partition 2

Partition 2

Partition 1

Partition 2

C Coordinator

Partition 1 Primary

Partition 2 Primary

Partition 1 Replica

Partition 1 Replica

Partition 2 Replica

Partition 2 Replica

Page 8: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Recovery

Page 9: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

2.1

Consider the idea of write-ahead logging.

Suppose an application did not follow this policy, and wrote data to the database before writing to the log. What could go wrong?

1 CandyBack

Page 10: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

2.2

2 CandyBack

Your system uses ARIES. How does the Dirty Page Table Look like after the crash assuming you the start of the transaction is LSN=1

1

2

WB WA

WD WA

CRASH

Flush

Page 11: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

1

2

WB WA

WD WA

CRASH

LSN Type TID PrevLSN Data

1 SOT 1

2 UP 1 1 B

3 UP 1 2 A

4 SOT 2

5 UP 2 4 D

6 EOT 1 3

7 UP 2 5 A

Flush

Page pageLSN

B 2

Page pageLSN

A 3

D 5

Back

DirtyPgTable

Page 12: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

2.5

Which configuration has better transaction processing performance? Which configuration has a faster recovery time? Why?

System 1: No-Force/Steal System 2: Force/No-Steal

5 CandyBack

Page 13: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Concurrency

Page 14: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

3.1

1 CandyBack

Under strict two-phase locking will t1 (t2) commit or abort assuming there are no other concurrent transactions?

Time Transaction Operation

12 T1 Start

13 T1 Read A

16 T2 Start

17 T2 Read C

18 T2 Write C

19 T2 Commit/Abort????

20 T1 Read C

21 T1 Write C

22 T1 Commit/Abort????

Page 15: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

3.2

2 CandyBack

Under snapshot isolation will t1 (t2) commit or abort assuming there are no other concurrent transactions?

Time Transaction Operation

12 T1 Start

13 T1 Read A

16 T2 Start

17 T2 Read C

18 T2 Write C

19 T2 Commit/Abort????

20 T1 Read C

21 T1 Write C

22 T1 Commit/Abort????

Page 16: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

3.3

3 CandyBack

Under OCC will t1 (t2) commit or abort assuming there are no other concurrent transactions?

Time Transaction Operation

12 T1 Start

13 T1 Read A

16 T2 Start

17 T2 Read C

18 T2 Write C

19 T2 Commit/Abort????

20 T1 Read C

21 T1 Write C

22 T1 Commit/Abort????

Page 17: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

Analytic Frameworks / Streaming

Page 18: The Concurrent Candy Question Bowl - db.csail.mit.edudb.csail.mit.edu/6.830/lectures/Jeopardy_Concurrency_Control_6814... · 1.4 4 Candy Back So far you used a Primary/Backup replication

4.1

1 CandyBack

Time in s

Event Temperature

0 e1 68

1 e2 69

2 e3 70

5 e4 69

7 e5 70

10 E6 71

What events would be included in a 1)Count-based sliding window of size 2 2)Time-based sliding window of 4s 3)Time-based Tumbling window of 4s 4)Count-based Landmark window