Thursday, July 13, 2006

Transactions Basics

Transactions Series Part 1

Transaction

It is a single logical operation on data.

ACID properties of Transaction

Atomic

The entire operation on the data should happen in its entirety, or should not happen at all. A transaction could involve multiple steps and for the transaction to complete, either all the steps should complete successfully or none at all. Any failure should abort the entire transaction.

Consistency

Data has data integrity or legal values which it can have. This data integrity should not be compromized by the transactions. For example, an account cannot have negative balance.

Isolation

The property which makes changes made by an operation local to it and not make other operations on system see it until its completion.

There are typically two ways of achieving isolation
  • Lock based concurrency control
  • Multiversion concurrency control
In the lock based concurrency model, typically objects are locked, so that another transaction will have to wait till the lock is released, which typically could be at the end of transaction.

In MVCC, multiple versions of the object are created for each transaction. For example, consider an object P, then this object has a read time called P-RT. Now, when a transaction Ti reads this object, a version of object P is created for the transaction and a time stamp for the transaction - Ti-TS is noted. Now, if the transaction Ti wants to write back any changes to P, then it is allowed to do only if another transaction Tj, whose time stamp Tj-TS is greater than Ti-TS and the object read time P-RT is less than Ti-TS. Otherwise the transaction is aborted and restarted.

By ANSI SQL standards, there are four levels of isolation -
  • Serializable - This is the most strict form of isolation level possible. In this mode, the system makes all the transaction run serially. In the case of lock base concurrency control, the database system seems to acquire a range lock. This level guarentees that a select query always returns the same number of records with the same values when inside a transaction. With MVCC, a snapshot isolated view is created and shared for each accessing transaction. If the transaction updates, ofcoure, there is a potential for abortion with MVCC.
  • Repeatable Read - This is the next level of isolation. With lock base concurrency control, all the data records or tuples are locked, but the range is not locked, and hence phantom reads are possible.
    Phantom Read - For example, If "select * from users where age between 10 and 30" selects 10 records, then these 10 records are locked and cannot be modified by another transaction. On the other hand, another transaction can write a new record with age 27, and if the first transaction ran the same query again, it would get another result with an extra tuple. This is because the range was locked. This is called phantom read. In this case, the system acquires a record lock on all the retrieved records but does not acquire a range lock allowing other transactions to insert records. This isolation level guarentees that a select query always returns the same value of the record.
  • Read Committed - In this case, records retrieved by a query are allowed to be modifiable by other transactions. No locks are acquired at all. This is a Non-Repeatable-Read isolation level. Meaning that the value of a record may change between multiple select statement in a transaction; only if another transaction commits.
  • Read Uncommitted - Same as Read Committed, the only difference being that a transaction can also see the dirty writes of another transaction. For example, a transaction can write data and before it can commit, the data is visible to other transactions. This is the lowest level of isolation.
Durability

This is the guarentee that once the user has committed the changes, the changes will persist and not be undone. It will survive any system failure, and that the database system has checked the integrity constraints and won't need to abort the transaction.

Atomicity and Durability are guarenteed by either of two types of strategies -
  • Write ahead logging (WAL)
  • Shadow writing.
Write ahead logging - In a system using WAL, all modifications are written to a log before they are applied to the database. Usually both redo and undo information is stored in the log. The motivation for WAL is to allow updates of the database to be done in-place.

Shadow logging - Shadow paging is a copy-on-write technique for avoiding in-place updates of pages. Instead, when a page is to be modified, a shadow page is allocated. Since the shadow page has no references (from other pages on disk), it can be modified liberally, without concern for consistency constraints, etc. When the page is ready to become durable, all pages that referred to the original are updated to refer to the new replacement page instead. Because the page is "activated" only when it is ready, it is atomic. If the referring pages must also be updated via shadow paging, this procedure may recurse many times, becoming quite costly.

12 Comments:

Blogger ninest123 Ninest said...

ninest123 10.27
tiffany jewelry, michael kors outlet, oakley sunglasses wholesale, ugg boots, louis vuitton, jordan shoes, nike air max, burberry outlet, uggs outlet, prada outlet, louis vuitton, ugg boots, louis vuitton outlet, michael kors outlet store, ray ban sunglasses, louis vuitton outlet, replica watches, replica watches, uggs outlet, michael kors outlet, polo ralph lauren outlet online, nike free, ray ban sunglasses, oakley sunglasses, christian louboutin outlet, michael kors outlet online, longchamp outlet, louis vuitton outlet, christian louboutin, tiffany and co, prada handbags, cheap oakley sunglasses, polo outlet, longchamp outlet, tory burch outlet, longchamp outlet, nike outlet, oakley sunglasses, oakley sunglasses, ray ban sunglasses, christian louboutin shoes, christian louboutin uk, chanel handbags, uggs on sale, burberry handbags, nike air max, kate spade outlet, michael kors outlet online

