Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

2/26/2016

ConcurrencyControlDatabaseManagementWikia

ConcurrencyControl
Definition
Concurrencycontrolisadatabasemanagementsystems(DBMS)conceptthatisusedtoaddressconflictswiththesimultaneousaccessingoralteringofdatathatcanoccurwitha
multiusersystem.concurrencycontrol,whenappliedtoaDBMS,ismeanttocoordinatesimultaneoustransactionswhilepreservingdataintegrity.[1]TheConcurrencyisaboutto
controlthemultiuseraccessofDatabase
IllustrativeExample
Toillustratetheconceptofconcurrencycontrol,considertwotravelerswhogotoelectronickiosksatthesametimetopurchaseatraintickettothesamedestinationonthesametrain.

Games Movies TV ExploreWikia


SearchDatabaseManagement...
SignIn
THEHOMEOFFANDOM
There'sonlyoneseatleftinthecoach,butwithoutconcurrencycontrol,it'spossiblethatbothtravelerswillenduppurchasingaticketforthatoneseat.However,withconcurrency
control,thedatabasewouldn'tallowthistohappen.Bothtravelerswouldstillbeabletoaccessthetrainseatingdatabase,butconcurrencycontrolwouldpreservedataaccuracyand
allowonlyonetravelertopurchasetheseat.
Thisexamplealsoillustratestheimportanceofaddressingthisissueinamultiuserdatabase.Obviously,onecouldquicklyrunintoproblemswiththeinaccuratedatathatcanresult
fromseveraltransactionsoccurringsimultaneouslyandwritingovereachother.Thefollowingsectionprovidesstrategiesforimplementingconcurrencycontrol.
ConcurrencyControlLockingStrategies
PessimisticLocking:Thisconcurrencycontrolstrategyinvolveskeepinganentityinadatabaselockedtheentiretimeitexistsinthedatabase'smemory.[2]Thislimitsorprevents
usersfromalteringthedataentitythatislocked.Therearetwotypesoflocksthatfallunderthecategoryofpessimisticlocking:writelockandreadlock.[2]
Withwritelock,everyonebuttheholderofthelockispreventedfromreading,updating,ordeletingtheentity.Withreadlock,otheruserscanreadtheentity,butnooneexceptforthe
lockholdercanupdateordeleteit.[2]
OptimisticLocking:Thisstrategycanbeusedwheninstancesofsimultaneoustransactions,orcollisions,areexpectedtobeinfrequent.[2]Incontrastwithpessimisticlocking,
optimisticlockingdoesn'ttrytopreventthecollisionsfromoccurring.Instead,itaimstodetectthesecollisionsandresolvethemonthechanceoccasionswhentheyoccur.[2]
Pessimisticlockingprovidesaguaranteethatdatabasechangesaremadesafely.However,itbecomeslessviableasthenumberofsimultaneoususersorthenumberofentities
involvedinatransactionincreasebecausethepotentialforhavingtowaitforalocktoreleasewillincrease.[2]
Optimisticlockingcanalleviatetheproblemofwaitingforlockstorelease,butthenusershavethepotentialtoexperiencecollisionswhenattemptingtoupdatethedatabase.
LockProblems:
Deadlock:
Whendealingwithlockstwoproblemscanarise,thefirstofwhichbeingdeadlock.Deadlockreferstoaparticularsituationwheretwoormoreprocessesareeachwaitingforanotherto
releasearesource,ormorethantwoprocessesarewaitingforresourcesinacircularchain.Deadlockisacommonprobleminmultiprocessingwheremanyprocessesshareaspecific
typeofmutuallyexclusiveresource.Somecomputers,usuallythoseintendedforthetimesharingand/orrealtimemarkets,areoftenequippedwithahardwarelock,orhardlock,which
guaranteesexclusiveaccesstoprocesses,forcingserialization.Deadlocksareparticularlydisconcertingbecausethereisnogeneralsolutiontoavoidthem.spaghetticansarenot
recyclablenow,STOPrecyclingthemnow!
Afittinganalogyofthedeadlockproblemcouldbeasituationlikewhenyougotounlockyourcardoorandyourpassengerpullsthehandleattheexactsametime,leavingthedoorstill
locked.Ifyouhaveeverbeeninasituationwherethepassengerisimpatientandkeepstryingtoopenthedoor,itcanbeveryfrustrating.Basicallyyoucangetstuckinanendless
cycle,andsincebothactionscannotbesatisfied,deadlockoccurs.
Livelock:
Livelockisaspecialcaseofresourcestarvation.Alivelockissimilartoadeadlock,exceptthatthestatesoftheprocessesinvolvedconstantlychangewithregardtooneanotherwile
neverprogressing.Thegeneraldefinitiononlystatesthataspecificprocessisnotprogressing.Forexample,thesystemkeepsselectingthesametransactionforrollbackcausingthe
transactiontoneverfinishexecuting.Anotherlivelocksituationcancomeaboutwhenthesystemisdecidingwhichtransactiongetsalockandwhichwaitsinaconflictsituation.
Anillustrationoflivelockoccurswhennumerouspeoplearriveatafourwaystop,andarenotquitesurewhoshouldproceednext.Ifnoonemakesasoliddecisiontogo,andallthecars
justkeepcreepingintotheintersectionafraidthatsomeoneelsewillpossiblyhitthem,thenakindoflivelockcanhappen.

