- Notifications
You must be signed in to change notification settings - Fork28
Commit2aaec65
committed
Avoid returning stale attribute bitmaps in RelationGetIndexAttrBitmap().
The problem with the original coding here is that we might receive (andclear) a relcache invalidation signal for the target relation down insideone of the index_open calls we're doing. Since the target is open, wewould not drop the relcache entry, just reset its rd_indexvalid andrd_indexlist fields. But RelationGetIndexAttrBitmap() kept going, andwould eventually cache and return potentially-obsolete attribute bitmaps.The case where this matters is where the inval signal was from a CREATEINDEX CONCURRENTLY telling us about a new index on a formerly-unindexedcolumn. (In all other cases, the lock we hold on the target rel shouldprevent any concurrent change in index state.) Even just returning thestale attribute bitmap is not such a problem, because it shouldn't matterduring the transaction in which we receive the signal. What hurts iscaching the stale data, because it can survive into later transactions,breaking CREATE INDEX CONCURRENTLY's expectation that later transactionswill not create new broken HOT chains. The upshot is that there's a windowfor building corrupted indexes during CREATE INDEX CONCURRENTLY.This patch fixes the problem by rechecking that the set of index OIDsis still the same at the end of RelationGetIndexAttrBitmap() as it wasat the start. If not, we loop back and try again. That's a littlemore than is strictly necessary to fix the bug --- in principle, wecould return the stale data but not cache it --- but it seems like abad idea on general principles for relcache to return data it knowsis stale.There might be more hazards of the same ilk, or there might be a betterway to fix this one, but this patch definitely improves matters and seemsunlikely to make anything worse. So let's push it into today's releaseseven as we continue to study the problem.Pavan Deolasee and myselfDiscussion:https://postgr.es/m/CABOikdM2MUq9cyZJi1KyLmmkCereyGp5JQ4fuwKoyKEde_mzkQ@mail.gmail.com1 parent549f747 commit2aaec65
1 file changed
+36
-7
lines changedLines changed: 36 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4747 | 4747 |
| |
4748 | 4748 |
| |
4749 | 4749 |
| |
4750 |
| - | |
4751 |
| - | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
4752 | 4754 |
| |
4753 | 4755 |
| |
4754 | 4756 |
| |
| |||
4761 | 4763 |
| |
4762 | 4764 |
| |
4763 | 4765 |
| |
| 4766 | + | |
4764 | 4767 |
| |
4765 | 4768 |
| |
4766 | 4769 |
| |
| |||
4789 | 4792 |
| |
4790 | 4793 |
| |
4791 | 4794 |
| |
4792 |
| - | |
| 4795 | + | |
4793 | 4796 |
| |
| 4797 | + | |
4794 | 4798 |
| |
4795 | 4799 |
| |
4796 | 4800 |
| |
| |||
4801 | 4805 |
| |
4802 | 4806 |
| |
4803 | 4807 |
| |
4804 |
| - | |
4805 |
| - | |
4806 |
| - | |
| 4808 | + | |
| 4809 | + | |
4807 | 4810 |
| |
4808 | 4811 |
| |
4809 | 4812 |
| |
| |||
4881 | 4884 |
| |
4882 | 4885 |
| |
4883 | 4886 |
| |
4884 |
| - | |
| 4887 | + | |
| 4888 | + | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
| 4892 | + | |
| 4893 | + | |
| 4894 | + | |
| 4895 | + | |
| 4896 | + | |
| 4897 | + | |
| 4898 | + | |
| 4899 | + | |
| 4900 | + | |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
| 4909 | + | |
| 4910 | + | |
| 4911 | + | |
| 4912 | + | |
| 4913 | + | |
4885 | 4914 |
| |
4886 | 4915 |
| |
4887 | 4916 |
| |
|
0 commit comments
Comments
(0)