Similar documents

Patterns in. Lecture 2 GoF Design Patterns Creational. Sharif University of Technology. Department of Computer Engineering

Library Intro AC800M

DESIGNINGCRYPTOGRAPHICPOSTAGEINDICIA. NevinHEINTZE BellLaboratories 600MountainAve,MurrayHillNJ07974,USA

COMMUTATIVE RINGS. Definition: A domain is a commutative ring R that satisfies the cancellation law for multiplication:

Microsoft Outlook 2013

Chapter 12. Development Tools for Microcontroller Applications

All of my instructors showed a true compassion for teaching. This passion helped students enjoy every class. Amanda

Persistent Binary Search Trees

Client Overview. Engagement Situation. Key Requirements

ITG Software Engineering

How To Protect Your Firewall From Attack From A Malicious Computer Or Network Device


1. License. Copyright 2016 gamedna studio. All rights reserved.

Magento ecommerce System Health Check Package

NSI XML Retail Accounting Report Consuming Application 1.0 Conformance Statement

CARS: Agency Standard Reports. Mark Ross and Bryan Erwin August 13, 2014

How To Develop Software For Cms Tracker Sub Structure Tests

Module 4 Creation and Management of Databases Using CDS/ISIS

Chapter 6: distributed systems

Computer Engineering - Computing Technology - Master's Degree Programme - 5 year

INDUSTRY REPORT ON AIRBAG INDUSTRY

Quality Management using Key Performance Indicators at MTU Aero Engines


Computer Security: Principles and Practice

GREATEST COMMON DIVISOR

Open Access Design of a Python-based Wireless Network Optimization and Testing System

ITIL-CMMII Comparison

Computer Security DD2395

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

Planning and Scheduling in Manufacturing and Services

Smarter Balanced Technology Implementation Readiness v July 2014

CAD TOOLS FOR VLSI. FLOORPLANNING Page 1 FLOORPLANNING

A Performance Evaluation of Open Source Graph Databases. Robert McColl David Ediger Jason Poovey Dan Campbell David A. Bader

IPSecuritas 3.x. Configuration Instructions. Collax Business Server. for

Application Decisions: Visa Type/Refusal Reason(s)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

IRPhEP Database and Analysis Tool (IDAT)

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

High Performance Computing Facility Specifications, Policies and Usage. Supercomputer Project. Bibliotheca Alexandrina

An Open Source eid Simulator Open Identity Summit 9th -11th September 2013

3.03 College Board Advanced Placement Test means the Advanced Placement test administered by the College Board and Educational Testing Service.

Campus Interview Survey

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

lubyk lua libraries for live arts Gaspard Bucher (Buma)! artist, musician, coder

Year-end closing procedures for Microsoft Dynamics GP Payroll

Agenda. Understanding of Firewall s definition and Categorization. Understanding of Firewall s Deployment Architectures

Receivables Management Year End Closing Checklists Dynamics GP2015

ITG Software Engineering

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Computational intelligence in intrusion detection systems

Research of Sales Contract Management System Based on WEB

How To Integrate Software And Systems

6.2 Permutations continued

AN ALGORITHM FOR DISK SPACE MANAGEMENT. whose workload consists of queries that retrieve information. These

Part I Courses Syllabus

INVESTIGATING THE ADMINISTRATIVE BARRIERS OF HUMAN RESOURCES DEVELOPMENT (A CASE STUDY OF RELIEF COMMITTEE OF IMAM KHOMEINI IN TEHRAN PROVINCE)

Java's garbage-collected heap

ExamView Level 1. Training Workbook. Module 3 Testing on a Local Area Network. at&t Communication Manager.lnk

Symantec Consulting Services

The Statement of Fitness for Work from sick note to fit note

1. To develop the multidisciplinary skills essential to produce the trained experts in cloud computing and big data required by academia and industry

AGraphDrawingandTranslationServiceon StinaBridgeman,AshimGargandRobertoTamassia DepartmentofComputerScience thewww*

d yn am i c s g p c l i e n t u se r g u i d e Version 4.6.5x

Applications to Computational Financial and GPU Computing. May 16th. Dr. Daniel Egloff

A hypervisor approach with real-time support to the MIPS M5150 processor

Robotics Engineering. Ohio Academic Content Standards Grade. Lesson Summary:

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Software Engineering Introduction & Background. Complaints. General Problems. Department of Computer Science Kent State University

Big Data. White Paper. Big Data Executive Overview WP-BD Jafar Shunnar & Dan Raver. Page 1 Last Updated

IBM WebSphere E i r c c V e V r e b r ee e k

Robust Data Sharing with Key-Value Stores

Learning Objective 1. The Impact of Information Technology on the Audit Process. Describe how IT improves internal control.

NAUTI FLY 75 AUTOMATIC 0,75m Ka band Trolley

ON GALOIS REALIZATIONS OF THE 2-COVERABLE SYMMETRIC AND ALTERNATING GROUPS

Creo Illustrate 3.0. Curriculum Guide

Business Portal for Microsoft Dynamics GP Human Resources Management Self Service Suite Canadian Release

PETITION/PROGRAM SHEET Degree: Bachelor of Science Major: Computer Science

Business Ready Licensing for Existing Microsoft Dynamics Clients

Linux Block I/O Scheduling. Aaron Carroll December 22, 2007

SoMA. Automated testing system of camera algorithms. Sofica Ltd

Armanino LLP Welcomes You To Today s Webinar: GP Tips and Tricks: Using Credit Cards in GP

Course Outline: Course 20489B: Developing Microsoft SharePoint Server 2013 Advanced Solutions

Fountas & Pinnell Online Data Management System for Benchmark Assessment System. Assessments

MiSeq: Imaging and Base Calling

From bsdtar to tarsnap

COMPUTER BASED REMOTE CONTROL FOR LAYOUT OF SCALED MODEL TRAINS

Metastorm BPM Interwoven Integration. Process Mapping solutions. Metastorm BPM Interwoven Integration. Introduction. The solution

DEMO of MIS Software - ASRLMS

Storage Class Memory Support in the Windows Operating System Neal Christiansen Principal Development Lead Microsoft

Document Security. ados.com ADOS Corporation ADOS Corporation

August AP Psych Reading Schedule Sun Mon Tue Wed Thu Fri Sat. 19 Freshmen only. 20 First Day! or 27 BLOCK

Supply Chain Management and Advanced Planning

QUALIFICATIONS PACK - OCCUPATIONAL STANDARDS FOR ELECTRONICS INDUSTRY. SECTOR: ELECTRONICS SUB-SECTOR: Semiconductor Design and Active Components

DMSplus for Microsoft SharePoint 2010

XML for Manufacturing Systems Integration

Applying Remote Side-Channel Analysis Attacks on a Security-enabled NFC Tag

GE Energy. User s Guide. Bently Nevada Technical Support Portal

How to Configure Microsoft System Operation Manager to Monitor Active Directory, Group Policy and Exchange Changes Using NetWrix Active Directory

Transcription:

GarbageCollectioninObjectOriented DatabasesUsingTransactionalCyclic PrasanRoy1 ReferenceCounting S.Sudarshan1 S.Seshadri1S.Ashwin1 AviSilberschatz2 fprasan,seshadri,sudarshag@cse.iitb.ernet.in 1IndianInstituteofTechnology, Mumbai400076,India MurrayHill,NJ07974 sashwin@cs.wisc.edu 2BellLaboratories avi@bell-labs.com grammerfromexplicitlydeallocatingmemory.inthispaper,wepresentagarbage Garbagecollectionisimportantinobject-orienteddatabasestofreethepro- Abstract collectionalgorithm,calledtransactionalcyclicreferencecounting(tcrc),for objectorienteddatabases.thealgorithmisbasedonavariantofareferencecountingalgorithmproposedforfunctionalprogramminglanguagesthealgorithmkeeps trackofauxiliaryreferencecountinformationtodetectandcollectcyclicgarbage. Thealgorithmworkscorrectlyinthepresenceofconcurrentlyrunningtransactions, andsystemfailures.itdoesnotobtainanylongtermlocks,therebyminimizing interferencewithtransactionprocessing.itusesrecoverysubsystemlogstodetect algorithmandpresentresultsofaperformancestudyoftheimplementation. pointerupdates;thus,existingcodeneednotberewritten.finally,itexploits schemainformation,ifavailable,toreducecosts.wehaveimplementedthetcrc Objectorienteddatabases(OODBs),unlikerelationaldatabases,supportthenotionof 1objectidentity,andobjectscanrefertootherobjectsviaobjectidentiers.Requiring Introduction theprogrammertowritecodetotrackobjectsandtheirreferences,andtodeleteobjects CurrentlyatUniversityofWisconsinMadison1

