Knowledge (XXG)

Two-phase locking

Source 📝

486:(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. 404:
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).
175:(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. 417:
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
76:, 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. 98:
locks. Refinements of the basic protocol may use more lock types. Using locks that block processes, 2PL, S2PL, and SS2PL may be subject to
563: 538: 586: 397:
The two phase locking rules can be summarized as: each transaction must never acquire a lock after it has released a lock. The
414: 553: 453: 172: 69: 62: 591: 505: 422: 99: 433:
To comply with the strict two-phase locking (S2PL) protocol, a transaction needs to comply with 2PL, and release its
380:
protocol, each transaction handles its locks in two distinct, consecutive phases during the transaction's execution:
35: 500: 119: 73: 387:(aka Growing phase): locks are acquired and no locks are released (the number of locks can only increase). 46: 122:
on an object if that transaction has acquired a lock on that object which has not yet been released.
66: 58: 31: 528: 581: 17: 559: 534: 460:
because it causes Bottleneck (while B-trees always starts searching from the parent root).
495: 398: 111: 549: 524: 575: 456:(a special case of cascade-less recoverability). This protocol is not appropriate in 253: 259: 401:
property is guaranteed for a schedule with transactions that obey this rule.
164:
A transaction is allowed to write an object if and only if it is holding a
153:
A transaction is allowed to read an object if and only if it is holding a
42: 393:(aka Contracting phase): locks are released and no locks are acquired. 457: 102:
that result from the mutual blocking of two or more transactions.
79:
By the 2PL protocol, locks are applied and removed in two phases:
86:
Shrinking phase: locks are released and no locks are acquired.
83:
Expanding phase: locks are acquired and no locks are released.
34:. For commit consensus within a distributed transaction, see 449:
locks are released regularly during the shrinking phase.
437:
locks only after the transaction has ended (i.e., either
530:
Concurrency Control and Recovery in Database Systems
90:Two types of locks are used by the basic protocol: 65:. It is also the name of the resulting set of 125:For 2PL, the only used data-access locks are 8: 527:, Vassos Hadzilacos, Nathan Goodman (1987): 231: 178: 517: 533:, Addison Wesley Publishing Company, 7: 237:guarantees conflict-serializability 25: 555:Transactional Information Systems 240:guarantees view-serializability 484:strong strict two-phase locking 464:Strong strict two-phase locking 413:The difference between 2PL and 72:(histories). The protocol uses 18:Strong strict two-phase locking 409:Conservative two-phase locking 1: 506:Deadlock (computer science) 110:Locks are used to guarantee 552:, Gottfried Vossen (2001): 141:). Below are the rules for 608: 478:Rigorous two-phase locking 452:Unlike 2PL, S2PL provides 246:guarantees recoverability 29: 27:Concurrency control method 180:Lock compatibility table 36:Two-phase commit protocol 429:Strict two-phase locking 63:conflict-serializability 501:Lock (computer science) 61:method that guarantees 587:Transaction processing 445:). On the other hand, 249:guarantees strictness 47:transaction processing 30:This article is about 243:eliminates deadlocks 106:Read and write locks 67:database transaction 592:Concurrency control 525:Philip A. Bernstein 474:Rigorous scheduling 181: 114:. A transaction is 59:concurrency control 57:) is a pessimistic 32:concurrency control 179: 435:write (exclusive) 378:two-phase locking 376:According to the 372:Two-phase locking 369: 368: 225: 224: 51:two-phase locking 16:(Redirected from 599: 566: 547: 541: 522: 232: 182: 21: 607: 606: 602: 601: 600: 598: 597: 596: 572: 571: 570: 569: 548: 544: 523: 519: 514: 496:Serializability 492: 482:To comply with 466: 431: 411: 399:serializability 391:Shrinking phase 385:Expanding phase 374: 230: 168:on that object. 161:on that object. 139:exclusive locks 112:serializability 108: 39: 28: 23: 22: 15: 12: 11: 5: 605: 603: 595: 594: 589: 584: 574: 573: 568: 567: 550:Gerhard Weikum 542: 516: 515: 513: 510: 509: 508: 503: 498: 491: 488: 465: 462: 430: 427: 410: 407: 395: 394: 388: 373: 370: 367: 366: 363: 360: 357: 354: 351: 348: 345: 341: 340: 337: 334: 331: 328: 325: 322: 319: 315: 314: 311: 308: 305: 302: 299: 296: 293: 289: 288: 285: 282: 279: 276: 273: 270: 267: 263: 262: 256: 250: 247: 244: 241: 238: 235: 229: 226: 223: 222: 217: 212: 208: 207: 202: 197: 193: 192: 189: 186: 177: 176: 169: 162: 107: 104: 88: 87: 84: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 604: 593: 590: 588: 585: 583: 580: 579: 577: 565: 564:1-55860-508-8 561: 557: 556: 551: 546: 543: 540: 539:0-201-10715-5 536: 532: 531: 526: 521: 518: 511: 507: 504: 502: 499: 497: 494: 493: 489: 487: 485: 480: 479: 475: 471: 463: 461: 459: 455: 450: 448: 447:read (shared) 444: 440: 436: 428: 426: 424: 421: 416: 408: 406: 402: 400: 392: 389: 386: 383: 382: 381: 379: 371: 364: 361: 358: 355: 352: 349: 346: 343: 342: 338: 335: 332: 329: 326: 323: 320: 317: 316: 312: 309: 306: 303: 300: 297: 294: 291: 290: 286: 283: 280: 277: 274: 271: 268: 265: 264: 261: 257: 255: 254:phantom reads 251: 248: 245: 242: 239: 236: 234: 233: 227: 221: 218: 216: 213: 210: 209: 206: 203: 201: 198: 195: 194: 190: 187: 184: 183: 174: 170: 167: 163: 160: 156: 152: 151: 150: 148: 144: 140: 136: 132: 128: 123: 121: 117: 113: 105: 103: 101: 97: 93: 85: 82: 81: 80: 77: 75: 71: 68: 64: 60: 56: 52: 48: 44: 37: 33: 19: 558:, Elsevier, 554: 545: 529: 520: 483: 481: 477: 473: 470:Rigorousness 469: 467: 451: 446: 442: 438: 434: 432: 419: 412: 403: 396: 390: 384: 377: 375: 219: 214: 204: 199: 165: 158: 154: 146: 142: 138: 134: 131:shared locks 130: 126: 124: 115: 109: 95: 91: 89: 78: 54: 50: 40: 260:dirty reads 211:write-lock 191:write-lock 147:write-locks 135:write-locks 576:Categories 512:References 454:strictness 196:read-lock 166:write-lock 159:write-lock 143:read-locks 127:read-locks 582:Databases 439:committed 423:deadlocks 258:prevents 252:prevents 188:read-lock 185:Lock type 155:read-lock 100:deadlocks 96:Exclusive 70:schedules 43:databases 490:See also 420:prevents 228:Variants 173:schedule 458:B-trees 443:aborted 116:holding 562:  537:  344:SS2PL 133:) and 92:Shared 476:, or 472:, or 318:S2PL 307:yes? 304:yes? 292:C2PL 74:locks 560:ISBN 535:ISBN 415:C2PL 365:Yes 362:Yes 359:Yes 356:Yes 347:Yes 339:Yes 336:Yes 333:Yes 330:Yes 321:Yes 313:Yes 301:Yes 298:Yes 295:Yes 269:Yes 266:2PL 145:and 120:lock 94:and 45:and 468:or 441:or 353:No 350:No 327:No 324:No 310:No 287:No 284:No 281:No 278:No 275:No 272:No 157:or 55:2PL 41:In 578:: 425:. 171:A 149:: 118:a 49:, 220:X 215:X 205:X 200:✔ 137:( 129:( 53:( 38:. 20:)

Index

Strong strict two-phase locking
concurrency control
Two-phase commit protocol
databases
transaction processing
concurrency control
conflict-serializability
database transaction
schedules
locks
deadlocks
serializability
lock
schedule
phantom reads
dirty reads
serializability
C2PL
deadlocks
strictness
B-trees
Serializability
Lock (computer science)
Deadlock (computer science)
Philip A. Bernstein
Concurrency Control and Recovery in Database Systems
ISBN
0-201-10715-5
Gerhard Weikum
Transactional Information Systems

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.