summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/libpq.rc.in
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-02-06 13:19:51 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-02-06 13:20:20 -0500
commit7fcddbdd031f1644952c26eebd3e0aa7007e9d37 (patch)
tree687429fbaaf78b2abe23f7596ae692b25c47fdfd /src/interfaces/libpq/libpq.rc.in
parent5853b9493510e12d9b82bf8fe3f6a1248027be2b (diff)
downloadpostgresql-7fcddbdd031f1644952c26eebd3e0aa7007e9d37.tar.gz
Avoid returning stale attribute bitmaps in RelationGetIndexAttrBitmap().
The problem with the original coding here is that we might receive (and clear) a relcache invalidation signal for the target relation down inside one of the index_open calls we're doing. Since the target is open, we would not drop the relcache entry, just reset its rd_indexvalid and rd_indexlist fields. But RelationGetIndexAttrBitmap() kept going, and would eventually cache and return potentially-obsolete attribute bitmaps. The case where this matters is where the inval signal was from a CREATE INDEX CONCURRENTLY telling us about a new index on a formerly-unindexed column. (In all other cases, the lock we hold on the target rel should prevent any concurrent change in index state.) Even just returning the stale attribute bitmap is not such a problem, because it shouldn't matter during the transaction in which we receive the signal. What hurts is caching the stale data, because it can survive into later transactions, breaking CREATE INDEX CONCURRENTLY's expectation that later transactions will not create new broken HOT chains. The upshot is that there's a window for building corrupted indexes during CREATE INDEX CONCURRENTLY. This patch fixes the problem by rechecking that the set of index OIDs is still the same at the end of RelationGetIndexAttrBitmap() as it was at the start. If not, we loop back and try again. That's a little more than is strictly necessary to fix the bug --- in principle, we could return the stale data but not cache it --- but it seems like a bad idea on general principles for relcache to return data it knows is stale. There might be more hazards of the same ilk, or there might be a better way to fix this one, but this patch definitely improves matters and seems unlikely to make anything worse. So let's push it into today's releases even as we continue to study the problem. Pavan Deolasee and myself Discussion: https://postgr.es/m/CABOikdM2MUq9cyZJi1KyLmmkCereyGp5JQ4fuwKoyKEde_mzkQ@mail.gmail.com
Diffstat (limited to 'src/interfaces/libpq/libpq.rc.in')
0 files changed, 0 insertions, 0 deletions