thatarenolongerreferenced,iserrorproneandleadstocommonprogrammingerrors suchasmemoryleaks(garbageobjectsthatarenotreferredtofromanywhere,and haven'tbeendeleted)anddanglingreferences.whiletheseproblemsarepresentin traditionalprogramminglanguages,theeectofamemoryleakislimitedtoindividual programsthatcreateandaccessthem.automatedgarbagecollectionisessentialin Theproblembecomesmoreseriousinpersistentobjectstores,sinceobjectsoutlivethe runsofprograms,sinceallgarbageisimplicitlycollectedwhentheprogramterminates. anobjectorienteddatabasetoprotectfromtheerrorsmentionedabove.infact,the SmalltalkbindingfortheODMGobjectdatabasestandardrequiresautomatedgarbage Allobjectsthatarereachablefromthepersistentrootorfromthetransientprogram objectsandthearcsarethereferencesbetweenobjects.thegraphhasapersistentroot. collection. stateofanon-goingtransactionarelive;whiletherestaregarbage.weoftencallobject WemodelanOODBinthestandardwayasanobjectgraph,whereinthenodesarethe referencesaspointers. space;theentireoldspaceisthenreclaimed.incontrast,themarkandsweepalgorithm CopyingCollectorbased[YNY94]andMarkandSweepbased[AFG95].Thecopying collectoralgorithmtraversestheentireobjectgraphandcopiesliveobjectsintoanew Therehavebeentwoapproachestogarbagecollectioninobjectorienteddatabases: databaseanddeletesallobjectsthatareunmarked.thecopyingcollectoralgorithm marksallliveobjectsbytraversingtheobjectgraphandthentraverses(sweeps)theentire cases,butmaydestroyprogrammerspeciedclusteringresultinginworseperformance reclustersobjectsdynamically;thereclusteringcanimprovelocalityofreferenceinsome inothercases.thegarbagecollectionalgorithmsof[yny94]aswellas[afg95]handle concurrencycontrolandrecoveryissues. prohibitivelyexpensivefordatabaseslargerthanthememorysize,particularlyifthere aremanycross-pagereferences.intheworstcase,whenthebuersizeisasmallfraction ofthedatabasesizeandobjectsinapagerefertoobjectsinotherpagesonly,there Withboththeabovealgorithms,thecostoftraversingtheentireobjectgraphcanbe maybeani/oforeverypointerinthedatabase.toalleviatethisproblem,earlierwork fewpages.eachpartitionstoresinter-partitionreferences,thatisreferencestoobjects [YNY94,AFG95]hasattemptedtodividethedatabaseintopartitionsconsistingofa inthepartitionfromobjectsinotherpartitions,inapersistentdatastructure.objects referredtofromotherpartitionsaretreatedasiftheyarereachablefromthepersistent partition.eachpartitionisgarbagecollectedindependentofotherpartitions;references root,andarenotgarbagecollectedeveniftheyarenotreferredtofromwithinthe eciencyoccurringifthewholepartitiontsintothebuerspace. moreecient;thesmallerthepartition,themoreecientthetraversal,withmaximum toobjectsinotherpartitionsarenotfollowed.thus,partitioningmakesthetraversal Unfortunately,smallpartitionsincreasetheprobabilityofself-referentialcyclesof 2

by[cwz94]showedthatevensmallincreasesindatabaseconnectivitycanproducesignicantamountsofsuchgarbage.therefore,itisnotclearthatpartitionsizescanbtitionedgarbagecollectionalgorithms.previousworkhasmaintainedthatsuchcross cyclestructureswillbefew,andwill\probably"notbeaproblem.however,simulations madeverysmallwithouteitherfailingtocollectlargeamountsofgarbageoremploying special(andexpensive)techniquestodetectsuchcyclicgarbage. ofkeepingacountofthenumberofpointerspointingtoeachobject.whenthereference countoftheobjectbecomeszero,itisgarbageandeligibleforcollection.reference countinghastheattractivepropertiesoflocalizedandincrementalprocessing.unfortu- AnaturalalternativeisReferenceCounting.ReferenceCountingisbasedontheidea garbagethatcrosspartitionboundaries;suchcyclicgarbageisnotdetectedbytheparnately,basicreferencecountingcannotdealwithself-referentialcyclesofobjects;each objectcouldhaveapositivereferencecount,yetalltheobjectsinthecyclemaybe unreachablefromthepersistentroot,andthereforebegarbage.however,anumberof extensionsofthebasicreferencingcountingalgorithmtohandlecyclicdatahavebeen proposedintheprogramminglanguagecommunity,including:[bro85,bro84,pvep88]. [Bro85,Bro84]forfunctionalprogramminglanguages,whichhandlesselfreferentialcycles Morerecentworkinthisareaincludes[Lin90,MWL90,JL91]. (TCRC),basedonBrownbridge'salgorithm,whichissuitableforgarbagecollectionin ofgarbage.wepresentanalgorithm,calledtransactionalcyclicreferencecounting Inthispaper,weconsideraversionofreferencecounting,proposedbyBrownbridge anoodb.thesalientfeaturesofthetcrcalgorithmare: Itdetectsallselfreferentialcyclesofgarbageunlikebasicreferencecounting,and Itperformsaverylocalizedversionofmark-and-sweeptohandlecyclicdata,with thepartitionedgarbagecollectionalgorithms. eachmark-and-sweeplikelytoaccessfarfewerobjectsthanaglobalmark-andsweep.thusitdoesnothavetoexaminetheentiredatabasewhilecollecting Itallowstransactionstorunconcurrently,anddoesnotobtainanylongtermlocks, therebyminimizinginterferencewithtransactionprocessing. garbage,exceptintheworstcase. Itisintegratedwithrecoveryalgorithms,andworkscorrectlyinspiteofsystem Itexploitsschemainformation,ifavailable,toreducecosts.Inparticular,ifthe crashes.italsousesrecoverysubsystemlogstodetectpointerupdates;thus,existingapplicationcodeneednotberewritten. schemagraphisacyclic,nocyclicreferencesarepossibleinthedatabaseandtcrc behavesidenticallytoreferencecounting. 3

before;webelievethisisoneofthecentralcontributionsofourpaper.wealsopresent Designingacyclicreferencingcountingalgorithmwhichallowsconcurrentupdatesand handlessystemcrashesisrathernon-trivial,andtoourknowledgehasnotbeendone aproofofcorrectnessofthetcrcalgorithm. weexpectistrueinanyrealisticscenario,pointerupdatesareonlyasmallfractionof countbeingupdated.thisoverheadwillhaveonlyasmallimpactonperformanceif,as referencecounts.however,eachpointerupdatecanonlyresultinatmostonereference Aproblemoftencitedagainstreferencecountingschemesistheoverheadofupdating theoverallupdates.fortcrc,moreover,theoverheadisosetbythereducedcostof tendedabstractofthispaper[ars+97],inthefollowingways.thereisnolongeran assumptionthattransactionsfollowstrict2pl;infactthecurrentalgorithmmakesno traversalswhilecollectinggarbage. assumptionsaboutthelockingpoliciesusedbythetransaction.thereisnolongeran Thealgorithmpresentedinthispaperimprovesonthatpresentedinanearlierex- assumptionthattransactionsfollowstrictwal(thatis,boththeundoandredovaluesmustbeloggedbeforeactuallyperformingtheupdate);onlythenormal(non-strict) WALisassumedtobefollowed.Thatis,thecurrentalgorithmrequiresundovaluesto amorerestrictedlocaltraversalthantheearlieralgorithm,andisthereforepotentially beloggedbeforetheupdate,whiletheredovaluesmaybeloggedanytimebeforetheend moreecient. ofthetransaction(beforeoraftertheupdate).finally,thecurrentalgorithmperforms ofthetransaction. afterthetransactionends,andarenotrequiredtobeforcedtotheserverbeforetheend thatis,updatesmadebyatransactionrunningattheclientcanbereectedattheserver Fortheclient-serversetting,thecurrentalgorithmalsorelaxestheforcerequirement; WepresentaperformancestudyofTCRCbasedontheimplementation;thestudyclearly illustratesthebenetsoftcrc. markandsweepalgorithmonastoragemanagercalledbrahmadevelopediniitbombay. WehaveimplementedaprototypeoftheTCRCalgorithmaswellasthepartitioned 2 Brownbridge'sCyclicReferenceCountingAlgorithm OurTransactionalCyclicReferenceCountingalgorithmisbasedontheCyclicReference Counting(CRC)algorithmproposedbyBrownbridge[Bro84,Bro85],inthecontextof functionalprogramminglanguages. [Bro84,Bro85]istolabeledgesintheobjectgraphasstrongorweak.Thelabellingis donesuchthatacycleintheobjectgraphcannotconsistofstrongedgesalone{itmust ThebasicideabehindtheCyclicReferenceCounting(CRC)algorithmofBrownbridge 4

haveatleastoneweakedge.twoseparatereferencecountsforstrongandforweakedges strongedgesornot.hence,intheabsenceoffurtherinformation,thealgorithmtakesthe ingeneraltocheaplydeterminewhetherlabellinganewedgeasstrongcreatesacycleof (denotedsrefcandwrefcrespectively)aremaintainedperobject.itisnotpossible conservativeviewthatlabellinganewedgestrongcouldcreateacycleofstrongedges, andlabelsthenewedgeweak. fromitaredeleted.ifthesrefciszero,butwrefcisnon-zero,thereisachance thatsisinvolvedinaselfreferentialcycleofgarbage.ifthesrefcofanobjects objects,thesrefcaswellaswrefciszero,thensisgarbageandsandtheedges TheSRefCandWRefCareupdatedasedgesarecreatedanddeleted.Ifforan TCRCalgorithmdoesnotguaranteethislastproperty). isgreaterthanzero,thensisguaranteedtobereachablefromtheroot(however,our SRefCofSiszeroandWRefCofSisnonzero,alocalizedmarkandsweepalgorithm detectswhethersandanyoftheobjectsreachablefromsareindeedgarbage.the theonlypotentialcandidatesforbecominggarbagearesandobjectsreachablefroms.if IftheobjectgraphdidnothaveanygarbagebeforethedeletionofanedgetoS,then fromsandcoloursthemred.letusdenotetheabovesetbyr.itthencoloursgreen localizedmarkandsweepperformsatraversalfromsandidentiesallobjectsreachable everyobjectinrthathasareferencefromanobjectoutsider(detectedusingreference counts).italsocoloursgreenallobjectsreachablefromanygreenobject.duringthis atleastonestrongpointertoit.wewilldescribethispointerstrengthupdateindetail greenmarkingphasesomepointerstrengthsareupdatedtoensurethateveryobjecthas inthecontextofourtransactionalcyclicreferencecountingalgorithm.attheend,all environmentwithconcurrentupdatestoobjects,anddonotdealwithpersistentdata objectsinrnotmarkedgreenaregarbageandaredeleted. rithm,weredesignedforasingleusersystem.theycannotbeusedinamulti-user andfailures.ourcontributionslieinextendingbrownbridge'salgorithmto(a)uselogs However,priorcyclicreferencecountingalgorithms,includingBrownbridge'salgo- ofupdatestodetectchangestoobjectreferences,(b)toworkinanenvironmentwith strongpointers. atime,and(e)optimizethelocalizedmarkandsweepsignicantlybyfollowingonly transactionaborts,(d)handleabatchofupdatesatatimeratherthanoneupdateat concurrentupdates,(c)toworkonpersistentdatainthepresenceofsystemfailuresand Inthissection,wedescribeoursystemmodelandoutlinethearchitecturalassumptions 3onwhichourgarbagecollectorisbased. SystemModelandAssumptions andredorecordsarerepresentedasundo(tid,oid,oset,old-value),andredo(tid,oid, Inourmodel,transactionslogundoandredoinformationforallupdates.Undo 5

oset,new-value),wheretiddenotesatransactionidentierandoidanobjectidentier. theosetwecandetermineifthevaluethathasbeenupdatedisapointereld.these Objectcreationisloggedasobject-allocation(tid,oid).Thecommitlogisrepresentedas commit(tid);andtheabortlogisrepresentedasabort(tid).werequirethatfromtheoid wecanidentifythetypeoftheobject(perhapsbyrstfetchingtheobject),andfrom requirementsaresatisedbymostdatabasesystems. (oid)isvalidonlyifiteitherreferstoapersistentroot,orispresentinapointereldof ofanactivetransactionthatreadtheoidfromanobjectinthedatabaseorcreated anobjectinthedatabase,orisinthetransientmemory(programvariablesorregisters) Aswithanyothergarbagecollectionscheme,weassumethatanobjectidentier theobjectitrefersto.notethatthisprecludestransactionsfrompassingoidstoother transactions,andfromstoringoidsinexternalpersistentstorage. Assumption3.1ThetransactionsfollowWAL,thatis,theylogtheundovaluebefore actuallyperformingtheupdate,buttheredovaluemaybeloggedanytime(beforeorafter theupdate).2 Assumption3.2Alllogsforatransactionareforcedtodiskbeforecommitorabort databases. (force-logs-at-abortinadditiontoforce-logs-at-commit).2 Theassumptionsabovearesatisedbytypicalstoragemanagersforobject-oriented WewillnowdescribetheTransactionalCyclicReferenceCounting(TCRC)algorithm. 4Werstdescribethedatastructuresneededbythetransactionalcyclicreferencecounting algorithm. numberofstrongpointerspointingtotheobject,aweakreferencecount(wrefc)giving Associatedwitheachobject,wemaintainastrongreferencecount(SRefC)givingthe 4.1 DataStructures thenumberofweakpointerspointingtotheobject,andastrengthbitfortheobject. Eachpointeralsohasastrengthbit.Thepointerisstrongifthestrengthbitinthepointer andthestrengthbitintheobjectpointedtohavethesamevalue;otherwisethepointer isweak.thisrepresentationofstrengthusingtwobitsisanimportantimplementation weak,andallweakpointerstotheobjectstrong.allthatneedbedoneistoipthe valueofthestrengthbitintheobject. thestrengthofallpointerstoanobject,thatismakingallstrongpointerstotheobject trick,frombrownbridge[bro84,bro85].itmakesveryecienttheoperationofipping 6

whichcontainsoidsfortheobjectswhichhaveazerosrefc,i.e.nostrongpointers incidentonthem.thepersistentrootisneverputintothewrt. TheTCRCalgorithmalsomaintainsanothertable,theWeakReferenceTable(WRT), crashbyscanningtheentiredatabase.therefore,itisnotnecessarytomakeitpersistentandincurtheoverheadofloggingupdatestothesestructures.reconstructingthis informationatcrashwillhoweveraecttheavailabilityofthedatabase.iffastrecovery Alltheaboveinformationcanbeconstructedfromtheobjectgraphafterasystem isrequiredthenwecouldmakethesestructurespersistentatthecostofextralogging. Thechoiceofwhetherornottomakethisinformationpersistentcanbelefttoeach installation. informationtobeupdated/inserted/deleted.thustheirupdateswillbeundoneifthe fromthewrtareloggedaspartofthetransactionwhosepointerupdatecausedthe updateofthestrengthbitofanobjectorofapointer,andtheinsertordeleteofentries Iftheabovestructuresaremadepersistent,thenupdatestoSRefCandWRefC, thismeansthatirrespectiveofwhethertheabovestructuresaremadepersistentthese crashes. transactiondoesnotcomplete,andwillberedone(whilerepeatinghistory)ifthesystem neednotbepersistent. Apartfromtheabovestructures,wehavethefollowingnon-persistentstructures{ whetherthecolouroftheobjectisredorgreen.thistableisstoredondisksincethesize ReferenceTable(RRT);thistableassociateswith(some)objectsastrongredreference count(sredrefc),aweakredreferencecount(wredrefc),andabitthatindicates Thereisanon-persistenttablewhichisusedduringgarbagecollection:theRed ofthistablecouldbelargeintheworstcase,butupdatestothistablearenotlogged. thetemporaryreferencetable(trt),whichcontainsallthoseoidssuchthatareference totheobjectwasaddedordeletedbyanactivetransaction,ortheobjectwascreated bythetransaction.anoidintrtistaggedwiththetidofthetransactionthatis Similarto[AFG95]TCRCalsomaintainsannon-persistentin-memorytablecalled reponsibleforitsinsertionintotrt.theremaybemultipleentriesintrtforthesame oid.anobjectwhoseoidisintrtmaynotbegarbageevenifitisunreachablefrom anyotherobject,sincethetransactionmaystoreareferencetotheobjectbackinthe 4.2 database.updatestotrtarealsonotlogged. TCRCconsistsoftwodistinctalgorithms,runbydierentprocesses.Therstistheloganalyzeralgorithm(LogAnalyzer).Thesecondalgorithmistheactualgarbagecollection TheAlgorithm takenforthedurationofcollectgarbage.wedescribethetwoalgorithmsbelow. algorithm(collectgarbage).theexecutionoftheseissynchronizedbytwolatches:a loganalyzerlatchthatistakenforthedurationofloganalyzer,andagclatchthatis 7

4.2.1LogAnalyzer Thelog-analyzeralgorithmanalyzeslogrecordsgeneratedbythetransaction,andperformsvariousactionsbasedonthelogrecords.Weshallassumeitisrunaspartofthe transactionitself,andisinvokedeachtimealogrecordisappendedtothesystemlog tail,andisatomicwithrespecttotheappendingofthelogrecord. thread,andwhenatransactionappendsalogrecordtothesystemlog,itactuallyonly deliversittothelog-analyzer,whichthenappendsthelogrecordtothesystemlog. Intheactualimplementation,itispossibletorunthelog-analyzerasaseparate IftheSRefCfallstozeroafterthedecrementthentheobject'soidisputintoWRT. decrementsthewrefcorsrefcforanobjectwhenapointertotheobjectisdeleted. ProcedureAddPointer,bydefault,setsthestrengthofthepointertobeweakandincrementstheWRefCoftheobjectpointedto.Thestrengthissettoweaksothatcycles Thelog-analyzermakesuseofthefollowingprocedures.ProcedureDeletePointer (whichisalsoacquiredbythegarbagecollectionthread)toestablishaconsistentpoint makesomenewpointersstrong. ofstrongedgesarenotcreated;however,wewillseeinsection6thatwemaybeableto theloganalyzeranddependingonthetypeofthelogrecordvariousactionsasoutlined inthelog.thelatchisobtainedforthedurationoftheprocedure.thelogisanalyzedby TheprocedureLogAnalyzerworksasfollows.Firstitobtainstheloganalyzerlatch belowaretaken. Forundo/redologrecordscausedbypointerupdates,thereferencecountsforthe aectedobjectsareupdated.thisisdonebydeletepointerincaseofundologs, Forlogrecordscorrespondingtothecreationofobjects,thereferencecountsfor thetrttaggedwiththetidofthetransactionthatmadetheupdate. andaddpointerincaseofredologs.theoidoftheaectedobjectisinsertedinto thenewobjectareinitializedtozero,andtheoidofthecreatedobjectisinserted Forend-of-transaction(commitorabort)logrecords,thealgorithmrsttriesto intothewrt.theoidofthecreatedobjectisinsertedintothetrttaggedwith thetidofthetransactionthatcreatedtheobject. notinprogressandremovealltheoidentriesfortheterminatingtransactionfrom thetrtandthegclatchreleasedthereafter(recallthateachoidentryintrtis taggedwiththetidofthetransactionthatisresponsibleforitspresenceintrt). getthegclatch.ifthelatchisobtainedimmediately,thengarbagecollectionis However,ifthegclatchcannotbeobtainedimmediatelythenagarbagecollectionis Alloperationsonpointerstrengthsandreferencecountsareprotectedbyalatchon inprogressconcurrently.inthiscase,theoidentriesfortheterminatingtransaction arenotremoved,butinsteadaggedforlaterremovalbythegarbagecollector. 8

WRTandTRTarealsoprotectedbylatches. theobjectpointedto,althoughnotexplicitlymentionedinouralgorithms.accessto Property4.1ThepersistentrootisneverplacedintheWRT.Ithasnoreferencesto it.thereforeitneveroccursinthetrtorrrt.2 Thefollowingpropertiesfollowfromtheabovediscussion. when(a)thetransactionhasendedand(b)garbagecollectionisnotinprogress.2 Property4.2TheobjectsinTRTcorrespondingtoatransactionareremovedonly 4.2.2GarbageCollector Thegarbagecollectionalgorithmisactivatedperiodically(possiblydependingonavailabilityoffreespace).Thealgorithmmakesuseofthefollowingsupportfunctions. inrrt.thepseudocodeforredtraverseappearsinfigure1.redtraverseperformsa fuzzylocalizedtraversaloftheobjectgraph.itisinvokedonallobjectsinwrtthatare garbage.therestofthegarbagecollectionalgorithmisrestrictedtoonlytheobjects ProcedureRedTraversepopulatestheRRTwithobjectsitidentiesaspotential notintrt.thereafter,anobjectisvisitedbyanyoftheinvocationsifandonlyifthe objectisnotintrtandalltheobjectsthathaveastrongpointertothisobjecthave beenvisitedearlier.nolocksareobtainedontheobjectsbeingtraversed.shortterm latchesmaybeobtainedonobjectsorpagestoensurephysicalconsistency.redtraverse objectinrrtattheinstantitvisitstheobject.redtraversealsomaintainsforeach objectinrrt,twocounts:sredrefcandwredrefc,givingrespectivelythenumber marksallvisitedobjectsredandputstheminrrt. ofstrongandweakpointerstotheobjectfromallotherobjectsvisited.thesecountsare Additionally,RedTraversecachesthereferencecounts(SRefCandWRefC)ofeach Figure1,theseobjectsarecolouredblue.Fortherestofthepaper,weignorethepresence sincesuchobjectsmaybeaddedtorrtlaterinthetraversal.inthepseudocodeof thesecountsforobjectsthatarereachablebyasingleweakedgefromobjectsinrrt, maintainedontheyduringthetraversal;inordertodoso,redtraversealsomaintains ofblueobjectsinrrt,andassumethattheyareexplicitlyremovedfromrrtafterthe lastinvocationofredtraverse.theinvocationsofredtraversearecollectivelytermedred traversal. objectsinrrtgreenandupdatingsomepointerstrengthstoensurethateveryobject absenceofupdatetransactionsduringthegarbagecollectionphase,noobjectwillbein itvisitshasatleastonestrongpointerreferringtotheobject(thisensuresthatinthe ProcedureGreenTraverseperformsafuzzytraversalwiththepurposeofmarkinglive WRTthusensuringthatthereisnoworktobedoneduringthenextgarbagecollections phase.seetheorem5.11foraformalproofofthisstatement).inaddition,thepointer 9

ProcedureRedTraverse(oid) Input:oid:(oidof)theobjecttobetraversed f gproceduretraverse(oid) ifoidisnotinrrt InsertRRT(oid) Input:oid:(oidof)theobjecttobetraversed f ifoidisnotintrtf foreachpointeroid!poidf colouroidred ifpoidisnotinrrt updatesredrefcpoidandwredrefcpoid ifsredrefcpoid==srefcpoid InsertRRT(poid) dependingonthestrengthofoid!poid g g Traverse(poid) /*thisisthelaststrongpointertopoid*/ Input:oid:(oidof)theobjecttobeinsertedintoRRT gprocedureinsertrrt(oid) f colouroidblue insertoidintorrt g cachecurrentvaluesofsrefcandwrefcforoid insrefcoidandwrefcoidrespectively withsredrefcoid=wredrefcoid=0 Figure1:PseudoCodeforRedTraverse 10

Input:oid:(oidof)theobjecttobetraversed ProcedureGreenTraverse(oid) f colouroidyellow forallpointersoid!poidf gforallpointersoid!poidf ifpoidisinrrtandisnotyellow ifpoidisgreenf GreenTraverse(poid) ifsrefcpoid==0 updatereferencecountsofpoid makeoid!poidstrong(ifweak) getloganalyzerlatch removepoidfromwrt gelsef releaseloganalyzerlatch updatereferencecountsofpoid getloganalyzerlatch releaseloganalyzerlatch makeoid!poidweak(ifstrong) gcolouroidgreen g ifsrefcpoid==0 insertpoidintowrt g Figure2:PseudocodeforGreenTraverse 11

ProcedureCollectGarbage f RRT=fg acquiregclatch /*P0*/ foreachoidinwrtbutnotintrt /*alsocachesthereferencecounts RedTraverse(oid) WaitforalltransactionsinTLISTtoend TLIST=listofalltransactionsactiveatP1 /*P1*/ ofvisitedobjectsinsrefcoidandwrefcoid*/ /*P2:instantwhenalltransactionsinTLISTend*/ L0: foreachoidinrrtbutnotintrtf ifsrefcoid+wrefcoid> /*SRefCoidandWRefCoidreferto cachedreferencecounts*/ ifsrefcoid==0/*oidisinwrt*/ SRedRefCoid+WRedRefCoidf updatereferencecountsofoid invertthestrengthofallreferencestooid getloganalyzerlatch removeoidfromwrt g/*p3*/ g GreenTraverse(oid) releaseloganalyzerlatch L1:foreachoidinRRTthatisredandisinTRT foreachoidinrrtthatisred /*P4*/ GreenTraverse(oid) releasegclatch removeallaggedentriesfromtrt /*P5*/ Collect(oid) g Figure3:PseudoCodeforCollectGarbage 12

strengthupdateshavetobedoneinsuchafashionthatstrongcyclesdonotremainat theendofthegarbagecollectionphase.thepseudocodeforgreentraverseappearsin Figure2.StartingfromtheobjectProcedureGreenTraverseisinvokedon,itvisitsallthe objectsinrrtthatarereachablefromthisobjectinadepthrstmanner:itbacktracks fromanobjectafterithasvisitedallobjectsinrrtreachablefromthatobject.just beforebacktrackingfromanobject,itcolourstheobjectgreenandupdates(ifneeded) thestrengthsofthereferencesoutoftheobject.ifthereferenceistoagreenobject,itis madestrongifitisweak;otherwiseifthereferenceistoanyotherobject(possiblytoan objectnotinrrt)thenitismadeweakifitisstrong.theinvocationsofgreentraverse arecollectivelytermedgreentraversal. pointedto.italsoremovestheobjectfromwrt. oftheobject,updatingthestoredreferencecounts(srefcandwrefc)oftheobjects ProcedureCollectactuallydeletesanobject;beforedoingso,itdeletesallpointersout infigure3.below,wepresentadiscussionofthestepsinvolved.additionally,wepoint outinstancesduringtheexecution(showninthegure)thatwillbereferredintheproof. ThegarbagecollectionalgorithmisimplementedbyProcedureCollectGarbage,shown toterminate. foralltransactionsthatwereactiveatsomepointp1aftertheendoftheredtraversal invokedonallobjectsthatareinwrtbutnotintrt.aftertheredtraversal,wewait Therststepistoacquiregclatch.AtsomepointP0afterthis,RedTraverseis (non-strict)walandarbitrarylockingprotocols.wepresenttheintuitionbelow;the formalproofappearsinsection5. IncaseatransactionTdoesnotfollowstrict-2PLlocking,thefollowingscenariocan Thiswaitisnecessaryforcorrectnessofthealgorithminfaceoftransactionsfollowing inx,andthenreleasesthelockonx.next,allthereferencestoygetdeletedandallthe occur.ttakesalockonsomeobjectx,readsthereferencetoyfromsomepointereld becauseoidofyiscachedbytwhichcaninsertapointertoyfromsomeotherobject transactionsthatmadethedeletionscommit(thiscanhappenbecausethasreleased thelockonx).thismakesyunreachablefromanyliveobject;butyisnotgarbage later.thewaitensuresthatalltransactionssuchastendbeforeanalysisproceeds. insertsthatoccuredduringtheredtraversalareforcedtodiskinadditiontotheundologs forpointerdeletionsbeforeanalysisproceeds;thisisbecauseallthelogsforatransaction are(byassumption)necessarilyforcedbeforetheendofthetransaction.thismakesthe Thewaitfurtherensures,infaceof(non-strict)WAL,thatalltheredologsforpointer alatchonthetransactiontablewhilescanningit.thisissafebecauseonlythefollowing TRTconsistentwithrespecttoanyinsertionordeletionofpointersthatmighthave occuredduringtheredtraversal. endsanddoesnotappearintlist thisisacceptablebecausewewerejustgoingto mayhappenwhilethescanisinprogress:(a)sometransactionthatwasactiveatp1 ThelistoftransactionsTLISTcanbedeterminedfuzzily thatis,weneednottake 13

waitforittoendanyway;or(b)somesometransactionstartsafterp1anditsentry appearsintlist thisisacceptablebecausethiscanonlyextendthewait.p2isthe GreenTraverseisinvokedonanobjectthatisinRRTbutnotinTRTifthetotalred instantwhenallthetransactionsintlistterminate. traversalisstrictlylessthanitstotalreferencecounts(srefc+wrefc)thatare referencecounts(sredrefc+wredrefc)fortheobjectcomputedduringthered Next,wedogreentraversaltomarkgreenallthelivenodesinRRT.AfterP2, countsupdatedatomicallywithrespecttothelog-analyzer(loganalyzerlatchisusedfor theinvocation,thestrengthsofallreferencestothisobjectareinvertedandthereference proof,theseobjectsarelive:theyarereferredfromsomeobjectnotinrrt.butbefore cachedduringtheredtraversal(ascheckedinstatementl0).aswillbeshowninthe ensurethatinabsenceofupdatetransactionsnoworkwillbedonebythenextgarbage collectionphaseisover,therewillbeatleastonestrongpointertotheobject(noticethat thispurpose).theinversionofstrengthsisnecessarytoensurethatafterthisgarbage mightcausestrongcyclestobeformed.but,asprovedinlemma5.8,thesewillnot allreferencestotheobjectfromobjectsnotinrrtmustbeweak).thisisnecessaryto collectionsphase;thisisformallyprovedintheorem5.11.thisinversionofstrengths existafterthisgarbagecollectionphaseisover. aboveobjectsarealsomarkedgreen,byinvokinggreentraverse.theseinvocationsget andcanpotentiallybestoredbackinthedatabase.objectsthatarereachablefromthe alsomarkedgreensincetheirreferencesmaystillbestoredinanongoingtransaction AftertheaboveinvocationscompleteatP3,anyobjectsinRRTthatareinTRTare overatp4. GreenTraverseonredobjectsthathavebeeninsertedintoTRTsincetheywerechecked followingsimpleprocedureisenough.wemakerepeatedscansoftherrt,invoking obtainedsuchthatatthispoint,noredobjectinrrtisintrt.itturnsoutthatthe Inthepseudocode,wehaveleftunspeciedhow(atstepL1)theconsistentpointis inthepreviousscan;andterminatingwhenwecomeacrossnosuchobjectinthelatest scan.theconsistentpointcorrespondstotheinstantthelastscanstarts.thisisbecause intrtduringthelastscan acontradiction. ifsomeobjectinrrtisredandisintrtatthestartofthelastscan,thenduringthe staysintrtbecauseofproperty4.2(b).butthen,itmustbedetectedtoberedand scanitstaysredbecauseofthefactthatgreentraverseisnotinvokedintheinterim;and is,sincegclatchwasacquired)areremoved. removablebytransactionsthatcompletedsincethegarbagecollectionphasebegan(that atp5.finally,thegclatchisreleasedandalltheentriesintrtthatweretaggedas AllobjectsinRRTthatareredatP4arecollectednext.Thecollectiongetsover 14

4.2.3SupportforLogicalUndobytheRecoveryManager TheTCRCalgorithmneedssomesupportfromtherecoverymanagerintheformof supportinglogicalundostoensurecorrectness.thissupportisrequiredonlyifwechoose tomaintainthereferencecounts,pointerstrengthsandwrtpersistent.therearesome actionswhoseundoshavetobeperformedlogicallyandnotphysically.wediscussthem belowanddiscusswhatthelogicalundoshoulddoineachcase: thepointerwiththestrengthsettobeweak(evenifitwasstrongearlier).similarly, thecorrectnessofthealgorithm.therightwaytoundoapointerdeletionistoreinsert update,ifperformednaively,mayintroducestrongcyclesinthegraph,whichcanaect PointerDeletionandStrengthUpdate:Undoofapointerdeletionorstrength theundoofapointerstrengthupdate(doneincaseofsystemcrashduringthegarbage strength). collectionphase)istosetthestrengthofthepointerasweak(irrespectiveoftheoriginal entobjectswhicharelockedbythetransactions.theobjectoitselfneednotbelocked sinceonlyareferencetoitisbeingupdated.onlyshorttermlatchesarenecessaryfor rentlyupdatedbymultipletransactions(includingthegarbagecollector)throughdier- ReferenceCountsUpdate:ThereferencecountsofanobjectOcanbeconcur- maintainingphysicalconsistency.ifatransactionthatupdatedthereferencecountofan objectaborts,itshouldbelogicallyundone:theundoofareferencecountincrementis isalwaysanincrementofwrefcsinceareinsertedpointerisalwaysweak. adecrementofthesamereferencecount,whiletheundoofareferencecountdecrement Weformallystatethedenitionofagarbageobject. 5 ProofofCorrectness reachablefromthepersistentrootorfromanyobjectinthetrtorfromanyobject Denition5.1(GarbageObject) whosereference(oid)hasbeenreadbyanyactivetransaction.2 Anobjectisdenedtobegarbageifitisnot doesnotsatisfytheotherconditionsandthereforeisgarbageintheconventionalsense. NotethateventuallyanobjectthatisgarbageintheconventionalsensewillleaveTRT andanyactivetransactionthatreadareferencetoitwillterminateandthuswillbecome TheabovedenitionconsidersanobjectasliveifitisreachablefromTRT,evenifit theabovedenition. garbageinthesenseofdenition5.1.ourlemmasandproofsaresimpliedbyusing 5.1 AtanyinstantbetweenP1andP4,anobjectxinRRTisinoneofthefollowingthree states: ObjectStates 15

S1:xisreachablefromanobjectoutsideRRTbutisnotreachable,throughapath S2:xisreachable,throughapathconsistingentirelyofobjectsinRRT,fromanobject consistingonlyofobjectsinrrt,fromanyobjectthatisinrrtandalsointrt. S3:xisneitherinstateS1norinstateS2,thatisxisneitherreachablefromanyobject outsiderrtnorfromanyobjectinrrtthatisalsointrt. inrrtthatisalsointrt. Intheabove,anobjectisassumedtobereachablefromitselfthroughanullpath. leavingoidsinwrtwhichwillbetraversedbyanothergarbagecollectionphase,which iteventuallycollectsallgarbageobjects. Abadlydesignedgarbagecollectionalgorithmcouldcreateinniteworkforitself,by WeneedtoprovethatTCRCissafe:itdoesnotcollectanyliveobjects;andcomplete: TCRC;thatis,intheabsenceofupdatetransactions,thesystemeventuallyreachesa inturnleavesoidsinwrt,adinnitum.weguaranteethatthisdoesnothappenin statewheregarbagecollectionthreaddoesnomorework. Lemma5.1IfatransactionnotinTLISTactiveataninstantPstrictlybetweenP1 resultsthatfollow. Wewillmakeuseofthefollowingpropertiesofthealgorithmintheproofofthe andp2hasreadareferencetoanobjectthatisinstates3atp,thentheobjectisin states2atp2. Proof:SupposesometransactionTnotinTLISTisactiveatPandhasreadareference tosomeobjectthatisinstates3atpbutnotinstates2atp2.letxbetherstsuch objecttowhichareferenceisreadbyt.also,letp0betheinstantwhentreadsthe rstobjectythathasareferencetox. possible: Case1:ThereferencefromytoxispresentatP. ThereferencefromytoxwaspresentatP0.Eitherofthefollowingtwocasesare T.Therefore,yisinstateS2atP2.IfthereferencefromytoxispresentatP2, thatisinstates3atpbutnotinstates2atp2areferencetowhichwasreadby toywasreadbytbeforethereferencetox.recallthatxwastherstobject SincexisinstateS3atP,ymustalsobeinstateS3atP.Denitely,areference betweenpandp2,thenbyassumption3.1andproperty4.2(b)xisintrt,and henceinstates2,atp2. thenxisinstates2atp2.otherwise,ifthereferencefromytoxhasbeendeleted Case2:ThereferencefromytoxisnotpresentatP. tion3.1,thelogfortheabovedeletionmusthavebeenanalyzedbetweenp0and ThereferencefromytoxhasbeendeletedbetweenP0andP.BecauseofAssump- 16

TheaboveimpliesthatxmustbeinstateS2atP2.Provedbycontradiction.2 Property4.2(b),xmustbeinTRT,andhenceinstateS2,atP. P.P0occuredafterP1becauseTcouldnothavebeenactiveatP1.Therefore,by transactionactiveatpcouldhavereadareferencetoit. Proof:SupposesometransactionTisactiveatPandhasreadareferencetosome Lemma5.2IfanobjectisinstateS3ataninstantPbetweenP2andP4,thenno byt.also,letp0betheinstantwhentreadstherstobjectythathasareferenceto x.denitely,areferencetoywasreadbytbeforethereferencetox.recallthatx objectthatisinstates3atp.letxbetherstsuchobjecttowhichareferenceisread P.ButitwaspresentatP0. instates3atp.sincexisinstates3atp,thereferencefromytoxisnotpresentat wastherstobjectinstates3areferencetowhichwasreadbyt.therefore,yisnot P0occuredafterP1becauseTcouldnothavebeenactiveatP1.Therefore,byProperty4.2(b),xmustbeinTRTatP,andthereforecannotbeinstateS3atP.Proved ThereferencefromytoxhasbeendeletedbetweenP0andP.BecauseofAssumption3.1,thelogfortheabovedeletionmusthavebeenanalyzedbetweenP0andP. bycontradiction.2 Lemma5.3IfanobjectvisinRRTbutisnotinTRTatP2,then(a)noreference tovisupdated(insertedordeleted)betweenp0andp1;and(b)allreferencestovthat Proof:NologcorrespondingtoanupdateofareferencetovthatoccursbeforeP1is redtraversal. existbetweenp0andp1areaccountedinthetotalreferencecountsofvcachedduring endbeforep2.therefore,byassumption3.2,thelogmustbeanalyzedbeforep2.but then,byproperty4.2(b),vwouldbeintrtatp2 acontradiction. analyzedafterp0.thisisbecausethetransactionthatisresponsiblefortheupdatemust andp1,considertheinstantwhenthelogforthereferenceupdateisanalyzed.asshown above,thismustoccurbeforep0.butthen,becausethetransactionisactiveatpby Property4.2(a)visinTRTatP,andthereforeisinTRTatP2byProperty4.2(b),a SupposeanupdateofsomereferencetovtakesplaceatsomeinstantPbetweenP0 oftheunaccountedreferenceisanalyzedatsomeinstantafterp0,acontradiction.the contradiction.thisprovespart(a)ofthelemma. countsofvatp0.thisisbecauseotherwiseitmustbethatthelogfortheinsertion totalreferencecountsforvmusthaveremainedunchangedbetweenp0andtheinstant AllreferencestovthatexistbetweenP0andP1areaccountedinthetotalreference whentheyarecachedduringtheredtraversal,againbecauseofthefactthatnologis 2analyzedintheinterimthatcancausethechange.Thisimpliespart(b)ofthelemma. 17

Lemma5.4IfanobjectinRRTisinstateS1atP2,thenitisreachablefromsome inrrtatp0.now,considertheinstantpwhentherstpathtoxfromsomeobjectnot Proof:SupposethatanobjectxinstateS1atP2isnotreachablefromanyobjectnot objectnotinrrtatp0. inrrtwascreated.lettheinsertionofthereferencefromobjectytoobjectzthatisin beinstates2atp2byassumption3.1andproperty4.2(b),whichisacontradiction. entirelyofobjectsinrrt.thispathremainsintacttillp2becauseotherwisexwould RRTberesponsibleforthesame.Then,atP,thereexistsapathfromztoxconsisting endbeforep2andthereforebecauseofassumption3.2andproperty4.2,zwouldbein startedafterp1. TRTatP2.ButthenxwouldbeinstateS2atP2leadingtoacontradiction.Thus,T IfthetransactionTthatmadetheaboveinsertionexistedbeforeP1,thenitwould havereadareferencetoz.butsincezisunreachablefromanyobjectnotinrrtor fromanyobjectintrtatp0,itmustbeinstates3atp0.butthen,bylemma5.1,z (andhencex)mustbeinstates2atp2,leadingtoacontradiction.2 ThisimpliesthatPoccuredafterP1.AtsomeinstantP0betweenP1andP,Tmust garbagecollection. Lemma5.5IfanobjectinRRTisinstateS3atsomeinstantPbetweenP2andP4, Thefollowingresultstatestherestrictionsonthestatetransitionofobjectsduring atransitiontosomeotherstateimmediatelyafterp. Proof:SupposethatanobjectxinstateS3atsomeinstantPbetweenP2andP4makes thenitremainsinstates3betweenpandp4. ofstates3,noobjectinaliesoutsiderrt.moreover,atpnoobjectinaisreachable xwouldalsobereachablefromthisobjectatpandthereforenotbeinstates3.this fromanobjectoutsiderrtorfromanobjectinrrtthatisalsointrt otherwise LetthesetAcontainalltheobjectsfromwhomxisreachableatP.Bydenition impliesthatallobjectsinaareinstates3atp. A;theinstantPcorrespondstotheoccurenceoftheupdateitself,ortheanalysisof thelogfortheupdate whicheverisearlier.thetransactiontthatisresponsiblefor theupdatemusthaveobtainedareferencetoybeforeitisabletomaketheupdateor Thetransitionofstatemustbeduetoanupdateofareferencetosomeobjectyin yisinstates3atpasshownabove.provedbycontradiction.2 P.BecauseofAssumption3.2,TisactiveatP.ButthiscontradictsLemma5.2because generatealogforthesame.inotherwords,tmusthaveobtainedareferencetoybefore Lemma5.6AtP4,anobjectinRRTisrediitisinstateS3. Next,weproveaninvariantofthealgorithm. 18

ByLemma5.5,xisnotinstateS3atP2. Proof:(Onlyif)SupposethatatP4,anobjectxinRRTisredandisnotinstateS3. intrtaregreen.twocasesarepossible. leadingtoterminationofthefor-loop.atp,therefore,allobjectsinrrtthatarealso ConsidertheinstantPwhentheconditioninthestatementL1evaluatestofalse Case1:xisinstateS1atP2. Then,byLemma5.4,itisreachablefromsomeobjectnotinRRTatP0.Letthe butvisinrrt.now,twosubcasesarepossible. Case1.1:ThepathfromutoxisintactbetweenP0andP. referencefromobjectutoobjectvbealongthepathsuchthatuisnotinrrt accountedintheredreferencecountsofv.thus,thecachedtotalreference accountedintheredreferencecountsofvareaccountedinthecachedtotal referencecountsofv.sinceuisnotinrrt,thereferencefromutovisnot ByLemma5.3(b),thereferencefromutovaswellasthereferencesthatare countsofvarestrictlygreaterthantheredreferencecountsofv. SincevisinRRTbutnotinTRT,statementL0willbeexecutedforv.For andisintactatthispoint,xwillbecolouredgreen(ifnotalreadyso). beinvokedonv.sincethepathfromvtoxconsistsofonlyobjectsinrrt thereasonsstatedabove,theconditionwillbesatisedandgreentraversewill Case1.2:ThepathfromutoxisbrokenbetweenP0andP. (ymightbethesameasx).beingintrt,ymustbegreenatp.butsincethe thepathisdeletedbetweenp0andp,butthepathfromytoxisintactatp pathfromytoxisintactbetweenp0andp,theinvocationofgreentraverse ConsidertheobjectyalongthepathatP0suchthatthereferencetoyalong Case2:xisinstateS2atP2. Thatis,atP2thereexistedapath,consistingonlyofobjectsinRRT,toxfrom thatcolouredygreenmustalsohavecolouredxgreen(ifnotalreadyso). someobjectinrrtthatisalsointrt.thepathcouldhavebrokenbetweenp2 andp.therestoftheproofissimilartocase1.2above.considertheobjecty alongthepathatp2suchthatthereferencetoyalongthepathisdeletedbetween P2andP,butthepathfromytoxisintactatP(ymightbethesameasx). BeinginTRT,ymustbegreenatP.Butsincethepathfromytoxisintact TheaboveimpliesthatxisgreenatP,andthereforeatP4 acontradiction.this betweenp2andp,theinvocationofgreentraversethatcolouredygreenmustalso provesthatxmustbeinstates3atp4.2 havecolouredxgreen(ifnotalreadyso). colouringgreensomeobjectythatisinstates3atp4. Proof:(If)Supposethatagreentraversalinvokedatsomeobjectxwasresponsiblefor 19

atp4 otherwiseywouldbeinstates2atp4byassumption3.1andproperty4.2(b). atthetimeoftheinvocation. Therefore,xmustalsobeinstateS3atP4.Inparticular,xcouldnothavebeeninTRT Thepathfromxtoythatexistedatthetimeofthegreentraversalmustbeintact conditioninstatementl0musthaveevaluatedtotruewhenitwasexecutedforx.that forx.thiscanonlyoccurifareferencefromsomeobjectztoxthatexisted(asper is,theredreferencecountsforxarestrictlylessthanthecachedtotalreferencecounts Butthen,theonlywaygreentraversalcouldhavebeeninvokedonxisthatthe thecachedtotalreferencecountsofx,bylemma5.3(b))betweenp0andp1wasnot traversedintheredtraversalandthereforeisnotaccountedintheredreferencecounts ofxḃylemma5.3(a),noupdateofanyreferencetoxtakesplacebetweenp0andp1. ThisimpliesthatthereferencefromztoxexistedatP0.Moreover,thisreferencecould nothavebeendeletedbetweenp0andp4,otherwisebyassumption3.1andproperty4.2 xwouldbeintrtatp4,acontradiction.thisfurtherimpliesthatzmustbeinrrt, otherwisexwouldnotbeins3atp4. thereferencefromztoxexistedatp0anditdidnotgetdeletedbetweenp0andp1. Butthen,thereferencewouldhavebeenaccountedintheredreferencecountsofv a contradiction.2 Now,weknowthatzwasvisitedbytheredtraversalbetweenP0andP1.Also, Theorem5.7(Safety)OnlygarbageobjectsarecollectedbyCollectGarbage. Theresultsstatedaboveareputtogetherintheformofthefollowingtheorem. Proof:AtP4,allredobjectsareinstateS3byLemma5.6.BydenitionofthestateS3, theseobjectsarenotreachablefrom(a)anyobjectnotinrrt.thisimpliesthatthey arenotreachablefromthepersistentroot(whichisneverinrrtbyproperty4.1)or fromanyobjectintrtnotinrrt;(b)anyobjectintrtthatisinrrt.therefore, theseobjectareneitherreachablefromthepersistentrootnorfromanyobjectintrt. ByLemma5.2,noreferencetoanyoftheseobjectshasbeenreadbyanytransaction activeatp4. Thisimplies,bydenition,thatallobjectsthatareredatP4aregarbage.Sinceonly AllobjectsfromwhichanobjectinstateS3isreachableatP4areinstateS3atP4. theseobjectsarecollectedbycollectgarbage,thetheoremisproved.2 Forthis,wefurtherneedthefollowingresults. Lemma5.8AcycleofstrongreferencescanexistonlybetweenP2andP5. Next,weprovethatTCRCiscomplete thatis,itcollectsallgarbageeventually. Proof:CollectGarbagechangesthereferencestrengthsonlybetweenP2andP5.Transactionscanonlydeletestrongreferences theyneverchangepointerstrengthsorinsert 20

strongpointers.weassumethatthereexistnocyclesofstrongreferenceswhentheobjectsareloaded.therefore,itissucienttoprovethatifthereexistnocyclesofstrong P5.SincetherearenocyclesofstrongreferencesatP2,wecannothaveacycleofstrong referencesatp2thenthereexistnocyclesofstrongreferencesatp5. referencesthatdoesnotcontainanobjectinrrtatp5. OnlythestrengthsofreferencesfromobjectsinRRTarechangedbetweenP2and xtoyaremadeweakduringthetraversal.thus,atp5thereexistnocyclesofstrong beforeitbacktrackedfromy.then,allreferencesfromytoxaremadestrongandfrom referencescontainingonlygreenobjects. Considertwogreenobjectsxandysuchthatthegreentraversalbacktrackedfromx RRTweak.ThisfurtherguaranteesthatthereexistnocyclesofstrongreferencesatP5 musthaveredobjects. ButallredobjectsatP4arecollectedasgarbagebeforeP5.Thisprovesthatthere Also,thegreentraversalmakesallreferencesfromgreenobjectstoobjectsnotin existnocyclescontainingstrongreferencesatp5.2 AsuchthatanobjectcomesafterallobjectsthathaveastrongreferencetoitatP0. Proof:LetAbethesetofallgarbageobjectsatP0.Wexanorderontheobjectsin Lemma5.9IfanobjectisgarbageP0thenitisinstateS3atP4. ThisispossiblebecausebyLemma5.8,cyclesofstrongreferencescannotexistatP0. Thereafter,itputsanobjectinRRTifitisnotinTRTandallobjectswhichhavestrong referencestothisobjectareinrrt. RecallthatredtraversalputsinRRTallobjectsinWRTthatarenotinTRT. Case1:TheredonotexistanystrongreferencestoxatP0.ButthenxisinWRT betwocasespossible. LetxbetherstobjectintheaboveorderingthatisnotinRRTatP2.Therecan atp0andnotintrtbecauseitisgarbage.beinggarbage,itremainsthatway Case2:ThereexiststrongreferencestoxatP0.SincexisgarbageatP0,allobjects invokedonit.thus,itmustbeincludedinrrt. duringthecourseoftheredtraversal,andthereforeredtraversemustbehavebeen thathaveastrongreferencetoxmustbegarbageatp0.butthen,theymustbe ina,andmustoccurbeforexintheordering.bythechoiceofx,alltheseobjects TheaboveimpliesthatxmustbeinRRTatP2 acontradiction.thisprovesthatall mustbeinrrtatp2.also,xisnotintrtbecauseitisgarbage.therefore,it objectsinaareinrrtatp2.further,noneoftheseobjects(whicharegarbageatp0) mustbeincludedinrrtduringtheredtraversal. arereachablefromobjectsnotinrrtatp2(whichareliveatp0).moreover,noneof 21

theseobjects,beinggarbagealsoatp2,arereachablefromobjectsthatareintrtat P2.Puttingtheabovetogether,weseethatallobjectsinAareinstateS3atP2. lemma.2 Theorem5.10(Completeness)AllgarbageobjectsareeventuallycollectedbyCollectGarbage. Proof:ByLemma5.9andLemma5.6,agarbageobjectwillbecolouredredatP4in therstcollectgarbageinvokedafteritbecamegarbageandthereforewillbecollected. 2Theorem5.11(BoundedWork) concurrentlyexecutingupdatetransactions,wrtwillbeemptyatp5. Proof:Sincetherearenotransactionupdatesexecutingconcurrentlywiththegarbage IfTRTisemptyatP0theninabsenceofany Butthen,byLemma5.5,allobjectsinAmustbeinstateS3atP4.Thisprovesthe lection. collection,thestrengthofallreferencesremainssameduringthecourseofgarbagecol- traversal.sincethisstrongreferenceisnottraversedbyduringthegreentraversal,it someobjectnotinrrt otherwisexwouldhavebeenincludedinrrtduringred referencefromsomeobjectinrrt,thenxmusthaveatleastonestrongreferencefrom First,weconsiderobjectsnotinRRT.IfanobjectxnotinRRTthathasastrong inrrtisnotinwrtatp5. isnevermadeweakbythegarbagecollector.further,sinceonlyobjectsinrrtget deleted,thereferencenevergetsdeletedeither.thisimpliesthatanyobjectthatisnot onestrongreferencetothemfromothergreenobjectsatp4. Thus,allgreenobjectsexcepttheonesonwhichthetraversalisinvokedhaveatleast traversedobjecttoasyetuntraversedobjectsinrrtstrongbeforetraversingthelatter. WeconsidertheobjectsinRRTnext.Thegreentraversalmakesthereferencesfroma traversalonit,thereferencestoitfromobjectsnotinrrtbecomestrong.because whenthestrengthsofreferencestoanobjectareinvertedbeforeinvocationofgreen referencesfromoutsiderrt.byconstruction,allthesereferencesareweak.therefore, BecausenoobjectisinTRT,greentraversalisstartedonlyonobjectswhichhave thesereferencesarenevertraversedduringthegreentraversal,theyarestrongatp4. collected,resultingindeletionofreferencesfromredobjectstogreenobjects.butfrom theresultsprovedabove,thesereferencedeletionscannotputanygreenobjectintowrt. greenobjectorfromanobjectnotinrrtatp4.betweenp4andp5,redobjectsare Summarizing,everygreenobjecthasatleastonestrongreferencetoitfromanother Thus,nogreenobjectisinWRTatP5. alltheobjectsbecausetheredonotexistanyredobjectsatp5.thus,itisprovedthat noobjectisinwrtatp5inabsenceoftransactionupdates.2 Thus,nogreenobjectorobjectnotinRRTisinWRTatP5.Butthisaccountsfor 22

latterinvocation;andthereforebylemma5.11thewrtwillbeemptyattheendof thesecondinvocation. CollectGarbagetotheendofthenext,thenTRTwillbeemptyatthebeginningofthe Inparticular,ifnoupdatetransactionsexistfromthebeginningofoneinvocationof WenowseehowtouseinformationfromthedatabaseschematooptimizeTCRC.The schemagraphisadirectedgraphinwhichthethenodesaretheclassesintheschema. 6 UsingtheSchemaGraph forthepointersbetweentheactualinstancesoftheobjects. AnedgefromnodeitonodejintheschemagraphdenotesthatClassihasanattribute graphisnotinvolvedinacycle,thenneithercananedgeeintheobjectgraphforwhich Eisthetemplate. thatisareferencetoclassj.thepointersintheschemagraphthusformatemplate Welabeledgeswhicharenotpartofacycleintheschemagraphasacyclicand IfanedgeEinaschema templateedgeintheschemagraphisacyclic,thestrengthofeissettobestrong.during garbagecollection,inredtraverse,wedonotfollowstrongedgeswhosetemplateedgeis theothersascyclic.whenaddinganedgeetotheobjectgraph,ifitscorresponding andtcrcbehavesjustlikereferencecounting,reducingthecostsignicantly. acyclic.intheextremecasewheretheschemagraphisacyclic,noedgesaretraversed, 7Inthissection,weoutlinethesetofassumptionsrequiredforouralgorithmtowork correctlyinadatashippingclientserverenvironment. ExtensiontoaClientServerEnvironment Assumption7.1Thetransactionsrunonlyattheclients.Theservercandetermine actionsrunningatanyclientalwaysseethelateststateofthedatabase.2 Assumption7.2Cacheconsistencyisguaranteedamongtheclients.Thatis,thetrans- whattransactionsarearepossiblyactiveattheclientsatanygiveninstant.2 attheserver(wal).2 Assumption7.3Allundorecordsarereceivedtheserverbeforetheupdateisreected Thisallowsustothinkofthetransactionsasrunningonasingleclient. abort(force-logs-at-abortinadditiontoforce-logs-at-commit).2 Assumption7.4Alllogsforatransactionarereceivedattheserverbeforecommitor 23

dataafterithasbeensenttotheserver. andwhetherornotdataiscachedattheclient.theclientscanretaincopiesofupdated Toguaranteethatthealgorithmworkscorrectlyintheclient-serversettingwiththe Ourtechniquesarenotaectedbytheunitofdatashipping(suchaspageorobject) aboveassumptions,theonlychangerequiredinthealgorithmisthefollowinggeneralizationofproperty4.2. when(a)thetransactionhasended;(b)allupdatesbythetransactionarereectedat Property7.1TheobjectsinTRTcorrespondingtoatransactionareremovedonly theserver;and(c)garbagecollectionisnotinprogressattheserver.2 Becausethedatabasestateattheserver(wherethegarbagecollectorisrunning)isnot current,itmighthappenthatanobjectmayhaveareferencetosomenewlycreated server.assuch,someextracarehastobetakenduringtraversalsoftheobjectgraph. NotethattheLogAnalyzeraswellastheCollectGarbagealgorithmsarerunatthe objectthatisnotyetpresentattheserver.suchadanglingreferenceissimplyignored duringthetraversals. referthereaderto[rss+98]foraproof. Wecanprovethecorrectnessofthealgorithmintheclientserversettingalsoand algorithmonanobjectmanagercalledbrahmadevelopedatiitbombay.brahma WeimplementedtheTCRCalgorithmandthePartitionedMarkandSweep(PMS) 8 PerformanceEvaluation supportsconcurrenttransactionsandhasacompleteimplementationofthearies recoveryalgorithm.itprovidesextendiblehashindicesaswellasb+-treeindicesas thetid(toalloweasydeletionofallentriesofatransaction). additionalaccessmechanisms. ontheoidwhilethetrtisanin-memoryhashtableindexedseparatelyontheoidand TheWRTisimplementedasanoptionallypersistentextendiblehashtableindexed onlypersistentstructuresrequiredbypmsareoneincomingreferencelist(irl)per SRefCandWRefCarestoredinanoptionallypersistenton-diskhashtable.The partitionwhichismaintainedasapersistentb+-tree. Thereferencecounts Inparticular,weworkedonthestandardsmall-9datasetinOO7whichwasalsoused in[yny94]fortheirsimulationstudy.theoo7parametersandtheirvaluesforthis datasetaregivenintable1andareexplainedbelow.figure4illustratestheoo7 OurperformancestudyinthissectionisbasedonthestandardOO7benchmark[CDN93]. Eachmoduleconsistsofatreeofobjectscalledassemblies.Thetreeisacompletetree benchmark. withafanoutofnumassmperassmandhasnumassmlevelslevels.thelast TheOO7datasetiscomposedofanumberofmodules,speciedbyNUMMODULES. 24

Module i id type builddate manual design_root Manual text complex assemblies base assemblies 1 2 3 4 N Design Library of Composite Parts Figure4:TheOO7Benchmark 25