9:46 AM  
Blogger ninest123 Ninest said...

hollister uk, nike roshe run uk, sac longchamp pas cher, nike air max uk, north face, vans pas cher, michael kors, kate spade, nike blazer pas cher, longchamp pas cher, ray ban uk, nike free run, abercrombie and fitch uk, louboutin pas cher, coach outlet store online, timberland pas cher, nike roshe, north face uk, polo ralph lauren, oakley pas cher, nike air max, sac vanessa bruno, hollister pas cher, polo lacoste, true religion outlet, ralph lauren uk, nike tn, sac hermes, ray ban pas cher, coach outlet, jordan pas cher, michael kors, coach purses, nike air force, true religion jeans, lululemon canada, michael kors pas cher, mulberry uk, nike air max uk, true religion outlet, burberry pas cher, michael kors outlet, nike free uk, converse pas cher, coach outlet, hogan outlet, new balance, guess pas cher, true religion outlet, air max

9:47 AM  
Blogger ninest123 Ninest said...

bottega veneta, new balance shoes, nike air max, soccer jerseys, louboutin, giuseppe zanotti outlet, lululemon, mac cosmetics, vans, nike trainers uk, vans outlet, abercrombie and fitch, reebok outlet, nike air max, converse, iphone 6 cases, insanity workout, ghd hair, hollister clothing, converse outlet, oakley, nfl jerseys, baseball bats, herve leger, gucci, nike huaraches, mont blanc pens, north face outlet, ferragamo shoes, valentino shoes, north face outlet, p90x workout, longchamp uk, nike roshe run, soccer shoes, wedding dresses, timberland boots, hollister, hermes belt, hollister, ralph lauren, jimmy choo outlet, chi flat iron, asics running shoes, ray ban, instyler, mcm handbags, beats by dre, celine handbags, babyliss, gucci handbags, michael kors outlet online

9:48 AM  
Blogger ninest123 Ninest said...

toms shoes, ugg, ugg uk, moncler, moncler, juicy couture outlet, hollister, ugg,uggs,uggs canada, michael kors outlet online, canada goose outlet, lancel, wedding dresses, moncler outlet, canada goose, swarovski, barbour uk, moncler, canada goose outlet, louis vuitton, ugg,ugg australia,ugg italia, louis vuitton, moncler uk, louis vuitton, ugg pas cher, louis vuitton, montre pas cher, links of london, marc jacobs, barbour, louis vuitton, canada goose uk, michael kors handbags, canada goose outlet, pandora charms, supra shoes, replica watches, canada goose, juicy couture outlet, coach outlet, karen millen uk, moncler outlet, moncler, pandora uk, doudoune moncler, thomas sabo, swarovski crystal, pandora jewelry, canada goose jackets, michael kors outlet, canada goose, doke gabbana, pandora jewelry
ninest123 10.27

9:49 AM  
Blogger Wenhao Guo said...

ugg outlet
ugg boots
moncler outlet
canada goose jackets
belstaff jackets
woolrich outlet
barbour coats
parajumpers coats
wellensteyn jackets
canada goose jackets
nobis outlet
barbour coats
moncler jackets
black friday deals
black friday 2015
cyber monday deals
cyber monday 2015
winter coats
winter jackets
snow boots
ugg boots
ugg outlet
ugg outlet
ugg sale
ugg australia
discount ugg boots
cheap ugg boots
michael kors factory outlet
canada goose outlet
canada goose jackets
canada goose jackets
canada goose outlet
ray ban sunglasses
cheap ray ban sunglasses
coach outlet store
swarovski outlet
achang1212

2:30 PM  
Blogger 艾丰 said...

jianbin1219
longchamp outlet
true religion sale
true religion outlet
fitflops shoes
fitflops sale
fitflops sale clearance
fitflops sale
fitflops shoes
michael kors outlet
michael kors outlet
michael kors outlet
tiffany and co
tiffany jewellery
beats by dr dre
beats by dre
oakley sunglasses
oakley sunglasses
ray-ban sunglasses
ray ban sunglasses
hollister uk
lululemon outlet
ugg outlet
ugg boots
ugg boots
rolex watches
mulberry handbags
mulberry bags
mulberry outlet
mulberry sale
mulberry handbags
mulberry handbags
louis vuitton handbags
louis vuitton handbags
toms shoes

11:01 AM  
Blogger Richika Sarkar said...

It is nice post
Visit Links:
Packers and Movers Mumbai
Packers and Movers Andheri
Packers and Movers Airoli
Packers and Movers Borivali
Packers and Movers Bandra
Packers and Movers Kalyan
Packers and Movers Kharghar
Packers and Movers Kandivali
Packers and Movers Thane

