80
Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - [email protected] 2014-2015

Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - [email protected] 2014-2015

Embed Size (px)

Citation preview

Page 1: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Parallel DatabasesCOMP3211 Advanced Databases

Dr Nicholas Gibbins - [email protected]

Page 2: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

2

Overview

• The I/O bottleneck

• Parallel architectures

• Parallel query processing

– Inter-operator parallelism

– Intra-operator parallelism

–Bushy parallelism

•Concurrency control

•Reliability

Page 3: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

The I/O Bottleneck

Page 4: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

4

The Memory Hierarchy, Revisited

Type Capacity Latency

Registers 101 bytes 1 cycle

L1 104 bytes <5 cycles

L2 105 bytes 5-10 cycles

RAM 109-1010 bytes 20-30 cycles (10-8 s)

Hard Disk 1011-1012 bytes 106 cycles (10-3 s)

Page 5: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

5

The I/O Bottleneck

Access time to secondary storage (hard disks) dominates performance of DBMSes

Two approaches to addressing this:

–Main memory databases (expensive!)

– Parallel databases (cheaper!)

Increase I/O bandwidth by spreading data across a number of disks

Page 6: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

6

Definitions

Parallelism

–An arrangement or state that permits several operations or tasks to be performed simultaneously rather than consecutively

Parallel Databases

– have the ability to split

– processing of data

– access to data

– across multiple processors, multiple disks

Page 7: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

7

Why Parallel Databases

•Hardware trends

•Reduced elapsed time for queries

• Increased transaction throughput

• Increased scalability

• Better price/performance

• Improved application availability

• Access to more data

• In short, for better performance

Page 8: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Parallel Architectures

Page 9: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

9

• Tightly coupled

• Symmetric Multiprocessor (SMP)

P = processor

M = memory

Shared Memory Architecture

P

Global Memory

PP

Page 10: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

10

• Less complex database software

• Limited scalability

• Single buffer

• Single database storage

Software – Shared Memory

P

Global Memory

PP

Page 11: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

11

• Loosely coupled

• Distributed Memory

Shared Disc Architecture

PPP

MMM

S

Page 12: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

12

• Avoids memory bottleneck

• Same page may be in more than one buffer at once – can lead to incoherence

• Needs global locking mechanism

• Single logical database storage

• Each processor has its own database buffer

Software – Shared Disc

PPP

MMM

S

Page 13: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

13

• Massively Parallel

• Loosely Coupled

• High Speed Interconnect (between processors)

Shared Nothing Architecture

PPP

MMM

Page 14: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

14

• Each processor owns part of the data

• Each processor has its own database buffer

• One page is only in one local buffer – no buffer incoherence

• Needs distributed deadlock detection

• Needs multiphase commit protocol

• Needs to break SQL requests into multiple sub-requests

Software - Shared Nothing

PPP

MMM

Page 15: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

15

Hardware vs. Software Architecture

• It is possible to use one software strategy on a different hardware arrangement

• Also possible to simulate one hardware configuration on another

–Virtual Shared Disk (VSD) makes an IBM SP shared nothing system look like a shared disc setup (for Oracle)

• From this point on, we deal only with shared nothing

Page 16: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

16

Shared Nothing Challenges

• Partitioning the data

•Keeping the partitioned data balanced

• Splitting up queries to get the work done

• Avoiding distributed deadlock

•Concurrency control

•Dealing with node failure

Page 17: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Parallel Query

Processing

Page 18: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

18

Dividing up the Work

Application

Coordinator Process

WorkerProcess

WorkerProcess

WorkerProcess

Page 19: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

19

Database Software on each node

App1

DBMS

W1 W2

C1

DBMS

W1 W2

App2

DBMS

W1 W2

C2

Page 20: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

20

Inter-Query Parallelism

Improves throughput

Different queries/transactions execute on different processors

– (largely equivalent to material in lectures on concurrency)

Page 21: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

21

Intra-Query Parallelism

Improves response times (lower latency)

Intra-operator (horizontal) parallelism

–Operators decomposed into independent operator instances, which perform the same operation on different subsets of data

Inter-operator (vertical) parallelism

–Operations are overlapped

– Pipeline data from one stage to the next without materialisation

Bushy (independent) parallelism

– Subtrees in query plan executed concurrently

Page 22: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Intra-Operator Parallelism

Page 23: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

23

Intra-Operator Parallelism

SQL Query

SubsetQueries

SubsetQueries

SubsetQueries

SubsetQueries

