Docsity

Multiversion Garbage - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

Toggle sidebar
bg1
Multiversion Garbage Collection
•Can delete an old version of x if no query will
ever read it
–There’s a later version of x whose tid ≤ T-Oldest
(or is on every active query’s commit list)
•Originally used in Prime Computer’s CODASYL
DB system and Oracle’s Rdb/VMS
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Multiversion Garbage - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Multiversion Garbage Collection

-^

Can delete an old version of x if no query willever read it^ –

There’s a later version of x whose tid ≤ T-Oldest(or is on every active query’s commit list)

-^

Originally used in Prime Computer’s CODASYLDB system and Oracle’s Rdb/VMS

Oracle MultiversionConcurrency Control

•^

Data page contains latest version of each record, whichpoints to older version in rollback segment.

-^

Read-committed query reads data as of its start time.

-^

Read-only isolation reads data as of transaction start time.

-^

“Serializable” query reads data as of the txn’s start time.^ –

An update checks that the updated record was not modifiedafter txn start time.

If that check fails, Oracle returns an error.

If there isn’t enough history for Oracle to perform the check,Oracle returns an error. (You can control the history area’s size.)

What if T

1

and T

modify each other’s readset concurrently? 2

8.10 Phantoms

•^

Problems when using 2PL with inserts and deletes T

: Read Accounts 1, 2, and 3 1 T

: Insert Accounts[4, Tacoma, 100] 2 T

: Read Assets(Tacoma), returns 500 2 T

: Write Assets(Tacoma, 600) 2 T

: Read Assets(Tacoma), returns 600 1 T

Acct# Commit

Location

Balance

Location

Total

Seattle

Tacoma

Tacoma

Seattle

Tacoma

Accounts

Assets The phantom record

The Phantom Phantom Problem

-^

It looks like T

1

should lock record 4, which isn’t

there!

-^

Which of T

’s operations determined that there 1

were only 3 records?^ –

Read end-of-file?

Read record counter?

SQL Select operation?

-^

This operation conflicts with T

’s Insert 2

Accounts[4,Tacoma,100]

-^

Therefore, Insert Accounts[4,Tacoma,100]shouldn’t run until after T

1

commits

Precision Locks

-^

Suppose update operations are on single records

-^

Maintain a list of predicate Read-locks

-^

Insert, Delete, & Update write-lock the record andcheck for conflict with all predicate locks

-^

Query sets a read lock on the predicate and checkfor conflict with all record locks

-^

Cheaper than predicate satisfiability, but still tooexpensive for practical implementation.

8.11 Shared Disk Systems

•^

Use a version number on the page and in the lock Process A

P

r

Process B

P

r

P

•^

Can cache a page in two processesthat write-lock different records

-^

Only one process at a time canhave write privilege

-^

Use a global lock manager

-^

When setting a write lock on P,may need to refresh the cachedcopy from disk (if another processrecently updated it)

Logging

-^

Since updates are happening on differentsystems, where is the log?

-^

A single log server is simplest, but makeslogging more expensive.

-^

Be careful not to flush to the log untilnecessary.^ –

This requires locally-assigned LSNs

Must flush the log before flushing an updated page

8.12 B-Trees

-^

An

index

maps field values to record ids.

Record id = [page-id, offset-within-page]

Most common DB index structures: hashing and B-trees

DB index structures are

page-oriented

-^

Hashing uses a function H:V

B, from field values to

block numbers.^ –

V = social security numbers. B = {1 .. 1000}H(v) = v mod 1000

If a page overflows, then use an extra overflow page

At 90% load on pages, 1.2 block accesses per request!

BUT, doesn’t help for key range access (10 < v < 75)