- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit5861b1f
committed
Use SnapshotDirty when checking for conflicting index names.
While choosing an autogenerated name for an index, look forpre-existing relations using a SnapshotDirty snapshot, instead of theprevious behavior that considered only committed-good pg_class rows.This allows us to detect and avoid conflicts against indexes that arestill being built.It's still possible to fail due to a race condition, but the windowis now just the amount of time that it takes DefineIndex to validateall its parameters, call smgrcreate(), and enter the index's pg_classrow. Formerly the race window covered the entire time needed tocreate and fill an index, which could be very long if the table islarge. Worse, if the conflicting index creation is part of a largertransaction, it wouldn't be visible till COMMIT.So this isn't a complete solution, but it should greatly amelioratethe problem, and the patch is simple enough to be back-patchable.It might at some point be useful to do the same for pg_constraintentries (cf. ChooseConstraintName, ConstraintNameExists, and relatedfunctions). However, in the absence of field complaints, I'll leavethat alone for now. The relation-name test should be good enough forindex-based constraints, while foreign-key constraints seem to be okaysince they require exclusive locks to create.Bug: #18959Reported-by: Maximilian Chrzan <maximilian.chrzan@here.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>Discussion:https://postgr.es/m/18959-f63b53b864bb1417@postgresql.orgBackpatch-through: 131 parent2f6e240 commit5861b1f
1 file changed
+36
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2592 | 2592 | | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | | - | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
2596 | 2598 | | |
2597 | 2599 | | |
2598 | 2600 | | |
| |||
2608 | 2610 | | |
2609 | 2611 | | |
2610 | 2612 | | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
2611 | 2619 | | |
2612 | 2620 | | |
2613 | 2621 | | |
2614 | 2622 | | |
2615 | 2623 | | |
2616 | 2624 | | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
2617 | 2629 | | |
2618 | 2630 | | |
2619 | | - | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
2620 | 2652 | | |
2621 | 2653 | | |
2622 | 2654 | | |
| |||
2628 | 2660 | | |
2629 | 2661 | | |
2630 | 2662 | | |
| 2663 | + | |
| 2664 | + | |
2631 | 2665 | | |
2632 | 2666 | | |
2633 | 2667 | | |
| |||
0 commit comments
Comments
(0)