Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Serializability with Snapshot Isolation underthe Hood
Mihaela Bornea 1, S. Elnikety 2, O. Hodson 2, A Fekete 3
1IBM Research 2Microsoft Research 3University of Sydney
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Motivation
Concurrency Control
Replication Model
Readset Certification
Evaluation
Conclusions
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Transaction Processing in Replicated Databases
I Database Replication:I Higher availability & better performanceI Maintaining consistency is challenging
I State of the Art:I GSI Replicated Databases.I Each replica uses Snapshot Isolation (SI).
I Goal:I Global One Copy Serializability.I Overall Isolation level stronger than the one of individual
components.I The replicated system keeps its performance.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Transaction Isolation
I Isolation is a correctness criterion.I Concurency in the system.I Multiple levels of isolation:
I Snapshot Isolation.I Serializability.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Snapshot Isolation
I Multi-version concurency control technique.I Important
I Used by Oracle, SQL Server, Postgres.I Sometimes the strongest isolation level available.
I Attractive performanceI Read-only transactions never block or abort.I Read-only transactions do not block update transactions.I Updates might abort. Certification needed.
I checks for ww conflicts.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Anomaly under SI
Time
R(X,Y)
R(X,Y) W(X) C
CT2
T1
Y=50
X=50
X=50
Y=50
X=−40
Y=−40
W(Y)
I X,Y balance of two bank accounts.I T1 and T2 withdraw 90E from X and YI Logic: X + Y > 0
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Serializability
I The strongest DB isolation level.I Illusion that transactions execute serially.I Programmers want it:
I As if there is no concurrency.I Commonly implemented with 2PL.
I expensive to achieve.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Serializability under SI
I Centralized DatabaseI Modify database engine, SSI.I Use Fekete’s work [SIGMOD 2008, best paper]
I Replicated DatabasesI Open question.I No modification of the database engine.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
GSI Replicated Database
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
SQL Transaction ModelA. SELECT expr_list FROM Ri WHERE pred(Ri )B. INSERT INTO Ri VALUES (values)C. UPDATE Ri SET attr_values WHERE pred(Ri )D. DELETE FROM Ri WHERE pred(Ri )E. SELECT agg(attr) FROM Ri WHERE pred(Ri )GROUP BY group_attrHAVING pred(agg(attr))
F. SELECT attr_listFROM R1...Ri ...RnWHERE pred(R1) LOP ...LOP pred(Ri ) LOP ... LOP pred(Rn)
LOP pred(attri,j , attri,j )G. SELECT attr_list
FROM R1...Ri ...Rn,SQWHERE pred(R1) LOP ...LOP pred(Ri ) LOP ... LOP pred(Rn)
LOP pred(SQ)H. SELECT attr_list
FROM R1...Ri ...RnWHERE pred(R1) LOP ...LOP pred(Ri ) LOP ... LOP pred(Rn)
LOP pred(attri ,SQ)
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
1SR Needs Readsets
I Snapshot Isolation (SI) → Generalized Snapshot Isolation(GSI)
I Certify WritesetI Serializability → One Copy Serializability (1SR)
I Certify WritesetI Certify Readset
I Yes, we have a proof :) !
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Writesets
I The Writeset contains modified tuplesI Introduced by UPDATE, INSERT and DELETEI Includes both new and old tuple valuesI All Writesets are managed at the Certifier.I Writeset certification is required by both GSI and 1SR
I checks if concurrent transactions modify the same item.I It is well knows how to manage the Writesets
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Readsets
I The Readset contains read tuples.I Introduced by SELECT, UPDATE, INSERT and DELETE.I Readsets certification is required by 1SR.
I checks if a transaction reads data modified by concurrenttransactions.
I Readset identification is challenging:I never done in replicated setting.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
So far ...
I We introduced SI.I Sometimes SI is not enough !I Serializability needed:
I Keep the nice properties of SI.I Open Problem for replicated databases:
I Readset management is difficult!
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Main Contribution - Readset Management
I Framework to manage the ReadsetsI Observation: each SQL statement has a predicate.
I The Readset is a list of predicates.I Readset certification requires predicate evaluation.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Certifier Design
I The Certifier manages:I persistent log.I main memory database, CertDB.
I The log is used for durability.I CertDB is used to certify update transactions.I CertDB maintains the Writeset of recently committed
transactions.I CertDB schema:
I the replicated schema.I commit version attribute.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Readset Certification
I Intuition:I Ensures that if the transaction executes on the latest
version it would read the same values.I Implementation:
I Replica identifies the Readset:I Extracts the predicate of each SQL statement.
I Replica expresses the readset as certification queries.I The certification queries are evaluated on CertDBI Empty conflict set indicates serializable execution
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Concurrent Transactions
I Snapshot versions at originating replicas.I Commit version of a transaction.I CertDB contains the writesets and committed version.I Consider a transaction T:
I version > snapshot(T )
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Readset for SELECT Statements
Transaction Queries
A. SELECT expr_list FROM Ri WHERE pred(Ri)
Certification Queries
A. SELECT * FROM Ri WHERE pred(Ri) ANDversion > snapshot(T )
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Readset for UPDATE Statements
Transaction Queries
B. INSERT INTO Ri VALUES (values)C. UPDATE Ri SET attr_values WHERE pred(Ri)D. DELETE FROM Ri WHERE pred(Ri)
Certification Queries
B. SELECT * FROM Ri WHERE pk = @pk ANDversion > snapshot(T )
C. SELECT * FROM Ri WHERE pred(Ri) ANDversion > snapshot(T )
D. SELECT * FROM Ri WHERE pred(Ri) ANDversion > snapshot(T )
Certifying the Readset also detects ww conflicts.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Experimental Study
I Impact of providing 1SR vs. GSI:I Lower throughput and higher response timeI Higher abort rate
I Replicated system with 8 replicasI TPC-W
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Workload
I TPC-W benchmark:I Web application (online book store).I Database schema consists of 10 tables.I Database size: 800 MB.I 13 transaction templates.I Ordering Mix(50% updates).I Browsing Mix (5% updates).
I Metrics:I Transactions per minute (TPM).I Response time.I Abort rate.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Scaling of SGSI with Replication Degree
0
10000
20000
30000
40000
50000
60000
0 150 300 450 600 750 900 1050
Th
rou
gh
pu
t, T
PM
Number of Clients
1-replica SGSI
1-replica GSI
2-replica SGSI
2-replica GSI
4-replica SGSI
4-replica GSI
8-replica SGSI
8-replica GSI
Throughput of TPC-WShopping Mix (20% updates)
0
500
1000
1500
2000
2500
3000
3500
4000
4500
0 150 300 450 600 750 900 1050
Re
sp
on
se
Tim
e,
ms
Number of Clients
1-replica SGSI
1-replica GSI
2-replica SGSI
2-replica GSI
4-replica SGSI
4-replica GSI
8-replica SGSI
8-replica GSI
Resp. Time of TPC-WShopping Mix (20% updates)
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Comparing SGSI to GSI
0
50
100
150
200
250
300
350
400
10000 20000 30000 40000 50000
Re
sp
on
se
Tim
e,
ms
Throughput, TPM
8-replica GSI
8-replica SGSI
Scalability of TPC-W ShoppingMix (20% updates)
0
20
40
60
80
100
10000 20000 30000 40000 50000
Ce
rtif
ier
CP
U U
tili
za
tio
n,
%
Throughput, TPM
8-replica GSI
8-replica SGSI
Certifier CPU Utilization TPC-WShopping Mix (20% updates)
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Sensitivity to Update Transaction Ratio
0
10000
20000
30000
40000
50000
60000
70000
80000
90000
0 250 500 750 1000 1250 1500
Th
rou
gh
pu
t, T
PM
Number of Clients
8-replica TPC-W Browsing Mix
8-replica TPC-W Shopping Mix
8-replica TPC-W Ordering Mix
SGSI Throughput of TPC-WMixes.
0
100
200
300
400
500
600
700
800
900
0 250 500 750 1000 1250 1500
Re
sp
on
se
Tim
e,
ms
Number of Clients
8-replica TPC-W Browsing Mix
8-replica TPC-W Shopping Mix
8-replica TPC-W Ordering Mix
SGSI Response Time ofTPC-W Mixes.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Abort Analysis via SmallBank
0
2
4
6
8
10
12
14
10 25 50 100 150 200 250 300
Co
nfl
icts
, %
Multi-Programming Level
ww conflictsrw conflicts
pivots
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Conclusions
I We introduced SGSI:I 1SR in replicated databases.
I Built a replicated system prototype.I Evaluated SGSI performance:
I SGSI is practical.I Moderated cost for small degree of replication.I Performance and scaling is comparable with GSI.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Readset for Joins
Transaction Queries
F. SELECT attr_listFROM R1...Ri ...Rn
WHERE pred(R1) LOP ...LOP pred(Ri) LOP ... LOP pred(Rn)LOP pred(attri,j , attri,j)
Certification Queries
for each relation Ri
F. SELECT * FROM Ri WHERE version > snapshot(T )
I An upper-set of the Readset is certified.I False aborts.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Data Managed at Certifier
I Accuracy depends the data maintained at the Certifier.I False aborts:
I not enough information to evaluate the ReadsetI Solution:
I manage a copy of relations at the Certifier.I physical design tuning problem.
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Extended CertDB
I Each data item has several instances.I New instace: UPDATE,INSERT.I Expired: UPDATE, DELETE.I Each copy relation is augmented with VStart and VEnd .I VStart and VEnd determine:
I update predicate: upd(Ri).I visibility predicate: vis(Ri).
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood
Outline Motivation Concurrency Control Replication Model Readset Certification Evaluation Conclusions
Extended Certification
Transaction Queries
F. SELECT attr_listFROM R1...Ri ...Rn
WHERE pred(R1) LOP ...LOP pred(Ri) LOP ... LOP pred(Rn)LOP pred(attri,j , attri,j)
Certification Queries
SELECT * FROM R1C ...RiC ...RnC
WHERE (query_pred)AND (upd(R1C ) ...OR upd(RiC ) ... OR upd(RnC ))AND (vis(R1C ) ...AND vis(RiC ) ... AND vis(RnC ))
M. Bornea, S. Elnikety, O. Hodson, A. Fekete IBM Research, Microsoft Research, Microsoft Research, University of Sydney
Serializability with Snapshot Isolation under the Hood