Two-phase locking

In databases and transaction processing, two-phase locking (2PL) is a pessimistic concurrency control method that guarantees conflict-serializability.[1][2] It is also the name of the resulting set of database transaction schedules (histories). The protocol uses locks, applied by a transaction to data, which may block (interpreted as signals to stop) other transactions from accessing the same data during the transaction's life.

By the 2PL protocol, locks are applied and removed in two phases:

  1. Expanding phase: locks are acquired and no locks are released.
  2. Shrinking phase: locks are released and no locks are acquired.

Two types of locks are used by the basic protocol: Shared and Exclusive locks. Refinements of the basic protocol may use more lock types. Using locks that block processes, 2PL, S2PL, and SS2PL may be subject to deadlocks that result from the mutual blocking of two or more transactions.

Read and write locks

Locks are used to guarantee serializability. A transaction is holding a lock on an object if that transaction has acquired a lock on that object which has not yet been released.

For 2PL, the only used data-access locks are read-locks (shared locks) and write-locks (exclusive locks). Below are the rules for read-locks and write-locks:

  • A transaction is allowed to read an object if and only if it is holding a read-lock or write-lock on that object.
  • A transaction is allowed to write an object if and only if it is holding a write-lock on that object.
  • A schedule (i.e., a set of transactions) is allowed to hold multiple locks on the same object simultaneously if and only if none of those locks are write-locks. If a disallowed lock attempts on being held simultaneously, it will be blocked.
Lock compatibility table
Lock type read-lock write-lock
read-lock X
write-lock X X

Variants

guarantees conflict-serializability guarantees view-serializability eliminates deadlocks guarantees recoverability guarantees strictness prevents phantom reads prevents dirty reads
2PL Yes No No No No No No
C2PL Yes Yes[citation needed] Yes yes?[citation needed] yes?[citation needed] No[citation needed] Yes[citation needed]
S2PL Yes No No Yes Yes Yes Yes
SS2PL Yes No No Yes Yes Yes Yes

Two-phase locking

According to the two-phase locking protocol, each transaction handles its locks in two distinct, consecutive phases during the transaction's execution:

  1. Expanding phase (aka Growing phase): locks are acquired and no locks are released (the number of locks can only increase).
  2. Shrinking phase (aka Contracting phase): locks are released and no locks are acquired.

The two phase locking rules can be summarized as: each transaction must never acquire a lock after it has released a lock. The serializability property is guaranteed for a schedule with transactions that obey this rule.

Typically, without explicit knowledge in a transaction on end of phase 1, the rule is safely determined only when a transaction has completed processing and requested commit. In this case, all the locks can be released at once (phase 2).

Conservative two-phase locking

The difference between 2PL and C2PL is that C2PL's transactions obtain all the locks they need before the transactions begin. This is to ensure that a transaction that already holds some locks will not block waiting for other locks. Conservative 2PL prevents deadlocks.

Strict two-phase locking

To comply with the strict two-phase locking (S2PL) protocol, a transaction needs to comply with 2PL, and release its write (exclusive) locks only after the transaction has ended (i.e., either committed or aborted). On the other hand, read (shared) locks are released regularly during the shrinking phase.

Unlike 2PL, S2PL provides strictness (a special case of cascade-less recoverability). This protocol is not appropriate in B-trees because it causes Bottleneck (while B-trees always starts searching from the parent root). [citation needed]

Strong strict two-phase locking

or Rigorousness, or Rigorous scheduling, or Rigorous two-phase locking

To comply with strong strict two-phase locking (SS2PL), a transaction's read and write locks are released only after that transaction has ended (i.e., either committed or aborted). A transaction obeying SS2PL has only a phase 1 and lacks a phase 2 until the transaction has completed. Every SS2PL schedule is also an S2PL schedule, but not vice versa.

See also

References

  1. ^ Philip A. Bernstein, Vassos Hadzilacos, Nathan Goodman (1987): Concurrency Control and Recovery in Database Systems, Addison Wesley Publishing Company, ISBN 0-201-10715-5
  2. ^ Gerhard Weikum, Gottfried Vossen (2001): Transactional Information Systems, Elsevier, ISBN 1-55860-508-8

Read other articles:

2011 film by Steven Spielberg War HorseTheatrical release posterDirected bySteven SpielbergScreenplay by Lee Hall Richard Curtis Based on War Horse (novel)by Michael Morpurgo War Horse (play)by Nick Stafford Produced by Steven Spielberg Kathleen Kennedy Starring Emily Watson David Thewlis Peter Mullan Niels Arestrup Jeremy Irvine CinematographyJanusz KamińskiEdited byMichael KahnMusic byJohn WilliamsProductioncompanies DreamWorks Pictures[1] Reliance Entertainment[1] Amblin Ente…

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Oktober 2022. BonepriceIndustriPortal Perbandingan HargaDidirikanOktober 2014 (Beta) Februari 2015 (Official)KantorpusatDKI Jakarta, IndonesiaPemilikBoneprice Metatech IndonesiaSitus webhttp://www.boneprice.com/ Boneprice merupakan layanan portal shopping search engine…

