Download presentation
Presentation is loading. Please wait.
Published byJeffery Craig Modified over 9 years ago
1
9/27/05© 2005 Microsoft Corporation1 Relaxed-Currency Serializability Philip A. Bernstein, Microsoft Research Alan Fekete, Univ. of Sydney Raghu Ramakrishnan, Univ. of Wisconsin
2
2 The Problem Many update transactions run at read-committed isolation level Implies update transactions can live with stale readsets Should we make this part of the application programming model?
3
3 The Opportunity Allow update transactions (txns) to attach “freshness constraints” on Read operations They can read stale values from a DB cache that satisfy their freshness constraints Extends such solutions to update txns: H. Guo, P. Larson, R. Ramakrishnan, J. Goldstein: Relaxed Currency and Consistency: How to Say "Good Enough" in SQL. SIGMOD 2004
4
4 Examples Suppose a txn reads data ≤ N seconds old If Article.Price < max, then place an order Vendor honors slightly out-of-date prices If (Instock < min) and not(Backordered) then call RefillInventory If the above test runs infrequently (e.g. hourly) then Backordered will be updated by Refill- Inventory before RefillInventory is called again.
5
5 Examples (2) For all equities { StartTxn; read [price, today’s volume]; log it; Commit } Different pairs may come from different snapshots
6
6 Notation Assume txn T i has a timestamp ts(T i ) Last-modified(x) Timestamp of the last update to x Valid-till(x) Timestamp of the next update to x Valid-interval(x) [last-modified(x), valid-till(x) ) Snapshot - for some timestamp ts i {x j DB | ts i valid-interval(x j )}
7
7 Types of Freshness Constraints Attach freshness constraints to Read(x) Time bound: bound(b) ts(T i ) – valid-till(x) < b Limited time-drift: drift(S, b): x,y S, values read are within b of each other. I.e., ( t x valid-interval(x)) ( t y valid-interval(y)) |t x -t y | b Snapshot consistency: Drift(S, 0)
8
8 Physical Execution Model Cache B Master Manager x M y M z M Master Database Cache Manager A x A y A Cache Manager B x B z B Cache A Copier r r User-transaction w w
9
9 Correctness User’s execution model is multiversion Because txns read out-of-date values Physical system model is replicated Because txns read from cache Relaxed-currency serializable Interleaved execution of the physical system equivalent-to Serial execution in user’s model
10
10 Transaction Execution Read - get a short-duration read-lock Gather txn timestamp constraints based on currency constraints on its reads Write - gets a commit-duration write-lock Commit - master assigns a timestamp that satisfies the txn’s constraints, or aborts Primary-copy replication propagates updates from master to caches.
11
11 Gathering Transaction Timestamp Constraints Store last-modified(x), valid-till(x) Time-bound: ts(T i ) – valid-till(x) < b ts(T i ) < valid-till(x) + b Constraint drift(S, b) is satisfiable if: P: max(last-modified(S)) < min(valid-till(S))+b Many possible optimizations
12
12 Performance If freshness constraints aren’t tight, then the vast majority of them will succeed. Since only short read locks are held, performance will be comparable to Degree 1 (Read Committed). Bober & Carey [ICDE 92] showed a 3x throughput improvement of Degree 1 over 2PL. We’re investigating further with a new simulation study.
13
13 Contributions An extended serializability model, Relaxed Currency (or RC-) Serializability, that accounts for out-of-date reads that satisfy user-specified freshness constraints. Concurrency control protocols that allow update transactions to read out-of-date data that satisfies the associated freshness constraints. Proofs that the protocols produce RC-serializable executions.
14
9/27/05© 2005 Microsoft Corporation14 Backup slides
15
15 Freshness Constraint Checking Limited Time-Drift Constraints Constraint drift(S, b) is satisfiable if: P: max(last-modified(S)) < min(valid-till(S))+b To see this, suppose x,y S. Suppose valid intervals are [t x, t x ), [t y, t y ) WLG, suppose t x t y. There are two cases: In (i) drift({x,y}, b) is satisfied txtx tyty txtx tyty (i) overlapping intervals(ii) disjoint intervals txtx tyty txtx tyty txtx tyty txtx tyty
16
16 Freshness Constraint Checking Limited Time-Drift Constraints (2) In (ii), we need t y -t x b, to satisfy drift({x,y}, b). This follows from (P), since P: max(last-modified(S)) < min(valid-till(S))+b t y max(last-modified(S)) min(valid-till(S))+b, and min(valid-till(S)) t x . txtx tyty txtx tyty (i) overlapping intervals(ii) disjoint intervals txtx tyty txtx tyty txtx tyty txtx tyty
17
17 Optimizations If master is multiversioned, then Replace valid-till(x) by [“x”, last-modified(x), b] last-modified(x) identifies version of x that the txn read Master uses valid-till(x M ) = last-modified of next version of x M or Else suppose txn includes L=last-modified(x) and V=valid-till(x). L identifies the version of x that the txn read. If last-modified(x M )=L, then use valid-till(x M ) instead of V
18
18 Optimizations (2) Cache could remember each txn’s readset. When x readset(T i ) is subsequently updated by T k, freeze T i ’s valid-till(x) to last-modified(x k ) Return it in response to phase one. If reads are issued in sequence Maintain a timestamp upper-bound, high(T i ). After each read, high(T i ) = min(high(T i ), valid-till(x) + b).
19
19 Optimizations Like bound(x, b), maintain low(T i ) and high(T i ) For each read, r i [x A ] if max(low, last-modified(x A )) > min(high, valid-till(x A )+b), then reject the read, r i [x A ] else { high(T i ) = min(high(T i ), valid-till(x A ) + b); low(T i ) = max(low, last-modified(x A )); } At commit time, low < high, so drift(S, b) is surely satisfied.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.