Processor

Processor

Processor

Processor

Page 24: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

24

Partitioning

Decomposition of operators relies on data being partitioned across the servers that comprise the parallel database

–Access data in parallel to mitigate the I/O bottleneck

Partitions should aim to spread I/O load evenly across servers

Choice of partitions affords different parallel query processing approaches:

–Range partitioning

–Hash partitioning

– Schema partitioning

Page 25: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

25

Range Partitioning

A-H

I-P

Q-Z

Page 26: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

26

Hash Partitioning

Table

Page 27: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

27

Schema Partitioning

Table 1

Table 2

Page 28: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

28

Rebalancing Data

Data in proper balance

Data grows, performance drops

Add new nodes and disc

Redistribute data to new nodes

Page 29: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

29

Intra-Operator Parallelism

Example query:

– SELECT c1,c2 FROM t WHERE c1>5.5

Assumptions:

– 100,000 rows

– Predicates eliminate 90% of the rows

Considerations for query plans:

–Data shipping

–Query shipping

Page 30: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

30

Data Shipping

πc1,c2

σc1>5.5

t1 t2 t3 t4

Page 31: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

31

Data Shipping

Coordinatorand Worker

Network

Worker Worker Worker Worker

25,000 tuples

25,000 tuples

25,000 tuples

25,000 tuples

10,000 tuples (c1,c2)

Page 32: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

32

Query Shipping

πc1,c2

σc1>5.

5

t1 t2 t3 t4

πc1,c2

σc1>5.

5

πc1,c2

σc1>5.

5

πc1,c2

σc1>5.

5

Page 33: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

33

Query Shipping

Coordinator

Network

Worker Worker Worker Worker

2,500 tuples

2,500 tuples

2,500 tuples

2,500 tuples

10,000 tuples (c1,c2)

Page 34: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

34

Query Shipping Benefits

•Database operations are performed where the data are, as far as possible

•Network traffic is minimised

• For basic database operators, code developed for serial implementations can be reused

• In practice, mixture of query shipping and data shipping has to be employed

Page 35: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Inter-Operator Parallelism

Page 36: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

36

Inter-Operator Parallelism

Allows operators with a producer-consumer dependency to be executed concurrently

–Results produced by producer are pipelined directly to consumer

–Consumer can start before producer has produced all results

–No need to materialise intermediate relations on disk (although available buffer memory is a constraint)

–Best suited to single-pass operators

Page 37: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

37

Inter-Operator Parallelism

time

Scan Join Sort

ScanJoin

Sort

Page 38: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

38

Intra- + Inter-Operator Parallelism

time

Scan Join Sort

ScanJoin

Sort

ScanScan

JoinJoin

SortSort

Page 39: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

39

The Volcano Architecture

Basic operators as usual:

– scan, join, sort, aggregate (sum, count, average, etc)

The Exchange operator

– Inserted between the steps of a query to:

– Pipeline results

–Direct streams of data to the next step(s), redistributing as necessary

Provides mechanism to support both vertical and horizontal parallelism

Page 40: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

40

Exchange Operators

Example query:

– SELECT county, SUM(order_item)FROM customer, orderWHERE order.customer_id=customer_idGROUP BY countyORDER BY SUM(order_item)

Page 41: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

41

Exchange Operators

SORT

GROUP

HASHJOIN

SCAN

SCAN

Customer Order

Page 42: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

42

Exchange Operators

EXCHANGE

SCAN

SCAN

Customer

HASHJOIN

HASHJOIN

HASHJOIN

Page 43: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

43

Exchange Operators

EXCHANGE

SCAN

SCAN

Customer

HASHJOIN

HASHJOIN

HASHJOIN

EXCHANGE

SCAN

SCAN

SCAN

Order

Page 44: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

44

EXCHANGE

SCAN

SCAN

Customer

HASHJOIN

HASHJOIN

HASHJOIN

EXCHANGE

SCAN

SCAN

SCAN

Order

EXCHANGE

EXCHANGE

GROUPGROUP

SORT

Page 45: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Bushy Parallelism

Page 46: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

46

Execute subtrees concurrently

Bushy Parallelism

σ

π

R S T U

π

Page 47: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Parallel Query Processing

Page 48: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

48

Some Parallel Queries

• Enquiry

•Collocated Join

•Directed Join

• Broadcast Join

•Repartitioned Join

Combine aspects of intra-operator and bushy parallelism

Page 49: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

49

Orders Database

CUSTKEY