Batu RajaDesaNegara IndonesiaProvinsiLampungKabupatenPesawaranKecamatanPunduh PidadaKode Kemendagri18.09.06.2003 Luas... km²Jumlah penduduk1535 jiwaKepadatan... jiwa/km² Untuk tempat lain yang bernama sama, lihat Batu Raja. Batu Raja adalah desa di kecamatan Punduh Pidada, Kabupaten Pesawaran, Lampung, Indonesia. Desa Batu Raja Terdiri Dari 6 Dusun yaitu Dusun Batu Raja Induk, Dusun Curup Jaya, Dusun Pematang Ulai, Dusun Bayu Rampit, Dusun Panglon Dan Dusun Harapan Jaya. Total Jumlah Kk D…

Wilayah III (Siantar - Simalungun - Tebing - Sergai)GKPI Jemaat Khusus Siantar KotaGerejaGereja Kristen Protestan IndonesiaKantorKota PematangsiantarWilayah pelayananKabupaten Serdang Bedagai Kabupaten Simalungun Kota Pematangsiantar Kota Tebing TinggiRessort15[1]Jemaat khusus11[1]Gereja120[1]Jumlah anggota jemaat29.760 jiwa[1] Rumah tangga6.718 KKPelayanKoordinatorPdt. Ebed Nainggolan[1][2]Penatua852[1] GKPI Wilayah III (Siantar - Simalung…

SantoDioskorus AgungThe Champion of OrthodoxyPaus Aleksandria ke-25 & Patriarkh Tahta St. MarkusAwal masa jabatan444Masa jabatan berakhirSeptember 454PendahuluKirilos Pilar KepercayaanPenerusTimotius IIInformasi pribadiLahirMesirWafatSeptember 454MakamPulau Gangra, PaphlagoniaKewarganegaraanMesirDenominasiKristen Ortodoks KoptikKediamanGereja Santo MarkusOrang kudusHari heringatan7 Thout dalam Kalender Koptik[1] (4 September dalam Kalender Julian) (17 September dalam Kalender Gregori…

Resolusi 1154Dewan Keamanan PBBIbukota Irak BaghdadTanggal2 Maret 1998Sidang no.3.858KodeS/RES/1154 (Dokumen)TopikSituasi di Irak dan KuwaitRingkasan hasil15 mendukungTidak ada menentangTidak ada abstainHasilDiadopsiKomposisi Dewan KeamananAnggota tetap Tiongkok Prancis Rusia Britania Raya Amerika SerikatAnggota tidak tetap Bahrain Brasil Kosta Rika Gabon Gambia Jepang Kenya Portugal Slovenia Swedia Resolusi 115…

American judge and politician (1923–2023) Senator Buckley redirects here. For other uses, see Senator Buckley (disambiguation). James L. BuckleyBuckley in the 1970sSenior Judge of the United States Court of Appeals for the District of Columbia CircuitIn officeAugust 31, 1996 – August 18, 2023Judge of the United States Court of Appeals for the District of Columbia CircuitIn officeDecember 17, 1985 – August 31, 1996Appointed byRonald ReaganPreceded byEdward Allen TammSuccee…

Stream in the U.S. state of Connecticut Duck Riverby Jerry Weiss, 2004 The Duck River is a short, partly tidal stream in Old Lyme, Connecticut. It joins the Connecticut River in the estuary at Watch Rock Park, just above the point where the Connecticut flows into Long Island Sound.[1][2][3] The river bisects the Old Lyme Cemetery. The Duck River is popular among artists and photographers. See also List of rivers of Connecticut References ^ CWTA - New London County Water T…

العلاقات المجرية السريلانكية المجر سريلانكا   المجر   سريلانكا تعديل مصدري - تعديل   العلاقات المجرية السريلانكية هي العلاقات الثنائية التي تجمع بين المجر وسريلانكا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتين: وجه المقارن…

MainTalk PageHelpParticipantsAwardsArticle AssessmentTemplatesTo doNew ArticlesSister Projects This Talk page is dedicated to matters related to WikiProject Israel. This is the talk page for discussing WikiProject Israel and anything related to its purposes and tasks. Put new text under old text. Click here to start a new topic. New to Wikipedia? Welcome! Learn to edit; get help. Assume good faith Be polite and avoid personal attacks Be welcoming to newcomers Seek dispute resolution if needed Sh…

Zita HanrotZita Hanrot, Februari 2016Lahir7 Desember 1989 (umur 34)Marseille, PrancisPekerjaanAktrisTahun aktif2004—sekarang Zita Hanrot (lahir 7 Desember 1989) adalah seorang aktris asal Prancis. Dia memenangkan César Award untuk Aktris Paling Menjanjikan pada tahun 2016 untuk perannya dalam film Fatima.[1] Referensi ^ Nahmias, Clara (23 February 2016). César 2016 : Qui es-tu Zita Hanrot ?. Premiere (dalam bahasa Prancis). Diakses tanggal 27 February 2016.  …

Ini adalah daftar lengkap pemegang pangkat Letnan Jenderal di Korps Marinir TNI Angkatan Laut, dulu dan sekarang. Pangkat Letnan Jenderal TNI (Marinir) (Jenderal bintang tiga) sampai saat ini merupakan pangkat tertinggi yang bisa didapat di oleh perwira tinggi Korps Marinir. Pangkat ini setara dengan Letnan Jenderal TNI di TNI Angkatan Darat dan Marsekal Madya TNI di TNI Angkatan Udara. Perwira tinggi bintang tiga TNI Angkatan Laut selain Korps Marinir, menggunakan pangkat Laksamana Madya TNI. P…

Russian football club Football clubAlania VladikavkazFull nameFootball Club Alania VladikavkazNickname(s)Red-YellowsFounded1921; 103 years ago (1921)GroundSultan Bilimkhanov Stadium, Grozny(while Republican Spartak Stadium is under reconstruction)Capacity10,250OwnerDaniil GurievGeneral directorRuslan SiukayevManagerYevgeni KaleshinLeagueRussian First League2022–233rd of 18WebsiteClub website Home colours Away colours Third colours FC Alania Vladikavkaz (Russian: Алания …

Европейская сардина Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеГруппа:Костные рыбыКласс:Лучепёрые рыбыПодкласс:Новопёрые …

Mathematical ways to group elements of a set This article is about grouping elements of a set. For partitioning an integer, see Integer partition. For the partition calculus of sets, see Infinitary combinatorics. A set of stamps partitioned into bundles: No stamp is in two bundles, no bundle is empty, and every stamp is in a bundle. The 52 partitions of a set with 5 elements. A colored region indicates a subset of X that forms a member of the enclosing partition. Uncolored dots indicate single-e…

For the newsletter, see Women in Music (periodical). This article may require copy editing for prosify lists, fix tone. You can assist by editing it. (November 2023) (Learn how and when to remove this template message) Part of a series onWomen in society Society Women's history (legal rights) Woman Animal advocacy Business Female entrepreneurs Gender representation on corporate boards of directors Diversity (politics) Diversity, equity, and inclusion Economic development Explorers and trave…

Early Neolithic settlement and archaeological site in Turkey Nevalı ÇoriLocation within TurkeyShow map of TurkeyNevalı Çori (Near East)Show map of Near EastAlternative nameNevalı Çori (Turkish)Newala Çori (Kurdish)LocationHilvan, Şanlıurfa Province, TurkeyRegionMesopotamiaCoordinates37°31′6″N 38°36′20″E / 37.51833°N 38.60556°E / 37.51833; 38.60556HistoryFounded8400 BCAbandoned8100 BCPeriodsPre-Pottery Neolithic BSite notesConditionSubmerged Neval…

Bilateral relationsJapan–Palau relations Japan Palau Diplomatic relations are maintained between Japan and Palau, a small island country in the western Pacific Ocean that was once a Japanese colony. There is a Japanese embassy on the Palauan island of Koror and a Palauan embassy in Tokyo. History Koror under Japanese administration The bilateral ties between the two countries originated in 1920, when Japan assumed control over the island colonies of the German colonial empire in the Pacific wh…

10th Air Base Wing10th Air Base Wing emblemActive1947–1949; 1952–1994; 1994–presentCountry United StatesBranch United States Air ForceRoleAir Base SupportPart ofUnited States Air Force AcademyGarrison/HQ United States Air Force AcademyMotto(s)Argus – Ceaseless WatchEngagementsOperation Desert Storm[1] Defense of Saudi Arabia Liberation and Defense of Kuwait Decorations Air Force Outstanding Unit Award[1] (13×)CommandersCurrentcommanderColonel Amy M. G…

VrauxcomuneVraux – Veduta LocalizzazioneStato Francia RegioneGrand Est Dipartimento Marna ArrondissementChâlons-en-Champagne CantoneChâlons-en-Champagne-2 TerritorioCoordinate49°01′N 4°14′E / 49.016667°N 4.233333°E49.016667; 4.233333 (Vraux)Coordinate: 49°01′N 4°14′E / 49.016667°N 4.233333°E49.016667; 4.233333 (Vraux) Superficie12,65 km² Abitanti486[1] (2009) Densità38,42 ab./km² Altre informazioniCod. postale51150…

Kembali kehalaman sebelumnya