forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit11470f5
committed
Allow locking updated tuples in tuple_update() and tuple_delete()
Currently, in read committed transaction isolation mode (default), we have thefollowing sequence of actions when tuple_update()/tuple_delete() findsthe tuple updated by concurrent transaction.1. Attempt to update/delete tuple with tuple_update()/tuple_delete(), which returns TM_Updated.2. Lock tuple with tuple_lock().3. Re-evaluate plan qual (recheck if we still need to update/delete and calculate the new tuple for update).4. Second attempt to update/delete tuple with tuple_update()/tuple_delete(). This attempt should be successful, since the tuple was previously locked.This patch eliminates step 2 by taking the lock during firsttuple_update()/tuple_delete() call. Heap table access method saves someefforts by checking the updated tuple once instead of twice. Futureundo-based table access methods, which will start from the latest row version,can immediately place a lock there.The code in nodeModifyTable.c is simplified by removing the nested switch/case.Discussion:https://postgr.es/m/CAPpHfdua-YFw3XTprfutzGp28xXLigFtzNbuFY8yPhqeq6X5kg%40mail.gmail.comReviewed-by: Aleksander Alekseev, Pavel Borisov, Vignesh C, Mason SharpReviewed-by: Andres Freund, Chris Travers1 parent764da77 commit11470f5
File tree
6 files changed
+285
-186
lines changed- src
- backend
- access
- heap
- table
- executor
- include
- access
- executor
- tools/pgindent
6 files changed
+285
-186
lines changedLines changed: 100 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 |
| |
49 | 55 |
| |
50 | 56 |
| |
| |||
299 | 305 |
| |
300 | 306 |
| |
301 | 307 |
| |
302 |
| - | |
| 308 | + | |
| 309 | + | |
303 | 310 |
| |
| 311 | + | |
| 312 | + | |
304 | 313 |
| |
305 | 314 |
| |
306 | 315 |
| |
307 | 316 |
| |
308 | 317 |
| |
309 |
| - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
310 | 348 |
| |
311 | 349 |
| |
312 | 350 |
| |
313 | 351 |
| |
314 | 352 |
| |
315 | 353 |
| |
316 | 354 |
| |
317 |
| - | |
| 355 | + | |
| 356 | + | |
318 | 357 |
| |
319 | 358 |
| |
320 | 359 |
| |
| |||
352 | 391 |
| |
353 | 392 |
| |
354 | 393 |
| |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
355 | 420 |
| |
356 | 421 |
| |
357 | 422 |
| |
| |||
360 | 425 |
| |
361 | 426 |
| |
362 | 427 |
| |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
363 | 444 |
| |
364 | 445 |
| |
365 | 446 |
| |
366 |
| - | |
| 447 | + | |
367 | 448 |
| |
368 | 449 |
| |
369 | 450 |
| |
| |||
374 | 455 |
| |
375 | 456 |
| |
376 | 457 |
| |
377 |
| - | |
378 |
| - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
379 | 463 |
| |
380 | 464 |
| |
381 | 465 |
| |
382 | 466 |
| |
383 |
| - | |
384 |
| - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
385 | 471 |
| |
386 |
| - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
387 | 478 |
| |
388 | 479 |
| |
389 | 480 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
306 | 306 |
| |
307 | 307 |
| |
308 | 308 |
| |
309 |
| - | |
| 309 | + | |
| 310 | + | |
310 | 311 |
| |
311 | 312 |
| |
312 | 313 |
| |
| |||
355 | 356 |
| |
356 | 357 |
| |
357 | 358 |
| |
358 |
| - | |
| 359 | + | |
| 360 | + | |
359 | 361 |
| |
360 | 362 |
| |
361 | 363 |
| |
|
0 commit comments
Comments
(0)