C_NAME … C_NATION …

ORDERKEY

DATE …CUSTKEY

SUPPKEY

S_NAME … S_NATION …

SUPPKEY

CUSTOMER

ORDER

SUPPLIER

Page 50: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

50

“How many customers live in the UK?”

Enquiry/Query

SCAN

COUNT

Slave Task

Coordinator SUM

Multiple partitionsof customer table

Return subcountsto coordinator

Return to application

Page 51: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

51

Collocated Join

“Which customers placed orders in July?”

UNION

ORDER

Tables both partitioned onCUSTKEY (the same key) andtherefore corresponding entriesare on the same node

Requires a JOIN of CUSTOMER and ORDER

SCAN SCAN

JOIN

CUSTOMER

Return to application

Page 52: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

52

Directed Join

“Which customers placed orders in July?”(tables have different keys)

UNION

CUSTOMER

SCAN

ORDER

SCAN

JOIN

Slave Task 1 Slave Task 2

Coordinator

Return to application

ORDER partitioned on ORDERKEY, CUSTOMER partitioned on CUSTKEYRetrieve rows from ORDER, then use ORDER.CUSTKEY to direct appropriate rows to nodes with CUSTOMER

Page 53: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

53

“Which customers and suppliers are in the same country?”

Broadcast Join

UNION

CUSTOMER

SCAN

SUPPLIER

SCAN

JOIN

Slave Task 1 Slave Task 2

Coordinator

Return to application

SUPPLIER partitioned on SUPPKEY, CUSTOMER on CUSTKEY.Join required on *_NATIONSend all SUPPLIER to each CUSTOMER node

BROADCAST

Page 54: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

54

“Which customers and suppliers are in the same country?”

Repartitioned Join

UNION

CUSTOMER

SCAN

SUPPLIER

Slave Task 1

Coordinator

SUPPLIER partitioned on SUPPKEY, CUSTOMER on CUSTKEY.Join required on *_NATION. Repartition both tables on *_NATION tolocalise and minimise the join effort

SCAN

Slave Task 2

JOIN

Slave Task 3

Return to application

Page 55: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

ConcurrencyControl

Page 56: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

56

Concurrency and Parallelism

• A single transaction may update data in several different places

•Multiple transactions may be using the same (distributed) tables simultaneously

•One or several nodes could fail

•Requires concurrency control and recovery across multiple nodes for:

– Locking and deadlock detection

– Two-phase commit to ensure ‘all or nothing’

Page 57: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

57

Locking and Deadlocks

•With Shared Nothing architecture, each node is responsible for locking its own data

•No global locking mechanism

•However:

– T1 locks item A on Node 1 and wants item B on Node 2

– T2 locks item B on Node 2 and wants item A on Node 1

–Distributed Deadlock

Page 58: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

58

Resolving Deadlocks

•One approach – Timeouts

• Timeout T2, after wait exceeds a certain interval

– Interval may need random element to avoid ‘chatter’i.e. both transactions give up at the same time and then try again

•Rollback T2 to let T1 to proceed

•Restart T2, which can now complete

Page 59: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

59

Resolving Deadlocks

•More sophisticated approach (DB2)

• Each node maintains a local ‘wait-for’ graph

•Distributed deadlock detector (DDD) runs at the catalogue node for each database

• Periodically, all nodes send their graphs to the DDD

•DDD records all locks found in wait state

• Transaction becomes a candidate for termination if found in same lock wait state on two successive iterations

Page 60: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Reliability

Page 61: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

61

Reliability

We wish to preserve the ACID properties for parallelised transactions

– Isolation is taken care of by 2PL protocol

– Isolation implies Consistency

–Durability can be taken care of node-by-node, with proper logging and recovery routines

–Atomicity is the hard part. We need to commit all parts of a transaction, or abort all parts

Two-phase commit protocol (2PC) is used to ensure that Atomicity is preserved

Page 62: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

62

Two-Phase Commit (2PC)

Distinguish between:

– The global transaction

– The local transactions into which the global transaction is decomposed

Global transaction is managed by a single site, known as the coordinator

Local transactions may be executed on separate sites, known as the participants

Page 63: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

63

Phase 1: Voting

•Coordinator sends “prepare T” message to all participants

• Participants respond with either “vote-commit T” or “vote-abort T”

•Coordinator waits for participants to respond within a timeout period

Page 64: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

64

Phase 2: Decision

• If all participants return “vote-commit T” (to commit), send “commit T” to all participants. Wait for acknowledgements within timeout period.