Home Shifting
Vehicle Shifting
Storage
Corporate Shifting

3:05 PM  
Blogger oakleyses said...

christian louboutin uk, louis vuitton outlet, christian louboutin shoes, michael kors pas cher, louis vuitton outlet, sac longchamp pas cher, prada handbags, gucci handbags, tiffany and co, polo ralph lauren outlet online, christian louboutin outlet, cheap oakley sunglasses, longchamp outlet, uggs on sale, polo outlet, louis vuitton, nike air max, oakley sunglasses, longchamp outlet, nike free, nike outlet, longchamp outlet, longchamp pas cher, chanel handbags, nike air max, oakley sunglasses, nike free run, tiffany jewelry, oakley sunglasses wholesale, louboutin pas cher, ray ban sunglasses, ugg boots, replica watches, air max, louis vuitton outlet, oakley sunglasses, nike roshe, louis vuitton, tory burch outlet, ray ban sunglasses, jordan shoes, christian louboutin, prada outlet, polo ralph lauren, burberry pas cher, ugg boots, jordan pas cher, kate spade outlet, ray ban sunglasses

8:38 AM  
Blogger oakleyses said...

nike blazer pas cher, mulberry uk, burberry handbags, michael kors, timberland pas cher, oakley pas cher, ray ban uk, vans pas cher, coach purses, north face, nike free uk, new balance, ray ban pas cher, sac hermes, michael kors, nike air force, ralph lauren uk, nike air max, kate spade, nike roshe run uk, true religion jeans, north face uk, hogan outlet, michael kors outlet online, nike air max uk, uggs outlet, nike tn, burberry outlet, hollister uk, coach outlet store online, replica handbags, lululemon canada, michael kors outlet online, michael kors outlet online, michael kors outlet, michael kors outlet online, converse pas cher, michael kors outlet, true religion outlet, true religion outlet, polo lacoste, hollister pas cher, coach outlet, guess pas cher, true religion outlet, abercrombie and fitch uk, nike air max uk, sac vanessa bruno, michael kors outlet

8:41 AM  
Blogger oakleyses said...

hollister, oakley, celine handbags, instyler, nike trainers uk, ghd hair, converse outlet, hollister clothing, hermes belt, beats by dre, ray ban, lancel, herve leger, timberland boots, nike air max, chi flat iron, longchamp uk, asics running shoes, vans, nike air max, insanity workout, reebok outlet, giuseppe zanotti outlet, abercrombie and fitch, nike roshe run, north face outlet, louboutin, jimmy choo outlet, iphone cases, gucci, mcm handbags, north face outlet, valentino shoes, soccer shoes, hollister, wedding dresses, babyliss, bottega veneta, baseball bats, p90x workout, nfl jerseys, nike huaraches, new balance shoes, soccer jerseys, mont blanc pens, ralph lauren, vans outlet, mac cosmetics, ferragamo shoes, lululemon

8:44 AM  
Blogger oakleyses said...

hollister, louis vuitton, moncler outlet, pandora uk, moncler, canada goose outlet, ugg,ugg australia,ugg italia, marc jacobs, toms shoes, moncler outlet, louis vuitton, canada goose, swarovski crystal, supra shoes, moncler, ugg, juicy couture outlet, wedding dresses, thomas sabo, karen millen uk, ugg pas cher, canada goose jackets, pandora jewelry, louis vuitton, moncler, swarovski, pandora jewelry, links of london, moncler uk, louis vuitton, coach outlet, ugg uk, canada goose uk, ugg,uggs,uggs canada, canada goose, doudoune moncler, louis vuitton, pandora charms, juicy couture outlet, canada goose outlet, canada goose outlet, canada goose, moncler, replica watches, montre pas cher

8:47 AM  
Blogger Liu Liu said...

Nick Saban’s relatively brief time as head coach of the Miami Dolphins is not looked upon fondly by most fans of the team. He went 15-17 christian louboutin shoes in his two seasons, but basically quit on the nfl jerseys store team in the final weeks Nike Air Max 90 of the 2006 season, focused more on his next job, at the University of Alabama, instead of the one he christian louboutin uk was under contract for.And at least one player who played – or at Christian Louboutin Women Flat least practiced – under Saban during those ill-fated christian louboutin men flat final weeks Nike Roshe Run hasn’t forgotten NFL Jerseys how Nike Free Run he was louboutin outlet treated. According to Nike Air Max 2015 Shoes receiver P.K. Sam, a journeyman cheap nfl jerseys who spent time with five NFL teams as well as two CFL clubs, Saban cut wholesale nfl jerseys him after he left the team christian louboutin Panettone spiked leather wallet briefly to see his dying father

2:51 PM  

Post a Comment

<< Home