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:

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 November 2022. Ivan KardumInformasi pribadiTanggal lahir 18 Juli 1987 (umur 36)Tempat lahir Osijek, Republik Federal Sosialis YugoslaviaTinggi 1,87 m (6 ft 1+1⁄2 in)Posisi bermain KiperInformasi klubKlub saat ini Austria WienNomor 26Karier jun…

Сельское поселение России (МО 2-го уровня)Новотитаровское сельское поселение Флаг[d] Герб 45°14′09″ с. ш. 38°58′16″ в. д.HGЯO Страна  Россия Субъект РФ Краснодарский край Район Динской Включает 4 населённых пункта Адм. центр Новотитаровская Глава сельского посел…

Highway in Sydney, New South Wales, Australia Cumberland Highway(numerous constituent roads)New South WalesCumberland Highway as Pennant Hills Road at Thornleigh in 2016Northeast endSouthwest endCoordinates 33°43′12″S 151°06′22″E / 33.719918°S 151.106190°E / -33.719918; 151.106190 (Northeast end) 33°54′53″S 150°55′14″E / 33.914697°S 150.920488°E / -33.914697; 150.920488 (Southwest end) General informationTypeHighwayL…

莎拉·阿什頓-西里洛2023年8月,阿什頓-西里洛穿著軍服出生 (1977-07-09) 1977年7月9日(46歲) 美國佛羅里達州国籍 美國别名莎拉·阿什頓(Sarah Ashton)莎拉·西里洛(Sarah Cirillo)金髮女郎(Blonde)职业記者、活動家、政治活動家和候選人、軍醫活跃时期2020年—雇主內華達州共和黨候選人(2020年)《Political.tips》(2020年—)《LGBTQ國度》(2022年3月—2022年10月)烏克蘭媒體…