BasicTimestamping:
Basictimestampingisaconcurrencycontrolmechanismthateliminatesdeadlock.Thismethoddoesntuselockstocontrolconcurrency,soitisimpossiblefordeadlocktooccur.
Accordingtothismethodauniquetimestampisassignedtoeachtransaction,usuallyshowingwhenitwasstarted.Thiseffectivelyallowsanagetobeassignedtotransactionsandan
ordertobeassigned.Dataitemshavebothareadtimestampandawritetimestamp.Thesetimestampsareupdatedeachtimethedataitemisreadorupdatedrespectively.
Problemsariseinthissystemwhenatransactiontriestoreadadataitemwhichhasbeenwrittenbyayoungertransaction.Thisiscalledalateread.Thismeansthatthedataitemhas
changedsincetheinitialtransactionstarttimeandthesolutionistorollbackthetimestampandacquireanewone.Anotherproblemoccurswhenatransactiontriestowriteadataitem
whichhasbeenreadbyayoungertransaction.Thisiscalledalatewrite.Thismeansthatthedataitemhasbeenreadbyanothertransactionsincethestarttimeofthetransactionthat
isalteringit.Thesolutionforthisproblemisthesameasforthelatereadproblem.Thetimestampmustberolledbackandanewoneacquired.[3]
Adheringtotherulesofthebasictimestampingprocessallowsthetransactionstobeserializedandachronologicalscheduleoftransactionscanthenbecreated.Timestampingmaynot
bepracticalinthecaseoflargerdatabaseswithhighlevelsoftransactions.Alargeamountofstoragespacewouldhavetobededicatedtostoringthetimestampsinthesecases.[4]

http://databasemanagement.wikia.com/wiki/Concurrency_Control

1/2

2/26/2016

ConcurrencyControlDatabaseManagementWikia

Sources:
[1]Coronel,Carlos,PeterRob.DatabaseSystems,sixthed.ThomsonCourseTechnology,2004.
[2]Ambler,Scott.IntroductiontoConcurrencyControl,2006<http://www.agiledata.org/essays/concurrencyControl.html

>

[2]Ambler,Scott.IntroductiontoConcurrencyControl,2006<http://www.alkissdesigners.kbo.co.ke >
[3]Ricardo,Catherine.DatabasesIlluminated,seconded.p386387Jones&BartlettLearning,2012.
[4]Kumar,V.TransactionManagementConcurrencyControlMechanisms,2012<http://sce.umkc.edu/~kumarv/cs470/transaction/Tmanagement.pdf
Categories:

>

Addcategory

Lifestyle

Entertainment

VideoGames

LIFESTYLE

About

Help

CommunityCentral

Careers

Advertise

API

ContactWikia

TermsofUse

PrivacyPolicy

GlobalSitemap

ContentisavailableunderCCBYSA.

http://databasemanagement.wikia.com/wiki/Concurrency_Control

2/2

You might also like