VI BTP

25
Transaction Management Transaction Management for XML for XML Taro L. Saito Department of Information Science University of Tokyo E-mail : [email protected]

description

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum v

Transcript of VI BTP

Page 1: VI BTP

Transaction Management for Transaction Management for XMLXML

Taro L. SaitoDepartment of Information Science

University of TokyoE-mail : [email protected]

Page 2: VI BTP

IntroductionIntroduction

Research Trends on XML– Query languages

• XML-QL, XQuery, XDuce, etc…• Update extension of XQuery (2001)

Most of them implicitly assume single user environments.

Page 3: VI BTP

XML as DatabaseXML as Database Multiple Users

– 1~1000, or more? – Querying and updating occur simultaneously

Transaction Management– Atomicity of query and update operations

• All-or-nothing execution– Consistency and Concurrency Control

• Locking system

Page 4: VI BTP

AchievementsAchievements

XerialXerial Transactional Database for XML– Concurrent Transactions

• Serializable schedule– Recoverability

• Handling transaction aborts and system failures – Updating XML

• Node insertion, deletion, modification, etc.– Transaction Language

• Query and update notations

Page 5: VI BTP

Xerial OverviewXerial Overview

XMLStorage

QueryCompiler

Transaction Requests

Transaction Scheduler

Serializable Schedule

DB AccessSystem

Outputs

actions

XMLsource

xml2db

Lock Requests Lock

Table

Read & Write

Log

Multi-Thread

Page 6: VI BTP

Data ModelData Model<customer id=“J-001”> <name> Jeffrey </name> <city> New York </city> <order oid=“3”> <item> Notebook </item> <date> 2002/02/11 </date> <num> 50 </num> </order> <order oid=“1”> <item> Blank Label </item> <date> 2002/02/10 </date> <num> 100 </num>

<status> delivered </status> </order></customer>

city

name“Jeffrey”

item

“J-001”

“New York”

“Notebook”

id

“2002/02/13”

“50”

order

num

customer

order

date

“3”

oid

item

“Blank Label”

“2002/02/10”

“100”

num

date

“1”

oid

status

“delivered”

Page 7: VI BTP

Querying XMLQuerying XML XQuery

– W3C standard– Query Language for XML– Use of Path expressions– Bind elements to a variable

city

name“Jeffrey”

item

“J-001”

“New York”

“Notebook”

id

“2002/02/13”

“50”

order

num

customer

order

date

“3”

oid

item

“Blank Label”

“2002/02/10”

“100”

num

date

“1”

oid

status

“delivered”

order orderorder order

FOR $x IN /customer/orderFOR $x IN /customer/order

WHERE $x/date = “2002/02/13”

Page 8: VI BTP

Locks for Tree-StructureLocks for Tree-Structure Subtree Level Locking

– Query to entire subtree is frequent in XML

– Reduce the # of locks Performance Factor

– The number of locks• Load of lock manager

– Granularity of locks• Concurrency

city

name“Jeffrey”

item

“J-001”

“New York”

“Notebook”

id

“2002/02/13”

“50”

order

num

customer

order

date

“3”

oid

item

“Blank Label”

“2002/02/10”

“100”

num

date

“1”

oid

status

“delivered”

Page 9: VI BTP

Lock Range ReductionLock Range Reduction Use Attribute Data

– Read Only– Available without locks

/customer/order[@oid=“3”]

city

name“Jeffrey”

item

“J-001”

“New York”

“Notebook”

id

“2002/02/13”

“50”

order

num

customer

order

date

“3”

oid

item

“Blank Label”

“2002/02/10”

“100”

num

date

“1”

oid

status

“delivered”

order

oidoidoid

Page 10: VI BTP

Transaction ManagementTransaction Management

Page 11: VI BTP

OperationsOperations

Query– XQuery Syntax

• FOR, WHERE, RETURN Update

– Insertion– Deletion– Modification

Page 12: VI BTP

Transaction LanguageTransaction Language

SET $x = /customerTRANSACTION $x { FOR $y IN $x/name,

$z IN $x/city WHERE $y = “Jeffrey” RETURN $z}