• If any participant returns “vote-abort T”, send “abort T” to all participants. Wait for acknowledgements within timeout period.

•When all acknowledgements received, transaction is completed.

• If a site does not acknowledge, resend global decision until it is acknowledged.

Page 65: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

65

Normal Operation

C Pprepare T

vote-commit T

commit T

ack

vote-commit Treceived from allparticipants

Page 66: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

66

Logging

C Pprepare T

vote-commit T

commit T

ack

<commit T>

<begin-commit T>

<end T>

<ready T>

<commit T>

vote-commit Treceived from allparticipants

Page 67: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

67

Aborted Transaction

C Pprepare T

vote-commit T

abort T

ack

<abort T>

<begin-commit T>

<end T>

<ready T>

<abort T>

vote-abort T received from at least one participant

Page 68: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

68

Aborted Transaction

C Pprepare T

vote-abort T

abort T

ack

<abort T>

<begin-commit T>

<end T>

<abort T>

P

vote-abort T received from at least one participant

Page 69: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

69

State Transitions

C Pprepare T

vote-commit T

commit T

ack

vote-commit Treceived from allparticipants

INITIAL

WAIT

COMMIT

INITIAL

READY

COMMIT

Page 70: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

70

State Transitions

C Pprepare T

vote-commit T

abort T

ack

vote-abort T received from at least one participant

INITIAL

WAIT

ABORT

INITIAL

READY

ABORT

Page 71: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

71

State Transitions

C Pprepare T

vote-abort T

abort T

ack

P

INITIAL

WAIT

ABORT

INITIAL

ABORT

Page 72: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

72

Coordinator State Diagram

sent: prepare T

recv: vote-abort Tsent: abort T

INITIAL

WAIT

ABORT COMMIT

recv: vote-commit Tsent: commit T

Page 73: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

73

Participant State Diagram

recv: prepare Tsent: vote-commit T

recv: commit Tsend: ack

INITIAL

READY

COMMIT ABORT

recv: prepare Tsent: vote-abort T

recv: abort Tsend: ack

Page 74: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

74

Dealing with failures

If the coordinator or a participant fails during the commit, two things happen:

– The other sites will time out while waiting for the next message from the failed site and invoke a termination protocol

–When the failed site restarts, it tries to work out the state of the commit by invoking a recovery protocol

The behaviour of the sites under these protocols depends on the state they were in when the site failed

Page 75: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

75

Termination Protocol: Coordinator

Timeout in WAIT

–Coordinator is waiting for participants to vote on whether they're going to commit or abort

–A missing vote means that the coordinator cannot commit the global transaction

–Coordinator may abort the global transaction

Timeout in COMMIT/ABORT

–Coordinator is waiting for participants to acknowledge successful commit or abort

–Coordinator resends global decision to participants who have not acknowledged

Page 76: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

76

Termination Protocol: Participant

Timeout in INITIAL

– Participant is waiting for a “prepare T”

–May unilaterally abort the transaction after a timeout

– If “prepare T” arrives after unilateral abort, either:

– resend the “vote-abort T” message or

– ignore (coordinator then times out in WAIT)

Timeout in READY

– Participant is waiting for the instruction to commit or abort – blocked without further information

– Participant can contact other participants to find one that knows the decision – cooperative termination protocol

Page 77: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

77

Recovery Protocol: Coordinator

Failure in INITIAL

–Commit not yet begun, restart commit procedure

Failure in WAIT

–Coordinator has sent “prepare T”, but has not yet received all vote-commit/vote-abort messages from participants

–Recovery restarts commit procedure by resending “prepare T”

Failure in COMMIT/ABORT

– If coordinator has received all “ack” messages, complete successfully

–Otherwise, terminate

Page 78: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

78

Recovery Protocol: Participant

Failure in INITIAL

– Participant has not yet voted

–Coordinator cannot have reached a decision

– Participant should unilaterally abort by sending “vote-abort T”

Failure in READY

– Participant has voted, but doesn't know what the global decision was

–Cooperative termination protocol

Failure in COMMIT/ABORT

–Resend “ack” message

Page 79: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

Parallel Utilities

Page 80: Parallel Databases COMP3211 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk 2014-2015

80

Parallel Utilities

Ancillary operations can also exploit the parallel hardware

– Parallel Data Loading/Import/Export

– Parallel Index Creation

– Parallel Rebalancing

– Parallel Backup

– Parallel Recovery