DOC PREVIEW
UMD CMSC 424 - Transactions

This preview shows page 1-2-16-17-18-33-34 out of 34 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

TransactionsOverviewHow does..Assumptions and GoalsNext…Transaction statesShadow CopySlide 8Slide 9A ScheduleSchedulesExample ScheduleAnother scheduleSlide 14Example Schedules (Cont.)SerializabilitySlide 17Conflict SerializabilityEquivalence by SwappingSlide 20Slide 21Slide 22Slide 23Slide 24Slide 25View-SerializabilityOther notions of serializabilityTesting for conflict-serializabilityExample Schedule (Schedule A) + Precedence GraphRecapRecoverabilitySlide 32Slide 33Slide 34TransactionsTransactionsAmol DeshpandeAmol DeshpandeCMSC424CMSC424OverviewOverviewTransaction: A sequence of database actions enclosed within special tagsProperties:Atomicity: Entire transaction or nothingConsistency: Transaction, executed completely, takes database from one consistent state to anotherIsolation: Concurrent transactions appear to run in isolationDurability: Effects of committed transactions are not lostConsistency: Transaction programmer needs to guarantee thatDBMS can do a few things, e.g., enforce constraints on the dataRest: DBMS guaranteesHow does..How does.... this relate to queries that we discussed ?Queries don’t update data, so durability and consistency not relevantWould want concurrency Consider a query computing total balance at the end of the dayWould want isolationWhat if somebody makes a transfer while we are computing the balanceTypically not guaranteed for such long-running queriesTPC-C vs TPC-HAssumptions and GoalsAssumptions and GoalsAssumptions:The system can crash at any timeSimilarly, the power can go out at any pointContents of the main memory won’t survive a crash, or power outageBUT… disks are durable. They might stop, but data is not lost.For now.Disks only guarantee atomic sector writes, nothing moreTransactions are by themselves consistentGoals:Guaranteed durability, atomicityAs much concurrency as possible, while not compromising isolation and/or consistencyTwo transactions updating the same account balance… NOTwo transactions updating different account balances… YESNext…Next…States of a transactionA simple solution called shadow copySatisfies Atomicity, Durability, and Consistency, but no ConcurrencyVery inefficientTransaction statesTransaction statesShadow CopyShadow CopyMake updates on a copy of the database.Switch pointers atomically after done.Some text editors work this wayShadow CopyShadow CopyAtomicity:As long as the DB pointer switch is atomic. Okay if DB pointer is in a single blockConcurrency:No.Isolation:No concurrency, so isolation is guaranteed.Durability:Assuming disk is durable (we will assume this for now).Very inefficient:Databases tend to be very large. Making extra copies not feasible. Further, no concurrency.Next…Next…Concurrency control schemesA CC scheme is used to guarantee that concurrency does not lead to problemsFor now, we will assume durability is not a problemSo no crashesThough transactions may still abortSchedulesWhen is concurrency okay ?Serial schedulesSerializabilityA ScheduleA ScheduleT1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A – tmpwrite(A)read(B)B = B+ tmpwrite(B)Transactions: T1: transfers $50 from A to B T2: transfers 10% of A to BDatabase constraint: A + B is constant (checking+saving accts)Effect: Before After A 100 45 B 50 105Each transaction obeys the constraint.This schedule does too.SchedulesSchedulesA schedule is simply a (possibly interleaved) execution sequence of transaction instructionsSerial Schedule: A schedule in which transaction appear one after the otherie., No interleavingSerial schedules satisfy isolation and consistencySince each transaction by itself does not introduce inconsistencyExample ScheduleExample ScheduleAnother “serial” schedule:T1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A – tmpwrite(A)read(B)B = B+ tmpwrite(B)Consistent ? Constraint is satisfied.Since each Xion is consistent, any serial schedule must be consistentEffect: Before After A 100 40 B 50 110Another scheduleAnother scheduleT1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A – tmpwrite(A)read(B)B = B+ tmpwrite(B)Is this schedule okay ?Lets look at the final effect…Effect: Before After A 100 45 B 50 105Consistent. So this schedule is okay too.Another scheduleAnother scheduleT1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A – tmpwrite(A)read(B)B = B+ tmpwrite(B)Is this schedule okay ?Lets look at the final effect…Effect: Before After A 100 45 B 50 105Further, the effect same as theserial schedule 1.Called serializableExample Schedules (Cont.)Example Schedules (Cont.) A “bad” scheduleNot consistentT1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A – tmpwrite(A)read(B)B = B+ tmpwrite(B)Effect: Before After A 100 50 B 50 60SerializabilitySerializabilityA schedule is called serializable if its final effect is the same as that of a serial scheduleSerializability  schedule is fine and does not result in inconsistent databaseSince serial schedules are fineNon-serializable schedules are unlikely to result in consistent databasesWe will ensure serializabilityTypically relaxed in real high-throughput environmentsSerializabilitySerializabilityNot possible to look at all n! serial schedules to check if the effect is the sameInstead we ensure serializability by allowing or not allowing certain schedulesConflict serializabilityView serializabilityView serializability allows more schedulesConflict SerializabilityConflict SerializabilityTwo read/write instructions “conflict” if They are by different transactionsThey operate on the same data itemAt least one is a “write” instructionWhy do we care ?If two read/write instructions don’t conflict, they can be “swapped” without any change in the final effectHowever, if they conflict they CAN’T be swapped without changing the final effectEquivalence by SwappingEquivalence by SwappingT1read(A)A = A -50write(A)read(B)B=B+50write(B)T2read(A)tmp = A*0.1A = A


View Full Document

UMD CMSC 424 - Transactions

Documents in this Course
Lecture 2

Lecture 2

36 pages

Databases

Databases

44 pages

Load more
Download Transactions
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Transactions and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Transactions 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?