SET $x = /customer[@id=”C-032”]TRANSACTION $x { FOR $o IN $x/order, $p IN $o/price WHERE $o/item = “book”, $p > 10000 INSERT $o { <comment>

tax has been imposed </comment>

} WRITE $p $p * 1.10}

Basic SyntaxBasic Syntax

Update TransactionUpdate Transaction

Page 13: VI BTP

LocksLocks

IS IX S X

IS Yes Yes Yes NoNoIX Yes Yes NoNo NoNoS Yes NoNo Yes NoNoX NoNo NoNo NoNo NoNo

Compatibility MatrixCompatibility Matrix

Ordinal Locks•S Shared Lock (read)

•X Exclusive Lock (write)

Warnings•IS Intention to Share

•IX Intention to Exclusive

Page 14: VI BTP

Warning ProtocolWarning Protocol Jim Gray et al, 1975. Original Rules

– All transactions must enter from the root

– To place a lock or warning on any element, we must hold a warning on its parent

– Never remove a lock or warning unless we hold no locks or warnings on its children

ED F

B

A

C

IS

S

Page 15: VI BTP

H

Warning Protocol for XMLWarning Protocol for XML Extension

– When we insert or delete nodes, we must obtain X lock on the parent of the destination

– Until we place a warning on a node, we cannot trace its pointers to the children

– A transaction never release locks or warnings until it finishes

• 2 phase locking

ED F

B

A

C

G

X

IX

Page 16: VI BTP

SerializabilitySerializability Serial Schedule

T1 T5T2T3 T4

If the effect on the database is equivalent to that of some serial schedule, the schedule is serializable

2-phase locking is serializable (theory)The warning protocol becomes serializable

Page 17: VI BTP

RecoverabilityRecoverability

2 Phase Locking– No dirty read– No cascading rollback

Recovery – From transaction aborts and system failures– By using log records

Page 18: VI BTP

Experimental ResultsExperimental Results

Page 19: VI BTP

HardwareHardware Pentium III 1GHz, Dual Processor Main Memory 2GB Hard Disk * 2

– 10000 RPM, Ultra160 SCSI– NTFS format (Windows 2000)– For database and log

Page 20: VI BTP

Data SourceData Source

XML Representation of TPC-C– Random Data– 11.5 MB– 3433271 tags– 17555 attributes– 293160 data

TPC-C– Benchmark for online

transaction processing on Relational Databases

W=5

D=10

C=50

Order=5

Page 21: VI BTP

Transactions Lock Node Mode Insert Modify Delete S1 (%) S2 (%) Search District Warehouse S 0 0 0 40 5

Insert Customer District X 30 1 0 20 10

Delete Customer District X 0 1 30 ~ 10 2

Insert Order Customer X 22 1 0 15 40

Write Payment Customer X 0 2 0 10 25

Delete Order Customer X 0 1 22 ~ 3 3

Order Status Order S 0 0 0 2 15

Transaction SetsTransaction Sets

Random 10,000 Transaction Sets– S1 Low Concurrency– S2 Insertion Intensive (more general)

Page 22: VI BTP

MethodologyMethodology

Compare 2 Methods– (a) The warning protocol (parallel)– (b) Obtain an X lock on the root (serial)

• Lock the whole database Measure

– Transaction Throughput– Average Response Time

Page 23: VI BTP

ResultsResults

Lock Time Update Time Response Time Elapsed Time (10,000 Transactions)

Transactions Per Second

S1 (a) 0.41702 0.06018 0.47956 96.328 103.812 (b) 0.75634 0.01039 0.76891 154.625 64.672

S2 (a) 0.30730 0.10657 0.41726 84.05 118.977 (b) 0.88859 0.00787 1.28200 180.33 55.453

S1 S2

(a) parallel

(b) serial

(a) parallel

(b) serial

number of number of transactiontransaction

number of number of transactiontransaction

time

(sec

.)

time

(sec

.)

Page 24: VI BTP

Future WorkFuture Work More Complex Operations

– Join operation between subtrees• Possibility of deadlocks

Degrees of Consistency– Lower the consistency for increasing the performance

Other Consistency Managements– Time stamp– Versioning– Multi-version 2 phase locking– etc.

Page 25: VI BTP