1926 film Not to be confused with the 2007 Canadian film American Venus. The American VenusTheatrical release posterDirected byFrank TuttleWritten byFrederick Stowers (scenario)Robert Benchley (titles)Story byTownsend MartinStarringEsther RalstonFord SterlingEdna May OliverLouise BrooksCinematographyJ. Roy HuntProductioncompanyFamous Players–LaskyDistributed byParamount PicturesRelease date January 31, 1926 (1926-01-31) Running time87 minutesCountryUnited StatesLanguageSilent (E…

Tombstone, kemungkinan pada tahun 1881 Baku tembak di O.K. Corral adalah peristiwa baku tembak yang berlangsung selama 30 detik antara penegak hukum dan anggota sebuah kelompok preman yang hanya tergabung secara longgar saja dan disebut Cowboys, yang berlangsung pada pukul 15:00, pada hari Rabu tanggal 26 Oktober 1881 di Tombstone, Teritori Arizona, Amerika Serikat. Peristiwa ini dianggap sebagai peristiwa baku tembak paling terkenal di Daerah Liar Barat Amerika. Baku tembak itu adalah hasil dar…

Bandar Udara Internasional Soekarno–HattaSoekarno–Hatta International AirportTerminal 1 dan Terminal 2 Soekarno Hatta difoto dari udara.IATA: CGKICAO: WIIIWMO: 96749InformasiJenisPublikPemilikInJourneyPengelolaAngkasa Pura IIMelayaniJabodetabekpunjurLokasiTangerang, Banten, IndonesiaDibuka1 Mei 1985; 39 tahun lalu (1985-05-01)Maskapai penghubung Batik Air Citilink Garuda Indonesia Lion Air Maskapai utama Indonesia AirAsia NAM Air Sriwijaya Air Super Air Jet Zona waktuWIB (UTC+07:00)Keti…

Bagian dari seriIslam Rukun Iman Keesaan Allah Malaikat Kitab-kitab Allah Nabi dan Rasul Allah Hari Kiamat Qada dan Qadar Rukun Islam Syahadat Salat Zakat Puasa Haji Sumber hukum Islam al-Qur'an Sunnah (Hadis, Sirah) Tafsir Akidah Fikih Syariat Sejarah Garis waktu Muhammad Ahlulbait Sahabat Nabi Khulafaur Rasyidin Khalifah Imamah Ilmu pengetahuan Islam abad pertengahan Penyebaran Islam Penerus Muhammad Budaya dan masyarakat Akademik Akhlak Anak-anak Dakwah Demografi Ekonomi Feminisme Filsafat Ha…

Untuk politikus Kanada, lihat Norman E. Cook. Norman Cook/Fatboy SlimFatboy Slim pada 2004.Informasi latar belakangNama lahirQuentin Leo CookNama lainFatboy Slim, dan lain-lain. Lihat bagian pseudonimLahir31 Juli 1963 (umur 60)Bromley, Kent, InggrisGenre Big beat electronica acid house trip hop nu-funk rave (sebagai Fatboy Slim) Alternative rock (dengan Housemartins) Pekerjaan DJ musisi produser rekaman Instrumen Turntables synthesizers keyboard bass gitar drum Tahun aktif1979–sekarangLab…

Americans of Costa Rican birth or descent Ethnic group Costa Rican AmericansTotal population154,784[1]0.05% of the U.S. population (2018)[1]Regions with significant populationsNew York Metro Area, Greater Los Angeles, South Florida, TexasLanguagesAmerican English, SpanishReligionPredominantly Roman Catholic, minority ProtestantRelated ethnic groupsLatino Americans, Spanish Americans Part of a series onHispanic andLatino Americans National origin groups Argentine Americans Bolivia…

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (ديسمبر 2018) 5° خط عرض 5 جنوب خريطة لجميع الإحداثيات من جوجل خريطة لجميع الإحداثيات من بينغ تصدير جميع الإحداثيات من كيه …

فئة الدم تحدد ،جزئيا، بمستضدات فئة الدم ABO الموجودة في خلايا الدم الحمراء. فئات الدم أو الزمر الدموية أو الفصائل الدموية[1] (بالإنجليزية: Blood Group)‏ عند الإنسان مختلفة بالنسبة لكل فرد.[2][3][4] فلكل إنسان محدد من الدم ينتمي إلى إحدى المجموعات الأربعة التالية: A B AB O ت…

Scottish musician (1943–2014) For the Australian rules footballer, see Jack Bruce (footballer). Jack BruceBruce with Cream on Fanclub, 1968BornJohn Symon Asher Bruce(1943-05-14)14 May 1943Bishopbriggs, Lanarkshire, ScotlandDied25 October 2014(2014-10-25) (aged 71)Sudbury, Suffolk, EnglandAlma materRoyal Conservatoire of ScotlandOccupations Musician singer songwriter composer producer Years active1962–2014Spouses Janet Godfrey ​ ​(m. 1964; div.&…

Classic FMPaese Regno Unito LinguaInglese Frequenze FM: 99.9–101.9 MHz DAB: 11D (England/Wales/N. Ireland) 12A (Scotland) Geary's Island Freeview: 731 Freesat: 721 Sky UK, Sky Ireland: 0106 Virgin Media: 922 Data di lancio7 settembre 1992 (31 anni) EditoreGlobal Group Canali gemellati theJazz Capital FM Capital XTRA Gold Heart Heart Dance Heart 80s Heart Extra LBC Smooth Radio Radio X MottoThe World's Greatest Music Sito webwww.classicfm.com/ Modifica dati su Wikidata · Manuale…

بنك الشركة المصرفية العربية الدوليةمعلومات عامةالبلد  مصر التأسيس 1976 النوع بنك المقر الرئيسي القاهرة موقع الويب saib.com.eg… تعديل - تعديل مصدري - تعديل ويكي بيانات هذه المقالة تحتاج للمزيد من الوصلات للمقالات الأخرى للمساعدة في ترابط مقالات الموسوعة. فضلًا ساعد في تحسين هذه …

County in South Dakota, United States County in South DakotaMarshall CountyCountyMarshall County Courthouse in BrittonLocation within the U.S. state of South DakotaSouth Dakota's location within the U.S.Coordinates: 45°46′N 97°36′W / 45.76°N 97.6°W / 45.76; -97.6Country United StatesState South DakotaFounded1885Named forMarshall VincentSeatBrittonLargest cityBrittonArea • Total886 sq mi (2,290 km2) • Land838 sq…

March 2013 United Kingdom BlizzardSnow in Cumbria on 23 March. TypeBlizzardFormed15 March 2013 [3]Dissipated25 March 2013 [1][2] Lowest pressure970 mb (28.64 inHg) Fatalitiesat least 2DamageUntotalledAreas affectedWales, Northern England, Northern Ireland, Southern ScotlandPart of the Spring 2013 United Kingdom cold spell The March 2013 United Kingdom winter storm was an exceptional weather event that took place in the United Kingdom and Ireland on the night of …

Portuguese footballer In this Portuguese name, the first or maternal family name is Silva and the second or paternal family name is Coentrão. Fábio Coentrão Coentrão with Real Madrid in 2012Personal informationFull name Fábio Alexandre da Silva Coentrão[1]Date of birth (1988-03-11) 11 March 1988 (age 36)[1]Place of birth Vila do Conde, Portugal[1]Height 1.78 m (5 ft 10 in)[1]Position(s) Left-back, wingerYouth career1999–2006 Rio Ave…

Route by which substances can enter the body through the skin Skin absorption is a route by which substances can enter the body through the skin. Along with inhalation, ingestion and injection, dermal absorption is a route of exposure for toxic substances and route of administration for medication. Absorption of substances through the skin depends on a number of factors, the most important of which are concentration, duration of contact, solubility of medication, and physical condition of the sk…

Type of court in many countries Circuit courts are court systems in several common law jurisdictions.[1] It may refer to: Courts that literally sit 'on circuit', i.e., judges move around a region or country to different towns or cities where they will hear cases; Courts that sit within a judicial circuit, i.e., an administrative division of a country's judiciary; or A higher-level trial court, e.g., for felony or indictment offences. History Origin in England The term circuit court is de…